@farm.js/core 0.1.73 → 0.1.75
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-VBCA3WZ6.cjs → agent-mcp-handler-73SGWVZT.cjs} +9 -9
- package/dist/{agent-mcp-handler-RK7LDYEL.mjs → agent-mcp-handler-PJKZHYSA.mjs} +8 -8
- package/dist/{agent-mcp.d-D_gHjCAE.d.ts → agent-mcp.d-Djvao5eV.d.ts} +24 -2
- package/dist/{agent-mcp.d-PvEf-1mi.d.mts → agent-mcp.d-wA13pwmS.d.mts} +24 -2
- package/dist/agent-runtime.cjs +9 -9
- package/dist/agent-runtime.d.mts +4 -4
- package/dist/agent-runtime.d.ts +4 -4
- package/dist/agent-runtime.mjs +8 -8
- package/dist/analyzer-23GCBYFI.cjs +16 -0
- package/dist/{analyzer-MFYCJT75.mjs → analyzer-LJHMFCDW.mjs} +2 -2
- package/dist/api/client.cjs +4 -4
- package/dist/api/client.d.mts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.mjs +3 -3
- package/dist/api/client.native.cjs +6 -6
- package/dist/api/client.native.d.mts +4 -4
- package/dist/api/client.native.d.ts +4 -4
- package/dist/api/client.native.mjs +3 -3
- package/dist/api/node.cjs +14 -13
- package/dist/api/node.d.mts +6 -6
- package/dist/api/node.d.ts +6 -6
- package/dist/api/node.mjs +13 -12
- package/dist/api/route-manager.cjs +23 -21
- package/dist/api/route-manager.d.mts +9 -7
- package/dist/api/route-manager.d.ts +9 -7
- package/dist/api/route-manager.mjs +22 -20
- package/dist/api/runtime.cjs +13 -12
- package/dist/api/runtime.d.mts +5 -5
- package/dist/api/runtime.d.ts +5 -5
- package/dist/api/runtime.mjs +12 -11
- package/dist/{api-client.d-Bp35zMqR.d.mts → api-client.d-CyVmI4Di.d.mts} +2 -2
- package/dist/{api-client.d-CFI_xL0V.d.ts → api-client.d-DrTM7BdH.d.ts} +2 -2
- package/dist/api.cjs +26 -24
- package/dist/api.d.mts +9 -9
- package/dist/api.d.ts +9 -9
- package/dist/api.mjs +25 -23
- package/dist/{app-manifest.d-BpVTg43i.d.ts → app-manifest.d-BukcP_EV.d.ts} +10 -1
- package/dist/{app-manifest.d-CN7cEWHX.d.mts → app-manifest.d-DIuqSi9k.d.mts} +10 -1
- package/dist/app-markdown.cjs +11 -7
- package/dist/app-markdown.d.mts +6 -6
- package/dist/app-markdown.d.ts +6 -6
- package/dist/app-markdown.mjs +10 -6
- package/dist/{app.d-DO4PTCWm.d.ts → app.d-BQqmM6Gy.d.ts} +55 -4
- package/dist/{app.d-BFWzAdTe.d.mts → app.d-YVuFb10p.d.mts} +55 -4
- package/dist/{base-path.d-BJ3SYpB8.d.mts → base-path.d-m7wvRMnG.d.mts} +15 -1
- package/dist/{base-path.d-BJ3SYpB8.d.ts → base-path.d-m7wvRMnG.d.ts} +15 -1
- package/dist/cache.cjs +2 -2
- package/dist/cache.d.mts +22 -1
- package/dist/cache.d.ts +22 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chunk-JYNNIGQO.cjs → chunk-25JGHAGH.cjs} +11 -1
- package/dist/{chunk-GWXZS7K5.mjs → chunk-2LKUR5QJ.mjs} +1 -1
- package/dist/{chunk-Z3IN6GEX.mjs → chunk-2NQ3S2SJ.mjs} +69 -12
- package/dist/chunk-2PJVEL56.cjs +90 -0
- package/dist/{chunk-HDPT6OYE.cjs → chunk-2RSVYJT6.cjs} +28 -4
- package/dist/{chunk-HGB4PM2C.cjs → chunk-2YJ4DHTD.cjs} +104 -32
- package/dist/{chunk-MGZVDX4R.mjs → chunk-3AJQFVWW.mjs} +3 -3
- package/dist/{chunk-E3HDJCWF.mjs → chunk-3GMD2E4Q.mjs} +3 -3
- package/dist/{chunk-JWY66PID.cjs → chunk-42EUEYW6.cjs} +21 -13
- package/dist/{chunk-255J7K4X.mjs → chunk-47R7CX4A.mjs} +6 -6
- package/dist/chunk-4PWGLPL6.mjs +284 -0
- package/dist/{chunk-7S7AAK2D.mjs → chunk-4QBFYEDC.mjs} +2 -1
- package/dist/{chunk-6O6PAZZR.mjs → chunk-4T2RB4JA.mjs} +5 -5
- package/dist/{chunk-XGTFLG73.cjs → chunk-4VLXQ55O.cjs} +37 -25
- package/dist/{chunk-KTDG4THT.cjs → chunk-4ZSZI6XL.cjs} +17 -17
- package/dist/{chunk-XGJVRPYL.cjs → chunk-52LTENRE.cjs} +3 -3
- package/dist/{chunk-QIXEU2WV.cjs → chunk-5AMH6AFA.cjs} +5 -3
- package/dist/{chunk-AYP2YFVN.mjs → chunk-5KAEGBIL.mjs} +75 -42
- package/dist/{chunk-WW3LRNQV.mjs → chunk-5O3SK3ZC.mjs} +5 -5
- package/dist/{chunk-GPO3LJDJ.cjs → chunk-5QZT2EQN.cjs} +2 -2
- package/dist/{chunk-RLFGKJQ6.mjs → chunk-5WFPZG7K.mjs} +20 -8
- package/dist/chunk-5XD2ULJG.mjs +114 -0
- package/dist/{chunk-4HGLJOXZ.cjs → chunk-62DZHPDK.cjs} +16 -11
- package/dist/{chunk-YXIQYWOK.cjs → chunk-63EFR2WF.cjs} +27 -8
- package/dist/{chunk-2RCCFB2Y.cjs → chunk-6B44ZU5P.cjs} +11 -11
- package/dist/{chunk-HFUOLILA.cjs → chunk-6D3CJFNU.cjs} +37 -21
- package/dist/{chunk-JX5VOLAV.cjs → chunk-6DBBMQWT.cjs} +38 -38
- package/dist/{chunk-FRO4BB2T.mjs → chunk-6MATGOEF.mjs} +1 -1
- package/dist/{chunk-CLEWORVY.cjs → chunk-7564NP5Z.cjs} +40 -43
- package/dist/{chunk-7H45IJWO.mjs → chunk-7DBJ2SWK.mjs} +1 -1
- package/dist/chunk-7E4FDO5X.mjs +265 -0
- package/dist/{chunk-FPBOAG6N.cjs → chunk-7EOSFIPN.cjs} +3 -3
- package/dist/{chunk-ICFPTHXM.mjs → chunk-7FQFK3OA.mjs} +7 -3
- package/dist/{chunk-TUOO6IK3.mjs → chunk-7H2TXT2K.mjs} +11 -1
- package/dist/{chunk-A4PWGL46.mjs → chunk-7KDCVSTR.mjs} +4 -4
- package/dist/{chunk-GPICBTDV.cjs → chunk-7Q2YWZF7.cjs} +6 -6
- package/dist/{chunk-CFG4QERR.cjs → chunk-7Q7UB4TL.cjs} +2 -2
- package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
- package/dist/chunk-A3LNXQJJ.cjs +265 -0
- package/dist/{chunk-IBVN7SW5.mjs → chunk-A5F55ZFA.mjs} +472 -143
- package/dist/{chunk-S6O2L47H.mjs → chunk-AG27TI6Q.mjs} +67 -5
- package/dist/{chunk-DC2AXGNZ.mjs → chunk-AM2M56SL.mjs} +1 -1
- package/dist/{chunk-JRHGJVJH.mjs → chunk-B5QRNCIE.mjs} +1 -1
- package/dist/{chunk-OIP62QEL.mjs → chunk-BGUTIQII.mjs} +24 -9
- package/dist/{chunk-DMAP4RND.cjs → chunk-BNCKXPCU.cjs} +98 -16
- package/dist/{chunk-TDCP3Z4T.cjs → chunk-BNTRXJL4.cjs} +3 -3
- package/dist/{chunk-BPAXGCKX.mjs → chunk-BRNPLD22.mjs} +30 -17
- package/dist/{chunk-JZGL2PIH.mjs → chunk-CDT7CGQT.mjs} +2 -2
- package/dist/{chunk-FEFCISOX.cjs → chunk-CEVXKJKF.cjs} +2 -2
- package/dist/{chunk-YZLEOMMA.mjs → chunk-CF74ABRI.mjs} +10 -10
- package/dist/chunk-CIY74JLV.cjs +134 -0
- package/dist/{chunk-FETMUBIA.mjs → chunk-CLM73YYD.mjs} +2 -2
- package/dist/{chunk-ME7RVELR.mjs → chunk-CSAIIMY3.mjs} +21 -2
- package/dist/{chunk-YAEN3L2F.cjs → chunk-CYNQPKA4.cjs} +23 -4
- package/dist/{chunk-M53MIIXY.mjs → chunk-CZOXZ6WQ.mjs} +1 -1
- package/dist/{chunk-Y2LU4LE5.mjs → chunk-DASQJ5UD.mjs} +2 -2
- package/dist/{chunk-WVQNXXNE.cjs → chunk-DD22NQFX.cjs} +2 -2
- package/dist/{chunk-OBYM5S5G.mjs → chunk-DUSTJ6A5.mjs} +20 -17
- package/dist/{chunk-ZFEJ2SF2.cjs → chunk-DZ3AZ7UK.cjs} +52 -52
- package/dist/{chunk-6YFC3ZFX.mjs → chunk-DZXD6CYJ.mjs} +1 -1
- package/dist/{chunk-AZ6IW6SF.mjs → chunk-EMTN5ABC.mjs} +1 -1
- package/dist/{chunk-AQIO3RNL.mjs → chunk-ERT6HQAI.mjs} +8 -3
- package/dist/{chunk-JDO346NV.mjs → chunk-F35C3TJZ.mjs} +1 -1
- package/dist/{chunk-ODBM54RT.cjs → chunk-F4ID7BGO.cjs} +33 -30
- package/dist/{chunk-C7GJDVN4.mjs → chunk-F7MJWW6A.mjs} +1 -1
- package/dist/{chunk-5OFNUETM.mjs → chunk-FCAYYLAE.mjs} +27 -3
- package/dist/{chunk-PWKAX5MS.cjs → chunk-FDZZ6K3N.cjs} +6 -6
- package/dist/{chunk-MHLNWRCJ.cjs → chunk-FE6KYDHC.cjs} +3 -3
- package/dist/{chunk-PTLXHRJZ.mjs → chunk-FLMALEY2.mjs} +37 -4
- package/dist/{chunk-IHTDLCDJ.cjs → chunk-G7B6NU4X.cjs} +23 -10
- package/dist/{chunk-JZQS3ZOI.mjs → chunk-GAAK3HDZ.mjs} +36 -7
- package/dist/{chunk-QMNWKQL4.cjs → chunk-GC5ROI3A.cjs} +4 -4
- package/dist/{chunk-JXIYH2NO.cjs → chunk-GCJ4GNMC.cjs} +4 -4
- package/dist/{chunk-WX63N6C5.mjs → chunk-GFXKO4UW.mjs} +106 -37
- package/dist/{chunk-CYRIIVD4.mjs → chunk-GLF44JKY.mjs} +3 -3
- package/dist/{chunk-GUZC226X.mjs → chunk-GLVDXRG2.mjs} +1 -1
- package/dist/{chunk-GZOKWJIW.mjs → chunk-GNY7BO7R.mjs} +18 -11
- package/dist/{chunk-OWQV6MLM.cjs → chunk-GYJT2U7J.cjs} +2 -1
- package/dist/{chunk-MBCRWU3P.cjs → chunk-H7OFZJCV.cjs} +8 -8
- package/dist/{chunk-JMOCMXTQ.mjs → chunk-H7QY7ZE4.mjs} +1 -1
- package/dist/{chunk-5LOARKDP.cjs → chunk-HFJLMALC.cjs} +42 -30
- package/dist/{chunk-CROAFCMW.mjs → chunk-HONTCUK6.mjs} +1 -1
- package/dist/{chunk-7PJARAQQ.mjs → chunk-HQ2VAJLW.mjs} +1 -1
- package/dist/{chunk-SVQX5HYW.mjs → chunk-HT2SZKXG.mjs} +92 -10
- package/dist/{chunk-7GMBETHM.mjs → chunk-HV2WZFUW.mjs} +1 -1
- package/dist/{chunk-DMXMIE2C.cjs → chunk-HVJ7IACB.cjs} +15 -7
- package/dist/{chunk-S7MWSFFP.cjs → chunk-IBEHVSU4.cjs} +2 -2
- package/dist/{chunk-QGCSUC5O.mjs → chunk-IDOUCM2X.mjs} +521 -296
- package/dist/{chunk-FN5UEC7I.mjs → chunk-IG2JE6WJ.mjs} +1 -1
- package/dist/{chunk-MQ4DYVFS.cjs → chunk-IIHZ2BEE.cjs} +3 -3
- package/dist/{chunk-TAU3OF5B.cjs → chunk-IK33N2AN.cjs} +1373 -694
- package/dist/{chunk-UVQRMUAR.cjs → chunk-IVBDRAOR.cjs} +1 -1
- package/dist/{chunk-2AFW7673.cjs → chunk-IXO6O2EL.cjs} +8 -7
- package/dist/{chunk-U7VH3Q5E.cjs → chunk-IYFBLWXU.cjs} +56 -25
- package/dist/{chunk-NDDRTFN4.mjs → chunk-J7EUGGTY.mjs} +2 -2
- package/dist/{chunk-UVZMSRHF.mjs → chunk-JA6RML7C.mjs} +3 -3
- package/dist/{chunk-CL52PD6D.cjs → chunk-JHZ6HULQ.cjs} +12 -9
- package/dist/{chunk-HTXKSREF.cjs → chunk-JNZDTE75.cjs} +532 -203
- package/dist/{chunk-VT25ERQK.mjs → chunk-JRBWBMP2.mjs} +24 -5
- package/dist/{chunk-4CTCSKAF.mjs → chunk-K6DXKHFE.mjs} +1 -1
- package/dist/{chunk-AXVRUDMB.cjs → chunk-K6PGK7DC.cjs} +2 -2
- package/dist/{chunk-TY5KCYDE.mjs → chunk-KHS3T3E5.mjs} +20 -8
- package/dist/{chunk-ILQ5DKYF.cjs → chunk-KPYQ32BA.cjs} +2 -2
- package/dist/{chunk-CSLHNBPS.cjs → chunk-KQS27YN7.cjs} +6 -6
- package/dist/{chunk-XI3OXOMK.mjs → chunk-KUXEII7V.mjs} +1 -1
- package/dist/{chunk-CA7DNRHO.cjs → chunk-L6E5BSNU.cjs} +3 -3
- package/dist/{chunk-VNBDN5W2.cjs → chunk-L7Y65BQU.cjs} +128 -59
- package/dist/{chunk-73K53YPP.mjs → chunk-LPXJEZJK.mjs} +30 -14
- package/dist/{chunk-B67CW2LM.mjs → chunk-LQBV2Y37.mjs} +34 -37
- package/dist/chunk-LQWIIBI2.cjs +86 -0
- package/dist/chunk-LXTYJ2HW.mjs +139 -0
- package/dist/{chunk-I4KPA2C6.mjs → chunk-MFU7SXAB.mjs} +10 -2
- package/dist/{chunk-YTVSWXEZ.cjs → chunk-ML4TOUZP.cjs} +76 -43
- package/dist/{chunk-E46NXBNJ.mjs → chunk-NLATR3T3.mjs} +12 -7
- package/dist/{chunk-OXNZUCHN.cjs → chunk-NPGXX7HN.cjs} +37 -37
- package/dist/chunk-NRWEY2CM.mjs +25 -0
- package/dist/{chunk-VPETSSWN.cjs → chunk-NSNQLBHR.cjs} +2 -2
- package/dist/chunk-NU5XLYRN.cjs +139 -0
- package/dist/chunk-NUWUEXUD.mjs +55 -0
- package/dist/{chunk-53EHWHT2.cjs → chunk-O4JYMU5N.cjs} +35 -22
- package/dist/{chunk-TNYC3TYP.mjs → chunk-O7JEFGUV.mjs} +2 -2
- package/dist/{chunk-62ZRA7XU.mjs → chunk-OCLCA3X3.mjs} +1 -1
- package/dist/{chunk-MJEKMT6B.mjs → chunk-OFIFRB62.mjs} +917 -238
- package/dist/{chunk-OB45EAQL.mjs → chunk-OVUU2RCQ.mjs} +4 -3
- package/dist/{chunk-YZK64PZT.cjs → chunk-OZARLCYQ.cjs} +1742 -898
- package/dist/{chunk-W44X6IC2.cjs → chunk-PBJ7MEOV.cjs} +13 -9
- package/dist/{chunk-2W4GNXGX.cjs → chunk-PBQGIA27.cjs} +2 -2
- package/dist/{chunk-B6RBJJ5G.mjs → chunk-PDACTAVX.mjs} +16 -3
- package/dist/{chunk-DQ2DI3Y7.mjs → chunk-PE2LEWXA.mjs} +6 -3
- package/dist/{chunk-LGR7565L.cjs → chunk-PG7J7XYT.cjs} +39 -24
- package/dist/{chunk-MMK4MZUN.mjs → chunk-PKXGFQZS.mjs} +1 -1
- package/dist/{chunk-YBY34UHB.mjs → chunk-PL7MCYYD.mjs} +47 -16
- package/dist/chunk-PWHF2C6A.mjs +134 -0
- package/dist/{chunk-DZHTNSQ5.cjs → chunk-Q2EKSSEG.cjs} +21 -21
- package/dist/{chunk-SPP3EZTJ.cjs → chunk-QDHR54S6.cjs} +139 -69
- package/dist/{chunk-REK6HZSU.mjs → chunk-QGYHE6VJ.mjs} +1565 -721
- package/dist/{chunk-ZOYKJBP5.cjs → chunk-QKW6DLDT.cjs} +2 -2
- package/dist/{chunk-Y5LEPEVH.mjs → chunk-QSLGE2ZC.mjs} +1 -1
- package/dist/{chunk-FSODPZRT.cjs → chunk-QUEYL2WM.cjs} +10 -10
- package/dist/{chunk-ZDAEHG2O.cjs → chunk-QYOAGT3E.cjs} +3 -3
- package/dist/{chunk-CPMME66W.mjs → chunk-R5X7FDOG.mjs} +73 -1
- package/dist/{chunk-O47W53D3.cjs → chunk-RDADQG5S.cjs} +7 -77
- package/dist/chunk-RDSHEHBA.mjs +82 -0
- package/dist/{chunk-C6CUUBY5.cjs → chunk-RHI67C2V.cjs} +5 -5
- package/dist/chunk-RK3YYUX6.cjs +114 -0
- package/dist/{chunk-K3RU5MOR.mjs → chunk-RK4MGL6Q.mjs} +1 -1
- package/dist/{chunk-LRB5OVRT.cjs → chunk-RKQOMG2X.cjs} +2 -2
- package/dist/chunk-RQRTH57V.cjs +82 -0
- package/dist/{chunk-HY6IVQ54.mjs → chunk-S7QEQCVV.mjs} +2 -2
- package/dist/{chunk-EGIY4A7V.cjs → chunk-SFSTZ7TB.cjs} +8 -8
- package/dist/{chunk-4Z3YLMSW.cjs → chunk-SX535SU5.cjs} +12 -12
- package/dist/{chunk-NLBK37HI.cjs → chunk-SXXSQVKK.cjs} +4 -4
- package/dist/{chunk-JZBU7V4D.mjs → chunk-SYPEMXW2.mjs} +126 -56
- package/dist/{chunk-5CFHQ7HM.mjs → chunk-TFEODQLG.mjs} +1 -1
- package/dist/{chunk-3GNVIYPO.cjs → chunk-TZ2YPXLB.cjs} +7 -7
- package/dist/{chunk-OEL5EPOJ.mjs → chunk-UD6KTSJS.mjs} +6 -76
- package/dist/{chunk-2EVESLP3.mjs → chunk-UJIBSFUE.mjs} +4 -4
- package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
- package/dist/chunk-UNOXV37V.cjs +55 -0
- package/dist/{chunk-TXE4SAMV.mjs → chunk-UOE6ZZZP.mjs} +1 -1
- package/dist/{chunk-OAEDVXVE.mjs → chunk-URQW27KO.mjs} +14 -6
- package/dist/chunk-VDQZV6BX.mjs +17 -0
- package/dist/chunk-VJ6L7TII.cjs +284 -0
- package/dist/{chunk-TPYAYFMF.cjs → chunk-VJI2LWTL.cjs} +2 -2
- package/dist/chunk-VWIW47FW.cjs +25 -0
- package/dist/{chunk-CKQAQFF6.mjs → chunk-WGNGM6MJ.mjs} +2 -2
- package/dist/{chunk-ROCF6UQD.cjs → chunk-WHCNJVYU.cjs} +74 -17
- package/dist/{chunk-4YHGQDTT.cjs → chunk-WJ5CCQBM.cjs} +35 -28
- package/dist/chunk-WKVYF2B5.cjs +17 -0
- package/dist/{chunk-5PDMBWAF.cjs → chunk-WRWJ7IWT.cjs} +7 -7
- package/dist/{chunk-ACGBXN3U.cjs → chunk-WW62HKA2.cjs} +55 -26
- package/dist/{chunk-XVSBALOY.cjs → chunk-X3Y6JWJG.cjs} +3 -3
- package/dist/{chunk-PXAHSCR6.cjs → chunk-XGDI4OUB.cjs} +103 -21
- package/dist/{chunk-4P5634G6.cjs → chunk-XRFGOYXG.cjs} +16 -11
- package/dist/{chunk-42KMUIWZ.cjs → chunk-XX6ZA2IO.cjs} +3 -3
- package/dist/{chunk-6IOZPJ3I.cjs → chunk-Y3DO7BIJ.cjs} +69 -7
- package/dist/{chunk-L5JDKFMQ.cjs → chunk-YBXIVQCE.cjs} +4 -4
- package/dist/{chunk-462MUII7.mjs → chunk-YCNKS6SD.mjs} +12 -12
- package/dist/{chunk-XUSJVHHD.cjs → chunk-YL7BKHYE.cjs} +935 -710
- package/dist/{chunk-7PPLTD3P.cjs → chunk-YN7G22MP.cjs} +6 -6
- package/dist/{chunk-TU6VAH4V.cjs → chunk-YRXPDKMM.cjs} +10 -10
- package/dist/{chunk-IXZSBO76.mjs → chunk-YSTKSZD2.mjs} +1 -1
- package/dist/{chunk-QDWMCFTH.mjs → chunk-YT2ZMLXK.mjs} +1 -1
- package/dist/{chunk-QEJWNXRI.cjs → chunk-YTNE4KGC.cjs} +3 -3
- package/dist/{chunk-E7QOEV5Z.cjs → chunk-YUCU6XB4.cjs} +4 -4
- package/dist/{chunk-NLRAQXAA.mjs → chunk-YVVY276M.mjs} +1 -1
- package/dist/{chunk-SUQACHER.mjs → chunk-Z2FFLTF5.mjs} +3 -3
- package/dist/{chunk-JSDV2NUN.mjs → chunk-Z3QXQN4U.mjs} +1 -1
- package/dist/{chunk-EYPSKXO4.mjs → chunk-Z4IRG4RG.mjs} +96 -9
- package/dist/{chunk-GJ7QVFAG.mjs → chunk-ZEWWZJPZ.mjs} +3 -1
- package/dist/chunk-ZIAWO6BC.mjs +86 -0
- package/dist/{chunk-JWLRBDDC.cjs → chunk-ZIOFRBIU.cjs} +100 -13
- package/dist/{chunk-3OJNNCDL.cjs → chunk-ZNXU4E6A.cjs} +8 -8
- package/dist/{chunk-RLEALQEN.mjs → chunk-ZO6TOLHL.mjs} +87 -5
- package/dist/{chunk-KDOZORJD.cjs → chunk-ZPCZWEU3.cjs} +24 -24
- package/dist/{chunk-QKEZLYON.cjs → chunk-ZV76IQG7.cjs} +2 -2
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/{client-component.d-C71rMuHF.d.mts → client-component.d-BeqVuqy2.d.mts} +80 -3
- package/dist/{client-component.d-sF-Znk0j.d.ts → client-component.d-CZ1NpHAY.d.ts} +80 -3
- package/dist/{client-plugins.d-B-Gd9mWR.d.mts → client-plugins.d-ChceYO9t.d.mts} +42 -8
- package/dist/{client-plugins.d-MFibjgBg.d.ts → client-plugins.d-D9kWC0QB.d.ts} +42 -8
- package/dist/client-plugins.d.mts +4 -4
- package/dist/client-plugins.d.ts +4 -4
- package/dist/client.cjs +17 -14
- package/dist/client.d.mts +11 -11
- package/dist/client.d.ts +11 -11
- package/dist/client.mjs +16 -13
- package/dist/config.d.mts +4 -4
- package/dist/config.d.ts +4 -4
- package/dist/cron.cjs +8 -4
- package/dist/cron.d.mts +11 -2
- package/dist/cron.d.ts +11 -2
- package/dist/cron.mjs +9 -5
- package/dist/desktop.d.mts +5 -5
- package/dist/desktop.d.ts +5 -5
- package/dist/{devtools-TDIJ6HVC.mjs → devtools-B3W3DLPG.mjs} +20 -19
- package/dist/{devtools-6K4QXFRL.cjs → devtools-T5I2WHRX.cjs} +22 -21
- package/dist/docs.cjs +29 -22
- package/dist/docs.d.mts +20 -6
- package/dist/docs.d.ts +20 -6
- package/dist/docs.mjs +28 -21
- package/dist/{endpoint.d-BkMSCRf6.d.mts → endpoint.d-BXbBpKoh.d.mts} +42 -1
- package/dist/{endpoint.d-BgHn0lhl.d.ts → endpoint.d-Dx_1k6Du.d.ts} +42 -1
- package/dist/environment/vite.cjs +6 -6
- package/dist/environment/vite.mjs +5 -5
- package/dist/headers.cjs +3 -3
- package/dist/{headers.d-uQ6BR59u.d.ts → headers.d-Aux4JVnm.d.ts} +1 -1
- package/dist/{headers.d-BUxGJTsj.d.mts → headers.d-BawakaPv.d.mts} +1 -1
- package/dist/headers.mjs +2 -2
- package/dist/i18n/client.cjs +15 -16
- package/dist/i18n/client.mjs +5 -6
- package/dist/i18n/index.cjs +4 -4
- package/dist/i18n/index.mjs +3 -3
- package/dist/i18n/server.cjs +5 -5
- package/dist/i18n/server.mjs +4 -4
- package/dist/image/server.cjs +5 -4
- package/dist/image/server.d.mts +5 -1
- package/dist/image/server.d.ts +5 -1
- package/dist/image/server.mjs +4 -3
- package/dist/image/sharp.cjs +53 -89
- package/dist/image/sharp.d.mts +2 -1
- package/dist/image/sharp.d.ts +2 -1
- package/dist/image/sharp.mjs +50 -86
- package/dist/index.cjs +113 -96
- package/dist/{index.d-CuWOJ-un.d.mts → index.d-Ccq42CPU.d.mts} +1 -1
- package/dist/{index.d-BCGfxCXY.d.ts → index.d-r1MLpgeE.d.ts} +1 -1
- package/dist/index.d.mts +64 -30
- package/dist/index.d.ts +64 -30
- package/dist/index.mjs +111 -94
- package/dist/integrations/orm.d.mts +4 -4
- package/dist/integrations/orm.d.ts +4 -4
- package/dist/integrations.cjs +9 -9
- package/dist/integrations.d.mts +4 -4
- package/dist/integrations.d.ts +4 -4
- package/dist/integrations.mjs +8 -8
- package/dist/internal/app-markdown-runtime.cjs +10 -6
- package/dist/internal/app-markdown-runtime.d.mts +17 -6
- package/dist/internal/app-markdown-runtime.d.ts +17 -6
- package/dist/internal/app-markdown-runtime.mjs +9 -5
- package/dist/internal/build-runtime.cjs +71 -67
- package/dist/internal/build-runtime.d.mts +6 -6
- package/dist/internal/build-runtime.d.ts +6 -6
- package/dist/internal/build-runtime.mjs +70 -66
- package/dist/internal/cli-runtime.cjs +35 -34
- package/dist/internal/cli-runtime.mjs +34 -33
- package/dist/internal/client-error-overlay.cjs +6 -6
- package/dist/internal/client-error-overlay.mjs +2 -2
- package/dist/internal/client-runtime.cjs +28 -3
- package/dist/internal/client-runtime.d.mts +45 -12
- package/dist/internal/client-runtime.d.ts +45 -12
- package/dist/internal/client-runtime.mjs +28 -3
- package/dist/internal/compression-runtime.d.mts +4 -4
- package/dist/internal/compression-runtime.d.ts +4 -4
- package/dist/internal/config-runtime.cjs +22 -21
- package/dist/internal/config-runtime.d.mts +6 -6
- package/dist/internal/config-runtime.d.ts +6 -6
- package/dist/internal/config-runtime.mjs +21 -20
- package/dist/internal/form-actions.cjs +7 -6
- package/dist/internal/form-actions.d.mts +2 -2
- package/dist/internal/form-actions.d.ts +2 -2
- package/dist/internal/form-actions.mjs +6 -5
- package/dist/internal/infra-analytics-runtime.cjs +15 -15
- package/dist/internal/infra-analytics-runtime.mjs +13 -13
- package/dist/internal/islands-server.cjs +2 -2
- package/dist/internal/islands-server.mjs +1 -1
- package/dist/internal/metadata-image-runtime.cjs +4 -4
- package/dist/internal/metadata-image-runtime.mjs +3 -3
- 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 +73 -40
- package/dist/internal/production-runtime.d.mts +133 -15
- package/dist/internal/production-runtime.d.ts +133 -15
- package/dist/internal/production-runtime.mjs +76 -43
- package/dist/internal/react-cache.cjs +3 -3
- package/dist/internal/react-cache.mjs +1 -1
- package/dist/internal/start-manifest.cjs +54 -0
- package/dist/internal/start-manifest.d.mts +43 -0
- package/dist/internal/start-manifest.d.ts +43 -0
- package/dist/internal/start-manifest.mjs +54 -0
- package/dist/internal/vercel-edge-middleware.cjs +8 -8
- package/dist/internal/vercel-edge-middleware.mjs +7 -7
- package/dist/{lifecycle.d-keQs5Swc.d.mts → lifecycle.d-OtGWAvJT.d.mts} +4 -0
- package/dist/{lifecycle.d-keQs5Swc.d.ts → lifecycle.d-OtGWAvJT.d.ts} +4 -0
- package/dist/manager-R7FV4A56.cjs +18 -0
- package/dist/{manager-JIA66YJ2.mjs → manager-YO2RHDYU.mjs} +7 -4
- package/dist/markdown.cjs +5 -5
- package/dist/markdown.d.mts +4 -4
- package/dist/markdown.d.ts +4 -4
- package/dist/markdown.mjs +4 -4
- package/dist/middleware.cjs +14 -14
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/middleware.mjs +13 -13
- package/dist/{mount.d-BIYmcGGg.d.mts → mount.d-BomEt2kV.d.mts} +1 -1
- package/dist/{mount.d-q8k0cJV0.d.ts → mount.d-Ca8eb9GB.d.ts} +1 -1
- package/dist/{native-server-fn-handler-QRTXGZA4.cjs → native-server-fn-handler-IWNKQEXK.cjs} +10 -8
- package/dist/{native-server-fn-handler-EP5AFJYE.mjs → native-server-fn-handler-LII4MDRR.mjs} +9 -7
- package/dist/native-tree-D3PW64ZL.cjs +28 -0
- package/dist/{native-tree-OYGKP2NZ.mjs → native-tree-G6ZWS7IR.mjs} +5 -5
- package/dist/{navigation-delegate.d-CYBUupsv.d.mts → navigation-delegate.d-B1ujRkYo.d.mts} +1 -1
- package/dist/{navigation-delegate.d-Btfs6Uoa.d.ts → navigation-delegate.d-DJCC2jXF.d.ts} +1 -1
- package/dist/navigation.cjs +13 -11
- package/dist/navigation.d.mts +7 -7
- package/dist/navigation.d.ts +7 -7
- package/dist/navigation.mjs +12 -10
- package/dist/{nitro-2LMOMIST.cjs → nitro-HKMVYIXY.cjs} +13 -13
- package/dist/{nitro-72TFIGGO.mjs → nitro-RHLKLYXH.mjs} +8 -8
- package/dist/{plugin-5PIQQVRP.cjs → plugin-5BNPYCER.cjs} +2 -2
- package/dist/{plugin-QZT747YW.mjs → plugin-FD4S2QEJ.mjs} +1 -1
- package/dist/plugin.cjs +65 -60
- package/dist/plugin.d.mts +7 -7
- package/dist/plugin.d.ts +7 -7
- package/dist/plugin.mjs +64 -59
- package/dist/query/client.cjs +20 -9
- package/dist/query/client.mjs +16 -5
- package/dist/{render-plan.d-0FHusf1D.d.ts → render-plan.d-BxRbaxYA.d.ts} +1 -1
- package/dist/{render-plan.d-BlyxqKMu.d.mts → render-plan.d-CFod_Zf-.d.mts} +1 -1
- package/dist/renderer/react/server.cjs +9 -1
- package/dist/renderer/react/server.d.mts +9 -1
- package/dist/renderer/react/server.d.ts +9 -1
- package/dist/renderer/react/server.mjs +8 -0
- package/dist/renderer-client.cjs +25 -26
- package/dist/renderer-client.d.mts +7 -7
- package/dist/renderer-client.d.ts +7 -7
- package/dist/renderer-client.mjs +15 -16
- package/dist/request.cjs +2 -2
- package/dist/{request.d-CPdVjssg.d.ts → request.d-DG4TeXMM.d.mts} +14 -2
- package/dist/{request.d-CX-gks1l.d.mts → request.d-DRQgaXGG.d.ts} +14 -2
- package/dist/request.d.mts +5 -5
- package/dist/request.d.ts +5 -5
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering.d-CcvZ_4N2.d.mts → route-rendering.d-BXtZKgqu.d.mts} +1 -1
- package/dist/{route-rendering.d-DcOoSNoG.d.ts → route-rendering.d-Db07UNVG.d.ts} +1 -1
- package/dist/{route.d-DrXkpvcg.d.mts → route.d-Cd4Fi6BA.d.ts} +3 -1
- package/dist/{route.d-hs-_cyHn.d.ts → route.d-ShmtqqVQ.d.mts} +3 -1
- package/dist/router.cjs +4 -4
- package/dist/{router.d-C8RHma4A.d.mts → router.d-B61kXqxJ.d.mts} +1 -1
- package/dist/{router.d-D2QnK8cM.d.ts → router.d-BC3hyjf0.d.ts} +1 -1
- package/dist/router.mjs +3 -3
- package/dist/routes.cjs +7 -5
- package/dist/routes.d.mts +4 -4
- package/dist/routes.d.ts +4 -4
- package/dist/routes.mjs +6 -4
- package/dist/{rsc-pipeline-LC2FBZAR.mjs → rsc-pipeline-LJ7YCGY6.mjs} +24 -23
- package/dist/{rsc-pipeline-NTAM65NT.cjs → rsc-pipeline-VENBFYXW.cjs} +25 -24
- package/dist/{runtime-MWAC7NWR.mjs → runtime-4DWUXZHS.mjs} +29 -29
- package/dist/{runtime-U4PAMTVH.cjs → runtime-UNDTYGQS.cjs} +40 -40
- package/dist/{runtime.d-BQUHHq8M.d.mts → runtime.d-Cl6EBGmC.d.mts} +3 -3
- package/dist/{runtime.d-1l_1bLrL.d.ts → runtime.d-SC95yDzr.d.ts} +3 -3
- package/dist/safe-fetch.cjs +15 -0
- package/dist/safe-fetch.d.mts +61 -0
- package/dist/safe-fetch.d.ts +61 -0
- package/dist/safe-fetch.mjs +15 -0
- package/dist/{schema-dev-notice-C2JINRZI.mjs → schema-dev-notice-CA55V57L.mjs} +2 -2
- package/dist/{schema-dev-notice-X7GG7QVB.cjs → schema-dev-notice-RWA2UTR6.cjs} +3 -3
- package/dist/server-action-security.cjs +7 -5
- package/dist/server-action-security.d.mts +11 -3
- package/dist/server-action-security.d.ts +11 -3
- package/dist/server-action-security.mjs +6 -4
- package/dist/server-fn-client.d.mts +3 -3
- package/dist/server-fn-client.d.ts +3 -3
- package/dist/server-fn.cjs +9 -7
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-fn.mjs +8 -6
- package/dist/server-plugins.cjs +8 -8
- package/dist/server-plugins.d.mts +53 -9
- package/dist/server-plugins.d.ts +53 -9
- package/dist/server-plugins.mjs +7 -7
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.cjs +10 -8
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server-query.mjs +9 -7
- package/dist/server.cjs +105 -103
- package/dist/server.d.mts +17 -17
- package/dist/server.d.ts +17 -17
- package/dist/server.mjs +78 -76
- package/dist/{spa-router.d-BzPdi48R.d.mts → spa-router.d-DrlXgDqY.d.mts} +13 -6
- package/dist/{spa-router.d-BJtXNeqo.d.ts → spa-router.d-DwM02Mwd.d.ts} +13 -6
- package/dist/testing.cjs +34 -32
- package/dist/testing.d.mts +4 -4
- package/dist/testing.d.ts +4 -4
- package/dist/testing.mjs +26 -24
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-DquC6qxy.d.ts → utils.d-C6KXz3uB.d.ts} +1 -1
- package/dist/{utils.d-B4ZW-6z6.d.mts → utils.d-CHzxAshz.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +65 -60
- package/dist/vite.d.mts +18 -8
- package/dist/vite.d.ts +18 -8
- package/dist/vite.mjs +64 -59
- package/dist/workflows.cjs +7 -7
- package/dist/workflows.mjs +6 -6
- package/package.json +18 -1
- package/dist/analyzer-V5ZMRIIY.cjs +0 -16
- package/dist/chunk-6I4BFRE7.cjs +0 -51
- package/dist/chunk-D4XGKF67.cjs +0 -127
- package/dist/chunk-EIVGPQN5.mjs +0 -51
- package/dist/chunk-MFQGU5CC.mjs +0 -127
- package/dist/chunk-NCIAP562.mjs +0 -27
- package/dist/chunk-QQ44FYRO.cjs +0 -27
- package/dist/chunk-RI3EVPKD.cjs +0 -57
- package/dist/manager-JOHU6BQI.cjs +0 -15
- package/dist/native-tree-R6CQMDTI.cjs +0 -28
|
@@ -23,16 +23,16 @@ import {
|
|
|
23
23
|
createReactProductionModePlugin,
|
|
24
24
|
withProductionNodeEnv
|
|
25
25
|
} from "./chunk-ZZGQD3LL.mjs";
|
|
26
|
-
import {
|
|
27
|
-
collectFarmNativeServerFns,
|
|
28
|
-
findFarmNativeScreenFiles
|
|
29
|
-
} from "./chunk-7GMBETHM.mjs";
|
|
30
26
|
import {
|
|
31
27
|
generateNativeMCPPluginSource
|
|
32
28
|
} from "./chunk-KQH2COEJ.mjs";
|
|
33
29
|
import {
|
|
34
30
|
FARM_MOBILE_SESSION_PLUGIN
|
|
35
31
|
} from "./chunk-B4CWYGCG.mjs";
|
|
32
|
+
import {
|
|
33
|
+
collectFarmNativeServerFns,
|
|
34
|
+
findFarmNativeScreenFiles
|
|
35
|
+
} from "./chunk-HV2WZFUW.mjs";
|
|
36
36
|
import {
|
|
37
37
|
assertFarmDocsAdapterServesNoGuardedPages,
|
|
38
38
|
compileFarmDocsAdapterEdgeManifest,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
hasFarmDocsRuntimeAdapter,
|
|
42
42
|
listFarmDocsAdapterPages,
|
|
43
43
|
listFarmDocsPagePaths
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-GLF44JKY.mjs";
|
|
45
45
|
import {
|
|
46
46
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
47
47
|
createFarmDocsHandler,
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
loadFarmDocsPage,
|
|
55
55
|
resolveFarmDocsContentDir,
|
|
56
56
|
toFarmDocsMarkdownPage
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-LPXJEZJK.mjs";
|
|
58
58
|
import {
|
|
59
59
|
generateFarmDocsSearchClientRuntime,
|
|
60
60
|
isFarmDocsSearchEnabled,
|
|
@@ -62,10 +62,10 @@ import {
|
|
|
62
62
|
} from "./chunk-ALEUMLJN.mjs";
|
|
63
63
|
import {
|
|
64
64
|
CDN_CACHE_CONTROL_HEADERS
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-URQW27KO.mjs";
|
|
66
66
|
import {
|
|
67
67
|
FARM_PRERENDER_ENV
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-2NQ3S2SJ.mjs";
|
|
69
69
|
import {
|
|
70
70
|
loadFarmDocsEngine
|
|
71
71
|
} from "./chunk-LRPPXKCX.mjs";
|
|
@@ -74,13 +74,16 @@ import {
|
|
|
74
74
|
getDeployTargetForPreset,
|
|
75
75
|
hasCustomFarmRouteContext,
|
|
76
76
|
resolveDeployOutputPath
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-YCNKS6SD.mjs";
|
|
78
78
|
import {
|
|
79
79
|
resolveFarmInstrumentationFile
|
|
80
80
|
} from "./chunk-57QAQU4F.mjs";
|
|
81
81
|
import {
|
|
82
82
|
resolveFarmInstrumentationRuntime
|
|
83
83
|
} from "./chunk-WNDAISB7.mjs";
|
|
84
|
+
import {
|
|
85
|
+
createFarmRouter
|
|
86
|
+
} from "./chunk-BRNPLD22.mjs";
|
|
84
87
|
import {
|
|
85
88
|
DEFAULT_NOT_FOUND_STYLES,
|
|
86
89
|
FARM_LAYOUT_ELEMENT_CLIENT_SOURCE,
|
|
@@ -88,8 +91,10 @@ import {
|
|
|
88
91
|
FARM_NAVIGATION_STREAM_READER_SOURCE,
|
|
89
92
|
FARM_REFRESH_FIELDS_SOURCE,
|
|
90
93
|
FARM_SERVER_TREE_LAYOUT_CLIENT_SOURCE,
|
|
94
|
+
FARM_VIDEO_PLAYER_HTML,
|
|
91
95
|
SHARP_INSTALL_HINT,
|
|
92
96
|
canBootFarmIslandsClient,
|
|
97
|
+
canFarmSkipKeptLayoutRender,
|
|
93
98
|
collectFarmWebMCPTools,
|
|
94
99
|
createFarmApp,
|
|
95
100
|
createFarmSourceAlias,
|
|
@@ -109,21 +114,25 @@ import {
|
|
|
109
114
|
resolveFarmImageProviderForRuntime,
|
|
110
115
|
resolveFarmImageServerRuntime,
|
|
111
116
|
resolveFarmNotFoundComponentPath,
|
|
112
|
-
resolveFarmRouteRootStrategy
|
|
113
|
-
|
|
117
|
+
resolveFarmRouteRootStrategy,
|
|
118
|
+
toBakedMarkdownSourcePath
|
|
119
|
+
} from "./chunk-OFIFRB62.mjs";
|
|
114
120
|
import {
|
|
121
|
+
TAILWIND_CSS_BROWSER_TARGET,
|
|
115
122
|
generateFarmClientPluginEntryCode,
|
|
116
123
|
hasFarmServerRuntimePlugins,
|
|
124
|
+
includesTailwindVitePlugin,
|
|
117
125
|
loadTailwindVitePlugin
|
|
118
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-MFU7SXAB.mjs";
|
|
119
127
|
import {
|
|
120
128
|
PluginManager
|
|
121
129
|
} from "./chunk-Z5ZZAGIH.mjs";
|
|
122
130
|
import {
|
|
123
131
|
generateFarmTypeArtifacts,
|
|
124
132
|
readRouteRenderingDirectiveFromFile,
|
|
133
|
+
resolveRouteRenderingConfig,
|
|
125
134
|
resolveRouteRenderingConfigFromFile
|
|
126
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-LQBV2Y37.mjs";
|
|
127
136
|
import {
|
|
128
137
|
HOISTED_HEAD_ELEMENT,
|
|
129
138
|
appMiddlewareMayHandlePath,
|
|
@@ -136,7 +145,7 @@ import {
|
|
|
136
145
|
layoutsCanCoverSamePage,
|
|
137
146
|
routeBoundaryCoversDirectory,
|
|
138
147
|
stripRouteGroups
|
|
139
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-HT2SZKXG.mjs";
|
|
140
149
|
import {
|
|
141
150
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
142
151
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -150,15 +159,15 @@ import {
|
|
|
150
159
|
listFarmBuiltInRoutePaths,
|
|
151
160
|
resolveFarmApiCatalogInput,
|
|
152
161
|
resolveFarmAppManifestInput
|
|
153
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-GNY7BO7R.mjs";
|
|
154
163
|
import {
|
|
155
164
|
FARM_DEFAULT_MCP_PATH,
|
|
156
165
|
createFarmDefaultMCPServer,
|
|
157
166
|
farmConfigMountsMCP
|
|
158
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-JA6RML7C.mjs";
|
|
159
168
|
import {
|
|
160
169
|
isFarmPreviewDeploymentEnvironment
|
|
161
|
-
} from "./chunk-
|
|
170
|
+
} from "./chunk-YSTKSZD2.mjs";
|
|
162
171
|
import {
|
|
163
172
|
FARM_NATIVE_SERVER_FN_PLUGIN
|
|
164
173
|
} from "./chunk-L4RTTTVE.mjs";
|
|
@@ -169,6 +178,7 @@ import {
|
|
|
169
178
|
enforceFarmIsolatedHydrationRouteBudget,
|
|
170
179
|
farmEnvironmentFunctionsPlugin,
|
|
171
180
|
getClientModuleHydrationPlan,
|
|
181
|
+
getClientModuleHydrationPlanKey,
|
|
172
182
|
getClientModuleMetadata,
|
|
173
183
|
getFarmClientHydrationPlanOptions,
|
|
174
184
|
resolveFarmIsolatedClientHydrationMode,
|
|
@@ -176,8 +186,9 @@ import {
|
|
|
176
186
|
usePackageClientBoundaryCacheFile,
|
|
177
187
|
usesFarmServerTree,
|
|
178
188
|
withFarmSourceSnapshot,
|
|
189
|
+
withFarmSourceSnapshotOf,
|
|
179
190
|
withPackageClientBoundaryCache
|
|
180
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-A5F55ZFA.mjs";
|
|
181
192
|
import {
|
|
182
193
|
generateFarmDocsAdapterClientRuntime,
|
|
183
194
|
getFarmDocsAdapterConfigModule
|
|
@@ -189,7 +200,7 @@ import {
|
|
|
189
200
|
import {
|
|
190
201
|
nitroRouteRulesBelowBasePath,
|
|
191
202
|
routeRulesToNitroRouteRules
|
|
192
|
-
} from "./chunk-
|
|
203
|
+
} from "./chunk-YVVY276M.mjs";
|
|
193
204
|
import {
|
|
194
205
|
applyFarmCspHashesToHtml,
|
|
195
206
|
createFarmCspNonce
|
|
@@ -214,38 +225,42 @@ import {
|
|
|
214
225
|
applyFarmCronVercelCrons,
|
|
215
226
|
createFarmCronCloudflareConfig,
|
|
216
227
|
mergeScheduledTasks,
|
|
217
|
-
prepareFarmCronForNitro
|
|
218
|
-
|
|
228
|
+
prepareFarmCronForNitro,
|
|
229
|
+
toFarmCronCloudflareScheduledTasks
|
|
230
|
+
} from "./chunk-CSAIIMY3.mjs";
|
|
219
231
|
import {
|
|
220
232
|
resolveServerActionsConfig
|
|
221
|
-
} from "./chunk-
|
|
233
|
+
} from "./chunk-NLATR3T3.mjs";
|
|
222
234
|
import {
|
|
223
235
|
createBundledEnv
|
|
224
236
|
} from "./chunk-N33DLJBC.mjs";
|
|
225
237
|
import {
|
|
226
|
-
|
|
227
|
-
|
|
238
|
+
FARM_MARKDOWN_PRECOMPILED_PAGES,
|
|
239
|
+
isFarmMarkdownPageFile,
|
|
240
|
+
parseMarkdownFrontmatter,
|
|
241
|
+
readFarmMarkdownRouteConfig
|
|
242
|
+
} from "./chunk-BGUTIQII.mjs";
|
|
228
243
|
import {
|
|
229
244
|
resolveFarmMdxComponentsModulePath,
|
|
230
245
|
resolveMdxConfig
|
|
231
246
|
} from "./chunk-UIJOLBUL.mjs";
|
|
232
247
|
import {
|
|
233
248
|
getFarmMarkdownAlternatePath
|
|
234
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-R5X7FDOG.mjs";
|
|
235
250
|
import {
|
|
236
251
|
withPlainDiagnostics
|
|
237
252
|
} from "./chunk-MGKWYPE3.mjs";
|
|
238
253
|
import {
|
|
239
254
|
applyFarmWorkflowVercelCrons,
|
|
240
255
|
prepareFarmWorkflowsForNitro
|
|
241
|
-
} from "./chunk-
|
|
256
|
+
} from "./chunk-3AJQFVWW.mjs";
|
|
242
257
|
import {
|
|
243
258
|
getFarmIntegrationPluginServerRuntime,
|
|
244
259
|
getIntegrationProviders
|
|
245
|
-
} from "./chunk-
|
|
260
|
+
} from "./chunk-5O3SK3ZC.mjs";
|
|
246
261
|
import {
|
|
247
262
|
FARM_INTEGRATION_API_BASE_PATH_KEY
|
|
248
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-CZOXZ6WQ.mjs";
|
|
249
264
|
import {
|
|
250
265
|
_collectFarmStorageModules
|
|
251
266
|
} from "./chunk-TJVUTGED.mjs";
|
|
@@ -253,10 +268,10 @@ import {
|
|
|
253
268
|
appendMiddlewareDirectory,
|
|
254
269
|
appendMiddlewareRoutePath,
|
|
255
270
|
compareMiddlewareRouteLocations
|
|
256
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-PKXGFQZS.mjs";
|
|
257
272
|
import {
|
|
258
273
|
APIRouteManager
|
|
259
|
-
} from "./chunk-
|
|
274
|
+
} from "./chunk-5WFPZG7K.mjs";
|
|
260
275
|
import {
|
|
261
276
|
readFarmI18nCatalogs
|
|
262
277
|
} from "./chunk-VO55MMBX.mjs";
|
|
@@ -277,14 +292,17 @@ import {
|
|
|
277
292
|
logger,
|
|
278
293
|
toPosixPath,
|
|
279
294
|
toViteModuleId
|
|
280
|
-
} from "./chunk-
|
|
295
|
+
} from "./chunk-Z3QXQN4U.mjs";
|
|
281
296
|
import {
|
|
282
297
|
resolveFarmAPIServerBasePath,
|
|
283
298
|
resolveFarmAPIServerRoutePath
|
|
284
299
|
} from "./chunk-2I6PUKWJ.mjs";
|
|
285
300
|
import {
|
|
286
301
|
FARM_VERSION
|
|
287
|
-
} from "./chunk-
|
|
302
|
+
} from "./chunk-H7QY7ZE4.mjs";
|
|
303
|
+
import {
|
|
304
|
+
FARM_VIDEO_PLAYER_PATH
|
|
305
|
+
} from "./chunk-AG27TI6Q.mjs";
|
|
288
306
|
import {
|
|
289
307
|
getFarmPresetRuntime,
|
|
290
308
|
resolveCloudflareProcessEnvFlags
|
|
@@ -294,7 +312,7 @@ import {
|
|
|
294
312
|
} from "./chunk-4O26BPUY.mjs";
|
|
295
313
|
import {
|
|
296
314
|
_runWithFarmCspNonce
|
|
297
|
-
} from "./chunk-
|
|
315
|
+
} from "./chunk-FCAYYLAE.mjs";
|
|
298
316
|
import {
|
|
299
317
|
applyFarmBasePath,
|
|
300
318
|
normalizeFarmBasePath,
|
|
@@ -303,31 +321,195 @@ import {
|
|
|
303
321
|
import {
|
|
304
322
|
compareRoutePatternSpecificity,
|
|
305
323
|
compareRouteSpecificity,
|
|
324
|
+
getRoutePatternShape,
|
|
306
325
|
getRoutePatternSpecificity
|
|
307
|
-
} from "./chunk-
|
|
326
|
+
} from "./chunk-5KAEGBIL.mjs";
|
|
308
327
|
|
|
309
328
|
// src/build/index.ts
|
|
310
|
-
import
|
|
311
|
-
import { existsSync as
|
|
329
|
+
import path17 from "path";
|
|
330
|
+
import { existsSync as existsSync4 } from "fs";
|
|
312
331
|
|
|
313
332
|
// src/nitro/universal-build.ts
|
|
314
333
|
import { randomBytes } from "crypto";
|
|
315
334
|
|
|
316
|
-
// src/nitro/
|
|
335
|
+
// src/nitro/static-range.ts
|
|
336
|
+
import { readFileSync, realpathSync } from "fs";
|
|
317
337
|
import path from "path";
|
|
338
|
+
var FARM_NITRO_STATIC_HANDLER_SOURCE = `import { HTTPError, defineHandler } from "h3";
|
|
339
|
+
import { decodePath, joinURL, withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
340
|
+
import { getAsset, isPublicAssetURL, readAsset } from "#nitro/virtual/public-assets";
|
|
341
|
+
const METHODS = new Set(["HEAD", "GET"]);
|
|
342
|
+
const EncodingMap = {
|
|
343
|
+
gzip: ".gz",
|
|
344
|
+
br: ".br",
|
|
345
|
+
zstd: ".zst"
|
|
346
|
+
};
|
|
347
|
+
const RANGE_RE = /^bytes=(\\d*)-(\\d*)$/i;
|
|
348
|
+
export default defineHandler((event) => {
|
|
349
|
+
if (event.req.method && !METHODS.has(event.req.method)) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
let id = decodePath(withLeadingSlash(withoutTrailingSlash(event.url.pathname)));
|
|
353
|
+
let asset;
|
|
354
|
+
const encodingHeader = event.req.headers.get("accept-encoding") || "";
|
|
355
|
+
const encodings = [...encodingHeader.split(",").map((e) => EncodingMap[e.trim()]).filter(Boolean).sort(), ""];
|
|
356
|
+
for (const encoding of encodings) {
|
|
357
|
+
for (const _id of [id + encoding, joinURL(id, "index.html" + encoding)]) {
|
|
358
|
+
const _asset = getAsset(_id);
|
|
359
|
+
if (_asset) {
|
|
360
|
+
asset = _asset;
|
|
361
|
+
id = _id;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (!asset) {
|
|
367
|
+
if (isPublicAssetURL(id)) {
|
|
368
|
+
event.res.headers.delete("Cache-Control");
|
|
369
|
+
throw new HTTPError({ status: 404 });
|
|
370
|
+
}
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (encodings.length > 1) {
|
|
374
|
+
event.res.headers.append("Vary", "Accept-Encoding");
|
|
375
|
+
}
|
|
376
|
+
const ifNotMatch = event.req.headers.get("if-none-match") === asset.etag;
|
|
377
|
+
if (ifNotMatch) {
|
|
378
|
+
event.res.status = 304;
|
|
379
|
+
event.res.statusText = "Not Modified";
|
|
380
|
+
return "";
|
|
381
|
+
}
|
|
382
|
+
const ifModifiedSinceH = event.req.headers.get("if-modified-since");
|
|
383
|
+
const mtimeDate = new Date(asset.mtime);
|
|
384
|
+
if (ifModifiedSinceH && asset.mtime && new Date(ifModifiedSinceH) >= mtimeDate) {
|
|
385
|
+
event.res.status = 304;
|
|
386
|
+
event.res.statusText = "Not Modified";
|
|
387
|
+
return "";
|
|
388
|
+
}
|
|
389
|
+
if (asset.type) {
|
|
390
|
+
event.res.headers.set("Content-Type", asset.type);
|
|
391
|
+
}
|
|
392
|
+
if (asset.etag && !event.res.headers.has("ETag")) {
|
|
393
|
+
event.res.headers.set("ETag", asset.etag);
|
|
394
|
+
}
|
|
395
|
+
if (asset.mtime && !event.res.headers.has("Last-Modified")) {
|
|
396
|
+
event.res.headers.set("Last-Modified", mtimeDate.toUTCString());
|
|
397
|
+
}
|
|
398
|
+
if (asset.encoding && !event.res.headers.has("Content-Encoding")) {
|
|
399
|
+
event.res.headers.set("Content-Encoding", asset.encoding);
|
|
400
|
+
}
|
|
401
|
+
let range;
|
|
402
|
+
if (!asset.encoding && asset.size > 0) {
|
|
403
|
+
event.res.headers.set("Accept-Ranges", "bytes");
|
|
404
|
+
// If-Range needs a strong validator match (RFC 9110 13.1.5).
|
|
405
|
+
const ifRange = event.req.headers.get("if-range");
|
|
406
|
+
if (event.req.method === "GET" && (!ifRange || (ifRange === asset.etag && !ifRange.startsWith("W/")))) {
|
|
407
|
+
range = parseRange(event.req.headers.get("range") || "", asset.size);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (range === "unsatisfiable") {
|
|
411
|
+
event.res.headers.delete("Cache-Control");
|
|
412
|
+
throw new HTTPError({ status: 416, headers: { "Content-Range": \`bytes */\${asset.size}\` } });
|
|
413
|
+
}
|
|
414
|
+
if (asset.size > 0 && !event.res.headers.has("Content-Length")) {
|
|
415
|
+
event.res.headers.set("Content-Length", asset.size.toString());
|
|
416
|
+
}
|
|
417
|
+
if (!range) {
|
|
418
|
+
return readAsset(id);
|
|
419
|
+
}
|
|
420
|
+
return Promise.resolve(readAsset(id)).then((data) => {
|
|
421
|
+
if (!(data instanceof Uint8Array)) {
|
|
422
|
+
return data;
|
|
423
|
+
}
|
|
424
|
+
event.res.status = 206;
|
|
425
|
+
event.res.headers.set("Content-Range", \`bytes \${range.start}-\${range.end}/\${asset.size}\`);
|
|
426
|
+
event.res.headers.set("Content-Length", String(range.end - range.start + 1));
|
|
427
|
+
return data.subarray(range.start, range.end + 1);
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
// One "bytes=" range; anything else (several ranges, other units) gets the whole file.
|
|
431
|
+
function parseRange(header, size) {
|
|
432
|
+
const match = RANGE_RE.exec(header);
|
|
433
|
+
if (!match) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const [, startStr, endStr] = match;
|
|
437
|
+
if (!startStr) {
|
|
438
|
+
if (!endStr) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const suffix = Number(endStr);
|
|
442
|
+
if (suffix === 0) {
|
|
443
|
+
return "unsatisfiable";
|
|
444
|
+
}
|
|
445
|
+
return { start: Math.max(size - suffix, 0), end: size - 1 };
|
|
446
|
+
}
|
|
447
|
+
const start = Number(startStr);
|
|
448
|
+
if (endStr && Number(endStr) < start) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (start >= size) {
|
|
452
|
+
return "unsatisfiable";
|
|
453
|
+
}
|
|
454
|
+
return { start, end: endStr ? Math.min(Number(endStr), size - 1) : size - 1 };
|
|
455
|
+
}
|
|
456
|
+
`;
|
|
457
|
+
function createNitroStaticRangePlugin(nitroPackageEntry, canonicalPages = []) {
|
|
458
|
+
const redirects = canonicalPages.filter((url) => url !== "/" && !url.startsWith("//")).map((url) => [url.endsWith("/") ? url.slice(0, -1) : url + "/", url]);
|
|
459
|
+
const original = "?farm-static-handler";
|
|
460
|
+
const handlerFile = path.join(path.dirname(nitroPackageEntry), "internal", "static.mjs");
|
|
461
|
+
const handlerIds = /* @__PURE__ */ new Set([toPosix(handlerFile)]);
|
|
462
|
+
try {
|
|
463
|
+
handlerIds.add(toPosix(realpathSync(handlerFile)));
|
|
464
|
+
} catch {
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
name: "farm:nitro-static-range",
|
|
468
|
+
resolveId(id) {
|
|
469
|
+
if (id.endsWith(original) && handlerIds.has(id.slice(0, -original.length))) return id;
|
|
470
|
+
return null;
|
|
471
|
+
},
|
|
472
|
+
load: {
|
|
473
|
+
filter: { id: /[\\/]internal[\\/]static\.mjs(?:\?.*)?$/ },
|
|
474
|
+
handler(id) {
|
|
475
|
+
const file = id.split("?", 1)[0];
|
|
476
|
+
if (!handlerIds.has(toPosix(file))) return null;
|
|
477
|
+
if (redirects.length && !id.endsWith(original)) {
|
|
478
|
+
return `import serve from ${JSON.stringify(toPosix(file) + original)};
|
|
479
|
+
const redirects = new Map(${JSON.stringify(redirects)});
|
|
480
|
+
export default function(event) {
|
|
481
|
+
const url = new URL(event.req.url);
|
|
482
|
+
const target = redirects.get(url.pathname);
|
|
483
|
+
if (target !== undefined) return new Response(null, { status: 308, headers: { Location: target + url.search } });
|
|
484
|
+
return serve(event);
|
|
485
|
+
}`;
|
|
486
|
+
}
|
|
487
|
+
const source = readFileSync(file, "utf8");
|
|
488
|
+
if (source.includes("Accept-Ranges")) return id.endsWith(original) ? source : null;
|
|
489
|
+
return FARM_NITRO_STATIC_HANDLER_SOURCE;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function toPosix(file) {
|
|
495
|
+
return file.split(path.sep).join("/");
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/nitro/client-css-href.ts
|
|
499
|
+
import path2 from "path";
|
|
318
500
|
var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
319
501
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
320
502
|
var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
|
|
321
503
|
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
322
|
-
const
|
|
504
|
+
const fs5 = await import("fs/promises");
|
|
323
505
|
try {
|
|
324
|
-
const bytes = await
|
|
506
|
+
const bytes = await fs5.readFile(sourcePath);
|
|
325
507
|
if (bytes.length === 0) return null;
|
|
326
508
|
const { createHash } = await import("crypto");
|
|
327
509
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
328
510
|
const name = hashedName(hash);
|
|
329
|
-
await
|
|
330
|
-
await
|
|
511
|
+
await fs5.mkdir(destinationDir, { recursive: true });
|
|
512
|
+
await fs5.writeFile(path2.join(destinationDir, name), bytes);
|
|
331
513
|
return name;
|
|
332
514
|
} catch {
|
|
333
515
|
return null;
|
|
@@ -335,25 +517,25 @@ async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
|
335
517
|
}
|
|
336
518
|
async function resolveHashedClientCssHref(clientOutputDir) {
|
|
337
519
|
const name = await hashAndCopy(
|
|
338
|
-
|
|
339
|
-
|
|
520
|
+
path2.join(clientOutputDir, "farm-client.css"),
|
|
521
|
+
path2.join(clientOutputDir, "assets"),
|
|
340
522
|
(hash) => `farm-client-h${hash}.css`
|
|
341
523
|
);
|
|
342
524
|
return name ? `/assets/${name}` : "/farm-client.css";
|
|
343
525
|
}
|
|
344
526
|
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
345
|
-
const
|
|
527
|
+
const fs5 = await import("fs/promises");
|
|
346
528
|
try {
|
|
347
|
-
const entries = await
|
|
529
|
+
const entries = await fs5.readdir(clientOutputDir);
|
|
348
530
|
return entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)) ?? null;
|
|
349
531
|
} catch {
|
|
350
532
|
return null;
|
|
351
533
|
}
|
|
352
534
|
}
|
|
353
535
|
async function resolveClientBootSrc(clientOutputDir) {
|
|
354
|
-
const
|
|
536
|
+
const fs5 = await import("fs/promises");
|
|
355
537
|
try {
|
|
356
|
-
const entries = await
|
|
538
|
+
const entries = await fs5.readdir(clientOutputDir);
|
|
357
539
|
const name = entries.find((entry) => /^farm-client-boot-h[0-9a-f]+\.js$/.test(entry));
|
|
358
540
|
return name ? `/${name}` : null;
|
|
359
541
|
} catch {
|
|
@@ -363,23 +545,24 @@ async function resolveClientBootSrc(clientOutputDir) {
|
|
|
363
545
|
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
364
546
|
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
365
547
|
if (!entryName) return "/farm-client.js";
|
|
366
|
-
const
|
|
548
|
+
const fs5 = await import("fs/promises");
|
|
367
549
|
const shim = `export * from "./${entryName}";
|
|
368
550
|
`;
|
|
369
|
-
await
|
|
551
|
+
await fs5.writeFile(path2.join(clientOutputDir, "farm-client.js"), shim);
|
|
370
552
|
return `/${entryName}`;
|
|
371
553
|
}
|
|
372
554
|
|
|
373
555
|
// src/nitro/universal-build.ts
|
|
374
556
|
import os from "os";
|
|
375
|
-
import
|
|
376
|
-
import { constants as fsConstants, existsSync as
|
|
557
|
+
import path16 from "path";
|
|
558
|
+
import { constants as fsConstants, existsSync as existsSync3, readFileSync as readFileSync2, realpathSync as realpathSync3, statSync } from "fs";
|
|
559
|
+
import { initSync as initModuleLexer, parse as lexModule } from "es-module-lexer";
|
|
377
560
|
import { fileURLToPath } from "url";
|
|
378
561
|
import { builtinModules, createRequire as createRequire2 } from "module";
|
|
379
562
|
import { isDeepStrictEqual } from "util";
|
|
380
563
|
|
|
381
564
|
// src/docs/compiler.ts
|
|
382
|
-
import
|
|
565
|
+
import path3 from "path";
|
|
383
566
|
var FARM_DOCS_COMPILED_ORIGIN = "https://farm-docs-build.invalid";
|
|
384
567
|
function normalizePathname(pathname) {
|
|
385
568
|
if (pathname === "/") return pathname;
|
|
@@ -442,8 +625,8 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
442
625
|
const pages = loadPages(contentDir, docs);
|
|
443
626
|
const basePath = normalizeFarmBasePath(options.basePath);
|
|
444
627
|
const absolutePaths = [
|
|
445
|
-
|
|
446
|
-
|
|
628
|
+
path3.resolve(options.root),
|
|
629
|
+
path3.resolve(contentDir),
|
|
447
630
|
docs.configPath || ""
|
|
448
631
|
];
|
|
449
632
|
const handler = createFarmDocsHandler(docs, {
|
|
@@ -566,7 +749,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
566
749
|
|
|
567
750
|
// src/nitro/client-module-preloads.ts
|
|
568
751
|
import fs from "fs/promises";
|
|
569
|
-
import
|
|
752
|
+
import path4 from "path";
|
|
570
753
|
var FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER = "__farm_client_module_preloads__";
|
|
571
754
|
var FARM_CLIENT_MODULE_PRELOADS_FILE = "client-module-preloads.json";
|
|
572
755
|
function collectFarmClientModulePreloads(bundle, options) {
|
|
@@ -604,7 +787,7 @@ function collectFarmClientModulePreloads(bundle, options) {
|
|
|
604
787
|
continue;
|
|
605
788
|
}
|
|
606
789
|
const moduleId = chunk.facadeModuleId.split("?")[0];
|
|
607
|
-
if (!
|
|
790
|
+
if (!path4.isAbsolute(moduleId)) continue;
|
|
608
791
|
const loaded = /* @__PURE__ */ new Set([...entryLoaded, chunk.fileName]);
|
|
609
792
|
modules[toViteModuleId(moduleId, options.root)] = [
|
|
610
793
|
chunk.fileName,
|
|
@@ -620,7 +803,7 @@ function createFarmClientModulePreloadPlugin(options) {
|
|
|
620
803
|
async generateBundle(_output, bundle) {
|
|
621
804
|
await fs.mkdir(options.buildDir, { recursive: true });
|
|
622
805
|
await fs.writeFile(
|
|
623
|
-
|
|
806
|
+
path4.join(options.buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE),
|
|
624
807
|
JSON.stringify(collectFarmClientModulePreloads(bundle, options))
|
|
625
808
|
);
|
|
626
809
|
}
|
|
@@ -629,19 +812,92 @@ function createFarmClientModulePreloadPlugin(options) {
|
|
|
629
812
|
async function readFarmClientModulePreloads(buildDir) {
|
|
630
813
|
try {
|
|
631
814
|
return JSON.parse(
|
|
632
|
-
await fs.readFile(
|
|
815
|
+
await fs.readFile(path4.join(buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE), "utf8")
|
|
633
816
|
);
|
|
634
817
|
} catch {
|
|
635
818
|
return null;
|
|
636
819
|
}
|
|
637
820
|
}
|
|
638
821
|
function encodeFarmClientModulePreloads(manifest) {
|
|
639
|
-
return
|
|
822
|
+
return encodeFarmBuildJSONPlaceholder(manifest);
|
|
823
|
+
}
|
|
824
|
+
function encodeFarmBuildJSONPlaceholder(value) {
|
|
825
|
+
return JSON.stringify(JSON.stringify(value)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
640
826
|
}
|
|
641
827
|
|
|
642
|
-
// src/
|
|
828
|
+
// src/nitro/client-route-table.ts
|
|
643
829
|
import fs2 from "fs/promises";
|
|
644
|
-
import
|
|
830
|
+
import path5 from "path";
|
|
831
|
+
var FARM_CLIENT_ROUTE_TABLE_MODULE = "farm-client-routes";
|
|
832
|
+
var FARM_CLIENT_ROUTE_TABLE_FILE = "client-route-table.json";
|
|
833
|
+
var FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER = "__farm_client_route_table__";
|
|
834
|
+
function createFarmClientRouteTable(clientPages) {
|
|
835
|
+
let loaders = 0;
|
|
836
|
+
return clientPages.map((page) => ({
|
|
837
|
+
pattern: page.pattern,
|
|
838
|
+
...page.directory ? { directory: page.directory } : {},
|
|
839
|
+
pageShouldHydrate: page.pageShouldHydrate,
|
|
840
|
+
...page.docs ? { docs: true } : {},
|
|
841
|
+
...page.hasIsolatedClientBoundaries ? { hasIsolatedClientBoundaries: true } : {},
|
|
842
|
+
islandStrategy: page.islandStrategy,
|
|
843
|
+
...page.pageShouldHydrate ? { loader: loaders++ } : {}
|
|
844
|
+
}));
|
|
845
|
+
}
|
|
846
|
+
function resolveFarmDocsClientRoutes(pages, docsPagePaths) {
|
|
847
|
+
const docsRoutes = /* @__PURE__ */ new Map();
|
|
848
|
+
for (const page of pages) {
|
|
849
|
+
if (page.docs) docsRoutes.set(getRoutePatternShape(page.pattern, "router"), page);
|
|
850
|
+
}
|
|
851
|
+
const docsTemplate = docsRoutes.values().next().value;
|
|
852
|
+
const groupedDocsPages = [];
|
|
853
|
+
const appPages = [];
|
|
854
|
+
const shadowed = [];
|
|
855
|
+
for (const page of pages) {
|
|
856
|
+
if (page.docs) continue;
|
|
857
|
+
const shape = getRoutePatternShape(page.pattern, "router");
|
|
858
|
+
const docsRoute = docsRoutes.get(shape);
|
|
859
|
+
const directory = page.directory ? { directory: page.directory } : {};
|
|
860
|
+
if (docsPagePaths.has(page.pattern)) {
|
|
861
|
+
if (docsRoute) docsRoutes.set(shape, { ...docsRoute, ...directory });
|
|
862
|
+
else if (docsTemplate && page.directory) {
|
|
863
|
+
groupedDocsPages.push({ ...docsTemplate, pattern: page.pattern, ...directory });
|
|
864
|
+
}
|
|
865
|
+
} else if (!docsRoute) {
|
|
866
|
+
appPages.push(page);
|
|
867
|
+
} else if (getRoutePatternSpecificity(docsRoute.pattern, "router").every(isStatic)) {
|
|
868
|
+
docsRoutes.delete(shape);
|
|
869
|
+
appPages.push(page);
|
|
870
|
+
} else {
|
|
871
|
+
docsRoutes.set(shape, { ...docsRoute, ...directory });
|
|
872
|
+
shadowed.push(page);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return { pages: [...docsRoutes.values(), ...groupedDocsPages, ...appPages], shadowed };
|
|
876
|
+
}
|
|
877
|
+
function isStatic(segment) {
|
|
878
|
+
return segment === "static";
|
|
879
|
+
}
|
|
880
|
+
function generateFarmClientRouteTableModule(table) {
|
|
881
|
+
return `export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
|
|
882
|
+
`;
|
|
883
|
+
}
|
|
884
|
+
async function writeFarmClientRouteTable(buildDir, table) {
|
|
885
|
+
await fs2.mkdir(buildDir, { recursive: true });
|
|
886
|
+
await fs2.writeFile(path5.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), JSON.stringify(table));
|
|
887
|
+
}
|
|
888
|
+
async function readFarmClientRouteTable(buildDir) {
|
|
889
|
+
try {
|
|
890
|
+
return JSON.parse(
|
|
891
|
+
await fs2.readFile(path5.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), "utf8")
|
|
892
|
+
);
|
|
893
|
+
} catch {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/docs/module-preloads.ts
|
|
899
|
+
import fs3 from "fs/promises";
|
|
900
|
+
import path6 from "path";
|
|
645
901
|
var FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER = "__farm_docs_module_preloads__";
|
|
646
902
|
var FARM_DOCS_MODULE_PRELOADS_FILE = "docs-module-preloads.json";
|
|
647
903
|
function normalizeModuleId(id) {
|
|
@@ -677,7 +933,7 @@ function collectFarmDocsModulePreloads(bundle, options) {
|
|
|
677
933
|
return value;
|
|
678
934
|
};
|
|
679
935
|
const pages = {};
|
|
680
|
-
const root = normalizeModuleId(
|
|
936
|
+
const root = normalizeModuleId(path6.resolve(options.root));
|
|
681
937
|
for (const [moduleId, chunk] of byModule) {
|
|
682
938
|
if (!/\.mdx?$/.test(moduleId) || !moduleId.startsWith(`${root}/`)) continue;
|
|
683
939
|
const own = [...withStaticImports(chunk.fileName, /* @__PURE__ */ new Set())].filter(
|
|
@@ -705,9 +961,9 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
705
961
|
entryName: options.entryName,
|
|
706
962
|
runtimeModuleIds
|
|
707
963
|
});
|
|
708
|
-
await
|
|
709
|
-
await
|
|
710
|
-
|
|
964
|
+
await fs3.mkdir(options.buildDir, { recursive: true });
|
|
965
|
+
await fs3.writeFile(
|
|
966
|
+
path6.join(options.buildDir, FARM_DOCS_MODULE_PRELOADS_FILE),
|
|
711
967
|
JSON.stringify(manifest)
|
|
712
968
|
);
|
|
713
969
|
}
|
|
@@ -716,7 +972,7 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
716
972
|
async function readFarmDocsModulePreloads(buildDir) {
|
|
717
973
|
try {
|
|
718
974
|
return JSON.parse(
|
|
719
|
-
await
|
|
975
|
+
await fs3.readFile(path6.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
|
|
720
976
|
);
|
|
721
977
|
} catch {
|
|
722
978
|
return null;
|
|
@@ -727,10 +983,10 @@ function encodeFarmDocsModulePreloads(manifest) {
|
|
|
727
983
|
}
|
|
728
984
|
|
|
729
985
|
// src/route-runtime-manifest.ts
|
|
730
|
-
import
|
|
986
|
+
import path7 from "path";
|
|
731
987
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
732
988
|
async function createFarmRouteRuntimeManifest(options) {
|
|
733
|
-
const root =
|
|
989
|
+
const root = path7.resolve(options.root || options.config.root || process.cwd());
|
|
734
990
|
const routes = [];
|
|
735
991
|
for (const [pattern, entry] of options.routeManager.getRoutes()) {
|
|
736
992
|
const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
|
|
@@ -799,10 +1055,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
799
1055
|
};
|
|
800
1056
|
}
|
|
801
1057
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
802
|
-
const
|
|
803
|
-
const manifestPath =
|
|
804
|
-
await
|
|
805
|
-
await
|
|
1058
|
+
const fs5 = await import("fs/promises");
|
|
1059
|
+
const manifestPath = path7.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
1060
|
+
await fs5.mkdir(directory, { recursive: true });
|
|
1061
|
+
await fs5.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
806
1062
|
`);
|
|
807
1063
|
return manifestPath;
|
|
808
1064
|
}
|
|
@@ -838,13 +1094,13 @@ function normalizeManifestSource(root, modulePath) {
|
|
|
838
1094
|
const queryIndex = modulePath.indexOf("?");
|
|
839
1095
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
840
1096
|
const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
|
|
841
|
-
const relativePath =
|
|
1097
|
+
const relativePath = path7.isAbsolute(filePath) ? path7.relative(root, filePath) : filePath;
|
|
842
1098
|
return `${relativePath.replace(/\\/g, "/")}${query}`;
|
|
843
1099
|
}
|
|
844
1100
|
|
|
845
1101
|
// src/nitro/vercel-route-runtime.ts
|
|
846
|
-
import
|
|
847
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
1102
|
+
import path8 from "path";
|
|
1103
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, basePath = "/") {
|
|
848
1104
|
const dynamicRoutes = manifest.routes.filter(
|
|
849
1105
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
850
1106
|
);
|
|
@@ -863,8 +1119,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
|
|
|
863
1119
|
group.routes.push(route);
|
|
864
1120
|
groups.set(key, group);
|
|
865
1121
|
}
|
|
866
|
-
const functionsDir =
|
|
867
|
-
const baseFunctionDir =
|
|
1122
|
+
const functionsDir = path8.join(outputDir, "functions");
|
|
1123
|
+
const baseFunctionDir = path8.join(functionsDir, "__nitro.func");
|
|
868
1124
|
const destinations = /* @__PURE__ */ new Map();
|
|
869
1125
|
let groupIndex = 0;
|
|
870
1126
|
for (const [key, group] of groups) {
|
|
@@ -874,9 +1130,9 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
|
|
|
874
1130
|
}
|
|
875
1131
|
groupIndex += 1;
|
|
876
1132
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
877
|
-
const functionDir =
|
|
878
|
-
await
|
|
879
|
-
await configureVercelFunction(functionDir, group.config,
|
|
1133
|
+
const functionDir = path8.join(functionsDir, `${functionName}.func`);
|
|
1134
|
+
await fs5.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
1135
|
+
await configureVercelFunction(functionDir, group.config, fs5);
|
|
880
1136
|
destinations.set(key, `/${functionName}`);
|
|
881
1137
|
}
|
|
882
1138
|
const routes = [];
|
|
@@ -913,15 +1169,15 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
913
1169
|
if (!normalizedBasePath) return source || "/";
|
|
914
1170
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
915
1171
|
}
|
|
916
|
-
async function configureVercelFunction(functionDir, config,
|
|
917
|
-
const configPath =
|
|
918
|
-
const current = JSON.parse(await
|
|
1172
|
+
async function configureVercelFunction(functionDir, config, fs5) {
|
|
1173
|
+
const configPath = path8.join(functionDir, ".vc-config.json");
|
|
1174
|
+
const current = JSON.parse(await fs5.readFile(configPath, "utf8"));
|
|
919
1175
|
const next = {
|
|
920
1176
|
...current,
|
|
921
1177
|
...config.regions?.length ? { regions: config.regions } : {},
|
|
922
1178
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
923
1179
|
};
|
|
924
|
-
await
|
|
1180
|
+
await fs5.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
925
1181
|
`);
|
|
926
1182
|
}
|
|
927
1183
|
function hasVercelFunctionControls(route) {
|
|
@@ -958,7 +1214,7 @@ function escapeRegExp(value) {
|
|
|
958
1214
|
}
|
|
959
1215
|
|
|
960
1216
|
// src/nitro/immutable-assets.ts
|
|
961
|
-
import
|
|
1217
|
+
import path9 from "path";
|
|
962
1218
|
var FARM_IMMUTABLE_ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
963
1219
|
var FARM_IMMUTABLE_ASSET_MAX_AGE = 31536e3;
|
|
964
1220
|
var FARM_IMMUTABLE_ASSET_PATH_SOURCE = "^/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-(?:mobile-)?client(?:-boot)?)-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$";
|
|
@@ -993,7 +1249,7 @@ function planFarmImmutableAssets(options) {
|
|
|
993
1249
|
for (const [dir, files] of dirFiles) {
|
|
994
1250
|
if (!routeDirs.has(dir) && files.every(isImmutable)) {
|
|
995
1251
|
plan.publicAssets.push({
|
|
996
|
-
dir:
|
|
1252
|
+
dir: path9.join(options.clientOutputDir, dir),
|
|
997
1253
|
baseURL: `/${dir}`,
|
|
998
1254
|
maxAge: FARM_IMMUTABLE_ASSET_MAX_AGE
|
|
999
1255
|
});
|
|
@@ -1004,11 +1260,11 @@ function planFarmImmutableAssets(options) {
|
|
|
1004
1260
|
return plan;
|
|
1005
1261
|
}
|
|
1006
1262
|
async function listFarmClientOutputFiles(dir) {
|
|
1007
|
-
const
|
|
1008
|
-
const entries = await
|
|
1263
|
+
const fs5 = await import("fs/promises");
|
|
1264
|
+
const entries = await fs5.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
|
|
1009
1265
|
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
1010
|
-
const relative =
|
|
1011
|
-
return `/${relative.split(
|
|
1266
|
+
const relative = path9.relative(dir, path9.join(entry.parentPath, entry.name));
|
|
1267
|
+
return `/${relative.split(path9.sep).join("/")}`;
|
|
1012
1268
|
});
|
|
1013
1269
|
}
|
|
1014
1270
|
|
|
@@ -1029,8 +1285,8 @@ function buildFarmVercelRoutes(options) {
|
|
|
1029
1285
|
const sourceRoutes = filesystemIndex >= 0 ? presetRoutes.slice(0, filesystemIndex) : [];
|
|
1030
1286
|
const preservedSourceRoutes = sourceRoutes.filter((route) => route.continue !== true);
|
|
1031
1287
|
return [
|
|
1032
|
-
...preservedSourceRoutes,
|
|
1033
1288
|
...middlewareRoutes,
|
|
1289
|
+
...preservedSourceRoutes,
|
|
1034
1290
|
...canonicalSlashRoutes,
|
|
1035
1291
|
createFarmVercelImmutableAssetRoute(),
|
|
1036
1292
|
{ handle: "filesystem" },
|
|
@@ -1081,7 +1337,7 @@ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
|
|
|
1081
1337
|
}
|
|
1082
1338
|
|
|
1083
1339
|
// src/nitro/ssr-public-assets.ts
|
|
1084
|
-
import
|
|
1340
|
+
import path10 from "path";
|
|
1085
1341
|
var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
1086
1342
|
function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
1087
1343
|
if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
|
|
@@ -1090,8 +1346,8 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
|
1090
1346
|
relativePath = decodeURI(relativePath);
|
|
1091
1347
|
} catch {
|
|
1092
1348
|
}
|
|
1093
|
-
const fileName =
|
|
1094
|
-
|
|
1349
|
+
const fileName = path10.posix.normalize(
|
|
1350
|
+
path10.posix.join(path10.posix.dirname(chunkFileName), relativePath)
|
|
1095
1351
|
);
|
|
1096
1352
|
return fileName.startsWith("../") ? null : fileName;
|
|
1097
1353
|
}
|
|
@@ -1135,7 +1391,7 @@ function collectServerOnlySSRAssets(bundle) {
|
|
|
1135
1391
|
}
|
|
1136
1392
|
}
|
|
1137
1393
|
for (const fileName of serverOnly) {
|
|
1138
|
-
const name =
|
|
1394
|
+
const name = path10.posix.basename(fileName);
|
|
1139
1395
|
if (publicReferenceSources.some((source) => source.includes(name))) {
|
|
1140
1396
|
serverOnly.delete(fileName);
|
|
1141
1397
|
}
|
|
@@ -1153,7 +1409,7 @@ function assertServerReadSSRAssetsSupported(bundle, preset, root) {
|
|
|
1153
1409
|
const output = bundle[fileName];
|
|
1154
1410
|
const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
|
|
1155
1411
|
if (!original) return fileName;
|
|
1156
|
-
return
|
|
1412
|
+
return path10.relative(root, path10.resolve(root, original)).split(path10.sep).join("/");
|
|
1157
1413
|
});
|
|
1158
1414
|
throw new Error(
|
|
1159
1415
|
`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.`
|
|
@@ -1169,7 +1425,7 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1169
1425
|
},
|
|
1170
1426
|
transform(code, id) {
|
|
1171
1427
|
if (!code.includes("import.meta.url")) return null;
|
|
1172
|
-
const chunkFileName =
|
|
1428
|
+
const chunkFileName = path10.relative(ssrOutputDir, id.split("?", 1)[0]).split(path10.sep).join("/");
|
|
1173
1429
|
if (bundle[chunkFileName]?.type !== "chunk") return null;
|
|
1174
1430
|
let changed = false;
|
|
1175
1431
|
const transformed = replaceServerFileReferences(
|
|
@@ -1197,10 +1453,10 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1197
1453
|
|
|
1198
1454
|
// src/nitro/netlify-entry.ts
|
|
1199
1455
|
import { existsSync } from "fs";
|
|
1200
|
-
import
|
|
1456
|
+
import path11 from "path";
|
|
1201
1457
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
1202
|
-
const entry =
|
|
1203
|
-
|
|
1458
|
+
const entry = path11.join(
|
|
1459
|
+
path11.dirname(nitroRuntimeEntry),
|
|
1204
1460
|
"..",
|
|
1205
1461
|
"presets",
|
|
1206
1462
|
"netlify",
|
|
@@ -1212,7 +1468,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
1212
1468
|
`[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.`
|
|
1213
1469
|
);
|
|
1214
1470
|
}
|
|
1215
|
-
return entry.split(
|
|
1471
|
+
return entry.split(path11.sep).join("/");
|
|
1216
1472
|
}
|
|
1217
1473
|
function createFarmNetlifyEntry(options) {
|
|
1218
1474
|
return `
|
|
@@ -1261,8 +1517,8 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
1261
1517
|
}
|
|
1262
1518
|
|
|
1263
1519
|
// src/build/strip-platform-config.ts
|
|
1264
|
-
import { realpathSync } from "fs";
|
|
1265
|
-
import
|
|
1520
|
+
import { realpathSync as realpathSync2 } from "fs";
|
|
1521
|
+
import path12 from "path";
|
|
1266
1522
|
var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
|
|
1267
1523
|
var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
|
|
1268
1524
|
function isConfigObject(node) {
|
|
@@ -1334,13 +1590,13 @@ function stripPlatformConfigSource(code, parse) {
|
|
|
1334
1590
|
}
|
|
1335
1591
|
function realPath(file) {
|
|
1336
1592
|
try {
|
|
1337
|
-
return
|
|
1593
|
+
return realpathSync2(file);
|
|
1338
1594
|
} catch {
|
|
1339
|
-
return
|
|
1595
|
+
return path12.resolve(file);
|
|
1340
1596
|
}
|
|
1341
1597
|
}
|
|
1342
1598
|
function farmStripPlatformConfigPlugin(configFiles) {
|
|
1343
|
-
const files = new Set(configFiles.flatMap((file) => [
|
|
1599
|
+
const files = new Set(configFiles.flatMap((file) => [path12.resolve(file), realPath(file)]));
|
|
1344
1600
|
return {
|
|
1345
1601
|
name: "farm:strip-platform-config",
|
|
1346
1602
|
// Before the TypeScript transform, so its import elision also drops imports only the
|
|
@@ -1350,9 +1606,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1350
1606
|
filter: { id: fileNamePattern(configFiles) },
|
|
1351
1607
|
async handler(code, id) {
|
|
1352
1608
|
const file = id.split("?", 1)[0];
|
|
1353
|
-
if (!files.has(
|
|
1609
|
+
if (!files.has(path12.resolve(file)) && !files.has(realPath(file))) return null;
|
|
1354
1610
|
const { parseAst } = await import("rolldown/parseAst");
|
|
1355
|
-
const extension =
|
|
1611
|
+
const extension = path12.extname(file).slice(1);
|
|
1356
1612
|
const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
|
|
1357
1613
|
const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
|
|
1358
1614
|
return stripped === null ? null : { code: stripped, map: null };
|
|
@@ -1361,9 +1617,62 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1361
1617
|
};
|
|
1362
1618
|
}
|
|
1363
1619
|
|
|
1620
|
+
// src/build/markdown-precompile.ts
|
|
1621
|
+
import { existsSync as existsSync2 } from "fs";
|
|
1622
|
+
import path13 from "path";
|
|
1623
|
+
import { pathToFileURL } from "url";
|
|
1624
|
+
import { Worker } from "worker_threads";
|
|
1625
|
+
var WORKER_SOURCE = `
|
|
1626
|
+
const { parentPort, workerData } = require("node:worker_threads");
|
|
1627
|
+
import(workerData.runtime).then(async ({ compileFarmMarkdownPage }) => {
|
|
1628
|
+
const pages = [];
|
|
1629
|
+
for (const body of workerData.bodies) {
|
|
1630
|
+
try {
|
|
1631
|
+
pages.push([body, await compileFarmMarkdownPage(body)]);
|
|
1632
|
+
} catch {}
|
|
1633
|
+
}
|
|
1634
|
+
parentPort.postMessage(pages);
|
|
1635
|
+
});
|
|
1636
|
+
`;
|
|
1637
|
+
function precompileFarmMarkdownPages(bodies, coreRoot) {
|
|
1638
|
+
const runtime = coreRoot ? path13.join(coreRoot, "dist", "internal", "app-markdown-runtime.mjs") : null;
|
|
1639
|
+
if (bodies.length === 0 || !runtime || !existsSync2(runtime)) {
|
|
1640
|
+
return { pages: Promise.resolve(/* @__PURE__ */ new Map()), dispose() {
|
|
1641
|
+
} };
|
|
1642
|
+
}
|
|
1643
|
+
let worker;
|
|
1644
|
+
const pages = new Promise((resolve) => {
|
|
1645
|
+
const done = (entries = []) => {
|
|
1646
|
+
worker = void 0;
|
|
1647
|
+
resolve(new Map(entries));
|
|
1648
|
+
};
|
|
1649
|
+
try {
|
|
1650
|
+
worker = new Worker(WORKER_SOURCE, {
|
|
1651
|
+
eval: true,
|
|
1652
|
+
workerData: { runtime: pathToFileURL(runtime).href, bodies: [...new Set(bodies)] }
|
|
1653
|
+
});
|
|
1654
|
+
} catch {
|
|
1655
|
+
done();
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
worker.once("message", (entries) => {
|
|
1659
|
+
void worker?.terminate();
|
|
1660
|
+
done(entries);
|
|
1661
|
+
});
|
|
1662
|
+
worker.once("error", () => done());
|
|
1663
|
+
worker.once("exit", () => done());
|
|
1664
|
+
});
|
|
1665
|
+
return {
|
|
1666
|
+
pages,
|
|
1667
|
+
dispose() {
|
|
1668
|
+
void worker?.terminate();
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1364
1673
|
// src/nitro/client-sourcemaps.ts
|
|
1365
|
-
import
|
|
1366
|
-
import
|
|
1674
|
+
import fs4 from "fs/promises";
|
|
1675
|
+
import path14 from "path";
|
|
1367
1676
|
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
1368
1677
|
function resolveFarmClientSourcemap(sourcemap) {
|
|
1369
1678
|
return sourcemap ? "hidden" : false;
|
|
@@ -1382,11 +1691,11 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
|
1382
1691
|
}
|
|
1383
1692
|
},
|
|
1384
1693
|
async writeBundle() {
|
|
1385
|
-
await
|
|
1694
|
+
await fs4.rm(options.outDir, { recursive: true, force: true });
|
|
1386
1695
|
for (const [fileName, source] of maps) {
|
|
1387
|
-
const target =
|
|
1388
|
-
await
|
|
1389
|
-
await
|
|
1696
|
+
const target = path14.join(options.outDir, fileName);
|
|
1697
|
+
await fs4.mkdir(path14.dirname(target), { recursive: true });
|
|
1698
|
+
await fs4.writeFile(target, source);
|
|
1390
1699
|
}
|
|
1391
1700
|
}
|
|
1392
1701
|
};
|
|
@@ -1468,7 +1777,7 @@ async function readMiddlewareFileConfig(filePath) {
|
|
|
1468
1777
|
|
|
1469
1778
|
// src/nitro/vercel-edge-middleware.ts
|
|
1470
1779
|
import { createRequire, isBuiltin } from "module";
|
|
1471
|
-
import
|
|
1780
|
+
import path15 from "path";
|
|
1472
1781
|
import { gzipSync } from "zlib";
|
|
1473
1782
|
var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
|
|
1474
1783
|
var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
|
|
@@ -1522,22 +1831,22 @@ ${modules.join("\n")}
|
|
|
1522
1831
|
});
|
|
1523
1832
|
`;
|
|
1524
1833
|
}
|
|
1525
|
-
async function resolveFarmCoreDir(root,
|
|
1526
|
-
const runtimeEntry = createRequire(
|
|
1834
|
+
async function resolveFarmCoreDir(root, fs5) {
|
|
1835
|
+
const runtimeEntry = createRequire(path15.join(root, "package.json")).resolve(
|
|
1527
1836
|
"@farm.js/core/internal/vercel-edge-middleware"
|
|
1528
1837
|
);
|
|
1529
|
-
return
|
|
1838
|
+
return fs5.realpath(path15.resolve(path15.dirname(runtimeEntry), "..", ".."));
|
|
1530
1839
|
}
|
|
1531
1840
|
function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
1532
1841
|
const streamStub = "\0farm-edge-node-stream";
|
|
1533
|
-
const corePrefix = coreDir +
|
|
1842
|
+
const corePrefix = coreDir + path15.sep;
|
|
1534
1843
|
return {
|
|
1535
1844
|
name: "farm-vercel-edge-node-modules",
|
|
1536
1845
|
resolveId(source, importer) {
|
|
1537
1846
|
if (!isBuiltin(source)) return null;
|
|
1538
1847
|
const name = source.replace(/^node:/, "").split("/")[0];
|
|
1539
1848
|
if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
|
|
1540
|
-
if (name === "stream" && importer &&
|
|
1849
|
+
if (name === "stream" && importer && path15.resolve(importer).startsWith(corePrefix)) {
|
|
1541
1850
|
return streamStub;
|
|
1542
1851
|
}
|
|
1543
1852
|
unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
|
|
@@ -1550,20 +1859,20 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
|
1550
1859
|
};
|
|
1551
1860
|
}
|
|
1552
1861
|
async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
1553
|
-
const { root, outputDir, buildDir, config, routes, guardedPages, fs:
|
|
1554
|
-
const functionDir =
|
|
1862
|
+
const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs5 } = options;
|
|
1863
|
+
const functionDir = path15.join(
|
|
1555
1864
|
outputDir,
|
|
1556
1865
|
"functions",
|
|
1557
1866
|
`${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
|
|
1558
1867
|
);
|
|
1559
|
-
const entryPath =
|
|
1560
|
-
await
|
|
1561
|
-
await
|
|
1868
|
+
const entryPath = path15.join(buildDir, "vercel-edge-middleware-entry.mjs");
|
|
1869
|
+
await fs5.mkdir(path15.dirname(entryPath), { recursive: true });
|
|
1870
|
+
await fs5.writeFile(
|
|
1562
1871
|
entryPath,
|
|
1563
1872
|
generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
|
|
1564
1873
|
);
|
|
1565
1874
|
const unsupported = /* @__PURE__ */ new Set();
|
|
1566
|
-
const coreDir = await resolveFarmCoreDir(root,
|
|
1875
|
+
const coreDir = await resolveFarmCoreDir(root, fs5);
|
|
1567
1876
|
const { rolldown } = await import("rolldown");
|
|
1568
1877
|
let code;
|
|
1569
1878
|
try {
|
|
@@ -1595,7 +1904,7 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
|
1595
1904
|
} catch (error) {
|
|
1596
1905
|
throw withPlainDiagnostics(error);
|
|
1597
1906
|
} finally {
|
|
1598
|
-
await
|
|
1907
|
+
await fs5.rm(entryPath, { force: true });
|
|
1599
1908
|
}
|
|
1600
1909
|
if (unsupported.size > 0) {
|
|
1601
1910
|
throw new Error(
|
|
@@ -1604,11 +1913,11 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
|
1604
1913
|
Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(", ")}), or remove runtime: "edge" so the middleware runs in the server and its pages render on request.`
|
|
1605
1914
|
);
|
|
1606
1915
|
}
|
|
1607
|
-
await
|
|
1608
|
-
await
|
|
1609
|
-
await
|
|
1610
|
-
await
|
|
1611
|
-
|
|
1916
|
+
await fs5.rm(functionDir, { recursive: true, force: true });
|
|
1917
|
+
await fs5.mkdir(functionDir, { recursive: true });
|
|
1918
|
+
await fs5.writeFile(path15.join(functionDir, "index.js"), code);
|
|
1919
|
+
await fs5.writeFile(
|
|
1920
|
+
path15.join(functionDir, ".vc-config.json"),
|
|
1612
1921
|
`${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
|
|
1613
1922
|
`
|
|
1614
1923
|
);
|
|
@@ -1626,11 +1935,11 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
|
|
|
1626
1935
|
// src/nitro/universal-build.ts
|
|
1627
1936
|
var FARM_NATIVE_STYLESHEETS_PLACEHOLDER = "__FARM_NATIVE_STYLESHEETS__";
|
|
1628
1937
|
async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
|
|
1629
|
-
const
|
|
1938
|
+
const fs5 = await import("fs/promises");
|
|
1630
1939
|
try {
|
|
1631
1940
|
return {
|
|
1632
|
-
[clientCssHref]: await
|
|
1633
|
-
|
|
1941
|
+
[clientCssHref]: await fs5.readFile(
|
|
1942
|
+
path16.join(clientOutputDir, clientCssHref.slice(1)),
|
|
1634
1943
|
"utf8"
|
|
1635
1944
|
)
|
|
1636
1945
|
};
|
|
@@ -1645,18 +1954,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1645
1954
|
);
|
|
1646
1955
|
}
|
|
1647
1956
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1648
|
-
var _dirname =
|
|
1957
|
+
var _dirname = path16.dirname(_filename);
|
|
1649
1958
|
function findFarmCoreRoot(from) {
|
|
1650
|
-
let dir =
|
|
1651
|
-
while (dir !==
|
|
1652
|
-
const manifest =
|
|
1653
|
-
if (
|
|
1959
|
+
let dir = path16.dirname(from);
|
|
1960
|
+
while (dir !== path16.dirname(dir)) {
|
|
1961
|
+
const manifest = path16.join(dir, "package.json");
|
|
1962
|
+
if (existsSync3(manifest)) {
|
|
1654
1963
|
try {
|
|
1655
|
-
if (JSON.parse(
|
|
1964
|
+
if (JSON.parse(readFileSync2(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1656
1965
|
} catch {
|
|
1657
1966
|
}
|
|
1658
1967
|
}
|
|
1659
|
-
dir =
|
|
1968
|
+
dir = path16.dirname(dir);
|
|
1660
1969
|
}
|
|
1661
1970
|
return null;
|
|
1662
1971
|
}
|
|
@@ -1666,16 +1975,16 @@ function toModulePath(file) {
|
|
|
1666
1975
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1667
1976
|
}
|
|
1668
1977
|
function findInstalledPackageDir(name, from) {
|
|
1669
|
-
for (let dir = from; ; dir =
|
|
1670
|
-
const candidate =
|
|
1671
|
-
if (
|
|
1978
|
+
for (let dir = from; ; dir = path16.dirname(dir)) {
|
|
1979
|
+
const candidate = path16.join(dir, "node_modules", name);
|
|
1980
|
+
if (existsSync3(path16.join(candidate, "package.json"))) {
|
|
1672
1981
|
try {
|
|
1673
|
-
return
|
|
1982
|
+
return realpathSync3(candidate);
|
|
1674
1983
|
} catch {
|
|
1675
1984
|
return null;
|
|
1676
1985
|
}
|
|
1677
1986
|
}
|
|
1678
|
-
if (dir ===
|
|
1987
|
+
if (dir === path16.dirname(dir)) return null;
|
|
1679
1988
|
}
|
|
1680
1989
|
}
|
|
1681
1990
|
function collectFarmDependencyDirs(root) {
|
|
@@ -1686,7 +1995,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1686
1995
|
seen.add(dir);
|
|
1687
1996
|
let manifest;
|
|
1688
1997
|
try {
|
|
1689
|
-
manifest = JSON.parse(
|
|
1998
|
+
manifest = JSON.parse(readFileSync2(path16.join(dir, "package.json"), "utf8"));
|
|
1690
1999
|
} catch {
|
|
1691
2000
|
return;
|
|
1692
2001
|
}
|
|
@@ -1694,10 +2003,10 @@ function collectFarmDependencyDirs(root) {
|
|
|
1694
2003
|
for (const name of Object.keys(manifest[field] ?? {})) queue.push({ name, from: dir });
|
|
1695
2004
|
}
|
|
1696
2005
|
};
|
|
1697
|
-
if (farmCoreRoot) visit(
|
|
2006
|
+
if (farmCoreRoot) visit(realpathSync3(farmCoreRoot));
|
|
1698
2007
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1699
2008
|
try {
|
|
1700
|
-
const manifest = JSON.parse(
|
|
2009
|
+
const manifest = JSON.parse(readFileSync2(path16.join(root, "package.json"), "utf8"));
|
|
1701
2010
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1702
2011
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1703
2012
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1764,17 +2073,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1764
2073
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1765
2074
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1766
2075
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1767
|
-
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
2076
|
+
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path16.sep).join("/");
|
|
1768
2077
|
}
|
|
1769
2078
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1770
2079
|
const nitroEntry = resolveNitroPackageEntry(root);
|
|
1771
|
-
const runtimeDir =
|
|
2080
|
+
const runtimeDir = path16.dirname(nitroEntry);
|
|
1772
2081
|
const nitroRequire = createRequire2(nitroEntry);
|
|
1773
2082
|
return {
|
|
1774
2083
|
...Object.fromEntries(
|
|
1775
2084
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1776
2085
|
`#nitro/runtime/${moduleName}`,
|
|
1777
|
-
|
|
2086
|
+
path16.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path16.sep).join("/")
|
|
1778
2087
|
])
|
|
1779
2088
|
),
|
|
1780
2089
|
// Farm's generated workflow and cron wrappers live under `.farm/` and
|
|
@@ -1783,18 +2092,31 @@ function resolveNitroInternalRuntimeAliases(root) {
|
|
|
1783
2092
|
...Object.fromEntries(
|
|
1784
2093
|
["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
|
|
1785
2094
|
specifier,
|
|
1786
|
-
nitroRequire.resolve(specifier).split(
|
|
2095
|
+
nitroRequire.resolve(specifier).split(path16.sep).join("/")
|
|
1787
2096
|
])
|
|
1788
2097
|
)
|
|
1789
2098
|
};
|
|
1790
2099
|
}
|
|
2100
|
+
function createPrerenderMarkdownPagesPlugin(pages) {
|
|
2101
|
+
return {
|
|
2102
|
+
name: "farm-prerender-markdown-pages",
|
|
2103
|
+
async banner(chunk) {
|
|
2104
|
+
if (!chunk.isEntry) return "";
|
|
2105
|
+
const compiled = await pages;
|
|
2106
|
+
if (compiled.size === 0) return "";
|
|
2107
|
+
return `globalThis[Symbol.for(${JSON.stringify(
|
|
2108
|
+
FARM_MARKDOWN_PRECOMPILED_PAGES.description
|
|
2109
|
+
)})] = new Map(${JSON.stringify([...compiled])});`;
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
1791
2113
|
function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveNitroPackageEntry) {
|
|
1792
2114
|
let nitroEntry;
|
|
1793
2115
|
return {
|
|
1794
2116
|
name: "farm-prerender-runtime-resolver",
|
|
1795
2117
|
async resolveId(id, _importer, options) {
|
|
1796
2118
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1797
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
2119
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path16.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1798
2120
|
return null;
|
|
1799
2121
|
}
|
|
1800
2122
|
if (nitroEntry === void 0) {
|
|
@@ -1817,7 +2139,7 @@ function createFarmStorageModuleRegistration(config) {
|
|
|
1817
2139
|
const modules = _collectFarmStorageModules(config.storage);
|
|
1818
2140
|
if (modules.length === 0) return "";
|
|
1819
2141
|
const root = config.root || process.cwd();
|
|
1820
|
-
const projectRequire = createRequire2(
|
|
2142
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
1821
2143
|
let runtimeRequire = projectRequire;
|
|
1822
2144
|
try {
|
|
1823
2145
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1844,7 +2166,7 @@ ${loaders.join("\n")}
|
|
|
1844
2166
|
});` : "";
|
|
1845
2167
|
}
|
|
1846
2168
|
function resolveNitroPackageEntry(root) {
|
|
1847
|
-
const projectRequire = createRequire2(
|
|
2169
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
1848
2170
|
let runtimeRequire = projectRequire;
|
|
1849
2171
|
try {
|
|
1850
2172
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1914,7 +2236,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1914
2236
|
}
|
|
1915
2237
|
function hasReactDomEdgeServerBuild(root) {
|
|
1916
2238
|
try {
|
|
1917
|
-
createRequire2(
|
|
2239
|
+
createRequire2(path16.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1918
2240
|
return true;
|
|
1919
2241
|
} catch {
|
|
1920
2242
|
return false;
|
|
@@ -1945,17 +2267,17 @@ function isNitroRollupExternal(id) {
|
|
|
1945
2267
|
var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
|
|
1946
2268
|
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
1947
2269
|
function isFarmCoreModule(file) {
|
|
1948
|
-
let dir =
|
|
1949
|
-
while (dir !==
|
|
1950
|
-
const manifest =
|
|
1951
|
-
if (
|
|
2270
|
+
let dir = path16.dirname(file.split("?", 1)[0]);
|
|
2271
|
+
while (dir !== path16.dirname(dir)) {
|
|
2272
|
+
const manifest = path16.join(dir, "package.json");
|
|
2273
|
+
if (existsSync3(manifest)) {
|
|
1952
2274
|
try {
|
|
1953
|
-
return JSON.parse(
|
|
2275
|
+
return JSON.parse(readFileSync2(manifest, "utf8")).name === "@farm.js/core";
|
|
1954
2276
|
} catch {
|
|
1955
2277
|
return false;
|
|
1956
2278
|
}
|
|
1957
2279
|
}
|
|
1958
|
-
dir =
|
|
2280
|
+
dir = path16.dirname(dir);
|
|
1959
2281
|
}
|
|
1960
2282
|
return false;
|
|
1961
2283
|
}
|
|
@@ -1966,7 +2288,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
|
1966
2288
|
filter: { id: exactIdPattern(["@vercel/og"]) },
|
|
1967
2289
|
handler(source, importer) {
|
|
1968
2290
|
if (source !== "@vercel/og") return null;
|
|
1969
|
-
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(
|
|
2291
|
+
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path16.basename(importer.split("?", 1)[0]));
|
|
1970
2292
|
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
1971
2293
|
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
1972
2294
|
}
|
|
@@ -1987,14 +2309,14 @@ export class ImageResponse {
|
|
|
1987
2309
|
};
|
|
1988
2310
|
}
|
|
1989
2311
|
function readVercelOgManifest(file) {
|
|
1990
|
-
let dir =
|
|
1991
|
-
while (dir !==
|
|
1992
|
-
const manifestPath =
|
|
1993
|
-
if (
|
|
1994
|
-
const manifest = JSON.parse(
|
|
2312
|
+
let dir = path16.dirname(file.split("?", 1)[0]);
|
|
2313
|
+
while (dir !== path16.dirname(dir)) {
|
|
2314
|
+
const manifestPath = path16.join(dir, "package.json");
|
|
2315
|
+
if (existsSync3(manifestPath)) {
|
|
2316
|
+
const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
|
|
1995
2317
|
return manifest.name === "@vercel/og" ? { dir, manifest } : null;
|
|
1996
2318
|
}
|
|
1997
|
-
dir =
|
|
2319
|
+
dir = path16.dirname(dir);
|
|
1998
2320
|
}
|
|
1999
2321
|
return null;
|
|
2000
2322
|
}
|
|
@@ -2002,7 +2324,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
|
|
|
2002
2324
|
const vercelOg = readVercelOgManifest(resolvedId);
|
|
2003
2325
|
const entry = vercelOg?.manifest.exports?.["."]?.[condition];
|
|
2004
2326
|
const file = typeof entry === "string" ? entry : entry?.default;
|
|
2005
|
-
return vercelOg && typeof file === "string" ?
|
|
2327
|
+
return vercelOg && typeof file === "string" ? path16.join(vercelOg.dir, file) : null;
|
|
2006
2328
|
}
|
|
2007
2329
|
function createEdgeMetadataImageRuntimePlugin({
|
|
2008
2330
|
condition,
|
|
@@ -2020,7 +2342,7 @@ function createEdgeMetadataImageRuntimePlugin({
|
|
|
2020
2342
|
if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
2021
2343
|
return null;
|
|
2022
2344
|
}
|
|
2023
|
-
const resolvedPath =
|
|
2345
|
+
const resolvedPath = path16.resolve(path16.dirname(importer.split("?", 1)[0]), source);
|
|
2024
2346
|
return { id: toPosixPath(resolvedPath), external: "absolute" };
|
|
2025
2347
|
}
|
|
2026
2348
|
};
|
|
@@ -2035,7 +2357,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
|
|
|
2035
2357
|
return null;
|
|
2036
2358
|
}
|
|
2037
2359
|
const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
|
|
2038
|
-
const encoded =
|
|
2360
|
+
const encoded = readFileSync2(path16.resolve(path16.dirname(file), request)).toString("base64");
|
|
2039
2361
|
return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
|
|
2040
2362
|
});
|
|
2041
2363
|
if (inlined !== code) return { code: inlined, map: null };
|
|
@@ -2054,13 +2376,13 @@ function createMetadataImageWasmPlugin() {
|
|
|
2054
2376
|
return null;
|
|
2055
2377
|
}
|
|
2056
2378
|
const requestPath = source.slice(0, -"?module".length);
|
|
2057
|
-
const resolvedPath =
|
|
2379
|
+
const resolvedPath = path16.isAbsolute(requestPath) ? requestPath : path16.resolve(path16.dirname(importer.split("?", 1)[0]), requestPath);
|
|
2058
2380
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
2059
2381
|
},
|
|
2060
2382
|
load(id) {
|
|
2061
2383
|
if (!id.startsWith(FARM_METADATA_IMAGE_WASM_PREFIX)) return null;
|
|
2062
2384
|
const wasmPath = id.slice(FARM_METADATA_IMAGE_WASM_PREFIX.length);
|
|
2063
|
-
const encoded =
|
|
2385
|
+
const encoded = readFileSync2(wasmPath).toString("base64");
|
|
2064
2386
|
return `
|
|
2065
2387
|
const encoded = ${JSON.stringify(encoded)};
|
|
2066
2388
|
const bytes = Uint8Array.from(atob(encoded), (character) => character.charCodeAt(0));
|
|
@@ -2079,11 +2401,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2079
2401
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
2080
2402
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
2081
2403
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
2082
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
2404
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path16.posix.normalize(path16.posix.join(path16.posix.dirname(fileName), normalizedImportId)) : null;
|
|
2083
2405
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
2084
2406
|
continue;
|
|
2085
2407
|
}
|
|
2086
|
-
if (
|
|
2408
|
+
if (path16.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
2087
2409
|
externalPackages.add(importId);
|
|
2088
2410
|
continue;
|
|
2089
2411
|
}
|
|
@@ -2095,15 +2417,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2095
2417
|
return externalPackages;
|
|
2096
2418
|
}
|
|
2097
2419
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
2098
|
-
const resolvedNitroEntry =
|
|
2099
|
-
const resolvedSSREntry =
|
|
2420
|
+
const resolvedNitroEntry = path16.resolve(nitroEntryPath);
|
|
2421
|
+
const resolvedSSREntry = path16.resolve(ssrOutputDir, ssrEntryFile);
|
|
2100
2422
|
return {
|
|
2101
2423
|
name: "farm-externalize-prebuilt-ssr",
|
|
2102
2424
|
resolveId(source, importer) {
|
|
2103
|
-
if (!importer ||
|
|
2425
|
+
if (!importer || path16.resolve(importer) !== resolvedNitroEntry) {
|
|
2104
2426
|
return null;
|
|
2105
2427
|
}
|
|
2106
|
-
const resolvedImport =
|
|
2428
|
+
const resolvedImport = path16.resolve(path16.dirname(importer), source);
|
|
2107
2429
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
2108
2430
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
2109
2431
|
}
|
|
@@ -2152,37 +2474,42 @@ async function minifyFarmServerChunk(code, fileName, options) {
|
|
|
2152
2474
|
}
|
|
2153
2475
|
return restoreLiteralModuleSpecifiers(result.code, fileName, rolldownUtils);
|
|
2154
2476
|
}
|
|
2477
|
+
var moduleLexerReady = false;
|
|
2478
|
+
function lexDynamicImportArguments(code) {
|
|
2479
|
+
if (!moduleLexerReady) {
|
|
2480
|
+
initModuleLexer();
|
|
2481
|
+
moduleLexerReady = true;
|
|
2482
|
+
}
|
|
2483
|
+
try {
|
|
2484
|
+
return lexModule(code)[0].filter((entry) => entry.d > -1).map((entry) => ({ start: entry.s, end: entry.e }));
|
|
2485
|
+
} catch {
|
|
2486
|
+
return null;
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2155
2489
|
function restoreLiteralModuleSpecifiers(code, fileName, { parseSync, Visitor }) {
|
|
2156
2490
|
const hasImportTemplate = code.includes("import(`");
|
|
2157
2491
|
const hasRequireTemplate = code.includes("require(`");
|
|
2158
2492
|
if (!hasImportTemplate && !hasRequireTemplate) return code;
|
|
2159
|
-
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
2160
|
-
if (parsed.errors.length > 0) {
|
|
2161
|
-
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
2162
|
-
}
|
|
2163
2493
|
const replacements = [];
|
|
2164
2494
|
let needsAst = hasRequireTemplate && /(?<![\w$])require\(`/.test(code);
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
}
|
|
2177
|
-
replacements.push({
|
|
2178
|
-
start: moduleRequest.start,
|
|
2179
|
-
end: moduleRequest.end,
|
|
2180
|
-
text: toAsciiStringLiteral(value)
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2495
|
+
const dynamicImports = needsAst ? null : lexDynamicImportArguments(code);
|
|
2496
|
+
if (!dynamicImports) needsAst = true;
|
|
2497
|
+
for (const { start, end } of dynamicImports ?? []) {
|
|
2498
|
+
const source = code.slice(start, end);
|
|
2499
|
+
if (!source.startsWith("`")) continue;
|
|
2500
|
+
const value = source.slice(1, -1);
|
|
2501
|
+
if (source.length < 2 || !source.endsWith("`") || /[\\\r\n`]|\$\{/.test(value)) {
|
|
2502
|
+
needsAst = true;
|
|
2503
|
+
break;
|
|
2504
|
+
}
|
|
2505
|
+
replacements.push({ start, end, text: toAsciiStringLiteral(value) });
|
|
2183
2506
|
}
|
|
2184
2507
|
if (needsAst) {
|
|
2185
2508
|
replacements.length = 0;
|
|
2509
|
+
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
2510
|
+
if (parsed.errors.length > 0) {
|
|
2511
|
+
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
2512
|
+
}
|
|
2186
2513
|
const restore = (node) => {
|
|
2187
2514
|
if (node?.type !== "TemplateLiteral") return;
|
|
2188
2515
|
const template = node;
|
|
@@ -2236,14 +2563,14 @@ function trimSlashes(value) {
|
|
|
2236
2563
|
function resolveBuildDocsContentDir(docs, root, srcDir) {
|
|
2237
2564
|
const configuredContentDir = docs.contentDir || docs.config.contentDir;
|
|
2238
2565
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
2239
|
-
const contentDir =
|
|
2240
|
-
return
|
|
2566
|
+
const contentDir = path16.isAbsolute(configuredContentDir) ? configuredContentDir : path16.join(root, configuredContentDir);
|
|
2567
|
+
return existsSync3(contentDir) ? contentDir : null;
|
|
2241
2568
|
}
|
|
2242
2569
|
const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
|
|
2243
|
-
const appDocsDir =
|
|
2244
|
-
if (
|
|
2245
|
-
const rootDocsDir =
|
|
2246
|
-
return
|
|
2570
|
+
const appDocsDir = path16.join(root, srcDir || "src", "app", entryDir);
|
|
2571
|
+
if (existsSync3(appDocsDir)) return appDocsDir;
|
|
2572
|
+
const rootDocsDir = path16.join(root, entryDir);
|
|
2573
|
+
return existsSync3(rootDocsDir) ? rootDocsDir : null;
|
|
2247
2574
|
}
|
|
2248
2575
|
function hasProjectPostcssConfig(root) {
|
|
2249
2576
|
const candidates = [
|
|
@@ -2259,7 +2586,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2259
2586
|
".postcssrc.mjs",
|
|
2260
2587
|
".postcssrc.ts"
|
|
2261
2588
|
];
|
|
2262
|
-
const projectRequire = createRequire2(
|
|
2589
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
2263
2590
|
return candidates.some((file) => {
|
|
2264
2591
|
try {
|
|
2265
2592
|
projectRequire.resolve(`./${file}`);
|
|
@@ -2270,7 +2597,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2270
2597
|
});
|
|
2271
2598
|
}
|
|
2272
2599
|
async function findFarmConfigPath(root) {
|
|
2273
|
-
const
|
|
2600
|
+
const fs5 = await import("fs/promises");
|
|
2274
2601
|
const candidates = [
|
|
2275
2602
|
"farm.config.ts",
|
|
2276
2603
|
"farm.config.mts",
|
|
@@ -2282,9 +2609,9 @@ async function findFarmConfigPath(root) {
|
|
|
2282
2609
|
"config.mjs"
|
|
2283
2610
|
];
|
|
2284
2611
|
for (const candidate of candidates) {
|
|
2285
|
-
const resolvedPath =
|
|
2612
|
+
const resolvedPath = path16.join(root, candidate);
|
|
2286
2613
|
try {
|
|
2287
|
-
await
|
|
2614
|
+
await fs5.access(resolvedPath);
|
|
2288
2615
|
return resolvedPath;
|
|
2289
2616
|
} catch {
|
|
2290
2617
|
}
|
|
@@ -2302,13 +2629,13 @@ function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
|
2302
2629
|
);
|
|
2303
2630
|
}
|
|
2304
2631
|
async function discoverMiddlewareRoutes(appDir) {
|
|
2305
|
-
const
|
|
2632
|
+
const fs5 = await import("fs/promises");
|
|
2306
2633
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
2307
2634
|
const routes = /* @__PURE__ */ new Map();
|
|
2308
2635
|
async function walk(dir, routePath, directory, discovered) {
|
|
2309
2636
|
let entries;
|
|
2310
2637
|
try {
|
|
2311
|
-
entries = await
|
|
2638
|
+
entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2312
2639
|
} catch {
|
|
2313
2640
|
return;
|
|
2314
2641
|
}
|
|
@@ -2319,7 +2646,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2319
2646
|
discovered.push({
|
|
2320
2647
|
path: routePath,
|
|
2321
2648
|
directory,
|
|
2322
|
-
filePath:
|
|
2649
|
+
filePath: path16.join(dir, middlewareFile.name)
|
|
2323
2650
|
});
|
|
2324
2651
|
}
|
|
2325
2652
|
for (const entry of entries) {
|
|
@@ -2327,7 +2654,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2327
2654
|
continue;
|
|
2328
2655
|
}
|
|
2329
2656
|
await walk(
|
|
2330
|
-
|
|
2657
|
+
path16.join(dir, entry.name),
|
|
2331
2658
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
2332
2659
|
appendMiddlewareDirectory(directory, entry.name),
|
|
2333
2660
|
discovered
|
|
@@ -2365,6 +2692,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2365
2692
|
logger.info(`\u{1F69C} Building Farm.js application (universal) with preset: ${preset}...`);
|
|
2366
2693
|
const rendererBuild = options.rendererBuildLifetime ? void 0 : new AbortController();
|
|
2367
2694
|
const rendererBuildLifetime = options.rendererBuildLifetime ?? rendererBuild.signal;
|
|
2695
|
+
let markdownPrecompile;
|
|
2368
2696
|
try {
|
|
2369
2697
|
const routeRuntimeManifestPromise = options.routeRuntimeManifest ? Promise.resolve(options.routeRuntimeManifest) : createFarmRouteRuntimeManifest({
|
|
2370
2698
|
config,
|
|
@@ -2374,18 +2702,27 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2374
2702
|
});
|
|
2375
2703
|
const routeRuntimeManifestResultPromise = Promise.allSettled([routeRuntimeManifestPromise]);
|
|
2376
2704
|
const pageRoutes = [];
|
|
2705
|
+
const searchPreserveRoutes = new Map(
|
|
2706
|
+
routeManager.getSearchPreserveRoutes().map((route) => [route.pattern, route])
|
|
2707
|
+
);
|
|
2377
2708
|
for (const [pattern, entry] of routeManager.getRoutes()) {
|
|
2378
2709
|
const markdownSourcePath = entry.markdownSourcePath || (isFarmMarkdownPageFile(entry.modulePath) ? entry.modulePath : void 0);
|
|
2710
|
+
const searchPreserve = searchPreserveRoutes.get(entry.pattern);
|
|
2379
2711
|
pageRoutes.push({
|
|
2380
2712
|
pattern,
|
|
2381
2713
|
...entry.directory ? { directory: entry.directory } : {},
|
|
2382
2714
|
modulePath: entry.modulePath,
|
|
2715
|
+
...searchPreserve ? { searchPreserve } : {},
|
|
2383
2716
|
...markdownSourcePath ? {
|
|
2384
|
-
source:
|
|
2717
|
+
source: readFileSync2(markdownSourcePath, "utf8"),
|
|
2385
2718
|
markdownSourcePath
|
|
2386
2719
|
} : {}
|
|
2387
2720
|
});
|
|
2388
2721
|
}
|
|
2722
|
+
markdownPrecompile = precompileFarmMarkdownPages(
|
|
2723
|
+
collectFarmPrerenderedMarkdownBodies(pageRoutes),
|
|
2724
|
+
farmCoreRoot
|
|
2725
|
+
);
|
|
2389
2726
|
const routeSlots = Array.from(
|
|
2390
2727
|
routeManager.getRouteSlots().values(),
|
|
2391
2728
|
(entry) => ({
|
|
@@ -2400,33 +2737,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2400
2737
|
})
|
|
2401
2738
|
);
|
|
2402
2739
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
2403
|
-
const
|
|
2404
|
-
const layoutRoutes = []
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
const entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
2409
|
-
for (const entry of entries) {
|
|
2410
|
-
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
2411
|
-
layoutRoutes.push({
|
|
2412
|
-
pattern: routePrefix,
|
|
2413
|
-
modulePath: path13.join(dir, entry.name)
|
|
2414
|
-
});
|
|
2415
|
-
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
2416
|
-
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
2417
|
-
await findLayoutsForClient(path13.join(dir, entry.name), childPrefix);
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
} catch {
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
await findLayoutsForClient(appDir);
|
|
2424
|
-
const seenLayoutPatterns = new Set(layoutRoutes.map((layout) => layout.pattern));
|
|
2425
|
-
for (const [pattern, entry] of routeManager.getLayouts()) {
|
|
2426
|
-
if (seenLayoutPatterns.has(pattern)) continue;
|
|
2427
|
-
seenLayoutPatterns.add(pattern);
|
|
2428
|
-
layoutRoutes.push({ pattern, modulePath: entry.modulePath });
|
|
2429
|
-
}
|
|
2740
|
+
const fs5 = await import("fs/promises");
|
|
2741
|
+
const layoutRoutes = Array.from(routeManager.getLayouts(), ([pattern, { modulePath }]) => ({
|
|
2742
|
+
pattern,
|
|
2743
|
+
modulePath
|
|
2744
|
+
}));
|
|
2430
2745
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
|
|
2431
2746
|
const isolatedClientBoundaryModules = routeManager.getIsolatedClientBoundaryModules(root);
|
|
2432
2747
|
const islandsErrors = routeManager.getIslandsErrors(root);
|
|
@@ -2437,8 +2752,9 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2437
2752
|
${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
2438
2753
|
);
|
|
2439
2754
|
}
|
|
2440
|
-
const hydrationPlanCache =
|
|
2441
|
-
const
|
|
2755
|
+
const hydrationPlanCache = routeManager.getRouteModuleHydrationPlans();
|
|
2756
|
+
const sourceSnapshot = routeManager.takeBuildSourceSnapshot();
|
|
2757
|
+
const clientOutputDir = path16.join(root, distDir, "client");
|
|
2442
2758
|
const [productionViteResult] = await productionViteResultPromise;
|
|
2443
2759
|
if (productionViteResult.status === "rejected") {
|
|
2444
2760
|
await routeRuntimeManifestResultPromise;
|
|
@@ -2450,8 +2766,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2450
2766
|
const rendererDisabled = isFarmRendererDisabled(config.renderer);
|
|
2451
2767
|
const buildClientBundle = async () => {
|
|
2452
2768
|
if (rendererDisabled) {
|
|
2453
|
-
await
|
|
2454
|
-
await
|
|
2769
|
+
await fs5.rm(clientOutputDir, { recursive: true, force: true });
|
|
2770
|
+
await fs5.mkdir(clientOutputDir, { recursive: true });
|
|
2455
2771
|
return;
|
|
2456
2772
|
}
|
|
2457
2773
|
return buildClient(
|
|
@@ -2467,7 +2783,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2467
2783
|
hydrationPlanCache,
|
|
2468
2784
|
rendererBuildLifetime,
|
|
2469
2785
|
routeManager.getProgrammaticClientRoutes(),
|
|
2470
|
-
mobileClient
|
|
2786
|
+
mobileClient,
|
|
2787
|
+
sourceSnapshot
|
|
2471
2788
|
);
|
|
2472
2789
|
};
|
|
2473
2790
|
const buildSSRBundle = () => buildSSRInMemory(
|
|
@@ -2483,7 +2800,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2483
2800
|
routeSlots,
|
|
2484
2801
|
isolatedClientBoundaryModules,
|
|
2485
2802
|
hydrationPlanCache,
|
|
2486
|
-
rendererBuildLifetime
|
|
2803
|
+
rendererBuildLifetime,
|
|
2804
|
+
sourceSnapshot
|
|
2487
2805
|
);
|
|
2488
2806
|
let clientBuildResult;
|
|
2489
2807
|
let ssrBuildResult;
|
|
@@ -2524,7 +2842,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2524
2842
|
hydrationPlanCache,
|
|
2525
2843
|
rendererBuildLifetime,
|
|
2526
2844
|
routeManager.getProgrammaticClientRoutes(),
|
|
2527
|
-
mobileClient
|
|
2845
|
+
mobileClient,
|
|
2846
|
+
sourceSnapshot
|
|
2528
2847
|
);
|
|
2529
2848
|
} catch (retryError) {
|
|
2530
2849
|
if (!(retryError instanceof IncompleteClientBuildOutputError)) throw retryError;
|
|
@@ -2533,6 +2852,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2533
2852
|
);
|
|
2534
2853
|
}
|
|
2535
2854
|
}
|
|
2855
|
+
sourceSnapshot?.clear();
|
|
2536
2856
|
const ssrResult = ssrBuildResult.value;
|
|
2537
2857
|
const routeRuntimeManifest = routeRuntimeManifestResult.value;
|
|
2538
2858
|
const runtimeValidation = validateFarmRouteRuntimeDeployment(routeRuntimeManifest, preset);
|
|
@@ -2542,6 +2862,9 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2542
2862
|
const { bundle: ssrBundle, entryFile: ssrEntryFile, configuredHeaderRoutes } = ssrResult;
|
|
2543
2863
|
assertServerReadSSRAssetsSupported(ssrBundle, preset, root);
|
|
2544
2864
|
await writeSSRAssetsToClient(ssrBundle, clientOutputDir);
|
|
2865
|
+
if (!rendererDisabled) {
|
|
2866
|
+
await writeFarmVideoPlayerToClient(clientOutputDir);
|
|
2867
|
+
}
|
|
2545
2868
|
if (config.docs.enabled) {
|
|
2546
2869
|
await copyFarmDocsFontAssetsToClient(root, clientOutputDir);
|
|
2547
2870
|
}
|
|
@@ -2560,13 +2883,14 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2560
2883
|
routeRuntimeManifest,
|
|
2561
2884
|
configuredHeaderRoutes,
|
|
2562
2885
|
nitroBuilderResultPromise,
|
|
2563
|
-
lifecyclePluginManager
|
|
2886
|
+
lifecyclePluginManager,
|
|
2887
|
+
markdownPrecompile?.pages
|
|
2564
2888
|
);
|
|
2565
2889
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
2566
|
-
|
|
2890
|
+
path16.join(root, distDir),
|
|
2567
2891
|
routeRuntimeManifest
|
|
2568
2892
|
);
|
|
2569
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
2893
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path16.relative(root, runtimeManifestPath)}`);
|
|
2570
2894
|
} catch (error) {
|
|
2571
2895
|
if (lifecyclePluginManager) {
|
|
2572
2896
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -2582,7 +2906,21 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2582
2906
|
throw error;
|
|
2583
2907
|
} finally {
|
|
2584
2908
|
rendererBuild?.abort();
|
|
2909
|
+
markdownPrecompile?.dispose();
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
function collectFarmPrerenderedMarkdownBodies(pageRoutes) {
|
|
2913
|
+
const bodies = [];
|
|
2914
|
+
for (const route of pageRoutes) {
|
|
2915
|
+
if (route.source === void 0 || !isFarmMarkdownPageFile(route.modulePath)) continue;
|
|
2916
|
+
const { body } = parseMarkdownFrontmatter(route.source);
|
|
2917
|
+
const rendering = resolveRouteRenderingConfig(
|
|
2918
|
+
readFarmMarkdownRouteConfig(body),
|
|
2919
|
+
route.source
|
|
2920
|
+
);
|
|
2921
|
+
if (rendering.ssg && rendering.revalidate === void 0) bodies.push(body);
|
|
2585
2922
|
}
|
|
2923
|
+
return bodies;
|
|
2586
2924
|
}
|
|
2587
2925
|
function shouldBuildFarmMobileClient(config) {
|
|
2588
2926
|
return Boolean(config.mobileClient) && !config.desktop;
|
|
@@ -2602,7 +2940,7 @@ function varyFarmNitroCacheRules(rules, headerNames) {
|
|
|
2602
2940
|
);
|
|
2603
2941
|
}
|
|
2604
2942
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
2605
|
-
const
|
|
2943
|
+
const fs5 = await import("fs/promises");
|
|
2606
2944
|
const serverOnlyAssets = collectServerOnlySSRAssets(bundle);
|
|
2607
2945
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
2608
2946
|
if (output.type !== "asset" || serverOnlyAssets.has(fileName)) continue;
|
|
@@ -2610,41 +2948,51 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
2610
2948
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
2611
2949
|
continue;
|
|
2612
2950
|
}
|
|
2613
|
-
const filePath =
|
|
2614
|
-
await
|
|
2615
|
-
await
|
|
2951
|
+
const filePath = path16.join(outputDir, fileName);
|
|
2952
|
+
await fs5.mkdir(path16.dirname(filePath), { recursive: true });
|
|
2953
|
+
await fs5.writeFile(filePath, output.source);
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
async function writeFarmVideoPlayerToClient(outputDir) {
|
|
2957
|
+
const fs5 = await import("fs/promises");
|
|
2958
|
+
const filePath = path16.join(outputDir, FARM_VIDEO_PLAYER_PATH.slice(1));
|
|
2959
|
+
await fs5.mkdir(path16.dirname(filePath), { recursive: true });
|
|
2960
|
+
try {
|
|
2961
|
+
await fs5.writeFile(filePath, FARM_VIDEO_PLAYER_HTML, { flag: "wx" });
|
|
2962
|
+
} catch (error) {
|
|
2963
|
+
if (error.code !== "EEXIST") throw error;
|
|
2616
2964
|
}
|
|
2617
2965
|
}
|
|
2618
2966
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
2619
|
-
const
|
|
2967
|
+
const fs5 = await import("fs/promises");
|
|
2620
2968
|
await Promise.all(
|
|
2621
2969
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
2622
|
-
const targetPath =
|
|
2623
|
-
await
|
|
2624
|
-
await
|
|
2970
|
+
const targetPath = path16.join(outputDir, url.replace(/^\/+/, ""));
|
|
2971
|
+
await fs5.mkdir(path16.dirname(targetPath), { recursive: true });
|
|
2972
|
+
await fs5.copyFile(sourcePath, targetPath);
|
|
2625
2973
|
})
|
|
2626
2974
|
);
|
|
2627
2975
|
}
|
|
2628
2976
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
2629
|
-
const
|
|
2630
|
-
const fontCssPath =
|
|
2977
|
+
const fs5 = await import("fs/promises");
|
|
2978
|
+
const fontCssPath = path16.join(outputDir, "farm-fonts.css");
|
|
2631
2979
|
let fontCss = fontCssSource;
|
|
2632
2980
|
if (fontCss === void 0) {
|
|
2633
2981
|
try {
|
|
2634
|
-
fontCss = await
|
|
2982
|
+
fontCss = await fs5.readFile(fontCssPath);
|
|
2635
2983
|
} catch {
|
|
2636
2984
|
return;
|
|
2637
2985
|
}
|
|
2638
2986
|
}
|
|
2639
|
-
const clientCssPath =
|
|
2987
|
+
const clientCssPath = path16.join(outputDir, "farm-client.css");
|
|
2640
2988
|
let clientCss = "";
|
|
2641
2989
|
try {
|
|
2642
|
-
clientCss = await
|
|
2990
|
+
clientCss = await fs5.readFile(clientCssPath, "utf8");
|
|
2643
2991
|
} catch {
|
|
2644
2992
|
}
|
|
2645
2993
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
2646
|
-
await
|
|
2647
|
-
await
|
|
2994
|
+
await fs5.writeFile(fontCssPath, normalizedFontCss);
|
|
2995
|
+
await fs5.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
|
|
2648
2996
|
}
|
|
2649
2997
|
function importsFarmClientBlockedPackage(id, packageName) {
|
|
2650
2998
|
return id === packageName || id.startsWith(`${packageName}/`);
|
|
@@ -2660,28 +3008,28 @@ var IncompleteClientBuildOutputError = class extends Error {
|
|
|
2660
3008
|
}
|
|
2661
3009
|
};
|
|
2662
3010
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
2663
|
-
const
|
|
3011
|
+
const fs5 = await import("fs/promises");
|
|
2664
3012
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
2665
|
-
const clientEntryPath =
|
|
3013
|
+
const clientEntryPath = path16.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
2666
3014
|
let clientEntrySize = 0;
|
|
2667
3015
|
try {
|
|
2668
|
-
const clientEntry = await
|
|
3016
|
+
const clientEntry = await fs5.stat(clientEntryPath);
|
|
2669
3017
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
2670
3018
|
} catch {
|
|
2671
3019
|
}
|
|
2672
3020
|
if (clientEntrySize === 0) {
|
|
2673
3021
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
2674
3022
|
}
|
|
2675
|
-
const clientCssPath =
|
|
2676
|
-
const globalsCssPath =
|
|
3023
|
+
const clientCssPath = path16.join(outputDir, "farm-client.css");
|
|
3024
|
+
const globalsCssPath = path16.join(root, srcDir, "app", "globals.css");
|
|
2677
3025
|
let expectsCss = false;
|
|
2678
3026
|
try {
|
|
2679
|
-
const globalsCss = await
|
|
3027
|
+
const globalsCss = await fs5.readFile(globalsCssPath, "utf8");
|
|
2680
3028
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
2681
3029
|
} catch {
|
|
2682
3030
|
}
|
|
2683
3031
|
try {
|
|
2684
|
-
const clientCss = await
|
|
3032
|
+
const clientCss = await fs5.stat(clientCssPath);
|
|
2685
3033
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
2686
3034
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
2687
3035
|
}
|
|
@@ -2690,11 +3038,11 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2690
3038
|
if (expectsCss) {
|
|
2691
3039
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
2692
3040
|
}
|
|
2693
|
-
await
|
|
3041
|
+
await fs5.writeFile(clientCssPath, "");
|
|
2694
3042
|
}
|
|
2695
3043
|
}
|
|
2696
3044
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
2697
|
-
const key =
|
|
3045
|
+
const key = getClientModuleHydrationPlanKey(modulePath, root, mode, options);
|
|
2698
3046
|
let plan = cache.get(key);
|
|
2699
3047
|
if (!plan) {
|
|
2700
3048
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2702,12 +3050,12 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
2702
3050
|
}
|
|
2703
3051
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
2704
3052
|
}
|
|
2705
|
-
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
|
|
2706
|
-
if (!mobile) await removeFarmMobileClientManifest(
|
|
3053
|
+
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false, sourceSnapshot) {
|
|
3054
|
+
if (!mobile) await removeFarmMobileClientManifest(path16.dirname(outputDir));
|
|
2707
3055
|
const viteBuild = productionVite.build;
|
|
2708
3056
|
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2709
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
2710
|
-
const
|
|
3057
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
3058
|
+
const fs5 = await import("fs/promises");
|
|
2711
3059
|
const pluginManager = new PluginManager2({
|
|
2712
3060
|
config,
|
|
2713
3061
|
isDev: false,
|
|
@@ -2760,7 +3108,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2760
3108
|
);
|
|
2761
3109
|
const syntheticDocsEntry = config.docs?.enabled && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
|
|
2762
3110
|
const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
|
|
2763
|
-
const
|
|
3111
|
+
const plan = (operation) => sourceSnapshot ? withFarmSourceSnapshotOf(sourceSnapshot, operation) : withFarmSourceSnapshot(operation);
|
|
3112
|
+
const { clientLayouts, clientRouteSlots } = plan(() => {
|
|
2764
3113
|
const clientLayouts2 = layoutRoutes.map((layout) => {
|
|
2765
3114
|
try {
|
|
2766
3115
|
const metadata = getCachedClientModuleHydrationPlan(
|
|
@@ -2874,14 +3223,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2874
3223
|
}
|
|
2875
3224
|
}
|
|
2876
3225
|
const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
|
|
2877
|
-
const
|
|
3226
|
+
const plan2 = getCachedClientModuleHydrationPlan(
|
|
2878
3227
|
slot.modulePath,
|
|
2879
3228
|
root,
|
|
2880
3229
|
isolatedMode,
|
|
2881
3230
|
hydrationPlanCache,
|
|
2882
3231
|
{ ...pagePlanOptions, serverOwners: true }
|
|
2883
3232
|
);
|
|
2884
|
-
return
|
|
3233
|
+
return plan2.isClientComponent ? [] : [{ slot, plan: plan2 }];
|
|
2885
3234
|
}) : [];
|
|
2886
3235
|
for (const { route, metadata } of routePlans) {
|
|
2887
3236
|
if (isAdapterDocsRoute(route.pattern)) continue;
|
|
@@ -2896,7 +3245,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2896
3245
|
}
|
|
2897
3246
|
const slotBoundaries = serverSlotPlans.filter(
|
|
2898
3247
|
({ slot }) => layoutAppliesToRoute(slot.ownerDirectory ?? slot.ownerPattern, routeDirectory(route))
|
|
2899
|
-
).flatMap(({ plan }) =>
|
|
3248
|
+
).flatMap(({ plan: plan2 }) => plan2.isolatedBoundaries);
|
|
2900
3249
|
if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
|
|
2901
3250
|
const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
|
|
2902
3251
|
const islandStrategy = resolveFarmRouteRootStrategy(
|
|
@@ -2964,14 +3313,33 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2964
3313
|
});
|
|
2965
3314
|
return { clientLayouts: clientLayouts2, clientRouteSlots: clientRouteSlots2 };
|
|
2966
3315
|
});
|
|
3316
|
+
const docsEntryOwns = (pattern) => syntheticDocsEntry === "/" || pattern === syntheticDocsEntry || pattern.startsWith(`${syntheticDocsEntry}/`);
|
|
3317
|
+
if (syntheticDocsEntry && clientPages.some((page) => !page.docs && docsEntryOwns(page.pattern))) {
|
|
3318
|
+
const docsPagePaths = new Set(
|
|
3319
|
+
discoverFarmDocsPages(
|
|
3320
|
+
resolveFarmDocsContentDir(config.docs, { root: config.root, srcDir: config.srcDir }),
|
|
3321
|
+
config.docs
|
|
3322
|
+
).map((page) => page.href)
|
|
3323
|
+
);
|
|
3324
|
+
const resolved = resolveFarmDocsClientRoutes(clientPages, docsPagePaths);
|
|
3325
|
+
for (const page of resolved.shadowed) {
|
|
3326
|
+
logger.warn(
|
|
3327
|
+
`\u26A0\uFE0F ${page.pattern} has the URL shape of the docs route ${syntheticDocsPatterns[1]}, whose pages answer first: the page renders only at paths without a docs page, and does not hydrate as a page there.`
|
|
3328
|
+
);
|
|
3329
|
+
}
|
|
3330
|
+
clientPages.splice(0, clientPages.length, ...resolved.pages);
|
|
3331
|
+
}
|
|
2967
3332
|
logger.info(
|
|
2968
3333
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2969
3334
|
);
|
|
3335
|
+
const clientRouteTable = createFarmClientRouteTable(clientPages);
|
|
3336
|
+
createFarmRouter(clientRouteTable.map((route) => ({ path: route.pattern, meta: route })));
|
|
3337
|
+
await writeFarmClientRouteTable(path16.dirname(outputDir), clientRouteTable);
|
|
2970
3338
|
const buildTarget = async (platform) => {
|
|
2971
|
-
const clientEntryRoot =
|
|
2972
|
-
await
|
|
2973
|
-
const clientEntryDir = await
|
|
2974
|
-
const clientEntryPath =
|
|
3339
|
+
const clientEntryRoot = path16.join(root, ".farm", "tmp");
|
|
3340
|
+
await fs5.mkdir(clientEntryRoot, { recursive: true });
|
|
3341
|
+
const clientEntryDir = await fs5.mkdtemp(path16.join(clientEntryRoot, "client-entry-"));
|
|
3342
|
+
const clientEntryPath = path16.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2975
3343
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2976
3344
|
clientPages,
|
|
2977
3345
|
clientLayouts,
|
|
@@ -3003,14 +3371,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3003
3371
|
);
|
|
3004
3372
|
const entryName = platform === "mobile" ? FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
|
|
3005
3373
|
const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
|
|
3006
|
-
await
|
|
3374
|
+
await fs5.writeFile(clientEntryPath, clientEntry.entry);
|
|
3375
|
+
await fs5.writeFile(
|
|
3376
|
+
path16.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
|
|
3377
|
+
generateFarmClientRouteTableModule(clientRouteTable)
|
|
3378
|
+
);
|
|
3007
3379
|
if (clientEntry.router !== void 0) {
|
|
3008
|
-
await
|
|
3380
|
+
await fs5.writeFile(path16.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
|
|
3009
3381
|
}
|
|
3010
3382
|
const clientInput = { [entryName]: clientEntryPath };
|
|
3011
3383
|
if (platform === "web" && canBootFarmIslandsClient(config)) {
|
|
3012
|
-
const clientBootPath =
|
|
3013
|
-
await
|
|
3384
|
+
const clientBootPath = path16.join(clientEntryDir, "farm-client-boot.tsx");
|
|
3385
|
+
await fs5.writeFile(
|
|
3014
3386
|
clientBootPath,
|
|
3015
3387
|
'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
|
|
3016
3388
|
);
|
|
@@ -3026,8 +3398,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3026
3398
|
if (hasScopedPostcssConfig) {
|
|
3027
3399
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
3028
3400
|
} else {
|
|
3029
|
-
const postcssConfigPath =
|
|
3030
|
-
await
|
|
3401
|
+
const postcssConfigPath = path16.join(clientEntryDir, "postcss.config.cjs");
|
|
3402
|
+
await fs5.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
3031
3403
|
postcssSearchPath = clientEntryDir;
|
|
3032
3404
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
3033
3405
|
builder: productionVite.builder,
|
|
@@ -3048,6 +3420,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3048
3420
|
// Preserve Farm's Vite 5 browser baseline when the production builder
|
|
3049
3421
|
// uses Vite 8, whose default target only covers newer browsers.
|
|
3050
3422
|
target: FARM_CLIENT_BUILD_TARGET,
|
|
3423
|
+
// Tailwind CSS 4 already requires newer browsers than that baseline. An app's own
|
|
3424
|
+
// `build.target` or `build.cssTarget` still decides, as Vite derives one from the other.
|
|
3425
|
+
...config.vite?.build?.target === void 0 && config.vite?.build?.cssTarget === void 0 && (includesTailwindVitePlugin(tailwindVitePlugin) || includesTailwindVitePlugin(config.vite?.plugins)) ? { cssTarget: TAILWIND_CSS_BROWSER_TARGET } : {},
|
|
3051
3426
|
outDir: outputDir,
|
|
3052
3427
|
emptyOutDir: platform === "web",
|
|
3053
3428
|
// Never public: see resolveFarmClientSourcemap.
|
|
@@ -3082,24 +3457,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3082
3457
|
plugins: [
|
|
3083
3458
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
3084
3459
|
createFarmPrivateClientSourcemapsPlugin({
|
|
3085
|
-
outDir:
|
|
3086
|
-
|
|
3460
|
+
outDir: path16.join(
|
|
3461
|
+
path16.dirname(outputDir),
|
|
3087
3462
|
platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
|
|
3088
3463
|
)
|
|
3089
3464
|
}),
|
|
3090
3465
|
// The web client's preload manifests; the mobile client records its files instead.
|
|
3091
3466
|
platform === "mobile" ? createFarmMobileClientManifestPlugin({
|
|
3092
|
-
buildDir:
|
|
3467
|
+
buildDir: path16.dirname(outputDir),
|
|
3093
3468
|
entryName
|
|
3094
3469
|
}) : createFarmClientModulePreloadPlugin({
|
|
3095
3470
|
root,
|
|
3096
|
-
buildDir:
|
|
3471
|
+
buildDir: path16.dirname(outputDir),
|
|
3097
3472
|
entryName: "farm-client"
|
|
3098
3473
|
}),
|
|
3099
3474
|
...adapterOwnsDocsRuntime && platform === "web" ? [
|
|
3100
3475
|
createFarmDocsModulePreloadPlugin({
|
|
3101
3476
|
root,
|
|
3102
|
-
buildDir:
|
|
3477
|
+
buildDir: path16.dirname(outputDir),
|
|
3103
3478
|
importer: clientEntryPath,
|
|
3104
3479
|
entryName: "farm-client",
|
|
3105
3480
|
modules: [
|
|
@@ -3111,7 +3486,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3111
3486
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
3112
3487
|
...rendererVitePlugins,
|
|
3113
3488
|
...config.vite.plugins || [],
|
|
3114
|
-
farmServerOnlyEntriesPlugin({ platform }),
|
|
3489
|
+
farmServerOnlyEntriesPlugin({ platform, distDir: config.distDir || ".farm" }),
|
|
3115
3490
|
farmDocsClientConfigPlugin(
|
|
3116
3491
|
adapterOwnsDocsRuntime ? getFarmDocsAdapterConfigModule(config.docs) : void 0
|
|
3117
3492
|
),
|
|
@@ -3180,7 +3555,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3180
3555
|
},
|
|
3181
3556
|
farmIslandContainersPlugin(config),
|
|
3182
3557
|
farmPlugin(
|
|
3183
|
-
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes },
|
|
3558
|
+
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes, sourceSnapshot },
|
|
3184
3559
|
pluginManager
|
|
3185
3560
|
),
|
|
3186
3561
|
farmEnvironmentFunctionsPlugin(config)
|
|
@@ -3208,8 +3583,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3208
3583
|
mergeFarmProductionViteConfig(clientViteConfig, config.vite, { clientOutput: true })
|
|
3209
3584
|
);
|
|
3210
3585
|
if (platform === "mobile") {
|
|
3211
|
-
await
|
|
3212
|
-
if (!await hasFarmMobileClientEntry(
|
|
3586
|
+
await fs5.rm(path16.join(outputDir, `${entryName}.css`), { force: true });
|
|
3587
|
+
if (!await hasFarmMobileClientEntry(path16.dirname(outputDir), outputDir)) {
|
|
3213
3588
|
throw new IncompleteClientBuildOutputError(
|
|
3214
3589
|
`${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
|
|
3215
3590
|
);
|
|
@@ -3220,7 +3595,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3220
3595
|
}
|
|
3221
3596
|
} finally {
|
|
3222
3597
|
try {
|
|
3223
|
-
await
|
|
3598
|
+
await fs5.rm(clientEntryDir, { recursive: true, force: true });
|
|
3224
3599
|
} catch {
|
|
3225
3600
|
}
|
|
3226
3601
|
}
|
|
@@ -3228,19 +3603,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3228
3603
|
await buildTarget("web");
|
|
3229
3604
|
if (mobile) await buildTarget("mobile");
|
|
3230
3605
|
}
|
|
3231
|
-
function toBakedMarkdownSourcePath(root, filePath) {
|
|
3232
|
-
if (!filePath) return "";
|
|
3233
|
-
if (!path13.isAbsolute(filePath)) return filePath.split(path13.sep).join("/");
|
|
3234
|
-
const relative = path13.relative(root, filePath);
|
|
3235
|
-
if (!relative || relative.startsWith("..") || path13.isAbsolute(relative)) {
|
|
3236
|
-
return path13.basename(filePath);
|
|
3237
|
-
}
|
|
3238
|
-
return relative.split(path13.sep).join("/");
|
|
3239
|
-
}
|
|
3240
3606
|
function generateUniversalRouterStateRuntime(streamNavigations = false) {
|
|
3241
3607
|
return `
|
|
3242
3608
|
const FARM_PAGE_STATE_KEY = "__farmPageState";
|
|
3243
3609
|
const FARM_HISTORY_INDEX_KEY = "__farmHistoryIndex";
|
|
3610
|
+
const FARM_HISTORY_KEY = "__farmHistoryKey";
|
|
3244
3611
|
const IDLE_NAVIGATION_STATE = {
|
|
3245
3612
|
state: "idle",
|
|
3246
3613
|
pending: false,
|
|
@@ -3260,8 +3627,8 @@ function createNavigationLocation(url) {
|
|
|
3260
3627
|
};
|
|
3261
3628
|
}
|
|
3262
3629
|
|
|
3263
|
-
function scrollElementStorageKey(
|
|
3264
|
-
return "farm-scroll-" +
|
|
3630
|
+
function scrollElementStorageKey(scrollKey, key) {
|
|
3631
|
+
return "farm-scroll-" + scrollKey + ":" + key;
|
|
3265
3632
|
}
|
|
3266
3633
|
|
|
3267
3634
|
function createHistoryState(path, pageState, currentState) {
|
|
@@ -3320,17 +3687,177 @@ function readHistoryIndex(state) {
|
|
|
3320
3687
|
return Number.isSafeInteger(value) ? value : null;
|
|
3321
3688
|
}
|
|
3322
3689
|
|
|
3690
|
+
function readHistoryKey(state) {
|
|
3691
|
+
if (!state || typeof state !== "object") return null;
|
|
3692
|
+
const value = state[FARM_HISTORY_KEY];
|
|
3693
|
+
return typeof value === "string" && value.length > 0 && value.length <= 64 ? value : null;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
// The time keeps keys unique across the reloads and documents that share a tab's sessionStorage.
|
|
3697
|
+
function createHistoryKey() {
|
|
3698
|
+
return Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 10);
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
// Scroll positions are saved per history entry, so the same URL twice in history keeps two
|
|
3702
|
+
// positions. An entry Farm did not write has no key and falls back to its path.
|
|
3703
|
+
function historyScrollKey(state, path) {
|
|
3704
|
+
return readHistoryKey(state) || path;
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
// The URL a navigated page names as canonical (search.stripDefaults, search.temporary). A loaded
|
|
3708
|
+
// document applies it from its bootstrap script, which a navigation never runs, so a navigation
|
|
3709
|
+
// reads it from the same props and writes that URL to history. The fragment stays the link's.
|
|
3710
|
+
function resolveFarmCanonicalNavigationURL(html, url) {
|
|
3711
|
+
const prefix = "window.__FARM_PROPS__=";
|
|
3712
|
+
const separator = ";window.__FARM_INTEGRATION_API_MANIFEST__=";
|
|
3713
|
+
const start = typeof html === "string" ? html.indexOf(prefix) : -1;
|
|
3714
|
+
if (start === -1 || html.indexOf('"__farmCanonicalPath":', start) === -1) return url;
|
|
3715
|
+
for (
|
|
3716
|
+
let end = html.indexOf(separator, start + prefix.length);
|
|
3717
|
+
end !== -1;
|
|
3718
|
+
end = html.indexOf(separator, end + 1)
|
|
3719
|
+
) {
|
|
3720
|
+
let canonicalPath;
|
|
3721
|
+
try {
|
|
3722
|
+
canonicalPath = JSON.parse(html.slice(start + prefix.length, end)).__farmCanonicalPath;
|
|
3723
|
+
} catch {
|
|
3724
|
+
// The separator was inside a string value; try the next one.
|
|
3725
|
+
continue;
|
|
3726
|
+
}
|
|
3727
|
+
if (typeof canonicalPath !== "string" || !canonicalPath.startsWith("/")) return url;
|
|
3728
|
+
const canonical = new URL(canonicalPath, url);
|
|
3729
|
+
if (canonical.origin !== url.origin) return url;
|
|
3730
|
+
canonical.hash = url.hash;
|
|
3731
|
+
return canonical;
|
|
3732
|
+
}
|
|
3733
|
+
return url;
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3323
3736
|
/*farm-router-end*/
|
|
3324
3737
|
function hasAbsoluteNavigationHref(href) {
|
|
3325
3738
|
return /^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(href) || href.startsWith("//");
|
|
3326
3739
|
}
|
|
3327
3740
|
`.trim();
|
|
3328
3741
|
}
|
|
3742
|
+
function generateFarmClientRouteTableRuntime(options) {
|
|
3743
|
+
const prefetch = `const farmPrefetchWhileRouteTableLoads = ${!options.streamNavigations};`;
|
|
3744
|
+
if (!options.table) {
|
|
3745
|
+
return `${prefetch}
|
|
3746
|
+
const clientRoutes = [];
|
|
3747
|
+
const clientRouteMatcher = createFarmRouter([]);
|
|
3748
|
+
const clientPageRouteMatcher = clientRouteMatcher;
|
|
3749
|
+
function loadFarmClientRouteTable() { return null; }
|
|
3750
|
+
function prefetchFarmClientRouteTable() {}
|
|
3751
|
+
const farmClientRoutesBoot = null;`;
|
|
3752
|
+
}
|
|
3753
|
+
return `${prefetch}
|
|
3754
|
+
let clientRoutes = [];
|
|
3755
|
+
let clientRouteMatcher = createFarmRouter([]);
|
|
3756
|
+
let clientPageRouteMatcher = clientRouteMatcher;
|
|
3757
|
+
let farmClientRouteTableLoad = null;
|
|
3758
|
+
let farmClientRouteTableLoaded = false;
|
|
3759
|
+
|
|
3760
|
+
function setFarmClientRoutes(routes) {
|
|
3761
|
+
clientRoutes = routes.map(function(route) {
|
|
3762
|
+
const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
|
|
3763
|
+
return { ...route, navigation: "html-fragment", load: load || null };
|
|
3764
|
+
});
|
|
3765
|
+
clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
|
|
3766
|
+
return { path: route.pattern, meta: route };
|
|
3767
|
+
}));
|
|
3768
|
+
clientPageRouteMatcher = ${options.docs ? `createFarmRouter(clientRoutes.filter(function(route) {
|
|
3769
|
+
return !route.docs;
|
|
3770
|
+
}).map(function(route) {
|
|
3771
|
+
return { path: route.pattern, meta: route };
|
|
3772
|
+
}))` : "clientRouteMatcher"};
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
// Null once the whole table is in place, else a promise that settles when it is.
|
|
3776
|
+
function loadFarmClientRouteTable() {
|
|
3777
|
+
if (farmClientRouteTableLoaded) return null;
|
|
3778
|
+
return farmClientRouteTableLoad || (farmClientRouteTableLoad = import("./${FARM_CLIENT_ROUTE_TABLE_MODULE}").then(function(module) {
|
|
3779
|
+
setFarmClientRoutes(module.default);
|
|
3780
|
+
farmClientRouteTableLoaded = true;
|
|
3781
|
+
}, function(error) {
|
|
3782
|
+
farmClientRouteTableLoad = null;
|
|
3783
|
+
throw error;
|
|
3784
|
+
}));
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
// A navigation to come (a prefetch, the lazy router) warms the table; that navigation handles a failure.
|
|
3788
|
+
function prefetchFarmClientRouteTable() {
|
|
3789
|
+
const table = loadFarmClientRouteTable();
|
|
3790
|
+
if (table) table.catch(function() {});
|
|
3791
|
+
}
|
|
3792
|
+
|
|
3793
|
+
const farmClientRoutesBoot = (function() {
|
|
3794
|
+
const boot = window.__FARM_CLIENT_ROUTES__;
|
|
3795
|
+
if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)) {
|
|
3796
|
+
setFarmClientRoutes(boot.routes);
|
|
3797
|
+
return null;
|
|
3798
|
+
}
|
|
3799
|
+
return loadFarmClientRouteTable().catch(function(error) {
|
|
3800
|
+
console.warn("[Farm.js] Could not load the client route table; the page was left as the server rendered it.", error);
|
|
3801
|
+
});
|
|
3802
|
+
})();
|
|
3803
|
+
|
|
3804
|
+
// A plain <a> has no prefetch, unlike Link: a pointer or focus reaching one warms the table its
|
|
3805
|
+
// navigation will read.
|
|
3806
|
+
const FARM_ROUTE_TABLE_INTENT_EVENTS = ["pointerover", "pointerdown", "focusin", "touchstart"];
|
|
3807
|
+
function warmFarmClientRouteTable(event) {
|
|
3808
|
+
const target = event.target;
|
|
3809
|
+
if (!target || !target.closest || !target.closest("a[href]")) return;
|
|
3810
|
+
for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
|
|
3811
|
+
document.removeEventListener(type, warmFarmClientRouteTable, true);
|
|
3812
|
+
}
|
|
3813
|
+
prefetchFarmClientRouteTable();
|
|
3814
|
+
}
|
|
3815
|
+
for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
|
|
3816
|
+
document.addEventListener(type, warmFarmClientRouteTable, { capture: true, passive: true });
|
|
3817
|
+
}`;
|
|
3818
|
+
}
|
|
3819
|
+
function generateFarmClientBootRoutesServerSource(tableSource) {
|
|
3820
|
+
return `// The client route table (client-route-table.ts), filled in from the client build. The client
|
|
3821
|
+
// loads it on its first navigation; a document names the entries its page boots with, found
|
|
3822
|
+
// with the client's own matcher, so its page hydrates without the table.
|
|
3823
|
+
const farmClientRouteTable = (() => {
|
|
3824
|
+
try {
|
|
3825
|
+
const table = JSON.parse(${tableSource});
|
|
3826
|
+
if (!Array.isArray(table) || table.length === 0) return null;
|
|
3827
|
+
const toRoute = function(route) { return { path: route.pattern, meta: route }; };
|
|
3828
|
+
const routes = createFarmRouter(table.map(toRoute));
|
|
3829
|
+
return {
|
|
3830
|
+
routes: routes,
|
|
3831
|
+
pages: table.some(function(route) { return route.docs; })
|
|
3832
|
+
? createFarmRouter(table.filter(function(route) { return !route.docs; }).map(toRoute))
|
|
3833
|
+
: routes,
|
|
3834
|
+
};
|
|
3835
|
+
} catch {
|
|
3836
|
+
return null;
|
|
3837
|
+
}
|
|
3838
|
+
})();
|
|
3839
|
+
|
|
3840
|
+
// The entries the client's matchRoute and getFarmPageDirectory read for this route path.
|
|
3841
|
+
function getFarmClientBootRoutes(routePathname) {
|
|
3842
|
+
if (!farmClientRouteTable || typeof routePathname !== "string") return undefined;
|
|
3843
|
+
const routes = [];
|
|
3844
|
+
const matched = farmClientRouteTable.routes.match(routePathname);
|
|
3845
|
+
if (matched) {
|
|
3846
|
+
routes.push(matched.route.meta);
|
|
3847
|
+
const page = matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
|
|
3848
|
+
if (page) routes.push(page.route.meta);
|
|
3849
|
+
}
|
|
3850
|
+
return { path: routePathname, routes: routes };
|
|
3851
|
+
}`;
|
|
3852
|
+
}
|
|
3329
3853
|
function generateClientPageDirectorySource() {
|
|
3330
3854
|
return `function getFarmPageDirectory(pathname) {
|
|
3331
3855
|
const path = getFarmRoutePathname(pathname);
|
|
3332
3856
|
let matched = clientRouteMatcher.match(path);
|
|
3333
|
-
if (matched && matched.route.meta.docs)
|
|
3857
|
+
if (matched && matched.route.meta.docs) {
|
|
3858
|
+
if (matched.route.meta.directory) return matched.route.meta.directory;
|
|
3859
|
+
matched = clientPageRouteMatcher.match(path);
|
|
3860
|
+
}
|
|
3334
3861
|
return matched ? matched.route.meta.directory || matched.route.meta.pattern : null;
|
|
3335
3862
|
}`;
|
|
3336
3863
|
}
|
|
@@ -3652,7 +4179,8 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3652
4179
|
|
|
3653
4180
|
initializeHistory: function() {
|
|
3654
4181
|
const existingIndex = readHistoryIndex(window.history.state);
|
|
3655
|
-
|
|
4182
|
+
const existingKey = readHistoryKey(window.history.state);
|
|
4183
|
+
if (existingIndex != null && existingKey != null) {
|
|
3656
4184
|
this.currentHistoryIndex = existingIndex;
|
|
3657
4185
|
this.currentHistoryState = window.history.state;
|
|
3658
4186
|
return;
|
|
@@ -3662,14 +4190,15 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3662
4190
|
...(window.history.state && typeof window.history.state === "object"
|
|
3663
4191
|
? window.history.state
|
|
3664
4192
|
: {}),
|
|
3665
|
-
[FARM_HISTORY_INDEX_KEY]: 0,
|
|
4193
|
+
[FARM_HISTORY_INDEX_KEY]: existingIndex != null ? existingIndex : 0,
|
|
4194
|
+
[FARM_HISTORY_KEY]: existingKey || createHistoryKey(),
|
|
3666
4195
|
};
|
|
3667
4196
|
window.history.replaceState(initialState, "", window.location.href);
|
|
3668
|
-
this.currentHistoryIndex =
|
|
4197
|
+
this.currentHistoryIndex = initialState[FARM_HISTORY_INDEX_KEY];
|
|
3669
4198
|
this.currentHistoryState = initialState;
|
|
3670
4199
|
} catch {
|
|
3671
|
-
this.currentHistoryIndex =
|
|
3672
|
-
this.currentHistoryState = null;
|
|
4200
|
+
this.currentHistoryIndex = existingIndex;
|
|
4201
|
+
this.currentHistoryState = existingIndex != null ? window.history.state : null;
|
|
3673
4202
|
}
|
|
3674
4203
|
},
|
|
3675
4204
|
|
|
@@ -3766,6 +4295,20 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3766
4295
|
!clientNavigation?.signal.aborted;
|
|
3767
4296
|
},
|
|
3768
4297
|
|
|
4298
|
+
// A prefetch made while a navigation swaps the page (an intent timer after the click, the
|
|
4299
|
+
// incoming page's links) would ask for it as the outgoing page shows it: its layouts, its React
|
|
4300
|
+
// root. It waits for the navigation to settle, and then skips the page it landed on.
|
|
4301
|
+
whenNavigationSettles: function() {
|
|
4302
|
+
return new Promise((resolve) => {
|
|
4303
|
+
const listener = (state) => {
|
|
4304
|
+
if (state.state !== "idle") return;
|
|
4305
|
+
this.navigationListeners.delete(listener);
|
|
4306
|
+
resolve();
|
|
4307
|
+
};
|
|
4308
|
+
this.navigationListeners.add(listener);
|
|
4309
|
+
});
|
|
4310
|
+
},
|
|
4311
|
+
|
|
3769
4312
|
finishNavigation: function(navigation) {
|
|
3770
4313
|
if (this.activeNavigation?.id !== navigation.id) return;
|
|
3771
4314
|
this.activeNavigation = null;
|
|
@@ -3962,6 +4505,9 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3962
4505
|
? this.currentHistoryIndex
|
|
3963
4506
|
: this.currentHistoryIndex + 1;
|
|
3964
4507
|
if (nextIndex != null) nextState[FARM_HISTORY_INDEX_KEY] = nextIndex;
|
|
4508
|
+
// A push is a new entry; createHistoryState copied the current entry's key into it.
|
|
4509
|
+
nextState[FARM_HISTORY_KEY] =
|
|
4510
|
+
(action === "replace" && readHistoryKey(nextState)) || createHistoryKey();
|
|
3965
4511
|
if (action === "replace") window.history.replaceState(nextState, "", url);
|
|
3966
4512
|
else window.history.pushState(nextState, "", url);
|
|
3967
4513
|
this.currentHistoryIndex = nextIndex;
|
|
@@ -3977,43 +4523,54 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3977
4523
|
|
|
3978
4524
|
registerScrollElement: function(key, element) {
|
|
3979
4525
|
this.scrollElements.set(key, element);
|
|
3980
|
-
this.restoreScrollElement(
|
|
4526
|
+
this.restoreScrollElement(
|
|
4527
|
+
historyScrollKey(this.currentHistoryState, window.location.pathname + window.location.search),
|
|
4528
|
+
key,
|
|
4529
|
+
element,
|
|
4530
|
+
);
|
|
3981
4531
|
return () => {
|
|
3982
4532
|
if (this.scrollElements.get(key) === element) this.scrollElements.delete(key);
|
|
3983
4533
|
};
|
|
3984
4534
|
},
|
|
3985
4535
|
|
|
3986
|
-
|
|
4536
|
+
// Without a key, saves the entry on screen (the unload handler, which may run on a stand-in).
|
|
4537
|
+
saveScrollPosition: function(scrollKey) {
|
|
4538
|
+
if (scrollKey === undefined) {
|
|
4539
|
+
scrollKey = historyScrollKey(
|
|
4540
|
+
this.currentHistoryState,
|
|
4541
|
+
window.location.pathname + window.location.search,
|
|
4542
|
+
);
|
|
4543
|
+
}
|
|
3987
4544
|
try {
|
|
3988
4545
|
sessionStorage.setItem(
|
|
3989
|
-
"farm-scroll-" +
|
|
4546
|
+
"farm-scroll-" + scrollKey,
|
|
3990
4547
|
JSON.stringify({ x: window.scrollX, y: window.scrollY }),
|
|
3991
4548
|
);
|
|
3992
4549
|
for (const [key, element] of this.scrollElements) {
|
|
3993
4550
|
sessionStorage.setItem(
|
|
3994
|
-
scrollElementStorageKey(
|
|
4551
|
+
scrollElementStorageKey(scrollKey, key),
|
|
3995
4552
|
JSON.stringify({ x: element.scrollLeft, y: element.scrollTop }),
|
|
3996
4553
|
);
|
|
3997
4554
|
}
|
|
3998
4555
|
} catch {}
|
|
3999
4556
|
},
|
|
4000
4557
|
|
|
4001
|
-
restoreScrollPosition: function(
|
|
4558
|
+
restoreScrollPosition: function(scrollKey) {
|
|
4002
4559
|
try {
|
|
4003
|
-
const saved = sessionStorage.getItem("farm-scroll-" +
|
|
4560
|
+
const saved = sessionStorage.getItem("farm-scroll-" + scrollKey);
|
|
4004
4561
|
if (saved) {
|
|
4005
4562
|
const position = JSON.parse(saved);
|
|
4006
4563
|
setTimeout(() => window.scrollTo(position.x, position.y), 0);
|
|
4007
4564
|
}
|
|
4008
4565
|
for (const [key, element] of this.scrollElements) {
|
|
4009
|
-
this.restoreScrollElement(
|
|
4566
|
+
this.restoreScrollElement(scrollKey, key, element);
|
|
4010
4567
|
}
|
|
4011
4568
|
} catch {}
|
|
4012
4569
|
},
|
|
4013
4570
|
|
|
4014
|
-
restoreScrollElement: function(
|
|
4571
|
+
restoreScrollElement: function(scrollKey, key, element) {
|
|
4015
4572
|
try {
|
|
4016
|
-
const saved = sessionStorage.getItem(scrollElementStorageKey(
|
|
4573
|
+
const saved = sessionStorage.getItem(scrollElementStorageKey(scrollKey, key));
|
|
4017
4574
|
if (!saved) return;
|
|
4018
4575
|
const position = JSON.parse(saved);
|
|
4019
4576
|
setTimeout(() => {
|
|
@@ -4040,6 +4597,8 @@ const farmRouterReady = [];
|
|
|
4040
4597
|
const farmRouterObserved = new Set();
|
|
4041
4598
|
|
|
4042
4599
|
function loadFarmRouter() {
|
|
4600
|
+
// The router's first navigation needs the route table: fetch both at once.
|
|
4601
|
+
if (!farmRouterLoading) prefetchFarmClientRouteTable();
|
|
4043
4602
|
return farmRouterLoading || (farmRouterLoading = import("./farm-client-router").then(function(module) {
|
|
4044
4603
|
farmLoadedRouter = module.spaRouter;
|
|
4045
4604
|
// The router module installs itself as the global; this object stays it, so a reference taken
|
|
@@ -4272,7 +4831,8 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
4272
4831
|
);
|
|
4273
4832
|
const appSetupPath = resolveFarmRendererAppSetup(root, renderer);
|
|
4274
4833
|
const rendererClientImports = isReactRenderer(renderer) ? `import React from "react";
|
|
4275
|
-
import { createRoot, hydrateRoot } from "react-dom/client"
|
|
4834
|
+
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
4835
|
+
import { restorePagePosition } from "@farm.js/core/internal/client-runtime";` : appSetupPath ? `import React, { createRoot, hydrateRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)};
|
|
4276
4836
|
import __farmAppSetup from ${JSON.stringify(toPosixPath(appSetupPath))};
|
|
4277
4837
|
__farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
|
|
4278
4838
|
const providerClientCode = generateFarmIntegrationProviderClientCode(
|
|
@@ -4280,10 +4840,10 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
4280
4840
|
root,
|
|
4281
4841
|
renderer.componentExtensions ?? []
|
|
4282
4842
|
);
|
|
4283
|
-
const globalsCssPath =
|
|
4843
|
+
const globalsCssPath = path16.join(root, srcDir, "app", "globals.css");
|
|
4284
4844
|
const serverStyleModules = [];
|
|
4285
4845
|
const cssImport = [
|
|
4286
|
-
...
|
|
4846
|
+
...existsSync3(globalsCssPath) ? [globalsCssPath] : [],
|
|
4287
4847
|
...serverStylesheets.filter((stylesheet) => stylesheet !== globalsCssPath)
|
|
4288
4848
|
].map((stylesheet) => {
|
|
4289
4849
|
if (!/\.module\.[a-z]+$/.test(stylesheet)) {
|
|
@@ -4379,7 +4939,7 @@ function isFarmDocsPath() {
|
|
|
4379
4939
|
// Farm.js Client Runtime (no client components)
|
|
4380
4940
|
${cssImport}
|
|
4381
4941
|
${layoutImports}
|
|
4382
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4942
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, readFarmLinkNavigateOptions, rememberFarmLinkLocale, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4383
4943
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4384
4944
|
${clientPluginEntry.imports}
|
|
4385
4945
|
${clientCachePersistence.imports}
|
|
@@ -4455,13 +5015,14 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4455
5015
|
this.cancelActiveNavigation();
|
|
4456
5016
|
return;
|
|
4457
5017
|
}
|
|
5018
|
+
// The entry still on screen: on Back/Forward the URL and history.state already name the destination.
|
|
5019
|
+
const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
|
|
4458
5020
|
if (action === "pop") {
|
|
4459
5021
|
this.currentHistoryIndex = readHistoryIndex(options.popState);
|
|
4460
5022
|
this.currentHistoryState = options.popState;
|
|
4461
5023
|
}
|
|
4462
5024
|
|
|
4463
|
-
|
|
4464
|
-
this.saveScrollPosition(from);
|
|
5025
|
+
this.saveScrollPosition(fromScrollKey);
|
|
4465
5026
|
const navigation = this.startNavigation(from, url, action);
|
|
4466
5027
|
let clientNavigation;
|
|
4467
5028
|
try {
|
|
@@ -4486,13 +5047,19 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4486
5047
|
if (!this.swapContent(html)) {
|
|
4487
5048
|
throw new Error("Farm could not swap the target document");
|
|
4488
5049
|
}
|
|
4489
|
-
|
|
4490
|
-
this.
|
|
5050
|
+
const historyUrl = resolveFarmCanonicalNavigationURL(html, url);
|
|
5051
|
+
this.writeHistoryEntry(
|
|
5052
|
+
action,
|
|
5053
|
+
historyUrl.pathname + historyUrl.search,
|
|
5054
|
+
options.state,
|
|
5055
|
+
historyUrl,
|
|
5056
|
+
);
|
|
5057
|
+
this.currentPath = historyUrl.pathname + historyUrl.search;
|
|
4491
5058
|
if (options.scroll !== false) {
|
|
4492
5059
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
4493
5060
|
else window.scrollTo(0, 0);
|
|
4494
5061
|
} else {
|
|
4495
|
-
this.restoreScrollPosition(to);
|
|
5062
|
+
this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
|
|
4496
5063
|
}
|
|
4497
5064
|
});
|
|
4498
5065
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
@@ -4579,6 +5146,13 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4579
5146
|
const url = new URL(href, window.location.href);
|
|
4580
5147
|
if (isFarmExternalNavigationURL(url, window.location.origin)) return;
|
|
4581
5148
|
if (isFarmDocsPath(url.pathname)) return;
|
|
5149
|
+
if (this.activeNavigation) {
|
|
5150
|
+
return this.whenNavigationSettles().then(() => {
|
|
5151
|
+
if (url.pathname + url.search !== window.location.pathname + window.location.search) {
|
|
5152
|
+
return this.prefetch(href);
|
|
5153
|
+
}
|
|
5154
|
+
});
|
|
5155
|
+
}
|
|
4582
5156
|
|
|
4583
5157
|
const pathname = url.pathname + url.search;
|
|
4584
5158
|
if (this.readFreshPrefetch(pathname) !== undefined) return;
|
|
@@ -4631,7 +5205,7 @@ window.addEventListener("beforeunload", function(event) {
|
|
|
4631
5205
|
event.preventDefault();
|
|
4632
5206
|
event.returnValue = "";
|
|
4633
5207
|
}
|
|
4634
|
-
spaRouter.saveScrollPosition(
|
|
5208
|
+
spaRouter.saveScrollPosition();
|
|
4635
5209
|
});
|
|
4636
5210
|
|
|
4637
5211
|
// Handle popstate (back/forward)
|
|
@@ -4657,12 +5231,16 @@ document.addEventListener("click", function(e) {
|
|
|
4657
5231
|
if (e.defaultPrevented) return;
|
|
4658
5232
|
|
|
4659
5233
|
e.preventDefault();
|
|
4660
|
-
|
|
5234
|
+
rememberFarmLinkLocale(anchor);
|
|
5235
|
+
spaRouter.navigate(href, readFarmLinkNavigateOptions(anchor));
|
|
4661
5236
|
});
|
|
5237
|
+
|
|
5238
|
+
// Link anchors on a page that does not hydrate prefetch through the router as Link would.
|
|
5239
|
+
installFarmLinkPrefetch();
|
|
4662
5240
|
`.trim();
|
|
4663
5241
|
}
|
|
4664
5242
|
const imports = [];
|
|
4665
|
-
const
|
|
5243
|
+
const routeLoaders = [];
|
|
4666
5244
|
const routeSlotEntries = [];
|
|
4667
5245
|
const isolatedBoundaryModules = /* @__PURE__ */ new Map();
|
|
4668
5246
|
clientPages.forEach((page) => {
|
|
@@ -4672,16 +5250,11 @@ document.addEventListener("click", function(e) {
|
|
|
4672
5250
|
toImportPath(boundary.modulePath)
|
|
4673
5251
|
);
|
|
4674
5252
|
}
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
${page.hasIsolatedClientBoundaries ? "hasIsolatedClientBoundaries: true," : ""}
|
|
4681
|
-
islandStrategy: ${JSON.stringify(page.islandStrategy)},
|
|
4682
|
-
navigation: "html-fragment",
|
|
4683
|
-
load: ${load},
|
|
4684
|
-
}`);
|
|
5253
|
+
if (page.pageShouldHydrate) {
|
|
5254
|
+
routeLoaders.push(
|
|
5255
|
+
` () => import(${JSON.stringify(toImportPath(page.modulePath))}).then((module) => module.default),`
|
|
5256
|
+
);
|
|
5257
|
+
}
|
|
4685
5258
|
});
|
|
4686
5259
|
const isolatedHydrationEnabled = isolatedBoundaryModules.size > 0;
|
|
4687
5260
|
const serverTreeEnabled = isolatedHydrationEnabled && clientPages.some((page) => page.serverTree);
|
|
@@ -4752,7 +5325,7 @@ ${layoutImports}
|
|
|
4752
5325
|
${rendererClientImports}
|
|
4753
5326
|
${isolatedHydrationImport}
|
|
4754
5327
|
${providerClientCode.imports}
|
|
4755
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
5328
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, readFarmLinkNavigateOptions, rememberFarmLinkLocale, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4756
5329
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4757
5330
|
import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
|
|
4758
5331
|
${clientPluginEntry.imports}
|
|
@@ -4771,18 +5344,15 @@ setFarmTrailingSlashPreference(${JSON.stringify(trailingSlash)});
|
|
|
4771
5344
|
installChunkErrorRecovery();
|
|
4772
5345
|
${clientCachePersistence.init}
|
|
4773
5346
|
|
|
4774
|
-
//
|
|
4775
|
-
const
|
|
4776
|
-
${
|
|
5347
|
+
// The page modules that hydrate, by their route's \`loader\` index
|
|
5348
|
+
const farmClientRouteLoaders = [
|
|
5349
|
+
${routeLoaders.join("\n")}
|
|
4777
5350
|
];
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
}).map(function(route) {
|
|
4784
|
-
return { path: route.pattern, meta: route };
|
|
4785
|
-
}));` : "const clientPageRouteMatcher = clientRouteMatcher;"}
|
|
5351
|
+
${generateFarmClientRouteTableRuntime({
|
|
5352
|
+
table: clientPages.length > 0,
|
|
5353
|
+
docs: clientPages.some((page) => page.docs),
|
|
5354
|
+
streamNavigations: islandValues
|
|
5355
|
+
})}
|
|
4786
5356
|
${generateClientPageDirectorySource()}
|
|
4787
5357
|
|
|
4788
5358
|
${isolatedHydrationRuntime}
|
|
@@ -4925,7 +5495,7 @@ function reviveServerPageProps(serverProps) {
|
|
|
4925
5495
|
: serverProps;
|
|
4926
5496
|
}
|
|
4927
5497
|
|
|
4928
|
-
async function createMatchedHydrationRoute(matched, pathname, searchParams,
|
|
5498
|
+
async function createMatchedHydrationRoute(matched, pathname, searchParams, navigationPage, serverProps, layoutSource, hydrationContainer) {
|
|
4929
5499
|
const hydrateLayouts = hasHydratableLayout(pathname);
|
|
4930
5500
|
const params = matched.params;
|
|
4931
5501
|
let pageElement = null;
|
|
@@ -4962,24 +5532,30 @@ async function createMatchedHydrationRoute(matched, pathname, searchParams, serv
|
|
|
4962
5532
|
pageElement = React.createElement(Component, props);
|
|
4963
5533
|
}
|
|
4964
5534
|
} else if (hydrateLayouts) {
|
|
5535
|
+
// A navigation passes the page element of the document it fetched, read as it is rather
|
|
5536
|
+
// than serialized and parsed again; hydration reads the page in this document.
|
|
4965
5537
|
const serverPage = document.getElementById("__farm_page__");
|
|
4966
|
-
const pageSource =
|
|
5538
|
+
const pageSource = navigationPage === undefined ? serverPage : navigationPage;
|
|
4967
5539
|
const serverTree = pageSource ? await createFarmServerTreePageElement(pageSource, pathname) : null;
|
|
4968
5540
|
// A payload-only page (islands mode) has no HTML to fall back to: fetch the whole document.
|
|
4969
|
-
if (
|
|
5541
|
+
if (
|
|
5542
|
+
!serverTree &&
|
|
5543
|
+
pageSource &&
|
|
5544
|
+
pageSource !== serverPage &&
|
|
5545
|
+
pageSource.querySelector('script[type="f/tree"][partial]')
|
|
5546
|
+
) {
|
|
4970
5547
|
return null;
|
|
4971
5548
|
}
|
|
4972
5549
|
pageElement = serverTree
|
|
4973
5550
|
? createLayoutPageBoundary(matched.route, serverTree)
|
|
4974
|
-
: createLayoutPageBoundary(
|
|
4975
|
-
matched.route,
|
|
4976
|
-
null,
|
|
4977
|
-
typeof serverHtml === "string" ? serverHtml : serverPage ? serverPage.innerHTML : "",
|
|
4978
|
-
);
|
|
5551
|
+
: createLayoutPageBoundary(matched.route, null, pageSource ? pageSource.innerHTML : "");
|
|
4979
5552
|
}
|
|
4980
5553
|
|
|
4981
5554
|
if (!pageElement) return null;
|
|
4982
|
-
if (!hydrateLayouts)
|
|
5555
|
+
if (!hydrateLayouts) {
|
|
5556
|
+
${isReactRenderer(renderer) ? "if (hydrationContainer) pageElement = restorePagePosition(React, hydrationContainer, pageElement);" : ""}
|
|
5557
|
+
return createFarmRouteState(pageElement, pathname, params, false);
|
|
5558
|
+
}
|
|
4983
5559
|
if (matched.route.pageShouldHydrate) {
|
|
4984
5560
|
pageElement = createLayoutPageBoundary(matched.route, pageElement);
|
|
4985
5561
|
}
|
|
@@ -5271,6 +5847,8 @@ async function hydrate() {
|
|
|
5271
5847
|
window.__FARM_PPR_HYDRATING__ = true;
|
|
5272
5848
|
await farmClientRuntime.start();
|
|
5273
5849
|
|
|
5850
|
+
// The route table, when the document named no entries for this URL.
|
|
5851
|
+
await farmClientRoutesBoot;
|
|
5274
5852
|
const pathname = window.location.pathname;
|
|
5275
5853
|
const matched = matchRoute(pathname);
|
|
5276
5854
|
${islandValues ? `if (
|
|
@@ -5346,15 +5924,17 @@ async function hydrate() {
|
|
|
5346
5924
|
return;
|
|
5347
5925
|
}
|
|
5348
5926
|
const searchParams = searchParamsToObject(new URLSearchParams(window.location.search));
|
|
5927
|
+
const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
|
|
5349
5928
|
const routeState = await createMatchedHydrationRoute(
|
|
5350
5929
|
matched,
|
|
5351
5930
|
pathname,
|
|
5352
5931
|
searchParams,
|
|
5353
5932
|
undefined,
|
|
5354
5933
|
window.__FARM_PROPS__,
|
|
5934
|
+
undefined,
|
|
5935
|
+
shouldHydrate ? container : undefined,
|
|
5355
5936
|
);
|
|
5356
5937
|
if (!routeState) return;
|
|
5357
|
-
const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
|
|
5358
5938
|
const hydrationSession = await farmClientRuntime.beginHydration({
|
|
5359
5939
|
container,
|
|
5360
5940
|
mode: shouldHydrate ? "hydrate" : "render",
|
|
@@ -5603,9 +6183,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5603
6183
|
partialNavigationHeaders: function() {
|
|
5604
6184
|
const root = document.getElementById("root") || document.body;
|
|
5605
6185
|
const layouts = getLayoutPatterns(root);
|
|
6186
|
+
// The root React owns, or one whose layouts hydrate together but have not yet: the
|
|
6187
|
+
// navigation creates it (swapContent).
|
|
6188
|
+
const rendersTree = reactRoot
|
|
6189
|
+
? reactRootContainer === root
|
|
6190
|
+
: root.id === "root" && hasHydratableLayout(window.location.pathname);
|
|
5606
6191
|
return {
|
|
5607
6192
|
...(layouts.length ? { "F-Layouts": JSON.stringify(layouts) } : {}),
|
|
5608
|
-
...(
|
|
6193
|
+
...(rendersTree ? { "F-Render": "tree" } : {}),
|
|
5609
6194
|
};
|
|
5610
6195
|
},
|
|
5611
6196
|
` : ""}
|
|
@@ -5647,6 +6232,21 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5647
6232
|
return;
|
|
5648
6233
|
}
|
|
5649
6234
|
|
|
6235
|
+
// The first navigation that matches a route waits for the client route table; a prefetch
|
|
6236
|
+
// usually loaded it already (generateFarmClientRouteTableRuntime). Without it (a deployment
|
|
6237
|
+
// that removed it, a network error), a document navigation is the safe fallback.
|
|
6238
|
+
const routeTable = loadFarmClientRouteTable();
|
|
6239
|
+
if (routeTable) {
|
|
6240
|
+
if (farmPrefetchWhileRouteTableLoads && !options.refresh) this.prefetch(url.href);
|
|
6241
|
+
try {
|
|
6242
|
+
await routeTable;
|
|
6243
|
+
} catch (error) {
|
|
6244
|
+
console.warn("[Farm.js] Could not load the client route table; navigating to " + href + " in full.", error);
|
|
6245
|
+
if (action === "push") window.location.assign(url.href);
|
|
6246
|
+
else window.location.replace(url.href);
|
|
6247
|
+
return;
|
|
6248
|
+
}
|
|
6249
|
+
}
|
|
5650
6250
|
const pathname = url.pathname;
|
|
5651
6251
|
const matched = matchRoute(pathname);
|
|
5652
6252
|
const from = this.currentPath;
|
|
@@ -5663,6 +6263,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5663
6263
|
this.cancelActiveNavigation();
|
|
5664
6264
|
return;
|
|
5665
6265
|
}
|
|
6266
|
+
// The entry still on screen: on Back/Forward the URL and history.state already name the destination.
|
|
6267
|
+
const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
|
|
5666
6268
|
if (action === "pop") {
|
|
5667
6269
|
this.currentHistoryIndex = readHistoryIndex(options.popState);
|
|
5668
6270
|
this.currentHistoryState = options.popState;
|
|
@@ -5671,8 +6273,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5671
6273
|
// A route transition invalidates any trigger waiting on the previous DOM boundary.
|
|
5672
6274
|
cancelPendingPageHydration();
|
|
5673
6275
|
this.stopNavigationStream();
|
|
5674
|
-
|
|
5675
|
-
this.saveScrollPosition(from);
|
|
6276
|
+
this.saveScrollPosition(fromScrollKey);
|
|
5676
6277
|
const navigation = this.startNavigation(from, url, action);
|
|
5677
6278
|
// A refresh keeps the islands still on the page (islands mode).
|
|
5678
6279
|
navigation.refresh = options.refresh === true;
|
|
@@ -5798,8 +6399,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5798
6399
|
// The history entry comes first, as on the client-render path: swapContent shows the
|
|
5799
6400
|
// page and its title, then waits for its islands, and a Back pressed meanwhile must
|
|
5800
6401
|
// leave the page on screen, not the one before it. Its islands also hydrate at their URL.
|
|
5801
|
-
|
|
5802
|
-
this.
|
|
6402
|
+
const historyUrl = resolveFarmCanonicalNavigationURL(html, url);
|
|
6403
|
+
this.writeHistoryEntry(
|
|
6404
|
+
action,
|
|
6405
|
+
historyUrl.pathname + historyUrl.search,
|
|
6406
|
+
options.state,
|
|
6407
|
+
historyUrl,
|
|
6408
|
+
);
|
|
6409
|
+
this.currentPath = historyUrl.pathname + historyUrl.search;
|
|
5803
6410
|
let swappedHtml = html;
|
|
5804
6411
|
let swapped = await this.swapContent(
|
|
5805
6412
|
html,
|
|
@@ -5841,7 +6448,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5841
6448
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
5842
6449
|
else window.scrollTo(0, 0);
|
|
5843
6450
|
} else {
|
|
5844
|
-
this.restoreScrollPosition(to);
|
|
6451
|
+
this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
|
|
5845
6452
|
}
|
|
5846
6453
|
await farmClientRuntime.resolveNavigation(clientNavigation);
|
|
5847
6454
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
@@ -5919,6 +6526,30 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5919
6526
|
const hydrateLayouts = hasHydratableLayout(newPathname);
|
|
5920
6527
|
const nextPage = newRoot.querySelector("#__farm_page__");
|
|
5921
6528
|
|
|
6529
|
+
${islandValues ? `// A layout that hydrates as one root but has not yet (its client components wait for a
|
|
6530
|
+
// click): its first navigation renders the page's payload in a new root, as later ones do.
|
|
6531
|
+
if (
|
|
6532
|
+
matched && hydrateLayouts && !reactRoot && currentRoot.id === "root" &&
|
|
6533
|
+
nextPage?.querySelector('script[type="f/tree"][partial]')
|
|
6534
|
+
) {
|
|
6535
|
+
const routeState = await createMatchedHydrationRoute(
|
|
6536
|
+
matched,
|
|
6537
|
+
newPathname,
|
|
6538
|
+
searchParamsToObject(targetUrl.searchParams),
|
|
6539
|
+
nextPage,
|
|
6540
|
+
nextPageProps,
|
|
6541
|
+
newRoot,
|
|
6542
|
+
);
|
|
6543
|
+
if (!isNavigationCurrent()) return false;
|
|
6544
|
+
if (!routeState) return "segment-mismatch";
|
|
6545
|
+
cancelPendingPageHydration();
|
|
6546
|
+
resetRouteSlotRoots();
|
|
6547
|
+
setFarmReactRoot(createRoot(currentRoot), currentRoot);
|
|
6548
|
+
renderFarmRoute(reactRoot, routeState);
|
|
6549
|
+
window.__FARM_ROUTE_SLOTS__ = nextRouteSlots;
|
|
6550
|
+
setFarmHydrated();
|
|
6551
|
+
return true;
|
|
6552
|
+
}` : ""}
|
|
5922
6553
|
// If React already owns the shared layout, update that root. React keeps
|
|
5923
6554
|
// matching layout component instances and their state mounted.
|
|
5924
6555
|
if (matched && hydrateLayouts && reactRoot && reactRootContainer === currentRoot) {
|
|
@@ -5927,7 +6558,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5927
6558
|
matched,
|
|
5928
6559
|
newPathname,
|
|
5929
6560
|
searchParams,
|
|
5930
|
-
nextPage
|
|
6561
|
+
nextPage,
|
|
5931
6562
|
nextPageProps,
|
|
5932
6563
|
newRoot,
|
|
5933
6564
|
);
|
|
@@ -5972,6 +6603,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5972
6603
|
searchParams,
|
|
5973
6604
|
undefined,
|
|
5974
6605
|
nextPageProps,
|
|
6606
|
+
undefined,
|
|
6607
|
+
pageContainer,
|
|
5975
6608
|
);
|
|
5976
6609
|
if (!isNavigationCurrent()) return false;
|
|
5977
6610
|
if (routeState) {
|
|
@@ -6022,6 +6655,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6022
6655
|
const url = new URL(href, window.location.href);
|
|
6023
6656
|
if (isFarmExternalNavigationURL(url, window.location.origin)) return;
|
|
6024
6657
|
if (isFarmDocsPath(url.pathname)) return;
|
|
6658
|
+
if (this.activeNavigation) {
|
|
6659
|
+
return this.whenNavigationSettles().then(() => {
|
|
6660
|
+
if (url.pathname + url.search !== window.location.pathname + window.location.search) {
|
|
6661
|
+
return this.prefetch(href);
|
|
6662
|
+
}
|
|
6663
|
+
});
|
|
6664
|
+
}
|
|
6665
|
+
prefetchFarmClientRouteTable();
|
|
6025
6666
|
|
|
6026
6667
|
// A prefetch warms an ordinary future navigation, which reads the bare
|
|
6027
6668
|
// URL key. Carrying the intercept identity here both missed every real
|
|
@@ -6073,6 +6714,9 @@ void farmClientRuntime.start();
|
|
|
6073
6714
|
/*farm-router-start*/
|
|
6074
6715
|
spaRouter.initializeHistory();
|
|
6075
6716
|
window.__FARM_SPA_ROUTER__ = spaRouter;
|
|
6717
|
+
// Link anchors on a page that does not hydrate prefetch through the router as Link would. In
|
|
6718
|
+
// islands mode this runs once the router loads, so a page still loads it only when it needs it.
|
|
6719
|
+
installFarmLinkPrefetch();
|
|
6076
6720
|
/*farm-router-end*/
|
|
6077
6721
|
|
|
6078
6722
|
window.addEventListener("beforeunload", function(event) {
|
|
@@ -6080,7 +6724,7 @@ window.addEventListener("beforeunload", function(event) {
|
|
|
6080
6724
|
event.preventDefault();
|
|
6081
6725
|
event.returnValue = "";
|
|
6082
6726
|
}
|
|
6083
|
-
spaRouter.saveScrollPosition(
|
|
6727
|
+
spaRouter.saveScrollPosition();
|
|
6084
6728
|
});
|
|
6085
6729
|
|
|
6086
6730
|
// Handle popstate (back/forward)
|
|
@@ -6106,7 +6750,8 @@ document.addEventListener("click", function(e) {
|
|
|
6106
6750
|
if (e.defaultPrevented) return;
|
|
6107
6751
|
|
|
6108
6752
|
e.preventDefault();
|
|
6109
|
-
|
|
6753
|
+
rememberFarmLinkLocale(anchor);
|
|
6754
|
+
spaRouter.navigate(href, readFarmLinkNavigateOptions(anchor));
|
|
6110
6755
|
});
|
|
6111
6756
|
|
|
6112
6757
|
// Initial hydration
|
|
@@ -6116,11 +6761,11 @@ if (isFarmDocsSearchPage()) {
|
|
|
6116
6761
|
void hydrate();
|
|
6117
6762
|
`.trim();
|
|
6118
6763
|
}
|
|
6119
|
-
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
|
|
6764
|
+
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime, sourceSnapshot) {
|
|
6120
6765
|
const viteBuild = productionVite.build;
|
|
6121
6766
|
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
6122
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
6123
|
-
const
|
|
6767
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
6768
|
+
const fs5 = await import("fs/promises");
|
|
6124
6769
|
const pluginManager = new PluginManager2({
|
|
6125
6770
|
config,
|
|
6126
6771
|
isDev: false,
|
|
@@ -6135,9 +6780,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6135
6780
|
buildLifetime: rendererBuildLifetime
|
|
6136
6781
|
});
|
|
6137
6782
|
if (!hasScopedPostcssConfig) {
|
|
6138
|
-
postcssConfigDir = await
|
|
6139
|
-
await
|
|
6140
|
-
|
|
6783
|
+
postcssConfigDir = await fs5.mkdtemp(path16.join(os.tmpdir(), "farm-postcss-"));
|
|
6784
|
+
await fs5.writeFile(
|
|
6785
|
+
path16.join(postcssConfigDir, "postcss.config.cjs"),
|
|
6141
6786
|
"module.exports = { plugins: [] };\n"
|
|
6142
6787
|
);
|
|
6143
6788
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -6162,7 +6807,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6162
6807
|
fileName: entry.fileName,
|
|
6163
6808
|
sourceType: "static",
|
|
6164
6809
|
staticInfo: entry.staticInfo,
|
|
6165
|
-
data: (await
|
|
6810
|
+
data: (await fs5.readFile(entry.modulePath)).toString("base64")
|
|
6166
6811
|
});
|
|
6167
6812
|
continue;
|
|
6168
6813
|
}
|
|
@@ -6222,10 +6867,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6222
6867
|
const appDirs = getFarmAppDirectories(config);
|
|
6223
6868
|
let openAPIReference = null;
|
|
6224
6869
|
if (config.openapi.enabled && config.openapi.route) {
|
|
6225
|
-
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-
|
|
6870
|
+
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-YO2RHDYU.mjs");
|
|
6226
6871
|
const openAPIManager = new OpenAPIManager(appDirs, config.openapi, {
|
|
6227
6872
|
mode: "production",
|
|
6228
6873
|
apiBaseURL: config.api.baseURL,
|
|
6874
|
+
routes: () => apiRouteManager.getRoutes().values(),
|
|
6229
6875
|
loadModule: (filePath) => apiRouteManager.loadModule(filePath)
|
|
6230
6876
|
});
|
|
6231
6877
|
const spec = await openAPIManager.generateSpec();
|
|
@@ -6479,9 +7125,16 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6479
7125
|
createVercelOgFontInlinePlugin(edgeMetadataImageRuntime.runtime)
|
|
6480
7126
|
] : [],
|
|
6481
7127
|
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
6482
|
-
farmServerOnlyEntriesPlugin(),
|
|
7128
|
+
farmServerOnlyEntriesPlugin({ distDir: config.distDir || ".farm" }),
|
|
6483
7129
|
farmIslandContainersPlugin(config),
|
|
6484
|
-
farmPlugin(
|
|
7130
|
+
farmPlugin(
|
|
7131
|
+
{
|
|
7132
|
+
...config,
|
|
7133
|
+
isolatedClientBoundaryModules,
|
|
7134
|
+
sourceSnapshot
|
|
7135
|
+
},
|
|
7136
|
+
pluginManager
|
|
7137
|
+
),
|
|
6485
7138
|
farmEnvironmentFunctionsPlugin(config),
|
|
6486
7139
|
...hasRuntimeConfigModule ? [
|
|
6487
7140
|
farmStripPlatformConfigPlugin(
|
|
@@ -6547,7 +7200,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6547
7200
|
} finally {
|
|
6548
7201
|
if (postcssConfigDir) {
|
|
6549
7202
|
try {
|
|
6550
|
-
await
|
|
7203
|
+
await fs5.rm(postcssConfigDir, { recursive: true, force: true });
|
|
6551
7204
|
} catch {
|
|
6552
7205
|
}
|
|
6553
7206
|
}
|
|
@@ -6560,7 +7213,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6560
7213
|
}
|
|
6561
7214
|
function readFarmAppPackageIdentity(root) {
|
|
6562
7215
|
try {
|
|
6563
|
-
return JSON.parse(
|
|
7216
|
+
return JSON.parse(readFileSync2(path16.join(root, "package.json"), "utf8"));
|
|
6564
7217
|
} catch {
|
|
6565
7218
|
return {};
|
|
6566
7219
|
}
|
|
@@ -6836,6 +7489,10 @@ function useFarmNodePageResponse(ResponseClass) {
|
|
|
6836
7489
|
// Web body the way reading response.body would.
|
|
6837
7490
|
const farmLazyBufferedHtml = new WeakMap();
|
|
6838
7491
|
|
|
7492
|
+
// Bind the stored shell to the response Farm built from it. A body replacement
|
|
7493
|
+
// gets a new response and takes the ordinary scan path.
|
|
7494
|
+
const farmPreloadShells = new WeakMap();
|
|
7495
|
+
|
|
6839
7496
|
function hasFarmContentType(headers) {
|
|
6840
7497
|
if (!headers) return false;
|
|
6841
7498
|
if (typeof headers.has === "function") return headers.has("content-type");
|
|
@@ -6943,7 +7600,8 @@ async function applyFarmPreloadBudget(response, pathname, request) {
|
|
|
6943
7600
|
// formatting), but do not consume and re-encode a proven preload-free body.
|
|
6944
7601
|
const ownedHtml = hasNoHtmlPreloads ? undefined : getFarmOwnedBufferedHtml(response);
|
|
6945
7602
|
const html = hasNoHtmlPreloads ? "" : (ownedHtml ?? await response.text());
|
|
6946
|
-
const managed = manageFarmDocumentPreloads(html, linkHeader, farmPreloadConfig
|
|
7603
|
+
const managed = manageFarmDocumentPreloads(html, linkHeader, farmPreloadConfig,
|
|
7604
|
+
ownedHtml === undefined ? undefined : farmPreloadShells.get(response));
|
|
6947
7605
|
// A remembered document the budget left unchanged keeps its unread body.
|
|
6948
7606
|
const reusesBody = hasNoHtmlPreloads || (ownedHtml !== undefined && managed.html === html);
|
|
6949
7607
|
if (ownedHtml !== undefined && !reusesBody && !isLazyPage) {
|
|
@@ -6983,6 +7641,10 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
|
|
|
6983
7641
|
}
|
|
6984
7642
|
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 = [], farmDocsAnalyticsPages = []) {
|
|
6985
7643
|
const farmRendererDisabled = isFarmRendererDisabled(config.renderer);
|
|
7644
|
+
const searchPreserveRoutes = pageRoutes.flatMap(
|
|
7645
|
+
(route) => route.searchPreserve ? [route.searchPreserve] : []
|
|
7646
|
+
);
|
|
7647
|
+
const searchPreserveRoutesSource = searchPreserveRoutes.length > 0 ? JSON.stringify(searchPreserveRoutes) : "";
|
|
6986
7648
|
const farmIslandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
|
|
6987
7649
|
const farmClientBoot = canBootFarmIslandsClient(config);
|
|
6988
7650
|
const farmMobileClient = shouldBuildFarmMobileClient(config);
|
|
@@ -7016,7 +7678,8 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
|
|
|
7016
7678
|
);
|
|
7017
7679
|
const hasReactSyncRender = isReactRenderer(config.renderer);
|
|
7018
7680
|
const rendererServerImports = isReactRenderer(config.renderer) ? `import * as React from "react";
|
|
7019
|
-
import * as ReactDOMServer from "react-dom/server"
|
|
7681
|
+
import * as ReactDOMServer from "react-dom/server";
|
|
7682
|
+
import { markPagePosition, markLayoutPosition } from "@farm.js/core/internal/production-runtime";${hasIsolatedClientGraphRuntime ? farmIslandsMode ? '\nimport { isolateFarmServerPageGraph, wrapFarmIsolatedClientGraph, renderFarmServerTreePage, renderFarmServerTreeLayout, withFarmIslandsRender } from "@farm.js/core/internal/islands-runtime";' : '\nimport { isolateFarmServerPageGraph, wrapFarmIsolatedClientGraph } from "@farm.js/core/internal/isolated-boundary";\nimport { renderFarmServerTreePage } from "@farm.js/core/internal/server-tree";' : ""}` : `import React, * as ReactDOMServer from ${JSON.stringify(config.renderer.server)};${generateFarmRendererAppSetupServerCode(config)}`;
|
|
7020
7683
|
const routeClientGraphServerRuntime = hasIsolatedClientGraphRuntime ? `function wrapFarmRouteClientGraph(element) {
|
|
7021
7684
|
return wrapFarmIsolatedClientGraph(React, element);
|
|
7022
7685
|
}
|
|
@@ -7245,7 +7908,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7245
7908
|
pattern: ${JSON.stringify(layout.pattern)},
|
|
7246
7909
|
module: ${varName},
|
|
7247
7910
|
shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)},
|
|
7248
|
-
islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${treeLayoutPatterns.has(layout.pattern) ? "\n serverTree: true," : ""}
|
|
7911
|
+
islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${treeLayoutPatterns.has(layout.pattern) ? "\n serverTree: true," : ""}${farmIslandsMode && canFarmSkipKeptLayoutRender(layout.modulePath, config.root) ? "\n skipKeptRender: true," : ""}${// A layout whose client components hydrate as islands of their own (islands mode,
|
|
7912
|
+
// isolatedClientHydration, or an async layout): it wraps a docs page as an app page.
|
|
7913
|
+
clientMetadata.hasIsolatedClientBoundaries ? "\n islands: true," : ""}
|
|
7249
7914
|
}`);
|
|
7250
7915
|
});
|
|
7251
7916
|
const slotOwnerCounts = new Map(routeSlots.map((slot) => [slot.ownerPattern, 0]));
|
|
@@ -7361,6 +8026,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7361
8026
|
const notFoundImport = notFoundPath ? `import * as CustomNotFound from ${toVirtualEntryImportSpecifier(notFoundPath)};` : "";
|
|
7362
8027
|
const apiRouteHelpersImport = apiRoutes.length > 0 ? `import { mergePluginAPIRoutes, getAllowedAPIRouteMethods, invokeAPIRouteEndpoint, createStaticAPIRouteMatcherAtBasePath, resolveAPIRouteEndpoint } from "@farm.js/core/api/runtime";` : "";
|
|
7363
8028
|
const productionRuntimeImport = `import {
|
|
8029
|
+
_getRequestCookieReadCount,
|
|
7364
8030
|
_getRequestReadCount,
|
|
7365
8031
|
_runWithAfterRequest,
|
|
7366
8032
|
_resolveCurrentCspNonce,
|
|
@@ -7390,7 +8056,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7390
8056
|
createDefaultErrorMarkup,
|
|
7391
8057
|
createFarmInstrumentationLifecycle,
|
|
7392
8058
|
createFarmLayoutSelector,
|
|
8059
|
+
createFarmLayoutBoundary,${config.docs?.enabled ? "\n createFarmDocsLayoutTree,\n farmDocsLayoutsWrapPage,\n placeFarmDocsLayoutRoot," : ""}
|
|
7393
8060
|
isInFarmRouteGroupScope,
|
|
8061
|
+
routeBoundaryCoversDirectory,
|
|
7394
8062
|
createFarmCacheKey,
|
|
7395
8063
|
createFarmMetadataRouteResponse,
|
|
7396
8064
|
createFarmAgentRobots,
|
|
@@ -7410,6 +8078,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7410
8078
|
listFarmMCPLlmsTxtLinks,
|
|
7411
8079
|
readFarmLlmsMarkdownFrom,
|
|
7412
8080
|
registerFarmMCPServer,
|
|
8081
|
+
_listFarmRegisteredMCPServerTools,
|
|
8082
|
+
_observeFarmRegisteredMCPResponse,
|
|
8083
|
+
_readFarmRegisteredMCPCalls,
|
|
7413
8084
|
renderFarmLlmsFullTxt,
|
|
7414
8085
|
resolveFarmAgentOrigin,
|
|
7415
8086
|
createFarmLlmsFullRenderer,
|
|
@@ -7451,6 +8122,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7451
8122
|
resolveFarmInstrumentationRuntime,
|
|
7452
8123
|
resolveFarmPreviewDeployment,
|
|
7453
8124
|
resolveFarmWebRequestOrigin,
|
|
8125
|
+
_withFarmTrustedProxyOrigin,
|
|
7454
8126
|
fetchFarmExternalRewrite,
|
|
7455
8127
|
runWithFarmRequestSpan,
|
|
7456
8128
|
createFarmSearchParams,
|
|
@@ -7467,7 +8139,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7467
8139
|
createFarmDeploymentMismatchResponse,
|
|
7468
8140
|
FARM_DEPLOYMENT_ID_HEADER,
|
|
7469
8141
|
getFarmDeploymentMismatch,
|
|
7470
|
-
withoutFarmDeploymentCookie,${config.mobileClient ? "\n createFarmNativeTreeResponse," : ""}${config.trailingSlash && (config.md?.enabled || hasMarkdownPages) ? "\n toFarmTrailingSlashPageRequest," : ""}${hasInfraAnalyticsRuntime ? "\n resolveFarmDocsEngineRouteLabel,\n resolveFarmDocsRouteLabel,\n resolveFarmMarkdownRouteLabel,\n resolveFarmMCPRouteLabel,\n setFarmRouteLabel," : ""}${hasFarmServerStorageConfig(config.storage) ? "\n _registerFarmStorageModules,\n disposeFarmStorage,\n initFarmStorage," : ""}
|
|
8142
|
+
withoutFarmDeploymentCookie,${config.mobileClient ? "\n createFarmNativeTreeResponse," : ""}${config.trailingSlash && (config.md?.enabled || hasMarkdownPages) ? "\n toFarmTrailingSlashPageRequest," : ""}${hasInfraAnalyticsRuntime ? "\n resolveFarmDocsEngineRouteLabel,\n resolveFarmDocsRouteLabel,\n resolveFarmMarkdownRouteLabel,\n resolveFarmMCPRouteLabel,\n setFarmRouteLabel," : ""}${hasFarmServerStorageConfig(config.storage) ? "\n _registerFarmStorageModules,\n disposeFarmStorage,\n initFarmStorage," : ""}${searchPreserveRoutesSource ? "\n _setFarmSearchPreserveRoutes," : ""}
|
|
7471
8143
|
} from "@farm.js/core/internal/production-runtime";${farmMobileClient ? `
|
|
7472
8144
|
import { _applyFarmMobileShellClient } from "@farm.js/core/internal/production-runtime";
|
|
7473
8145
|
// The mobile client documents load when a mobile shell asks for them (RFC 0004, 7.2), filled in
|
|
@@ -7554,7 +8226,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
7554
8226
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
7555
8227
|
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;";
|
|
7556
8228
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
7557
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
8229
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path16.isAbsolute(config.mdx.components) ? config.mdx.components : path16.join(config.root, config.mdx.components) : null;
|
|
7558
8230
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
7559
8231
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
7560
8232
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -7725,7 +8397,7 @@ ${instrumentationImport}
|
|
|
7725
8397
|
${imageRuntimeImport}
|
|
7726
8398
|
${imageNodeRuntimeImport}
|
|
7727
8399
|
import { farmFontPreloadHeader } from "virtual:farm-font-runtime";
|
|
7728
|
-
import { isFarmRouteActive } from "@farm.js/core/router";
|
|
8400
|
+
import { createFarmRouter, isFarmRouteActive } from "@farm.js/core/router";
|
|
7729
8401
|
${rendererServerImports}
|
|
7730
8402
|
|
|
7731
8403
|
${routeClientGraphServerRuntime}
|
|
@@ -7776,7 +8448,7 @@ const farmUserConfig = ${configModulePath ? "(FarmUserConfigModule.default || Fa
|
|
|
7776
8448
|
const farmRuntimeConfigs = [${[...layerConfigValues, "farmUserConfig"].join(", ")}].filter(Boolean);
|
|
7777
8449
|
const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
|
|
7778
8450
|
|
|
7779
|
-
function
|
|
8451
|
+
function renderFarmDefault404Page() {
|
|
7780
8452
|
return React.createElement(React.Fragment, null,
|
|
7781
8453
|
React.createElement("style", null, ${JSON.stringify(DEFAULT_NOT_FOUND_STYLES)}),
|
|
7782
8454
|
React.createElement("main", {
|
|
@@ -7802,6 +8474,12 @@ function FarmDefault404Page() {
|
|
|
7802
8474
|
);
|
|
7803
8475
|
}
|
|
7804
8476
|
|
|
8477
|
+
// Renderers that compile their own components (Vue, Svelte) render a plain function as a
|
|
8478
|
+
// component only once it is marked; unmarked, Vue printed this page as "[object Object]".
|
|
8479
|
+
const FarmDefault404Page = typeof React.markFunctionComponent === "function"
|
|
8480
|
+
? React.markFunctionComponent(renderFarmDefault404Page)
|
|
8481
|
+
: renderFarmDefault404Page;
|
|
8482
|
+
|
|
7805
8483
|
/** The app's not-found page, or Farm's, without layouts. */
|
|
7806
8484
|
function createFarmNotFoundElement(pathname) {
|
|
7807
8485
|
const NotFoundPage = hasCustomNotFound && CustomNotFoundComponent ? CustomNotFoundComponent : FarmDefault404Page;
|
|
@@ -8093,7 +8771,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
8093
8771
|
|
|
8094
8772
|
// API routes bundled at build time
|
|
8095
8773
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
8096
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
8774
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path18, methods }) => ({ path: path18, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
8097
8775
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
8098
8776
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
8099
8777
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -8115,7 +8793,10 @@ function fetchFarmInnerRequest(request, context) {
|
|
|
8115
8793
|
const farmLocalAPIBasePath = ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))};
|
|
8116
8794
|
// Deployment skew protection (see the deployment docs): documents embed this ID, page responses
|
|
8117
8795
|
// name it, and a page request from a browser holding another deployment's page is refused.
|
|
8118
|
-
const farmDeploymentId = ${JSON.stringify(config.deploymentId)}
|
|
8796
|
+
const farmDeploymentId = ${JSON.stringify(config.deploymentId)};${searchPreserveRoutesSource ? `
|
|
8797
|
+
// Pages with search.preserve: Farm links render the same href here and in the browser.
|
|
8798
|
+
const farmSearchPreserveRoutes = ${searchPreserveRoutesSource};
|
|
8799
|
+
_setFarmSearchPreserveRoutes(farmSearchPreserveRoutes);` : ""}
|
|
8119
8800
|
const farmDeploymentCookiePath = ${JSON.stringify(config.basePath || "/")};
|
|
8120
8801
|
// Reports a failure Farm answers itself (an API or integration route's 500) to the plugin
|
|
8121
8802
|
// runtime request.
|
|
@@ -8139,7 +8820,17 @@ farmAppManifestInput.guardCoversPath = (path) =>
|
|
|
8139
8820
|
path,
|
|
8140
8821
|
farmLocalAPIBasePath,
|
|
8141
8822
|
);
|
|
8142
|
-
|
|
8823
|
+
${config.docs?.enabled ? `// A docs runtime's MCP server lists its tools when asked over MCP, in process. A build
|
|
8824
|
+
// can't change them, so they are read once.
|
|
8825
|
+
if (farmDocsHandler) {
|
|
8826
|
+
farmAppManifestInput.registeredMCP = (request) =>
|
|
8827
|
+
_listFarmRegisteredMCPServerTools(farmDocsHandler, request, {
|
|
8828
|
+
basePath: ${JSON.stringify(config.basePath)},
|
|
8829
|
+
guardCoversPath: farmAppManifestInput.guardCoversPath,
|
|
8830
|
+
cache: true,
|
|
8831
|
+
});
|
|
8832
|
+
}
|
|
8833
|
+
` : ""}` : ""}
|
|
8143
8834
|
function isFarmLocalAPIPathname(pathname) {
|
|
8144
8835
|
return farmLocalAPIBasePath !== "/" &&
|
|
8145
8836
|
(pathname === farmLocalAPIBasePath ||
|
|
@@ -8223,7 +8914,7 @@ function serializeFarmInlineValue(value) {
|
|
|
8223
8914
|
.replace(/\\u2029/g, "\\\\u2029");
|
|
8224
8915
|
}
|
|
8225
8916
|
|
|
8226
|
-
function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps) {
|
|
8917
|
+
function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps, routePathname) {
|
|
8227
8918
|
const integrationManifest = ${hasRuntimeIntegrationConfig ? "getRegisteredIntegrationAPIManifest()" : "{}"};
|
|
8228
8919
|
const serializedRouteSlots = serializeFarmInlineValue(selectedRouteSlots || []);
|
|
8229
8920
|
const serializedPageProps = serializeFarmInlineValue(pageProps || {});
|
|
@@ -8231,7 +8922,15 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
8231
8922
|
';window.__FARM_INTEGRATION_API_MANIFEST__=' +
|
|
8232
8923
|
serializeFarmInlineValue(integrationManifest) +
|
|
8233
8924
|
';window.__FARM_ROUTE_SLOTS__=' + serializedRouteSlots +
|
|
8234
|
-
';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';'
|
|
8925
|
+
';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';'${searchPreserveRoutesSource ? ` +
|
|
8926
|
+
'window[Symbol.for("farm.searchPreserveRoutes")]=' + serializeFarmInlineValue(farmSearchPreserveRoutes) + ';'` : ""};
|
|
8927
|
+
// The client boots at the canonical path when the script below moves it there.
|
|
8928
|
+
const bootRoutes = getFarmClientBootRoutes(
|
|
8929
|
+
typeof canonicalPath === "string" && canonicalPath.startsWith("/")
|
|
8930
|
+
? getFarmRoutePathname(canonicalPath.split(/[?#]/)[0])
|
|
8931
|
+
: routePathname
|
|
8932
|
+
);
|
|
8933
|
+
if (bootRoutes) source += 'window.__FARM_CLIENT_ROUTES__=' + serializeFarmInlineValue(bootRoutes) + ';';
|
|
8235
8934
|
if (typeof canonicalPath === "string" && canonicalPath.startsWith("/")) {
|
|
8236
8935
|
const serializedPath = serializeFarmInlineValue(canonicalPath);
|
|
8237
8936
|
source += 'if(location.pathname+location.search!==' + serializedPath + '){' +
|
|
@@ -8316,15 +9015,25 @@ function createFarmFlushToken() {
|
|
|
8316
9015
|
}
|
|
8317
9016
|
|
|
8318
9017
|
async function farmKeptLayoutsRender(ReactDOMServer, layouts, keptCount, params) {
|
|
9018
|
+
// RFC 0007: the build proved these layouts cannot throw or read the request, so rendering them
|
|
9019
|
+
// again would only produce markup the browser already shows.
|
|
9020
|
+
let skip = true;
|
|
9021
|
+
for (let index = 0; index < keptCount; index++) {
|
|
9022
|
+
if (layouts[index].skipKeptRender !== true) skip = false;
|
|
9023
|
+
}
|
|
9024
|
+
if (skip) return true;
|
|
8319
9025
|
let element = null;
|
|
8320
9026
|
for (let index = keptCount - 1; index >= 0; index--) {
|
|
8321
9027
|
const Layout = layouts[index].module.default;
|
|
8322
9028
|
if (Layout) element = React.createElement(Layout, { children: element, params });
|
|
8323
9029
|
}
|
|
8324
9030
|
try {
|
|
9031
|
+
// The markup is thrown away, so client components render as plain components, as in a root
|
|
9032
|
+
// that hydrates whole: their props are not encoded for a browser that never receives them.
|
|
9033
|
+
// Server components, guards included, run as usual.
|
|
8325
9034
|
const rendered = await renderFarmElement(
|
|
8326
9035
|
ReactDOMServer,
|
|
8327
|
-
wrapWithFarmIntegrationProviders(element),
|
|
9036
|
+
wrapWithFarmIntegrationProviders(wrapFarmRouteClientGraph(element)),
|
|
8328
9037
|
);
|
|
8329
9038
|
if (rendered.stream) {
|
|
8330
9039
|
const reader = rendered.stream.getReader();
|
|
@@ -9044,6 +9753,9 @@ function createFarmErrorDocument(html, title) {
|
|
|
9044
9753
|
' ' + renderFarmClientEntryScript() + '\\n</body>';
|
|
9045
9754
|
},
|
|
9046
9755
|
);
|
|
9756
|
+
// The charset and viewport a layout's own document leaves out, as on a page and the
|
|
9757
|
+
// not-found page: without the viewport the error page lays out at desktop width on phones.
|
|
9758
|
+
fullHtml = ensureFarmDocumentMeta(fullHtml, renderViewportHead(undefined));
|
|
9047
9759
|
return fullHtml.trim().startsWith("<!DOCTYPE")
|
|
9048
9760
|
? fullHtml
|
|
9049
9761
|
: "<!DOCTYPE html>\\n" + fullHtml;
|
|
@@ -9058,6 +9770,8 @@ const farmClientModulePreloads = (() => {
|
|
|
9058
9770
|
return null;
|
|
9059
9771
|
}
|
|
9060
9772
|
})();
|
|
9773
|
+
${generateFarmClientBootRoutesServerSource(`"${FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER}"`)}
|
|
9774
|
+
|
|
9061
9775
|
const farmClientEntryPreloadTags = farmClientModulePreloads
|
|
9062
9776
|
? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
|
|
9063
9777
|
: "";
|
|
@@ -9116,6 +9830,7 @@ function renderFarmI18nAlternateLinks(requestPath, snapshot, request, metadata)
|
|
|
9116
9830
|
return renderFarmLocaleAlternateLinks(routePathname, snapshot, {
|
|
9117
9831
|
metadataBase: metadata ? metadata.metadataBase : undefined,
|
|
9118
9832
|
origin: request ? resolveFarmI18nAlternateOrigin(request) : undefined,
|
|
9833
|
+
languages: metadata && metadata.alternates ? metadata.alternates.languages : undefined,
|
|
9119
9834
|
});
|
|
9120
9835
|
}
|
|
9121
9836
|
|
|
@@ -10011,9 +10726,10 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10011
10726
|
|
|
10012
10727
|
const pathname = getFarmRoutePathname(new URL(request.url).pathname);
|
|
10013
10728
|
const applicableLayouts = getApplicableLayouts(pathname);
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10729
|
+
// Layouts with client components wrap the docs page: one that hydrates, or one whose client
|
|
10730
|
+
// components are islands of their own, as on an app page.
|
|
10731
|
+
if (!farmDocsLayoutsWrapPage(applicableLayouts)) return response;
|
|
10732
|
+
const shouldHydrateLayout = applicableLayouts.some((layout) => layout.shouldHydrate === true);
|
|
10017
10733
|
|
|
10018
10734
|
const source = await response.text();
|
|
10019
10735
|
const bodyMatch = source.match(/<body([^>]*)>([\\s\\S]*?)<\\/body>/i);
|
|
@@ -10027,39 +10743,34 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10027
10743
|
|
|
10028
10744
|
const matchedRoute = matchPageRoute(pathname);
|
|
10029
10745
|
const params = matchedRoute?.params || {};
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10746
|
+
// The docs page takes the place of an app page: the same page and layout boundaries, which the
|
|
10747
|
+
// browser draws around the docs HTML (createLayoutPageBoundary). Islands mode: a layout around a
|
|
10748
|
+
// client provider renders as a server tree, which the browser rebuilds with the docs page at its
|
|
10749
|
+
// outlet. The development server renders the same tree (docs-layout-tree.ts).
|
|
10750
|
+
const wrappedElement = await createFarmDocsLayoutTree(React, {
|
|
10751
|
+
pageHtml: bodyMatch[2],
|
|
10752
|
+
layouts: applicableLayouts.map((layout) => ({
|
|
10753
|
+
pattern: layout.pattern,
|
|
10754
|
+
Component: layout.module.default,
|
|
10755
|
+
shouldHydrate: layout.shouldHydrate,
|
|
10756
|
+
islandStrategy: layout.islandStrategy,
|
|
10757
|
+
serverTree: layout.serverTree,
|
|
10758
|
+
})),
|
|
10759
|
+
params,
|
|
10760
|
+
// Islands mode only: no other build marks a server-tree layout or imports this renderer.
|
|
10761
|
+
renderServerTreeLayout: ${farmIslandsMode ? "renderFarmServerTreeLayout" : "undefined"},
|
|
10762
|
+
layoutKey: ${farmIslandsMode ? "function(pattern) { return getFarmLayoutKey(pattern, params); }" : "undefined"},
|
|
10045
10763
|
});
|
|
10046
10764
|
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
wrappedElement = React.createElement(LayoutComponent, {
|
|
10051
|
-
children: wrappedElement,
|
|
10052
|
-
params,
|
|
10053
|
-
});
|
|
10054
|
-
}
|
|
10055
|
-
}
|
|
10056
|
-
|
|
10765
|
+
// Only a layout that hydrates renders as one client root; otherwise its client components
|
|
10766
|
+
// render as islands, as on an app page.
|
|
10767
|
+
const rootElement = wrapWithFarmIntegrationProviders(wrappedElement);
|
|
10057
10768
|
const renderedRoot = await renderFarmElement(
|
|
10058
10769
|
ReactDOMServer,
|
|
10059
10770
|
React.createElement(
|
|
10060
10771
|
"div",
|
|
10061
10772
|
{ id: "root" },
|
|
10062
|
-
wrapFarmRouteClientGraph(
|
|
10773
|
+
shouldHydrateLayout ? wrapFarmRouteClientGraph(rootElement) : rootElement,
|
|
10063
10774
|
),
|
|
10064
10775
|
);
|
|
10065
10776
|
let rootMarkup = renderedRoot.html;
|
|
@@ -10067,6 +10778,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10067
10778
|
rootMarkup = await new Response(renderedRoot.stream).text();
|
|
10068
10779
|
if (renderedRoot.streamErrors.length > 0) throw renderedRoot.streamErrors[0];
|
|
10069
10780
|
}
|
|
10781
|
+
// A root layout that renders the document gives #root its body; the docs runtime keeps its own.
|
|
10782
|
+
rootMarkup = placeFarmDocsLayoutRoot(rootMarkup);
|
|
10070
10783
|
let html = source.replace(
|
|
10071
10784
|
bodyMatch[0],
|
|
10072
10785
|
// Function replacement: rendered markup may contain $-sequences ($&, $', $$).
|
|
@@ -10090,7 +10803,7 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10090
10803
|
: html.replace(/<[/]head>/i, clientStylesheet + "</head>");
|
|
10091
10804
|
}
|
|
10092
10805
|
if (!html.includes('id="__farm_route_slots_data__"')) {
|
|
10093
|
-
html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript() + "\\n</body>"; });
|
|
10806
|
+
html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript(undefined, undefined, undefined, pathname) + "\\n</body>"; });
|
|
10094
10807
|
}
|
|
10095
10808
|
if (!html.includes('src="/__farm_client_js_src__"')) {
|
|
10096
10809
|
html = html.replace(
|
|
@@ -10138,7 +10851,6 @@ function getPPRShellBypassReason(request, middlewareData, middlewareContext) {
|
|
|
10138
10851
|
if (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce) return "csp-nonce";
|
|
10139
10852
|
const method = request.method.toUpperCase();
|
|
10140
10853
|
if (method !== "GET" && method !== "HEAD") return "method";
|
|
10141
|
-
if (withoutFarmDeploymentCookie(request.headers.get("cookie"))) return "cookie";
|
|
10142
10854
|
if (request.headers.get("authorization")) return "authorization";
|
|
10143
10855
|
if (request.headers.get("x-farm-intercept-from")) return "route-interception";
|
|
10144
10856
|
if (request.headers.get("x-farm-ppr-refresh")) return "refresh";
|
|
@@ -10170,13 +10882,9 @@ function getPPRHeaders(status, config) {
|
|
|
10170
10882
|
|
|
10171
10883
|
if (status === "bypass") {
|
|
10172
10884
|
headers["Cache-Control"] = "private, no-store";
|
|
10173
|
-
return headers;
|
|
10174
10885
|
}
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
headers["Cache-Control"] = \`s-maxage=\${config.revalidate}, stale-while-revalidate\`;
|
|
10178
|
-
}
|
|
10179
|
-
|
|
10886
|
+
// A shareable shell answers with the route's shared policy (getRouteSharedCacheControl), the
|
|
10887
|
+
// documented "public, s-maxage=<revalidate>, stale-while-revalidate=300", on a miss and a hit.
|
|
10180
10888
|
return headers;
|
|
10181
10889
|
}
|
|
10182
10890
|
|
|
@@ -10197,13 +10905,10 @@ function getRouteSharedCacheControl(route, pprCanCache) {
|
|
|
10197
10905
|
return resolveRouteSharedCacheControl(resolveRouteRenderingView(route), pprCanCache);
|
|
10198
10906
|
}
|
|
10199
10907
|
|
|
10908
|
+
// { html, cookieIndependent }: cookieIndependent marks a shell whose render read no cookies.
|
|
10200
10909
|
async function getCachedPPRShell(cacheKey) {
|
|
10201
10910
|
const entry = await pprShellCache.getEntryAsync(cacheKey);
|
|
10202
|
-
|
|
10203
|
-
return null;
|
|
10204
|
-
}
|
|
10205
|
-
|
|
10206
|
-
return entry.value.html;
|
|
10911
|
+
return entry ? entry.value : null;
|
|
10207
10912
|
}
|
|
10208
10913
|
|
|
10209
10914
|
/**
|
|
@@ -10509,7 +11214,13 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10509
11214
|
const owned = getFarmAppOwnedDocsEnginePaths(config.agent, applicationMetadataRoutes);
|
|
10510
11215
|
return owned.length ? ` && !${JSON.stringify(owned)}.includes(normalizeRuntimePath(routePathname))` : "";
|
|
10511
11216
|
})()}) {
|
|
10512
|
-
const
|
|
11217
|
+
const farmDocsRequest = cloneFarmRequestWithContext(request);
|
|
11218
|
+
// Tool calls to a docs runtime's MCP server emit mcp.tool.complete, as @farm.js/mcp's do.
|
|
11219
|
+
const farmRegisteredMCPCalls = await _readFarmRegisteredMCPCalls(
|
|
11220
|
+
farmDocsRequest,
|
|
11221
|
+
${JSON.stringify(config.basePath)},
|
|
11222
|
+
);
|
|
11223
|
+
const docsResponse = await farmDocsHandler(farmDocsRequest);
|
|
10513
11224
|
if (docsResponse) {${hasInfraAnalyticsRuntime ? `
|
|
10514
11225
|
const farmAnalyticsRoute = adapterContext?.[farmRouteLabelSlot];
|
|
10515
11226
|
if (farmAnalyticsRoute) {
|
|
@@ -10520,7 +11231,19 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10520
11231
|
}` : ""}
|
|
10521
11232
|
if (!docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html")) {
|
|
10522
11233
|
return applyProductionMiddlewareHeaders(
|
|
10523
|
-
withFarmDocsRequestCache(
|
|
11234
|
+
withFarmDocsRequestCache(
|
|
11235
|
+
_observeFarmRegisteredMCPResponse(
|
|
11236
|
+
docsResponse,
|
|
11237
|
+
farmRegisteredMCPCalls,
|
|
11238
|
+
typeof adapterContext?.waitUntil === "function"
|
|
11239
|
+
? adapterContext.waitUntil.bind(adapterContext)
|
|
11240
|
+
: undefined,
|
|
11241
|
+
),
|
|
11242
|
+
request,
|
|
11243
|
+
farmLocaleResolution,
|
|
11244
|
+
middlewareData,
|
|
11245
|
+
middlewareContext,
|
|
11246
|
+
),
|
|
10524
11247
|
middlewareHeaders,
|
|
10525
11248
|
);
|
|
10526
11249
|
}
|
|
@@ -10816,7 +11539,9 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10816
11539
|
if (matchedRoute && request.method === "POST") {
|
|
10817
11540
|
const actionResponse = await _runWithMiddlewareData(middlewareData || {}, () =>
|
|
10818
11541
|
_runWithMiddlewareContext(middlewareContext || {}, () =>
|
|
10819
|
-
handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl
|
|
11542
|
+
handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl, {
|
|
11543
|
+
trustProxy: farmServerConfig.trustProxy === true,
|
|
11544
|
+
})
|
|
10820
11545
|
)
|
|
10821
11546
|
);
|
|
10822
11547
|
if (actionResponse) return applyProductionMiddlewareHeaders(actionResponse, middlewareHeaders);
|
|
@@ -10853,7 +11578,10 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10853
11578
|
}
|
|
10854
11579
|
: matchedRoute` : "matchedRoute"};
|
|
10855
11580
|
emitFarmEvent({ type: "route.matched", pathname, route: route.pattern, params });
|
|
10856
|
-
|
|
11581
|
+
// A shell started before the page reads its data: revalidatePath() during the render
|
|
11582
|
+
// leaves the stored shell stale (see FarmDataCache.startWriteAsync).
|
|
11583
|
+
let pprShellWrite = null;
|
|
11584
|
+
|
|
10857
11585
|
try {
|
|
10858
11586
|
${farmIslandsMode ? `// Islands mode: the layouts the navigating browser keeps, decided before the shell cache
|
|
10859
11587
|
// so a PPR route caches each segment under its own key. A static page, a layout that
|
|
@@ -10875,7 +11603,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10875
11603
|
? getPPRShellBypassReason(request, middlewareData, middlewareContext)
|
|
10876
11604
|
: undefined;
|
|
10877
11605
|
let pprCanCache = pprConfig.enabled && !pprBypassReason;
|
|
10878
|
-
|
|
11606
|
+
let pprCacheKey = pprCanCache
|
|
10879
11607
|
? getPPRShellCacheKey(
|
|
10880
11608
|
url,
|
|
10881
11609
|
farmLocaleResolution?.locale,
|
|
@@ -10891,8 +11619,18 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10891
11619
|
emitFarmEvent({ type: "ppr.refresh.start", route: pathname });
|
|
10892
11620
|
}
|
|
10893
11621
|
}
|
|
11622
|
+
const cachedPPRShellEntry = pprCacheKey ? await getCachedPPRShell(pprCacheKey) : null;
|
|
11623
|
+
const pprVisitorCookies = Boolean(withoutFarmDeploymentCookie(request.headers.get("cookie")));
|
|
11624
|
+
if (cachedPPRShellEntry && pprVisitorCookies && !cachedPPRShellEntry.cookieIndependent) {
|
|
11625
|
+
// The shell's render read cookies (the theme, an auth helper), so it is what a visitor
|
|
11626
|
+
// without them sees: this visitor's page renders on its own and is not stored.
|
|
11627
|
+
pprCanCache = false;
|
|
11628
|
+
pprCacheKey = null;
|
|
11629
|
+
emitFarmEvent({ type: "ppr.shell.bypass", route: pathname, reason: "cookie" });
|
|
11630
|
+
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "cookie" });
|
|
11631
|
+
}
|
|
10894
11632
|
if (pprCacheKey) {
|
|
10895
|
-
const cachedPPRShell =
|
|
11633
|
+
const cachedPPRShell = cachedPPRShellEntry?.html;
|
|
10896
11634
|
if (cachedPPRShell) {
|
|
10897
11635
|
emitFarmEvent({ type: "ppr.shell.hit", route: pathname, key: pprCacheKey });
|
|
10898
11636
|
emitFarmEvent({
|
|
@@ -10902,25 +11640,46 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10902
11640
|
status: 200,
|
|
10903
11641
|
durationMs: Date.now() - requestStartTime,
|
|
10904
11642
|
});
|
|
10905
|
-
|
|
11643
|
+
const response = rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(cachedPPRShell, {
|
|
10906
11644
|
status: 200,
|
|
10907
11645
|
headers: {
|
|
10908
11646
|
"Content-Type": "text/html; charset=utf-8",
|
|
10909
|
-
"x-farm-preload-buffered":
|
|
11647
|
+
"x-farm-preload-buffered": "1",
|
|
10910
11648
|
...(farmFontPreloadHeader ? { "Link": farmFontPreloadHeader } : {}),
|
|
10911
11649
|
...getPPRHeaders("hit", pprConfig),
|
|
11650
|
+
// The policy the miss that stored this shell was sent with.
|
|
11651
|
+
...(getRouteSharedCacheControl(route, true)
|
|
11652
|
+
? { "Cache-Control": getRouteSharedCacheControl(route, true) }
|
|
11653
|
+
: {}),
|
|
11654
|
+
// A stored shell read no request state, so a visitor's cookies cannot change it, but
|
|
11655
|
+
// the response to a request with credentials stays out of shared caches.
|
|
11656
|
+
...(hasPrivateFarmRequestHeaders(request, farmLocaleResolution)
|
|
11657
|
+
? { "Cache-Control": "private, no-store" }
|
|
11658
|
+
: {}),
|
|
10912
11659
|
// A segment is one navigation's answer, never a CDN entry: some CDNs ignore Vary.
|
|
10913
11660
|
...(farmKeptLayouts
|
|
10914
11661
|
? { "Cache-Control": "private, no-store", "Vary": "F-Layouts" }
|
|
10915
11662
|
: {}),
|
|
10916
11663
|
},
|
|
10917
11664
|
}), middlewareHeaders), cachedPPRShell);
|
|
11665
|
+
farmPreloadShells.set(response, cachedPPRShellEntry);
|
|
11666
|
+
return response;
|
|
10918
11667
|
}
|
|
10919
11668
|
emitFarmEvent({ type: "ppr.shell.miss", route: pathname, key: pprCacheKey });
|
|
11669
|
+
if (request.method.toUpperCase() !== "HEAD") {
|
|
11670
|
+
pprShellWrite = await pprShellCache.startWriteAsync({
|
|
11671
|
+
// revalidatePath() takes the route path ("/pricing"), as the docs show, while the
|
|
11672
|
+
// shell answers the public one ("/console/fr/pricing"): either clears it.
|
|
11673
|
+
paths: [...new Set([pathname, getFarmRoutePathname(pathname)])],
|
|
11674
|
+
tags: ["ppr"],
|
|
11675
|
+
revalidate: pprConfig.revalidate ?? false,
|
|
11676
|
+
});
|
|
11677
|
+
}
|
|
10920
11678
|
}
|
|
10921
11679
|
|
|
10922
11680
|
// Reads from here on belong to the page render, not to middleware.
|
|
10923
11681
|
const requestReadsBeforeRender = _getRequestReadCount();
|
|
11682
|
+
const requestCookieReadsBeforeRender = _getRequestCookieReadCount();
|
|
10924
11683
|
// A swr or cache route rule stores this page by URL for every visitor. Nitro hands Farm the
|
|
10925
11684
|
// request without its cookies, Authorization, or any header the rule does not key on, so a
|
|
10926
11685
|
// render that reads nothing of the request is that shared page, whatever its route config.
|
|
@@ -11242,6 +12001,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11242
12001
|
pageElement,
|
|
11243
12002
|
);
|
|
11244
12003
|
|
|
12004
|
+
${isReactRenderer(config.renderer) ? "if (route.shouldHydrate && !shouldHydrateLayout) pageElement = markPagePosition(React, pageElement);" : ""}
|
|
11245
12005
|
// Wrap with layouts (from innermost to outermost)
|
|
11246
12006
|
// Layouts are sorted by depth (root first), so we process in reverse
|
|
11247
12007
|
let wrappedElement = pageElement;
|
|
@@ -11297,19 +12057,13 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11297
12057
|
params,
|
|
11298
12058
|
...slotProps,
|
|
11299
12059
|
});
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
"data-farm-layout-key":
|
|
11308
|
-
farmLayoutKeyOf && !shouldHydrateLayout
|
|
11309
|
-
? farmLayoutKeyOf(layout.pattern, params)
|
|
11310
|
-
: undefined,
|
|
11311
|
-
style: { display: "contents" },
|
|
11312
|
-
},
|
|
12060
|
+
// A layout chain that hydrates renders whole anyway: it has no key.
|
|
12061
|
+
wrappedElement = createFarmLayoutBoundary(
|
|
12062
|
+
React,
|
|
12063
|
+
layout.pattern,
|
|
12064
|
+
farmLayoutKeyOf && !shouldHydrateLayout
|
|
12065
|
+
? farmLayoutKeyOf(layout.pattern, params)
|
|
12066
|
+
: undefined,
|
|
11313
12067
|
wrappedElement,
|
|
11314
12068
|
);
|
|
11315
12069
|
}
|
|
@@ -11319,6 +12073,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11319
12073
|
wrappedElement = wrapFarmRouteClientGraph(wrappedElement);
|
|
11320
12074
|
}
|
|
11321
12075
|
|
|
12076
|
+
${isReactRenderer(config.renderer) ? "if (route.shouldHydrate && !shouldHydrateLayout) wrappedElement = markLayoutPosition(React, wrappedElement);" : ""}
|
|
11322
12077
|
wrappedElement = wrapWithFarmIntegrationProviders(wrappedElement);
|
|
11323
12078
|
return renderFarmElement(ReactDOMServer, wrappedElement, route.pattern, farmFlushToken);
|
|
11324
12079
|
};
|
|
@@ -11407,6 +12162,16 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11407
12162
|
emitFarmEvent({ type: "ppr.shell.bypass", route: pathname, reason: "request-read" });
|
|
11408
12163
|
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "request-read" });
|
|
11409
12164
|
}
|
|
12165
|
+
// An auth helper or integration client read this visitor's cookies: the shell a later
|
|
12166
|
+
// visitor gets must come from one without them.
|
|
12167
|
+
const renderReadCookies = () =>
|
|
12168
|
+
_getRequestCookieReadCount() !== requestCookieReadsBeforeRender;
|
|
12169
|
+
if (shouldCachePPRShell && pprVisitorCookies && renderReadCookies()) {
|
|
12170
|
+
shouldCachePPRShell = false;
|
|
12171
|
+
pprCanCache = false;
|
|
12172
|
+
emitFarmEvent({ type: "ppr.shell.bypass", route: pathname, reason: "cookie" });
|
|
12173
|
+
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "cookie" });
|
|
12174
|
+
}
|
|
11410
12175
|
|
|
11411
12176
|
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(config.agent?.jsonLd ?? false)} });
|
|
11412
12177
|
const title = renderedMetadata.title;
|
|
@@ -11550,7 +12315,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11550
12315
|
return ' ' + renderFarmClientBootstrapScript(
|
|
11551
12316
|
pageProps.__farmCanonicalPath,
|
|
11552
12317
|
farmDeferredData.data.slots,
|
|
11553
|
-
farmDeferredData.data.page
|
|
12318
|
+
farmDeferredData.data.page,
|
|
12319
|
+
routePathname
|
|
11554
12320
|
) + '\\n' +
|
|
11555
12321
|
' ' + renderFarmClientEntryScript(early) + '\\n';
|
|
11556
12322
|
};
|
|
@@ -11707,7 +12473,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11707
12473
|
() => ' ' + renderFarmClientBootstrapScript(
|
|
11708
12474
|
pageProps.__farmCanonicalPath,
|
|
11709
12475
|
farmDeferredData.data.slots,
|
|
11710
|
-
farmDeferredData.data.page
|
|
12476
|
+
farmDeferredData.data.page,
|
|
12477
|
+
routePathname
|
|
11711
12478
|
) + renderFarmDeferredDataScript(farmDeferredData.records) + '\\n' +
|
|
11712
12479
|
' ' + farmEntryScript + '\\n</body>',
|
|
11713
12480
|
);
|
|
@@ -11725,7 +12492,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11725
12492
|
</head>
|
|
11726
12493
|
<body>
|
|
11727
12494
|
<div id="root">\${html}</div>
|
|
11728
|
-
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
12495
|
+
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page, routePathname)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
11729
12496
|
\${farmEntryScript}
|
|
11730
12497
|
</body>
|
|
11731
12498
|
</html>\`;
|
|
@@ -11750,23 +12517,24 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11750
12517
|
pprCacheKey &&
|
|
11751
12518
|
request.method.toUpperCase() !== "HEAD"
|
|
11752
12519
|
) {
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
12520
|
+
// The theme document above reads the theme cookie too. A render that read cookies
|
|
12521
|
+
// stores what a visitor without them sees, and only from such a visitor.
|
|
12522
|
+
const shellReadCookies = renderReadCookies();
|
|
12523
|
+
if (shellReadCookies && pprVisitorCookies) {
|
|
12524
|
+
emitFarmEvent({ type: "ppr.shell.bypass", route: pathname, reason: "cookie" });
|
|
12525
|
+
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "cookie" });
|
|
12526
|
+
} else {
|
|
12527
|
+
await pprShellWrite?.commit(pprCacheKey, {
|
|
12528
|
+
html: fullHtml,
|
|
12529
|
+
...(shellReadCookies ? {} : { cookieIndependent: true }),
|
|
12530
|
+
});
|
|
12531
|
+
emitFarmEvent({
|
|
12532
|
+
type: "ppr.shell.cached",
|
|
12533
|
+
route: pathname,
|
|
12534
|
+
key: pprCacheKey,
|
|
12535
|
+
revalidate: pprConfig.revalidate,
|
|
12536
|
+
});
|
|
12537
|
+
}
|
|
11770
12538
|
}
|
|
11771
12539
|
|
|
11772
12540
|
if (pprBypassReason === "refresh") {
|
|
@@ -11794,6 +12562,19 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11794
12562
|
), middlewareHeaders), fullHtml);
|
|
11795
12563
|
}
|
|
11796
12564
|
} catch (error) {
|
|
12565
|
+
// A Response the page, a layout, or generateMetadata throws answers the request as it is
|
|
12566
|
+
// (a 3xx redirect, a 401 with its WWW-Authenticate), as development sends it.
|
|
12567
|
+
if (error instanceof Response) {
|
|
12568
|
+
emitFarmEvent({
|
|
12569
|
+
type: "render.complete",
|
|
12570
|
+
route: pathname,
|
|
12571
|
+
pathname,
|
|
12572
|
+
status: error.status,
|
|
12573
|
+
durationMs: Date.now() - requestStartTime,
|
|
12574
|
+
});
|
|
12575
|
+
return applyProductionMiddlewareHeaders(error, middlewareHeaders);
|
|
12576
|
+
}
|
|
12577
|
+
|
|
11797
12578
|
if (isFarmRedirectError(error)) {
|
|
11798
12579
|
const redirect = getFarmRedirectError(error);
|
|
11799
12580
|
const redirectUrl =
|
|
@@ -11834,6 +12615,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11834
12615
|
emitFarmEvent({ type: "render.error", route: pathname, error });
|
|
11835
12616
|
console.error("SSR Error:", error);
|
|
11836
12617
|
return renderFarmErrorResponse(error, routePathname, params);
|
|
12618
|
+
} finally {
|
|
12619
|
+
pprShellWrite?.release();
|
|
11837
12620
|
}
|
|
11838
12621
|
}
|
|
11839
12622
|
|
|
@@ -11873,7 +12656,13 @@ ${servesDefaultMCP ? `
|
|
|
11873
12656
|
...(middlewareData?.size ? { middleware: { data: middlewareData } } : {}),
|
|
11874
12657
|
});
|
|
11875
12658
|
|
|
11876
|
-
|
|
12659
|
+
// The boundary renders inside its own segment's layouts and those above it, never inside a
|
|
12660
|
+
// deeper layout: a layout below the boundary that throws would throw again inside it.
|
|
12661
|
+
const applicableLayouts = getApplicableLayouts(errorRoutePathname, errorDirectory).filter(
|
|
12662
|
+
function(layout) {
|
|
12663
|
+
return routeBoundaryCoversDirectory(layout.pattern, errorBoundaryMatch.route.pattern);
|
|
12664
|
+
}
|
|
12665
|
+
);
|
|
11877
12666
|
for (let i = applicableLayouts.length - 1; i >= 0; i--) {
|
|
11878
12667
|
const LayoutComponent = applicableLayouts[i].module.default;
|
|
11879
12668
|
if (LayoutComponent) {
|
|
@@ -12062,7 +12851,7 @@ ${farmRendererDisabled ? `
|
|
|
12062
12851
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
12063
12852
|
.replace(
|
|
12064
12853
|
/<\\/body>/i,
|
|
12065
|
-
() => ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
12854
|
+
() => ' ' + renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname) + '\\n' +
|
|
12066
12855
|
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
12067
12856
|
);
|
|
12068
12857
|
fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
|
|
@@ -12082,7 +12871,7 @@ ${farmRendererDisabled ? `
|
|
|
12082
12871
|
</head>
|
|
12083
12872
|
<body>
|
|
12084
12873
|
<div id="root">\${html}</div>
|
|
12085
|
-
\${renderFarmClientBootstrapScript()}
|
|
12874
|
+
\${renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname)}
|
|
12086
12875
|
\${renderFarmClientEntryScript()}
|
|
12087
12876
|
</body>
|
|
12088
12877
|
</html>\`;
|
|
@@ -12219,7 +13008,10 @@ export async function fetch(request, context) {${imageRuntime === "none" ? "" :
|
|
|
12219
13008
|
return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
|
|
12220
13009
|
}
|
|
12221
13010
|
|
|
12222
|
-
async function handleFarmFetch(request, context) {
|
|
13011
|
+
async function handleFarmFetch(request, context) {${config.server.trustProxy ? `
|
|
13012
|
+
// server.trustProxy: middleware, pages, and API routes read the URL the visitor requested,
|
|
13013
|
+
// at the origin the trusted proxy forwards, as in development.
|
|
13014
|
+
request = _withFarmTrustedProxyOrigin(request);` : ""}
|
|
12223
13015
|
const healthResponse = await farmProductionLifecycle.handleHealthRequest(request);
|
|
12224
13016
|
if (healthResponse) return healthResponse;
|
|
12225
13017
|
|
|
@@ -12536,8 +13328,8 @@ function hasFarmNitroCacheRouteRule(routeRules) {
|
|
|
12536
13328
|
return swr !== void 0 && swr !== false || cache !== void 0 && cache !== false || !!headers && typeof headers === "object" && Object.keys(headers).length > 0;
|
|
12537
13329
|
});
|
|
12538
13330
|
}
|
|
12539
|
-
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
|
|
12540
|
-
const [
|
|
13331
|
+
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager, markdownPrecompiledPages) {
|
|
13332
|
+
const [fs5, nitroBuilderResult] = await Promise.all([
|
|
12541
13333
|
import("fs/promises"),
|
|
12542
13334
|
nitroBuilderResultPromise
|
|
12543
13335
|
]);
|
|
@@ -12546,8 +13338,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12546
13338
|
const isVercel = preset === "vercel";
|
|
12547
13339
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
12548
13340
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
12549
|
-
const runtimeServerOutputDir = isVercel ?
|
|
12550
|
-
const ssrOutputDir =
|
|
13341
|
+
const runtimeServerOutputDir = isVercel ? path16.join(outputDir, "functions", "__nitro.func") : path16.join(outputDir, "server");
|
|
13342
|
+
const ssrOutputDir = path16.join(root, distDir, "ssr");
|
|
12551
13343
|
const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
|
|
12552
13344
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
12553
13345
|
(image) => image.sourceType === "module"
|
|
@@ -12663,21 +13455,34 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12663
13455
|
"Cloudflare Pages does not install Cron Triggers. Use the cloudflare-module preset or an external scheduler with .farm/cron-manifest.json."
|
|
12664
13456
|
);
|
|
12665
13457
|
}
|
|
12666
|
-
const
|
|
13458
|
+
const portableScheduledTasks = mergeScheduledTasks(
|
|
13459
|
+
farmWorkflows.scheduledTasks,
|
|
13460
|
+
farmCron.scheduledTasks
|
|
13461
|
+
);
|
|
13462
|
+
const scheduledTasks = preset.startsWith("cloudflare") ? toFarmCronCloudflareScheduledTasks(portableScheduledTasks) : portableScheduledTasks;
|
|
12667
13463
|
const cloudflareCronConfig = farmCron.provider === "host" ? createFarmCronCloudflareConfig(farmCron.jobs) : void 0;
|
|
12668
|
-
const [
|
|
13464
|
+
const [
|
|
13465
|
+
clientCssHref,
|
|
13466
|
+
clientJsSrc,
|
|
13467
|
+
clientBootSrc,
|
|
13468
|
+
docsModulePreloads,
|
|
13469
|
+
clientModulePreloads,
|
|
13470
|
+
clientRouteTable
|
|
13471
|
+
] = await Promise.all([
|
|
12669
13472
|
resolveHashedClientCssHref(clientOutputDir),
|
|
12670
13473
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
12671
13474
|
resolveClientBootSrc(clientOutputDir),
|
|
12672
|
-
readFarmDocsModulePreloads(
|
|
12673
|
-
readFarmClientModulePreloads(
|
|
13475
|
+
readFarmDocsModulePreloads(path16.join(root, distDir)),
|
|
13476
|
+
readFarmClientModulePreloads(path16.join(root, distDir)),
|
|
13477
|
+
readFarmClientRouteTable(path16.join(root, distDir))
|
|
12674
13478
|
]);
|
|
12675
13479
|
let nativeStylesheets;
|
|
12676
13480
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
12677
13481
|
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
13482
|
+
const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
|
|
12678
13483
|
const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
|
|
12679
13484
|
await finalizeFarmMobileClient({
|
|
12680
|
-
buildDir:
|
|
13485
|
+
buildDir: path16.join(root, distDir),
|
|
12681
13486
|
clientOutputDir,
|
|
12682
13487
|
webEntry: clientJsSrc,
|
|
12683
13488
|
webBoot: clientBootSrc,
|
|
@@ -12696,6 +13501,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12696
13501
|
if (output.code.includes(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
12697
13502
|
output.code = output.code.split(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER).join(encodedClientModulePreloads);
|
|
12698
13503
|
}
|
|
13504
|
+
if (output.code.includes(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER)) {
|
|
13505
|
+
output.code = output.code.split(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER).join(encodedClientRouteTable);
|
|
13506
|
+
}
|
|
12699
13507
|
if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
|
|
12700
13508
|
output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
|
|
12701
13509
|
}
|
|
@@ -12713,15 +13521,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12713
13521
|
output.code = output.code.split(JSON.stringify(FARM_NATIVE_STYLESHEETS_PLACEHOLDER)).join(JSON.stringify(JSON.stringify(nativeStylesheets)));
|
|
12714
13522
|
}
|
|
12715
13523
|
}
|
|
12716
|
-
await
|
|
13524
|
+
await fs5.mkdir(ssrOutputDir, { recursive: true });
|
|
12717
13525
|
await Promise.all(
|
|
12718
13526
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
12719
|
-
const filePath =
|
|
12720
|
-
await
|
|
12721
|
-
await
|
|
13527
|
+
const filePath = path16.join(ssrOutputDir, fileName);
|
|
13528
|
+
await fs5.mkdir(path16.dirname(filePath), { recursive: true });
|
|
13529
|
+
await fs5.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
12722
13530
|
})
|
|
12723
13531
|
);
|
|
12724
|
-
const nitroEntryPath =
|
|
13532
|
+
const nitroEntryPath = path16.join(ssrOutputDir, "nitro-entry.mjs");
|
|
12725
13533
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
12726
13534
|
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
12727
13535
|
const nitroEntryCode = `
|
|
@@ -12927,7 +13735,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12927
13735
|
})
|
|
12928
13736
|
}` : ""}
|
|
12929
13737
|
`.trim();
|
|
12930
|
-
await
|
|
13738
|
+
await fs5.writeFile(nitroEntryPath, nitroEntryCode);
|
|
12931
13739
|
const desktopServerEntry = config.desktop ? {
|
|
12932
13740
|
basePath: config.basePath === "/" ? "" : config.basePath || "",
|
|
12933
13741
|
guardModule: "@farm.js/core/internal/desktop-guard"
|
|
@@ -12938,21 +13746,21 @@ function toFarmNodeResponse(request, response) {
|
|
|
12938
13746
|
`[Farm] A desktop build runs its server in the shell, so it needs the "bun" or "node-server" preset, not "${preset}".`
|
|
12939
13747
|
);
|
|
12940
13748
|
}
|
|
12941
|
-
await
|
|
12942
|
-
|
|
13749
|
+
await fs5.writeFile(
|
|
13750
|
+
path16.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
|
|
12943
13751
|
FARM_DESKTOP_ENV_MODULE_SOURCE
|
|
12944
13752
|
);
|
|
12945
13753
|
}
|
|
12946
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
13754
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path16.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
12947
13755
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
12948
|
-
await
|
|
12949
|
-
|
|
13756
|
+
await fs5.writeFile(
|
|
13757
|
+
path16.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
12950
13758
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
12951
13759
|
);
|
|
12952
|
-
await
|
|
13760
|
+
await fs5.writeFile(
|
|
12953
13761
|
farmNodeServerEntryPath,
|
|
12954
13762
|
createFarmNodeServerEntry({
|
|
12955
|
-
nitroEntryFile:
|
|
13763
|
+
nitroEntryFile: path16.basename(nitroEntryPath),
|
|
12956
13764
|
nodeAdapterModule,
|
|
12957
13765
|
server: config.server,
|
|
12958
13766
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
|
|
@@ -12960,12 +13768,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
12960
13768
|
})
|
|
12961
13769
|
);
|
|
12962
13770
|
}
|
|
12963
|
-
const farmBunServerEntryPath = preset === "bun" ?
|
|
13771
|
+
const farmBunServerEntryPath = preset === "bun" ? path16.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
12964
13772
|
if (farmBunServerEntryPath) {
|
|
12965
|
-
await
|
|
13773
|
+
await fs5.writeFile(
|
|
12966
13774
|
farmBunServerEntryPath,
|
|
12967
13775
|
createFarmBunServerEntry({
|
|
12968
|
-
nitroEntryFile:
|
|
13776
|
+
nitroEntryFile: path16.basename(nitroEntryPath),
|
|
12969
13777
|
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
12970
13778
|
server: config.server,
|
|
12971
13779
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
|
|
@@ -12973,18 +13781,18 @@ function toFarmNodeResponse(request, response) {
|
|
|
12973
13781
|
})
|
|
12974
13782
|
);
|
|
12975
13783
|
}
|
|
12976
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
13784
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path16.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
12977
13785
|
if (farmNetlifyEntryPath) {
|
|
12978
|
-
await
|
|
13786
|
+
await fs5.writeFile(
|
|
12979
13787
|
farmNetlifyEntryPath,
|
|
12980
13788
|
createFarmNetlifyEntry({
|
|
12981
13789
|
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
12982
13790
|
})
|
|
12983
13791
|
);
|
|
12984
13792
|
}
|
|
12985
|
-
const farmCloudflareEnvPath = preset === "cloudflare-pages" ?
|
|
13793
|
+
const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path16.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
|
|
12986
13794
|
if (farmCloudflareEnvPath) {
|
|
12987
|
-
await
|
|
13795
|
+
await fs5.writeFile(
|
|
12988
13796
|
farmCloudflareEnvPath,
|
|
12989
13797
|
`export default function farmCloudflareEnv(event) {
|
|
12990
13798
|
const env = event.req.runtime?.cloudflare?.env
|
|
@@ -13056,7 +13864,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13056
13864
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
13057
13865
|
serverDir: false,
|
|
13058
13866
|
serverEntry: false,
|
|
13059
|
-
buildDir:
|
|
13867
|
+
buildDir: path16.join(root, distDir, ".nitro"),
|
|
13060
13868
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
13061
13869
|
compatibilityDate: "2024-12-01",
|
|
13062
13870
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -13080,7 +13888,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
13080
13888
|
// answered independently, as by the production server, so keeping several
|
|
13081
13889
|
// in flight overlaps the worker's rendering with this thread's per-route work.
|
|
13082
13890
|
concurrency: Math.min(os.availableParallelism(), 8),
|
|
13083
|
-
routes: prerenderRoutes.map(toPrerenderPublicPath)
|
|
13891
|
+
routes: prerenderRoutes.map(toPrerenderPublicPath),
|
|
13892
|
+
// Cloudflare's asset server answers a directory index (about/index.html) at the
|
|
13893
|
+
// trailing-slash URL and redirects the other spelling to it, so a page is written as
|
|
13894
|
+
// about.html unless trailingSlash asks for the slash, as Nitro's Netlify and Vercel
|
|
13895
|
+
// presets already write it.
|
|
13896
|
+
...preset.startsWith("cloudflare") ? { autoSubfolderIndex: config.trailingSlash === true } : {}
|
|
13084
13897
|
}
|
|
13085
13898
|
} : {},
|
|
13086
13899
|
experimental: {
|
|
@@ -13145,7 +13958,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13145
13958
|
if (pluginManager) {
|
|
13146
13959
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
13147
13960
|
}
|
|
13148
|
-
const expectedServerDir =
|
|
13961
|
+
const expectedServerDir = path16.join(outputDir, "server");
|
|
13149
13962
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
13150
13963
|
(key) => key !== "external" && key !== "plugins"
|
|
13151
13964
|
);
|
|
@@ -13160,10 +13973,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
13160
13973
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
13161
13974
|
const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && Boolean(
|
|
13162
13975
|
nitroConfig.handlers?.some(
|
|
13163
|
-
(handler) =>
|
|
13976
|
+
(handler) => path16.resolve(handler?.handler || "") === nitroEntryPath
|
|
13164
13977
|
)
|
|
13165
13978
|
);
|
|
13166
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms &&
|
|
13979
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path16.resolve(nitroConfig.output?.serverDir || "") === path16.resolve(expectedServerDir);
|
|
13167
13980
|
const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
|
|
13168
13981
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
13169
13982
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
@@ -13173,16 +13986,23 @@ function toFarmNodeResponse(request, response) {
|
|
|
13173
13986
|
const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
|
|
13174
13987
|
const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
|
|
13175
13988
|
const ssrRollupPlugin = canReusePrebuiltSSR ? prebuiltSSRPlugin : createServerReadSSRAssetsPlugin(ssrBundle, ssrOutputDir);
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
nitroConfig.rollupConfig
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13989
|
+
const configuredRollupPlugins = nitroConfig.rollupConfig?.plugins;
|
|
13990
|
+
nitroConfig.rollupConfig = {
|
|
13991
|
+
...nitroConfig.rollupConfig,
|
|
13992
|
+
plugins: [
|
|
13993
|
+
...Array.isArray(configuredRollupPlugins) ? configuredRollupPlugins : configuredRollupPlugins ? [configuredRollupPlugins] : [],
|
|
13994
|
+
...ssrRollupPlugin ? [ssrRollupPlugin] : [],
|
|
13995
|
+
// Added after the checks above: it changes no SSR output, only how public files answer
|
|
13996
|
+
// `Range` and how a prerendered page's other slash spelling redirects. Nitro's static
|
|
13997
|
+
// handler answers both spellings, and a route rule cannot redirect one of them: Nitro's
|
|
13998
|
+
// router matches the rule at the canonical URL too, which loops on h3 before 2.0.8.
|
|
13999
|
+
// Platform presets serve their own static files and redirects.
|
|
14000
|
+
createNitroStaticRangePlugin(
|
|
14001
|
+
resolveNitroPackageEntry(root),
|
|
14002
|
+
isVercel || preset.startsWith("cloudflare") || preset.startsWith("netlify") ? [] : prerenderRoutes.map(toPrerenderPublicPath)
|
|
14003
|
+
)
|
|
14004
|
+
]
|
|
14005
|
+
};
|
|
13186
14006
|
nitroConfig.minify = useFarmServerMinifier ? false : shouldMinify;
|
|
13187
14007
|
const nitroInstance = await nitroBuilder.createNitro(nitroConfig);
|
|
13188
14008
|
let prerenderOrder = /* @__PURE__ */ new Map();
|
|
@@ -13201,6 +14021,21 @@ function toFarmNodeResponse(request, response) {
|
|
|
13201
14021
|
const orderOf = (route) => prerenderOrder.get(route) ?? Number.MAX_SAFE_INTEGER;
|
|
13202
14022
|
prerenderedRoutes.sort((a, b) => orderOf(a.route) - orderOf(b.route));
|
|
13203
14023
|
});
|
|
14024
|
+
const prerenderPagePaths = new Set(prerenderRoutes.map(toPrerenderPublicPath));
|
|
14025
|
+
let skippedNonHtmlPrerenderRoute = false;
|
|
14026
|
+
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
14027
|
+
if (route.error || !prerenderPagePaths.has(route.route)) return;
|
|
14028
|
+
if (route.contentType?.toLowerCase().includes("html")) return;
|
|
14029
|
+
route.skip = true;
|
|
14030
|
+
skippedNonHtmlPrerenderRoute = true;
|
|
14031
|
+
const configuredRule = configuredNitroRouteRules[route.route];
|
|
14032
|
+
if (configuredRule) nitroInstance.options.routeRules[route.route] = configuredRule;
|
|
14033
|
+
else delete nitroInstance.options.routeRules[route.route];
|
|
14034
|
+
logger.info(`\u21AA Keeping SSG route ${route.route} server-handled (it does not render HTML)`);
|
|
14035
|
+
});
|
|
14036
|
+
nitroInstance.hooks.hook("prerender:done", () => {
|
|
14037
|
+
if (skippedNonHtmlPrerenderRoute) nitroInstance.routing.sync();
|
|
14038
|
+
});
|
|
13204
14039
|
if (config.md?.enabled) {
|
|
13205
14040
|
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
13206
14041
|
if (!route.contents || !route.contentType?.toLowerCase().includes("html")) return;
|
|
@@ -13253,7 +14088,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13253
14088
|
const configuredPlugins = rollupConfig.plugins;
|
|
13254
14089
|
rollupConfig.plugins = [
|
|
13255
14090
|
...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [],
|
|
13256
|
-
createPrerenderRuntimeResolverPlugin(config.root)
|
|
14091
|
+
createPrerenderRuntimeResolverPlugin(config.root),
|
|
14092
|
+
...markdownPrecompiledPages ? [createPrerenderMarkdownPagesPlugin(markdownPrecompiledPages)] : []
|
|
13257
14093
|
];
|
|
13258
14094
|
});
|
|
13259
14095
|
});
|
|
@@ -13269,8 +14105,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13269
14105
|
};
|
|
13270
14106
|
prerendererConfig.output = {
|
|
13271
14107
|
...prerendererConfig.output,
|
|
13272
|
-
serverDir:
|
|
13273
|
-
prerendererConfig.buildDir ??
|
|
14108
|
+
serverDir: path16.join(
|
|
14109
|
+
prerendererConfig.buildDir ?? path16.join(root, distDir, ".nitro"),
|
|
13274
14110
|
"prerender"
|
|
13275
14111
|
)
|
|
13276
14112
|
};
|
|
@@ -13289,11 +14125,11 @@ function toFarmNodeResponse(request, response) {
|
|
|
13289
14125
|
const prerenderServerDir = prerenderer.options.output.serverDir;
|
|
13290
14126
|
await copyPrebuiltSSRBundle(
|
|
13291
14127
|
ssrBundle,
|
|
13292
|
-
|
|
14128
|
+
path16.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
13293
14129
|
null,
|
|
13294
|
-
|
|
14130
|
+
fs5
|
|
13295
14131
|
);
|
|
13296
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
14132
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs5);
|
|
13297
14133
|
});
|
|
13298
14134
|
});
|
|
13299
14135
|
}
|
|
@@ -13327,7 +14163,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13327
14163
|
else process.env[FARM_PRERENDER_ENV] = previousPrerender;
|
|
13328
14164
|
}
|
|
13329
14165
|
}
|
|
13330
|
-
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir,
|
|
14166
|
+
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs5, preset) : Promise.resolve(null);
|
|
13331
14167
|
const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
|
|
13332
14168
|
ssrBundle,
|
|
13333
14169
|
shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
|
|
@@ -13340,7 +14176,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13340
14176
|
await nitroInstance.close();
|
|
13341
14177
|
if (nitroBuildResult.status === "rejected") {
|
|
13342
14178
|
if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
|
|
13343
|
-
await
|
|
14179
|
+
await fs5.rm(sharpRuntimeStageResult.value.stageDir, {
|
|
13344
14180
|
recursive: true,
|
|
13345
14181
|
force: true
|
|
13346
14182
|
});
|
|
@@ -13353,20 +14189,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
13353
14189
|
if (prebuiltSSRFilesResult.status === "rejected") {
|
|
13354
14190
|
throw prebuiltSSRFilesResult.reason;
|
|
13355
14191
|
}
|
|
13356
|
-
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir,
|
|
14192
|
+
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs5, preset) : null);
|
|
13357
14193
|
const runtimeCopyPromise = (async () => {
|
|
13358
14194
|
if (stagedSharpRuntime) {
|
|
13359
|
-
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir,
|
|
14195
|
+
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs5);
|
|
13360
14196
|
}
|
|
13361
14197
|
if (useExternalMetadataImageRuntime) {
|
|
13362
|
-
await copyMetadataImageRuntime(root, runtimeServerOutputDir,
|
|
14198
|
+
await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs5);
|
|
13363
14199
|
}
|
|
13364
14200
|
})();
|
|
13365
14201
|
const copyResults = await Promise.allSettled([
|
|
13366
14202
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
13367
14203
|
prebuiltSSRFilesResult.value,
|
|
13368
|
-
|
|
13369
|
-
|
|
14204
|
+
path16.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
14205
|
+
fs5
|
|
13370
14206
|
) : Promise.resolve(),
|
|
13371
14207
|
runtimeCopyPromise
|
|
13372
14208
|
]);
|
|
@@ -13375,17 +14211,17 @@ function toFarmNodeResponse(request, response) {
|
|
|
13375
14211
|
);
|
|
13376
14212
|
if (failedCopy) throw failedCopy.reason;
|
|
13377
14213
|
if (canReusePrebuiltSSR) {
|
|
13378
|
-
await registerPrebuiltSSRPackageImport(
|
|
14214
|
+
await registerPrebuiltSSRPackageImport(path16.join(outputDir, "server"), ssrEntryFile, fs5);
|
|
13379
14215
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
13380
14216
|
}
|
|
13381
14217
|
if (useRolldownBuilder) {
|
|
13382
14218
|
logger.info("\u26A1 Built the Node adapter with Rolldown");
|
|
13383
14219
|
}
|
|
13384
14220
|
if (preset === "node-server" && !desktopServerEntry) {
|
|
13385
|
-
await installFarmCompileCacheLauncher(
|
|
14221
|
+
await installFarmCompileCacheLauncher(path16.join(outputDir, "server"), fs5);
|
|
13386
14222
|
}
|
|
13387
14223
|
if (preset.startsWith("cloudflare")) {
|
|
13388
|
-
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir,
|
|
14224
|
+
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs5);
|
|
13389
14225
|
}
|
|
13390
14226
|
if (pluginManager) {
|
|
13391
14227
|
await pluginManager.runHookParallel("afterNitroBuild", {
|
|
@@ -13399,13 +14235,13 @@ function toFarmNodeResponse(request, response) {
|
|
|
13399
14235
|
await postProcessVercelOutput(
|
|
13400
14236
|
root,
|
|
13401
14237
|
outputDir,
|
|
13402
|
-
|
|
14238
|
+
fs5,
|
|
13403
14239
|
config,
|
|
13404
14240
|
farmWorkflows,
|
|
13405
14241
|
routeRuntimeManifest,
|
|
13406
14242
|
farmCron.provider === "host" ? farmCron.jobs : [],
|
|
13407
14243
|
{
|
|
13408
|
-
buildDir:
|
|
14244
|
+
buildDir: path16.join(root, distDir),
|
|
13409
14245
|
middlewareRoutes: edgeMiddlewareRoutes,
|
|
13410
14246
|
guardedPages: edgeGuardedPrerenderRoutes
|
|
13411
14247
|
},
|
|
@@ -13419,19 +14255,19 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
13419
14255
|
return {
|
|
13420
14256
|
dir: outputDir,
|
|
13421
14257
|
...preset === "node-server" ? {
|
|
13422
|
-
serverDir:
|
|
13423
|
-
publicDir:
|
|
14258
|
+
serverDir: path16.join(outputDir, "server"),
|
|
14259
|
+
publicDir: path16.join(outputDir, "public")
|
|
13424
14260
|
} : isVercel ? {
|
|
13425
|
-
serverDir:
|
|
13426
|
-
publicDir:
|
|
14261
|
+
serverDir: path16.join(outputDir, "functions", "__nitro.func"),
|
|
14262
|
+
publicDir: path16.join(outputDir, "static")
|
|
13427
14263
|
} : {}
|
|
13428
14264
|
};
|
|
13429
14265
|
}
|
|
13430
|
-
async function populateCloudflareProcessEnv(serverDir,
|
|
13431
|
-
const wranglerPath =
|
|
14266
|
+
async function populateCloudflareProcessEnv(serverDir, fs5) {
|
|
14267
|
+
const wranglerPath = path16.join(serverDir, "wrangler.json");
|
|
13432
14268
|
let source;
|
|
13433
14269
|
try {
|
|
13434
|
-
source = await
|
|
14270
|
+
source = await fs5.readFile(wranglerPath, "utf8");
|
|
13435
14271
|
} catch (error) {
|
|
13436
14272
|
if (error.code === "ENOENT") return;
|
|
13437
14273
|
throw error;
|
|
@@ -13439,7 +14275,7 @@ async function populateCloudflareProcessEnv(serverDir, fs4) {
|
|
|
13439
14275
|
const wrangler = JSON.parse(source);
|
|
13440
14276
|
const flags = resolveCloudflareProcessEnvFlags(wrangler);
|
|
13441
14277
|
if (!flags) return;
|
|
13442
|
-
await
|
|
14278
|
+
await fs5.writeFile(
|
|
13443
14279
|
wranglerPath,
|
|
13444
14280
|
JSON.stringify({ ...wrangler, compatibility_flags: flags }, null, 2)
|
|
13445
14281
|
);
|
|
@@ -13452,52 +14288,53 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
|
13452
14288
|
}))
|
|
13453
14289
|
);
|
|
13454
14290
|
}
|
|
13455
|
-
async function writeSSRBundleFiles(files, targetDir,
|
|
13456
|
-
await
|
|
14291
|
+
async function writeSSRBundleFiles(files, targetDir, fs5) {
|
|
14292
|
+
await fs5.rm(targetDir, { recursive: true, force: true });
|
|
13457
14293
|
await Promise.all(
|
|
13458
14294
|
files.map(async ({ fileName, contents }) => {
|
|
13459
|
-
const targetPath =
|
|
13460
|
-
await
|
|
13461
|
-
await
|
|
14295
|
+
const targetPath = path16.join(targetDir, fileName);
|
|
14296
|
+
await fs5.mkdir(path16.dirname(targetPath), { recursive: true });
|
|
14297
|
+
await fs5.writeFile(targetPath, contents);
|
|
13462
14298
|
})
|
|
13463
14299
|
);
|
|
13464
14300
|
}
|
|
13465
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions,
|
|
13466
|
-
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir,
|
|
14301
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs5) {
|
|
14302
|
+
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs5);
|
|
13467
14303
|
}
|
|
13468
|
-
async function installFarmCompileCacheLauncher(serverDir,
|
|
13469
|
-
const entryPath =
|
|
13470
|
-
const serverPath =
|
|
13471
|
-
const entry = await
|
|
14304
|
+
async function installFarmCompileCacheLauncher(serverDir, fs5) {
|
|
14305
|
+
const entryPath = path16.join(serverDir, "index.mjs");
|
|
14306
|
+
const serverPath = path16.join(serverDir, FARM_SERVER_MODULE_FILE);
|
|
14307
|
+
const entry = await fs5.readFile(entryPath, "utf8").catch((error) => {
|
|
13472
14308
|
if (error.code === "ENOENT") return null;
|
|
13473
14309
|
throw error;
|
|
13474
14310
|
});
|
|
13475
14311
|
if (entry === null) return false;
|
|
13476
14312
|
if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
|
|
13477
|
-
await
|
|
13478
|
-
await
|
|
13479
|
-
await
|
|
14313
|
+
await fs5.rename(entryPath, serverPath);
|
|
14314
|
+
await fs5.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
|
|
14315
|
+
await fs5.rm(path16.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
|
|
13480
14316
|
return true;
|
|
13481
14317
|
}
|
|
13482
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
13483
|
-
const packagePath =
|
|
13484
|
-
const packageJSON = await
|
|
14318
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs5) {
|
|
14319
|
+
const packagePath = path16.join(serverDir, "package.json");
|
|
14320
|
+
const packageJSON = await fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13485
14321
|
if (error.code === "ENOENT") return { type: "module" };
|
|
13486
14322
|
throw error;
|
|
13487
14323
|
});
|
|
13488
14324
|
const existingImports = packageJSON.imports && typeof packageJSON.imports === "object" ? packageJSON.imports : {};
|
|
13489
14325
|
const outputEntry = `${FARM_SSR_OUTPUT_DIR}/${ssrEntryFile}`.replace(/\\/g, "/");
|
|
14326
|
+
packageJSON.type ?? (packageJSON.type = "module");
|
|
13490
14327
|
packageJSON.imports = {
|
|
13491
14328
|
...existingImports,
|
|
13492
14329
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
13493
14330
|
};
|
|
13494
|
-
await
|
|
13495
|
-
await
|
|
14331
|
+
await fs5.mkdir(serverDir, { recursive: true });
|
|
14332
|
+
await fs5.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
13496
14333
|
`);
|
|
13497
14334
|
}
|
|
13498
|
-
async function moveVercelOutputPath(src, dest,
|
|
14335
|
+
async function moveVercelOutputPath(src, dest, fs5) {
|
|
13499
14336
|
try {
|
|
13500
|
-
await
|
|
14337
|
+
await fs5.rename(src, dest);
|
|
13501
14338
|
return;
|
|
13502
14339
|
} catch (error) {
|
|
13503
14340
|
const code = error?.code;
|
|
@@ -13505,38 +14342,38 @@ async function moveVercelOutputPath(src, dest, fs4) {
|
|
|
13505
14342
|
throw error;
|
|
13506
14343
|
}
|
|
13507
14344
|
}
|
|
13508
|
-
await
|
|
13509
|
-
await
|
|
14345
|
+
await fs5.cp(src, dest, { recursive: true, force: true });
|
|
14346
|
+
await fs5.rm(src, { recursive: true, force: true });
|
|
13510
14347
|
}
|
|
13511
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
13512
|
-
const serverDir =
|
|
13513
|
-
const functionsDir =
|
|
13514
|
-
const nitroFuncDir =
|
|
13515
|
-
const staticDir =
|
|
13516
|
-
const publicDir =
|
|
13517
|
-
await
|
|
13518
|
-
const serverContents = await
|
|
14348
|
+
async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
|
|
14349
|
+
const serverDir = path16.join(outputDir, "server");
|
|
14350
|
+
const functionsDir = path16.join(outputDir, "functions");
|
|
14351
|
+
const nitroFuncDir = path16.join(functionsDir, "__nitro.func");
|
|
14352
|
+
const staticDir = path16.join(outputDir, "static");
|
|
14353
|
+
const publicDir = path16.join(outputDir, "public");
|
|
14354
|
+
await fs5.mkdir(nitroFuncDir, { recursive: true });
|
|
14355
|
+
const serverContents = await fs5.readdir(serverDir).catch((error) => {
|
|
13519
14356
|
if (error.code === "ENOENT") return [];
|
|
13520
14357
|
throw error;
|
|
13521
14358
|
});
|
|
13522
14359
|
for (const file of serverContents) {
|
|
13523
|
-
await moveVercelOutputPath(
|
|
14360
|
+
await moveVercelOutputPath(path16.join(serverDir, file), path16.join(nitroFuncDir, file), fs5);
|
|
13524
14361
|
}
|
|
13525
|
-
if (serverContents.length > 0) await
|
|
14362
|
+
if (serverContents.length > 0) await fs5.rm(serverDir, { recursive: true, force: true });
|
|
13526
14363
|
try {
|
|
13527
|
-
await moveVercelOutputPath(publicDir, staticDir,
|
|
14364
|
+
await moveVercelOutputPath(publicDir, staticDir, fs5);
|
|
13528
14365
|
} catch (error) {
|
|
13529
14366
|
if (error?.code !== "ENOENT") throw error;
|
|
13530
14367
|
}
|
|
13531
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
13532
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
13533
|
-
const configPath =
|
|
13534
|
-
const configContent = await
|
|
14368
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5);
|
|
14369
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs5);
|
|
14370
|
+
const configPath = path16.join(outputDir, "config.json");
|
|
14371
|
+
const configContent = await fs5.readFile(configPath, "utf-8");
|
|
13535
14372
|
const vercelConfig = JSON.parse(configContent);
|
|
13536
14373
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
13537
14374
|
outputDir,
|
|
13538
14375
|
routeRuntimeManifest,
|
|
13539
|
-
|
|
14376
|
+
fs5,
|
|
13540
14377
|
config.basePath
|
|
13541
14378
|
);
|
|
13542
14379
|
const edgeMiddlewareRoutes = edgeMiddleware.middlewareRoutes.filter(
|
|
@@ -13550,7 +14387,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13550
14387
|
config,
|
|
13551
14388
|
routes: edgeMiddlewareRoutes,
|
|
13552
14389
|
guardedPages: edgeMiddleware.guardedPages,
|
|
13553
|
-
fs:
|
|
14390
|
+
fs: fs5
|
|
13554
14391
|
});
|
|
13555
14392
|
}
|
|
13556
14393
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
@@ -13564,30 +14401,30 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13564
14401
|
farmWorkflows.workflows
|
|
13565
14402
|
);
|
|
13566
14403
|
const vercelConfigWithCrons = applyFarmCronVercelCrons(vercelConfigWithWorkflowCrons, cronJobs);
|
|
13567
|
-
await
|
|
14404
|
+
await fs5.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
13568
14405
|
logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
13569
14406
|
}
|
|
13570
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
14407
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
|
|
13571
14408
|
if (!config.docs?.enabled) return;
|
|
13572
14409
|
const [mainRoot, ...extraRoots] = getFarmDocsRoots(config.docs);
|
|
13573
14410
|
await copyFarmDocsRootContent(
|
|
13574
14411
|
mainRoot,
|
|
13575
14412
|
root,
|
|
13576
14413
|
config.srcDir,
|
|
13577
|
-
|
|
13578
|
-
|
|
14414
|
+
path16.join(nitroFuncDir, "farm-docs-content"),
|
|
14415
|
+
fs5
|
|
13579
14416
|
);
|
|
13580
14417
|
for (const [index, docsRoot] of extraRoots.entries()) {
|
|
13581
14418
|
await copyFarmDocsRootContent(
|
|
13582
14419
|
docsRoot,
|
|
13583
14420
|
root,
|
|
13584
14421
|
config.srcDir,
|
|
13585
|
-
|
|
13586
|
-
|
|
14422
|
+
path16.join(nitroFuncDir, "farm-docs-roots", String(index)),
|
|
14423
|
+
fs5
|
|
13587
14424
|
);
|
|
13588
14425
|
}
|
|
13589
14426
|
}
|
|
13590
|
-
async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir,
|
|
14427
|
+
async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs5) {
|
|
13591
14428
|
const docsContentDir = resolveBuildDocsContentDir(docs, root, srcDir);
|
|
13592
14429
|
if (!docsContentDir) return;
|
|
13593
14430
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
@@ -13599,19 +14436,19 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
|
|
|
13599
14436
|
`${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.`
|
|
13600
14437
|
);
|
|
13601
14438
|
}
|
|
13602
|
-
await
|
|
13603
|
-
await
|
|
13604
|
-
await
|
|
14439
|
+
await fs5.rm(bundledContentDir, { recursive: true, force: true });
|
|
14440
|
+
await fs5.mkdir(path16.dirname(bundledContentDir), { recursive: true });
|
|
14441
|
+
await fs5.cp(docsContentDir, bundledContentDir, {
|
|
13605
14442
|
recursive: true,
|
|
13606
14443
|
force: true,
|
|
13607
14444
|
dereference: true
|
|
13608
14445
|
});
|
|
13609
|
-
await
|
|
13610
|
-
|
|
14446
|
+
await fs5.writeFile(
|
|
14447
|
+
path16.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
13611
14448
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
13612
14449
|
`
|
|
13613
14450
|
);
|
|
13614
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
14451
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path16.relative(root, docsContentDir)}`);
|
|
13615
14452
|
}
|
|
13616
14453
|
function resolveServerFunctionPlatform(preset) {
|
|
13617
14454
|
return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
|
|
@@ -13626,9 +14463,9 @@ function platformFieldAllows(field, value) {
|
|
|
13626
14463
|
const allowed = entries.filter((entry) => !entry.startsWith("!"));
|
|
13627
14464
|
return allowed.length === 0 || allowed.includes(value);
|
|
13628
14465
|
}
|
|
13629
|
-
async function stageSharpRuntime(config, root, distDir,
|
|
14466
|
+
async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
13630
14467
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
13631
|
-
const projectRequire = createRequire2(
|
|
14468
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
13632
14469
|
let sharpRequire = projectRequire;
|
|
13633
14470
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
13634
14471
|
try {
|
|
@@ -13638,10 +14475,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13638
14475
|
}
|
|
13639
14476
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
13640
14477
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
13641
|
-
const stageRoot =
|
|
13642
|
-
await
|
|
13643
|
-
const stageDir = await
|
|
13644
|
-
const targetNodeModules =
|
|
14478
|
+
const stageRoot = path16.join(root, distDir, "tmp");
|
|
14479
|
+
await fs5.mkdir(stageRoot, { recursive: true });
|
|
14480
|
+
const stageDir = await fs5.mkdtemp(path16.join(stageRoot, "sharp-runtime-"));
|
|
14481
|
+
const targetNodeModules = path16.join(stageDir, "node_modules");
|
|
13645
14482
|
function copyPackage(packageName, parentRequire) {
|
|
13646
14483
|
const activeCopy = packageCopies.get(packageName);
|
|
13647
14484
|
if (activeCopy) return activeCopy;
|
|
@@ -13652,19 +14489,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13652
14489
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
13653
14490
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
13654
14491
|
if (!packageJsonPath) return;
|
|
13655
|
-
const packageJson = JSON.parse(await
|
|
14492
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
13656
14493
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
13657
|
-
const packageDir =
|
|
13658
|
-
const targetDir =
|
|
14494
|
+
const packageDir = path16.dirname(packageJsonPath);
|
|
14495
|
+
const targetDir = path16.join(targetNodeModules, ...packageName.split("/"));
|
|
13659
14496
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
13660
|
-
await
|
|
14497
|
+
await fs5.mkdir(path16.dirname(targetDir), { recursive: true });
|
|
13661
14498
|
const packageRequire = createRequire2(packageJsonPath);
|
|
13662
14499
|
const dependencies = {
|
|
13663
14500
|
...packageJson.dependencies,
|
|
13664
14501
|
...packageJson.optionalDependencies
|
|
13665
14502
|
};
|
|
13666
14503
|
await settleAllOrThrow([
|
|
13667
|
-
|
|
14504
|
+
fs5.cp(packageDir, targetDir, {
|
|
13668
14505
|
recursive: true,
|
|
13669
14506
|
force: true,
|
|
13670
14507
|
dereference: true,
|
|
@@ -13681,7 +14518,7 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13681
14518
|
throw new Error(`Farm image optimization requires sharp. ${SHARP_INSTALL_HINT}`);
|
|
13682
14519
|
}
|
|
13683
14520
|
} catch (error) {
|
|
13684
|
-
await
|
|
14521
|
+
await fs5.rm(stageDir, { recursive: true, force: true });
|
|
13685
14522
|
throw error;
|
|
13686
14523
|
}
|
|
13687
14524
|
return {
|
|
@@ -13691,19 +14528,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13691
14528
|
)
|
|
13692
14529
|
};
|
|
13693
14530
|
}
|
|
13694
|
-
async function installStagedSharpRuntime(staged, nitroFuncDir,
|
|
13695
|
-
const stagedNodeModules =
|
|
13696
|
-
const targetNodeModules =
|
|
14531
|
+
async function installStagedSharpRuntime(staged, nitroFuncDir, fs5) {
|
|
14532
|
+
const stagedNodeModules = path16.join(staged.stageDir, "node_modules");
|
|
14533
|
+
const targetNodeModules = path16.join(nitroFuncDir, "node_modules");
|
|
13697
14534
|
try {
|
|
13698
|
-
await mergeStagedDirectory(stagedNodeModules, targetNodeModules,
|
|
13699
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
14535
|
+
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs5);
|
|
14536
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
13700
14537
|
functionPackage.dependencies = {
|
|
13701
14538
|
...functionPackage.dependencies,
|
|
13702
14539
|
...staged.dependencies
|
|
13703
14540
|
};
|
|
13704
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14541
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13705
14542
|
} finally {
|
|
13706
|
-
await
|
|
14543
|
+
await fs5.rm(staged.stageDir, { recursive: true, force: true });
|
|
13707
14544
|
}
|
|
13708
14545
|
logger.info(
|
|
13709
14546
|
`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
|
|
@@ -13716,15 +14553,15 @@ async function settleAllOrThrow(operations) {
|
|
|
13716
14553
|
);
|
|
13717
14554
|
if (failure) throw failure.reason;
|
|
13718
14555
|
}
|
|
13719
|
-
async function mergeStagedDirectory(sourceDir, targetDir,
|
|
13720
|
-
await
|
|
13721
|
-
const entries = await
|
|
14556
|
+
async function mergeStagedDirectory(sourceDir, targetDir, fs5) {
|
|
14557
|
+
await fs5.mkdir(targetDir, { recursive: true });
|
|
14558
|
+
const entries = await fs5.readdir(sourceDir, { withFileTypes: true });
|
|
13722
14559
|
await settleAllOrThrow(
|
|
13723
14560
|
entries.map(async (entry) => {
|
|
13724
|
-
const sourcePath =
|
|
13725
|
-
const targetPath =
|
|
14561
|
+
const sourcePath = path16.join(sourceDir, entry.name);
|
|
14562
|
+
const targetPath = path16.join(targetDir, entry.name);
|
|
13726
14563
|
try {
|
|
13727
|
-
await
|
|
14564
|
+
await fs5.rename(sourcePath, targetPath);
|
|
13728
14565
|
return;
|
|
13729
14566
|
} catch (error) {
|
|
13730
14567
|
const code = error.code;
|
|
@@ -13733,29 +14570,29 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
13733
14570
|
}
|
|
13734
14571
|
}
|
|
13735
14572
|
if (entry.isDirectory()) {
|
|
13736
|
-
await mergeStagedDirectory(sourcePath, targetPath,
|
|
13737
|
-
await
|
|
14573
|
+
await mergeStagedDirectory(sourcePath, targetPath, fs5);
|
|
14574
|
+
await fs5.rm(sourcePath, { recursive: true, force: true });
|
|
13738
14575
|
return;
|
|
13739
14576
|
}
|
|
13740
|
-
await
|
|
14577
|
+
await fs5.cp(sourcePath, targetPath, {
|
|
13741
14578
|
force: true,
|
|
13742
14579
|
dereference: true,
|
|
13743
14580
|
mode: fsConstants.COPYFILE_FICLONE
|
|
13744
14581
|
});
|
|
13745
|
-
await
|
|
14582
|
+
await fs5.rm(sourcePath, { force: true });
|
|
13746
14583
|
})
|
|
13747
14584
|
);
|
|
13748
14585
|
}
|
|
13749
14586
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
13750
14587
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
13751
14588
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
13752
|
-
const file = generated.modulePath ? toPosixPath(
|
|
14589
|
+
const file = generated.modulePath ? toPosixPath(path16.relative(root, generated.modulePath)) : "";
|
|
13753
14590
|
throw new Error(
|
|
13754
14591
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
13755
14592
|
);
|
|
13756
14593
|
}
|
|
13757
14594
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
13758
|
-
const projectRequire = createRequire2(
|
|
14595
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
13759
14596
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
13760
14597
|
if (packageJsonPath) return packageJsonPath;
|
|
13761
14598
|
try {
|
|
@@ -13764,38 +14601,38 @@ function resolveMetadataImageRuntimePackageJson(root) {
|
|
|
13764
14601
|
return null;
|
|
13765
14602
|
}
|
|
13766
14603
|
}
|
|
13767
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
14604
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs5) {
|
|
13768
14605
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
13769
14606
|
if (!packageJsonPath) return;
|
|
13770
|
-
const packageJson = JSON.parse(await
|
|
13771
|
-
const packageDir =
|
|
13772
|
-
const targetDir =
|
|
13773
|
-
await
|
|
13774
|
-
await
|
|
14607
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
14608
|
+
const packageDir = path16.dirname(packageJsonPath);
|
|
14609
|
+
const targetDir = path16.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
14610
|
+
await fs5.mkdir(path16.dirname(targetDir), { recursive: true });
|
|
14611
|
+
await fs5.cp(packageDir, targetDir, {
|
|
13775
14612
|
recursive: true,
|
|
13776
14613
|
force: true,
|
|
13777
14614
|
dereference: true,
|
|
13778
14615
|
mode: fsConstants.COPYFILE_FICLONE
|
|
13779
14616
|
});
|
|
13780
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
14617
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
13781
14618
|
functionPackage.dependencies = {
|
|
13782
14619
|
...functionPackage.dependencies,
|
|
13783
14620
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
13784
14621
|
};
|
|
13785
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14622
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13786
14623
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
13787
14624
|
}
|
|
13788
|
-
async function readNitroOutputPackage(outputDir,
|
|
13789
|
-
const packagePath =
|
|
13790
|
-
return
|
|
14625
|
+
async function readNitroOutputPackage(outputDir, fs5) {
|
|
14626
|
+
const packagePath = path16.join(outputDir, "package.json");
|
|
14627
|
+
return fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13791
14628
|
if (error.code === "ENOENT") return {};
|
|
13792
14629
|
throw error;
|
|
13793
14630
|
});
|
|
13794
14631
|
}
|
|
13795
|
-
async function writeNitroOutputPackage(outputDir, packageJson,
|
|
13796
|
-
await
|
|
13797
|
-
await
|
|
13798
|
-
|
|
14632
|
+
async function writeNitroOutputPackage(outputDir, packageJson, fs5) {
|
|
14633
|
+
await fs5.mkdir(outputDir, { recursive: true });
|
|
14634
|
+
await fs5.writeFile(
|
|
14635
|
+
path16.join(outputDir, "package.json"),
|
|
13799
14636
|
`${JSON.stringify(packageJson, null, 2)}
|
|
13800
14637
|
`
|
|
13801
14638
|
);
|
|
@@ -13811,70 +14648,73 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
13811
14648
|
}
|
|
13812
14649
|
}
|
|
13813
14650
|
try {
|
|
13814
|
-
let directory =
|
|
13815
|
-
while (directory !==
|
|
13816
|
-
const candidate =
|
|
13817
|
-
if (
|
|
14651
|
+
let directory = path16.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
14652
|
+
while (directory !== path16.dirname(directory)) {
|
|
14653
|
+
const candidate = path16.join(directory, "package.json");
|
|
14654
|
+
if (existsSync3(candidate)) {
|
|
13818
14655
|
try {
|
|
13819
|
-
const manifest = JSON.parse(
|
|
14656
|
+
const manifest = JSON.parse(readFileSync2(candidate, "utf8"));
|
|
13820
14657
|
if (manifest.name === packageName) return candidate;
|
|
13821
14658
|
} catch {
|
|
13822
14659
|
}
|
|
13823
14660
|
}
|
|
13824
|
-
if (
|
|
13825
|
-
directory =
|
|
14661
|
+
if (path16.basename(directory) === "node_modules") break;
|
|
14662
|
+
directory = path16.dirname(directory);
|
|
13826
14663
|
}
|
|
13827
14664
|
} catch {
|
|
13828
14665
|
}
|
|
13829
14666
|
return null;
|
|
13830
14667
|
}
|
|
13831
|
-
async function resolveProjectInstalledPackageDir(root, packageName,
|
|
13832
|
-
let directory =
|
|
14668
|
+
async function resolveProjectInstalledPackageDir(root, packageName, fs5) {
|
|
14669
|
+
let directory = path16.resolve(root);
|
|
13833
14670
|
while (true) {
|
|
13834
|
-
const candidate =
|
|
14671
|
+
const candidate = path16.join(directory, "node_modules", ...packageName.split("/"));
|
|
13835
14672
|
try {
|
|
13836
|
-
const packageDir = await
|
|
13837
|
-
if ((await
|
|
14673
|
+
const packageDir = await fs5.realpath(candidate);
|
|
14674
|
+
if ((await fs5.stat(path16.join(packageDir, "package.json"))).isFile()) return packageDir;
|
|
13838
14675
|
} catch {
|
|
13839
14676
|
}
|
|
13840
|
-
const parent =
|
|
14677
|
+
const parent = path16.dirname(directory);
|
|
13841
14678
|
if (parent === directory) return null;
|
|
13842
14679
|
directory = parent;
|
|
13843
14680
|
}
|
|
13844
14681
|
}
|
|
13845
|
-
|
|
13846
|
-
|
|
14682
|
+
var PRISMA_RUNTIME_GENERATE_ONLY_FILE = /^query_(?:engine|compiler)_bg\.|\.map$|\.d\.m?ts$/;
|
|
14683
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs5) {
|
|
14684
|
+
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs5);
|
|
13847
14685
|
if (!prismaClientDir) return;
|
|
13848
|
-
const generatedClientDir =
|
|
14686
|
+
const generatedClientDir = path16.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
13849
14687
|
try {
|
|
13850
|
-
await
|
|
14688
|
+
await fs5.access(generatedClientDir);
|
|
13851
14689
|
} catch {
|
|
13852
14690
|
return;
|
|
13853
14691
|
}
|
|
13854
|
-
const targetNodeModules =
|
|
13855
|
-
const targetPrismaScopeDir =
|
|
13856
|
-
const targetGeneratedDir =
|
|
13857
|
-
const targetClientDir =
|
|
13858
|
-
|
|
13859
|
-
await
|
|
14692
|
+
const targetNodeModules = path16.join(nitroFuncDir, "node_modules");
|
|
14693
|
+
const targetPrismaScopeDir = path16.join(targetNodeModules, "@prisma");
|
|
14694
|
+
const targetGeneratedDir = path16.join(targetNodeModules, ".prisma", "client");
|
|
14695
|
+
const targetClientDir = path16.join(targetPrismaScopeDir, "client");
|
|
14696
|
+
const runtimeDir = path16.join(prismaClientDir, "runtime");
|
|
14697
|
+
await fs5.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
14698
|
+
await fs5.cp(prismaClientDir, targetClientDir, {
|
|
13860
14699
|
recursive: true,
|
|
13861
|
-
force: true
|
|
14700
|
+
force: true,
|
|
14701
|
+
filter: (source) => path16.dirname(source) !== runtimeDir || !PRISMA_RUNTIME_GENERATE_ONLY_FILE.test(path16.basename(source))
|
|
13862
14702
|
});
|
|
13863
|
-
await
|
|
14703
|
+
await fs5.cp(generatedClientDir, targetGeneratedDir, {
|
|
13864
14704
|
recursive: true,
|
|
13865
14705
|
force: true
|
|
13866
14706
|
});
|
|
13867
|
-
const clientPackagePath =
|
|
14707
|
+
const clientPackagePath = path16.join(prismaClientDir, "package.json");
|
|
13868
14708
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
13869
|
-
readNitroOutputPackage(nitroFuncDir,
|
|
13870
|
-
|
|
14709
|
+
readNitroOutputPackage(nitroFuncDir, fs5),
|
|
14710
|
+
fs5.readFile(clientPackagePath, "utf-8")
|
|
13871
14711
|
]);
|
|
13872
14712
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
13873
14713
|
functionPackage.dependencies = {
|
|
13874
14714
|
...functionPackage.dependencies,
|
|
13875
14715
|
"@prisma/client": clientPackage.version
|
|
13876
14716
|
};
|
|
13877
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14717
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13878
14718
|
}
|
|
13879
14719
|
function islandsActionKeyCode() {
|
|
13880
14720
|
const key = randomBytes(32).toString("base64url");
|
|
@@ -14004,6 +14844,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
14004
14844
|
rendererBuild.signal
|
|
14005
14845
|
);
|
|
14006
14846
|
const farmApp = createFarmApp(config, projectModuleServer);
|
|
14847
|
+
if (options.universal !== false) farmApp.getRouteManager().keepBuildSourceSnapshot();
|
|
14007
14848
|
await farmApp.initialize();
|
|
14008
14849
|
const routeManager = farmApp.getRouteManager();
|
|
14009
14850
|
const serverRenderer = farmApp.getServerRenderer();
|
|
@@ -14050,9 +14891,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
14050
14891
|
} else {
|
|
14051
14892
|
const { build: legacyViteBuild } = await import("vite");
|
|
14052
14893
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
14053
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
14894
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path17.join(root, distDir, "client"));
|
|
14054
14895
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
14055
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
14896
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path17.join(root, distDir, "server"));
|
|
14056
14897
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
14057
14898
|
await buildNitro(
|
|
14058
14899
|
config,
|
|
@@ -14132,7 +14973,10 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14132
14973
|
// resolves as it does in the server build. Module-entry packages load pre-bundled, as in
|
|
14133
14974
|
// `farm dev`: unbundled, lucide-react alone is ~1,750 modules through the module runner,
|
|
14134
14975
|
// which a docs build waited on after its bundles.
|
|
14135
|
-
farmServerOnlyEntriesPlugin({
|
|
14976
|
+
farmServerOnlyEntriesPlugin({
|
|
14977
|
+
prebundleServerPackages: true,
|
|
14978
|
+
distDir: config.distDir || ".farm"
|
|
14979
|
+
})
|
|
14136
14980
|
],
|
|
14137
14981
|
server: {
|
|
14138
14982
|
middlewareMode: true,
|
|
@@ -14154,8 +14998,8 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14154
14998
|
root,
|
|
14155
14999
|
// Vite keys its pre-bundled dependencies on the config, mode included, so this server and
|
|
14156
15000
|
// `farm dev` sharing one cache would each rebuild it after the other ran.
|
|
14157
|
-
cacheDir:
|
|
14158
|
-
|
|
15001
|
+
cacheDir: path17.join(
|
|
15002
|
+
path17.resolve(root, viteConfig.cacheDir ?? path17.join("node_modules", ".vite")),
|
|
14159
15003
|
"farm-build"
|
|
14160
15004
|
),
|
|
14161
15005
|
configFile: false,
|
|
@@ -14194,7 +15038,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14194
15038
|
farmPlugin,
|
|
14195
15039
|
farmServerOnlyEntriesPlugin
|
|
14196
15040
|
} = await import("./vite.mjs");
|
|
14197
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
15041
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
14198
15042
|
const pluginManager = new PluginManager2({
|
|
14199
15043
|
config,
|
|
14200
15044
|
isDev: false,
|
|
@@ -14212,7 +15056,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14212
15056
|
},
|
|
14213
15057
|
plugins: [
|
|
14214
15058
|
farmI18nClientBridgePlugin(),
|
|
14215
|
-
farmServerOnlyEntriesPlugin(),
|
|
15059
|
+
farmServerOnlyEntriesPlugin({ distDir: config.distDir || ".farm" }),
|
|
14216
15060
|
farmIslandContainersPlugin(config),
|
|
14217
15061
|
farmPlugin(config, pluginManager),
|
|
14218
15062
|
farmEnvironmentFunctionsPlugin(config)
|
|
@@ -14222,7 +15066,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14222
15066
|
}
|
|
14223
15067
|
async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
14224
15068
|
const { farmI18nClientBridgePlugin, farmIslandContainersPlugin, farmPlugin } = await import("./vite.mjs");
|
|
14225
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
15069
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
14226
15070
|
const pluginManager = new PluginManager2({
|
|
14227
15071
|
config,
|
|
14228
15072
|
isDev: false,
|
|
@@ -14255,16 +15099,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14255
15099
|
});
|
|
14256
15100
|
}
|
|
14257
15101
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
14258
|
-
const appDir =
|
|
15102
|
+
const appDir = path17.join(root, srcDir, "app");
|
|
14259
15103
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
14260
|
-
const candidate =
|
|
14261
|
-
if (
|
|
15104
|
+
const candidate = path17.join(appDir, `page${extension}`);
|
|
15105
|
+
if (existsSync4(candidate)) return candidate;
|
|
14262
15106
|
}
|
|
14263
|
-
return
|
|
15107
|
+
return path17.join(appDir, "page.tsx");
|
|
14264
15108
|
}
|
|
14265
15109
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
14266
15110
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
14267
|
-
import("./nitro-
|
|
15111
|
+
import("./nitro-RHLKLYXH.mjs"),
|
|
14268
15112
|
import("nitro/builder")
|
|
14269
15113
|
]);
|
|
14270
15114
|
let nitroConfig = await createNitroConfig(
|
|
@@ -14278,23 +15122,23 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14278
15122
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
14279
15123
|
}
|
|
14280
15124
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
14281
|
-
const serverOutputDir =
|
|
14282
|
-
const publicOutputDir =
|
|
15125
|
+
const serverOutputDir = path17.join(outputDir, "server");
|
|
15126
|
+
const publicOutputDir = path17.join(outputDir, "public");
|
|
14283
15127
|
const { mkdir, cp } = await import("fs/promises");
|
|
14284
15128
|
await mkdir(serverOutputDir, { recursive: true });
|
|
14285
15129
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14286
|
-
const clientDir =
|
|
15130
|
+
const clientDir = path17.join(root, distDir, "client");
|
|
14287
15131
|
try {
|
|
14288
15132
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14289
15133
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
14290
15134
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
14291
|
-
const manifestPath =
|
|
14292
|
-
const assetsDir =
|
|
15135
|
+
const manifestPath = path17.join(publicOutputDir, "farm-client-manifest.json");
|
|
15136
|
+
const assetsDir = path17.join(publicOutputDir, "assets");
|
|
14293
15137
|
const manifestExists = await import("fs/promises").then(
|
|
14294
|
-
(
|
|
15138
|
+
(fs5) => fs5.access(manifestPath).then(() => true).catch(() => false)
|
|
14295
15139
|
);
|
|
14296
15140
|
const assetsExist = await import("fs/promises").then(
|
|
14297
|
-
(
|
|
15141
|
+
(fs5) => fs5.access(assetsDir).then(() => true).catch(() => false)
|
|
14298
15142
|
);
|
|
14299
15143
|
if (manifestExists && assetsExist) {
|
|
14300
15144
|
logger.info("\u2705 Verified client assets are present");
|
|
@@ -14305,8 +15149,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14305
15149
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
14306
15150
|
throw error;
|
|
14307
15151
|
}
|
|
14308
|
-
const serverDir =
|
|
14309
|
-
const nitroServerDir =
|
|
15152
|
+
const serverDir = path17.join(root, distDir, "server");
|
|
15153
|
+
const nitroServerDir = path17.join(root, distDir, ".nitro", "server", "farm");
|
|
14310
15154
|
try {
|
|
14311
15155
|
await mkdir(nitroServerDir, { recursive: true });
|
|
14312
15156
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -14315,7 +15159,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14315
15159
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
14316
15160
|
}
|
|
14317
15161
|
const nitro = await createNitro(nitroConfig);
|
|
14318
|
-
const registryPath =
|
|
15162
|
+
const registryPath = path17.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
14319
15163
|
try {
|
|
14320
15164
|
const { farmRegistry } = await import(
|
|
14321
15165
|
/* @vite-ignore */
|
|
@@ -14332,7 +15176,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14332
15176
|
}
|
|
14333
15177
|
farmRegistry.routePaths = routePaths;
|
|
14334
15178
|
try {
|
|
14335
|
-
const clientManifestPath =
|
|
15179
|
+
const clientManifestPath = path17.join(root, distDir, "client", "farm-client-manifest.json");
|
|
14336
15180
|
const { readFile } = await import("fs/promises");
|
|
14337
15181
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
14338
15182
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|