@farm.js/core 0.1.74 → 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-NRIL4JBC.cjs → agent-mcp-handler-73SGWVZT.cjs} +9 -9
- package/dist/{agent-mcp-handler-HX4F4VKN.mjs → agent-mcp-handler-PJKZHYSA.mjs} +8 -8
- package/dist/{agent-mcp.d-CX8_oOT_.d.ts → agent-mcp.d-Djvao5eV.d.ts} +24 -2
- package/dist/{agent-mcp.d-BEhDfdWc.d.mts → agent-mcp.d-wA13pwmS.d.mts} +24 -2
- package/dist/agent-runtime.cjs +7 -7
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +6 -6
- package/dist/analyzer-23GCBYFI.cjs +16 -0
- package/dist/{analyzer-2K35LIQZ.mjs → analyzer-LJHMFCDW.mjs} +2 -2
- package/dist/api/client.cjs +4 -4
- package/dist/api/client.mjs +3 -3
- package/dist/api/client.native.cjs +6 -6
- package/dist/api/client.native.mjs +3 -3
- package/dist/api/node.cjs +12 -12
- package/dist/api/node.d.mts +3 -3
- package/dist/api/node.d.ts +3 -3
- package/dist/api/node.mjs +11 -11
- package/dist/api/route-manager.cjs +20 -20
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/route-manager.mjs +19 -19
- package/dist/api/runtime.cjs +11 -11
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api/runtime.mjs +10 -10
- package/dist/api.cjs +23 -23
- package/dist/api.d.mts +4 -4
- package/dist/api.d.ts +4 -4
- package/dist/api.mjs +22 -22
- package/dist/{app-manifest.d-CVEx1CFB.d.ts → app-manifest.d-BukcP_EV.d.ts} +1 -1
- package/dist/{app-manifest.d-BcXt2yCx.d.mts → app-manifest.d-DIuqSi9k.d.mts} +1 -1
- package/dist/app-markdown.cjs +7 -7
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +6 -6
- package/dist/{app.d-B6i8CSrx.d.ts → app.d-BQqmM6Gy.d.ts} +29 -4
- package/dist/{app.d-DowzSmT5.d.mts → app.d-YVuFb10p.d.mts} +29 -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 +14 -1
- package/dist/cache.d.ts +14 -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-B3XY6FMC.mjs → chunk-2NQ3S2SJ.mjs} +3 -3
- package/dist/chunk-2PJVEL56.cjs +90 -0
- package/dist/{chunk-4M5ESTJ2.cjs → chunk-2RSVYJT6.cjs} +19 -3
- package/dist/{chunk-PG6ZIHKE.cjs → chunk-2YJ4DHTD.cjs} +2 -2
- package/dist/{chunk-MGZVDX4R.mjs → chunk-3AJQFVWW.mjs} +3 -3
- package/dist/{chunk-DRHHTHA3.mjs → chunk-3GMD2E4Q.mjs} +3 -3
- package/dist/{chunk-S3D6SL2V.cjs → chunk-42EUEYW6.cjs} +17 -12
- package/dist/{chunk-D2IAYGYA.mjs → chunk-47R7CX4A.mjs} +6 -6
- package/dist/{chunk-YQWRBBAA.mjs → chunk-4PWGLPL6.mjs} +1 -1
- package/dist/{chunk-7S7AAK2D.mjs → chunk-4QBFYEDC.mjs} +2 -1
- package/dist/{chunk-UHAARKF3.mjs → chunk-4T2RB4JA.mjs} +5 -5
- package/dist/{chunk-KMYOKQPP.cjs → chunk-4VLXQ55O.cjs} +27 -22
- package/dist/{chunk-V6T3UJAH.cjs → chunk-4ZSZI6XL.cjs} +17 -17
- package/dist/{chunk-XGJVRPYL.cjs → chunk-52LTENRE.cjs} +3 -3
- package/dist/{chunk-RQ4UZJPR.cjs → chunk-5AMH6AFA.cjs} +5 -3
- package/dist/{chunk-AYP2YFVN.mjs → chunk-5KAEGBIL.mjs} +75 -42
- package/dist/{chunk-FCBUNILW.mjs → chunk-5O3SK3ZC.mjs} +4 -4
- package/dist/{chunk-IJFNXP3D.cjs → chunk-5QZT2EQN.cjs} +2 -2
- package/dist/{chunk-X2KNHD4B.mjs → chunk-5WFPZG7K.mjs} +8 -8
- package/dist/{chunk-TPDKFRQX.cjs → chunk-62DZHPDK.cjs} +16 -11
- package/dist/{chunk-DTBRSRTR.cjs → chunk-63EFR2WF.cjs} +6 -5
- package/dist/{chunk-2RCCFB2Y.cjs → chunk-6B44ZU5P.cjs} +11 -11
- package/dist/{chunk-ZRCGPSUM.cjs → chunk-6D3CJFNU.cjs} +37 -21
- package/dist/{chunk-65OS2TOT.cjs → chunk-6DBBMQWT.cjs} +34 -34
- package/dist/{chunk-IP2R2TAE.mjs → chunk-6MATGOEF.mjs} +1 -1
- package/dist/{chunk-ACAEFEOH.cjs → chunk-7564NP5Z.cjs} +10 -10
- 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-DRBXYJZ6.mjs → chunk-7FQFK3OA.mjs} +2 -2
- 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-A3LNXQJJ.cjs +265 -0
- package/dist/{chunk-BFOMCSZ2.mjs → chunk-A5F55ZFA.mjs} +184 -27
- 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-R6Q6VSGU.mjs → chunk-BGUTIQII.mjs} +1 -1
- package/dist/{chunk-3OMLZLDE.cjs → chunk-BNCKXPCU.cjs} +44 -0
- package/dist/{chunk-35GBGSQZ.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-BNXV3PRM.mjs → chunk-CF74ABRI.mjs} +10 -10
- package/dist/chunk-CIY74JLV.cjs +134 -0
- package/dist/{chunk-IZ5WOTQP.mjs → chunk-CLM73YYD.mjs} +2 -2
- package/dist/{chunk-FGXSWRWA.mjs → chunk-CSAIIMY3.mjs} +1 -1
- package/dist/{chunk-EF5AP4CV.cjs → chunk-CYNQPKA4.cjs} +2 -2
- package/dist/{chunk-M53MIIXY.mjs → chunk-CZOXZ6WQ.mjs} +1 -1
- package/dist/{chunk-ROPMQNCG.mjs → chunk-DASQJ5UD.mjs} +2 -2
- package/dist/{chunk-BWFBTTJ5.cjs → chunk-DD22NQFX.cjs} +2 -2
- package/dist/{chunk-AL6E63FZ.mjs → chunk-DUSTJ6A5.mjs} +20 -17
- package/dist/{chunk-EWIEJQP6.cjs → chunk-DZ3AZ7UK.cjs} +52 -52
- package/dist/{chunk-6YFC3ZFX.mjs → chunk-DZXD6CYJ.mjs} +1 -1
- package/dist/{chunk-Q4G52OSW.mjs → chunk-EMTN5ABC.mjs} +1 -1
- package/dist/{chunk-GK2GBIXD.mjs → chunk-ERT6HQAI.mjs} +8 -3
- package/dist/{chunk-ZLRWO5GK.mjs → chunk-F35C3TJZ.mjs} +1 -1
- package/dist/{chunk-F244KE2D.cjs → chunk-F4ID7BGO.cjs} +33 -30
- package/dist/{chunk-C7GJDVN4.mjs → chunk-F7MJWW6A.mjs} +1 -1
- package/dist/{chunk-WTTJ2YS2.mjs → chunk-FCAYYLAE.mjs} +18 -2
- 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-GRHSQYD4.cjs → chunk-G7B6NU4X.cjs} +11 -11
- package/dist/{chunk-E4T7WJJN.mjs → chunk-GAAK3HDZ.mjs} +28 -7
- package/dist/{chunk-QMNWKQL4.cjs → chunk-GC5ROI3A.cjs} +4 -4
- package/dist/{chunk-JXIYH2NO.cjs → chunk-GCJ4GNMC.cjs} +4 -4
- package/dist/{chunk-KNEYWPZV.mjs → chunk-GFXKO4UW.mjs} +42 -10
- package/dist/{chunk-AU5UPNOD.mjs → chunk-GLF44JKY.mjs} +3 -3
- package/dist/{chunk-GUZC226X.mjs → chunk-GLVDXRG2.mjs} +1 -1
- package/dist/{chunk-FEQ72ZHD.mjs → chunk-GNY7BO7R.mjs} +6 -6
- package/dist/{chunk-OWQV6MLM.cjs → chunk-GYJT2U7J.cjs} +2 -1
- package/dist/{chunk-XZPI44Q7.cjs → chunk-H7OFZJCV.cjs} +8 -8
- package/dist/{chunk-IG4IQMIW.mjs → chunk-H7QY7ZE4.mjs} +1 -1
- package/dist/{chunk-2TZ3F6TN.cjs → chunk-HFJLMALC.cjs} +25 -25
- package/dist/{chunk-CROAFCMW.mjs → chunk-HONTCUK6.mjs} +1 -1
- package/dist/{chunk-7PJARAQQ.mjs → chunk-HQ2VAJLW.mjs} +1 -1
- package/dist/{chunk-LHFGTR7F.mjs → chunk-HT2SZKXG.mjs} +92 -10
- package/dist/{chunk-6JEXH7N6.mjs → chunk-HV2WZFUW.mjs} +1 -1
- package/dist/{chunk-ENYBDM4U.cjs → chunk-HVJ7IACB.cjs} +15 -7
- package/dist/{chunk-WS4SLJW5.mjs → chunk-IDOUCM2X.mjs} +142 -170
- package/dist/{chunk-FN5UEC7I.mjs → chunk-IG2JE6WJ.mjs} +1 -1
- package/dist/{chunk-MQ4DYVFS.cjs → chunk-IIHZ2BEE.cjs} +3 -3
- package/dist/{chunk-56HHUSR5.cjs → chunk-IK33N2AN.cjs} +1281 -685
- package/dist/{chunk-RSL3YFJG.cjs → chunk-IVBDRAOR.cjs} +1 -1
- package/dist/{chunk-FNWL5DMG.cjs → chunk-IXO6O2EL.cjs} +6 -6
- package/dist/{chunk-B5WZP3T3.cjs → chunk-IYFBLWXU.cjs} +41 -23
- package/dist/{chunk-R4BWNP73.mjs → chunk-JA6RML7C.mjs} +3 -3
- package/dist/{chunk-JSUVQ5HG.cjs → chunk-JHZ6HULQ.cjs} +12 -9
- package/dist/{chunk-NXGQIXR7.cjs → chunk-JNZDTE75.cjs} +313 -156
- package/dist/{chunk-KWUZJZ23.mjs → chunk-JRBWBMP2.mjs} +4 -3
- package/dist/{chunk-YH33PZ3K.mjs → chunk-K6DXKHFE.mjs} +1 -1
- package/dist/{chunk-AXVRUDMB.cjs → chunk-K6PGK7DC.cjs} +2 -2
- package/dist/{chunk-72NTEYCX.mjs → chunk-KHS3T3E5.mjs} +15 -10
- package/dist/{chunk-D4TYE6MY.cjs → chunk-KPYQ32BA.cjs} +2 -2
- package/dist/{chunk-J42QN7OC.cjs → chunk-KQS27YN7.cjs} +6 -6
- package/dist/{chunk-KUMKBBYP.mjs → chunk-KUXEII7V.mjs} +1 -1
- package/dist/{chunk-CA7DNRHO.cjs → chunk-L6E5BSNU.cjs} +3 -3
- package/dist/{chunk-47ZDUDN5.cjs → chunk-L7Y65BQU.cjs} +64 -32
- package/dist/{chunk-OSKIG4OP.mjs → chunk-LPXJEZJK.mjs} +30 -14
- package/dist/{chunk-CF77L6RL.mjs → chunk-LQBV2Y37.mjs} +4 -4
- package/dist/{chunk-HK4VJI27.cjs → chunk-LQWIIBI2.cjs} +11 -1
- package/dist/{chunk-BIX46FTI.mjs → chunk-MFU7SXAB.mjs} +10 -2
- package/dist/{chunk-YTVSWXEZ.cjs → chunk-ML4TOUZP.cjs} +76 -43
- package/dist/{chunk-ZD7JUTBY.mjs → chunk-NLATR3T3.mjs} +2 -2
- package/dist/{chunk-P3EZKU6L.cjs → chunk-NPGXX7HN.cjs} +37 -37
- package/dist/{chunk-3BUJIPKE.cjs → chunk-NSNQLBHR.cjs} +2 -2
- 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-JI6N4W2I.mjs → chunk-OFIFRB62.mjs} +813 -217
- package/dist/{chunk-CXQZQK6R.mjs → chunk-OVUU2RCQ.mjs} +2 -2
- package/dist/{chunk-Q3MVNRAO.cjs → chunk-OZARLCYQ.cjs} +1005 -582
- package/dist/{chunk-HBLYSWIJ.cjs → chunk-PBJ7MEOV.cjs} +9 -9
- package/dist/{chunk-4AB62NMW.cjs → chunk-PBQGIA27.cjs} +2 -2
- package/dist/{chunk-RBRIKT6B.mjs → chunk-PDACTAVX.mjs} +3 -3
- package/dist/{chunk-AO5IRA2N.mjs → chunk-PE2LEWXA.mjs} +6 -3
- package/dist/{chunk-VZKCGHWC.cjs → chunk-PG7J7XYT.cjs} +6 -6
- package/dist/{chunk-MMK4MZUN.mjs → chunk-PKXGFQZS.mjs} +1 -1
- package/dist/{chunk-NKETXVKP.mjs → chunk-PL7MCYYD.mjs} +32 -14
- package/dist/chunk-PWHF2C6A.mjs +134 -0
- package/dist/{chunk-JWHRVBCZ.cjs → chunk-Q2EKSSEG.cjs} +21 -21
- package/dist/{chunk-EHJOSIXM.cjs → chunk-QDHR54S6.cjs} +11 -11
- package/dist/{chunk-YWDRWG4L.mjs → chunk-QGYHE6VJ.mjs} +872 -449
- package/dist/{chunk-ZOYKJBP5.cjs → chunk-QKW6DLDT.cjs} +2 -2
- package/dist/{chunk-3ODLJRA6.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-VKLV7GF4.mjs → chunk-R5X7FDOG.mjs} +1 -1
- package/dist/{chunk-O47W53D3.cjs → chunk-RDADQG5S.cjs} +7 -77
- package/dist/chunk-RDSHEHBA.mjs +82 -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-MUITBU5Z.mjs → chunk-S7QEQCVV.mjs} +2 -2
- package/dist/{chunk-HKZVC5GP.cjs → chunk-SFSTZ7TB.cjs} +8 -8
- package/dist/{chunk-ZZGANFQH.cjs → chunk-SX535SU5.cjs} +12 -12
- package/dist/{chunk-NLBK37HI.cjs → chunk-SXXSQVKK.cjs} +4 -4
- package/dist/{chunk-ELJQWUAR.mjs → chunk-SYPEMXW2.mjs} +2 -2
- package/dist/{chunk-XXKMAHYE.mjs → chunk-TFEODQLG.mjs} +1 -1
- package/dist/{chunk-BSJMWCWM.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-UNOXV37V.cjs +55 -0
- package/dist/{chunk-H2ZJ35NW.mjs → chunk-UOE6ZZZP.mjs} +1 -1
- package/dist/{chunk-O6K4G7YA.mjs → chunk-URQW27KO.mjs} +10 -5
- package/dist/chunk-VDQZV6BX.mjs +17 -0
- package/dist/{chunk-2DOI6HLJ.cjs → chunk-VJ6L7TII.cjs} +3 -3
- package/dist/{chunk-QL3YZTGZ.cjs → chunk-VJI2LWTL.cjs} +2 -2
- package/dist/{chunk-7RKHXF4P.mjs → chunk-WGNGM6MJ.mjs} +2 -2
- package/dist/{chunk-77SVUQM5.cjs → chunk-WHCNJVYU.cjs} +10 -10
- package/dist/{chunk-DM2YGTRH.cjs → chunk-WJ5CCQBM.cjs} +23 -23
- package/dist/chunk-WKVYF2B5.cjs +17 -0
- package/dist/{chunk-MKQ27TGW.cjs → chunk-WRWJ7IWT.cjs} +7 -7
- package/dist/{chunk-Y4FEQBKY.cjs → chunk-WW62HKA2.cjs} +47 -26
- package/dist/{chunk-XVSBALOY.cjs → chunk-X3Y6JWJG.cjs} +3 -3
- package/dist/{chunk-O2A6HE76.cjs → chunk-XGDI4OUB.cjs} +103 -21
- package/dist/{chunk-LIQJYEQP.cjs → chunk-XRFGOYXG.cjs} +4 -4
- 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-JZ43UD6S.mjs → chunk-YCNKS6SD.mjs} +12 -12
- package/dist/{chunk-FYV6DTAG.cjs → chunk-YL7BKHYE.cjs} +538 -566
- package/dist/{chunk-G7S6XG6X.cjs → chunk-YN7G22MP.cjs} +6 -6
- package/dist/{chunk-VKRMO3EZ.cjs → chunk-YRXPDKMM.cjs} +10 -10
- package/dist/{chunk-VFPFXMTF.mjs → chunk-YSTKSZD2.mjs} +1 -1
- package/dist/{chunk-QDWMCFTH.mjs → chunk-YT2ZMLXK.mjs} +1 -1
- package/dist/{chunk-EMRYJG4U.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-MQ5HA7H2.mjs → chunk-Z2FFLTF5.mjs} +3 -3
- package/dist/{chunk-JSDV2NUN.mjs → chunk-Z3QXQN4U.mjs} +1 -1
- package/dist/{chunk-HRQV5Q3J.mjs → chunk-Z4IRG4RG.mjs} +96 -9
- package/dist/{chunk-JOECBGY7.mjs → chunk-ZEWWZJPZ.mjs} +3 -1
- package/dist/{chunk-2GQBBOFH.mjs → chunk-ZIAWO6BC.mjs} +11 -1
- package/dist/{chunk-WH3PBJS7.cjs → chunk-ZIOFRBIU.cjs} +100 -13
- package/dist/{chunk-3OJNNCDL.cjs → chunk-ZNXU4E6A.cjs} +8 -8
- package/dist/{chunk-KIRIFO6T.mjs → chunk-ZO6TOLHL.mjs} +44 -0
- package/dist/{chunk-737MIVX3.cjs → chunk-ZPCZWEU3.cjs} +24 -24
- package/dist/{chunk-NET6PBUH.cjs → chunk-ZV76IQG7.cjs} +2 -2
- package/dist/{client-component.d-edV76QvU.d.mts → client-component.d-BeqVuqy2.d.mts} +2 -2
- package/dist/{client-component.d-DYOwmq0c.d.ts → client-component.d-CZ1NpHAY.d.ts} +2 -2
- package/dist/{client-plugins.d-DwvqqGsU.d.mts → client-plugins.d-ChceYO9t.d.mts} +24 -3
- package/dist/{client-plugins.d-BmJYW2FY.d.ts → client-plugins.d-D9kWC0QB.d.ts} +24 -3
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +15 -13
- package/dist/client.d.mts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.mjs +14 -12
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/cron.cjs +4 -4
- package/dist/cron.mjs +3 -3
- package/dist/desktop.d.mts +2 -2
- package/dist/desktop.d.ts +2 -2
- package/dist/{devtools-WPX62NG2.mjs → devtools-B3W3DLPG.mjs} +18 -18
- package/dist/{devtools-YMDS7PUA.cjs → devtools-T5I2WHRX.cjs} +20 -20
- package/dist/docs.cjs +27 -21
- package/dist/docs.d.mts +17 -3
- package/dist/docs.d.ts +17 -3
- package/dist/docs.mjs +26 -20
- package/dist/environment/vite.cjs +6 -6
- package/dist/environment/vite.mjs +5 -5
- package/dist/headers.cjs +3 -3
- package/dist/{headers.d-BIbQyAxJ.d.ts → headers.d-Aux4JVnm.d.ts} +1 -1
- package/dist/{headers.d-BtNxFc2s.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 +99 -93
- package/dist/{index.d-CQdDRXd1.d.mts → index.d-Ccq42CPU.d.mts} +1 -1
- package/dist/{index.d-CQ_wUzOV.d.ts → index.d-r1MLpgeE.d.ts} +1 -1
- package/dist/index.d.mts +19 -19
- package/dist/index.d.ts +19 -19
- package/dist/index.mjs +96 -90
- package/dist/integrations/orm.d.mts +1 -1
- package/dist/integrations/orm.d.ts +1 -1
- package/dist/integrations.cjs +7 -7
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +6 -6
- package/dist/internal/app-markdown-runtime.cjs +6 -6
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +5 -5
- package/dist/internal/build-runtime.cjs +68 -66
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +67 -65
- package/dist/internal/cli-runtime.cjs +33 -33
- package/dist/internal/cli-runtime.mjs +32 -32
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +23 -2
- package/dist/internal/client-runtime.d.mts +29 -8
- package/dist/internal/client-runtime.d.ts +29 -8
- package/dist/internal/client-runtime.mjs +23 -2
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +20 -20
- package/dist/internal/config-runtime.d.mts +3 -3
- package/dist/internal/config-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.mjs +19 -19
- package/dist/internal/form-actions.cjs +6 -6
- package/dist/internal/form-actions.mjs +5 -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 +63 -40
- package/dist/internal/production-runtime.d.mts +80 -13
- package/dist/internal/production-runtime.d.ts +80 -13
- package/dist/internal/production-runtime.mjs +66 -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/manager-R7FV4A56.cjs +18 -0
- package/dist/{manager-RHB2P35B.mjs → manager-YO2RHDYU.mjs} +5 -5
- package/dist/markdown.cjs +5 -5
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +4 -4
- package/dist/middleware.cjs +14 -14
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.mjs +13 -13
- package/dist/{mount.d-6bhpBQQB.d.mts → mount.d-BomEt2kV.d.mts} +1 -1
- package/dist/{mount.d-C-u7rFkM.d.ts → mount.d-Ca8eb9GB.d.ts} +1 -1
- package/dist/{native-server-fn-handler-W4FSD76W.cjs → native-server-fn-handler-IWNKQEXK.cjs} +9 -8
- package/dist/{native-server-fn-handler-I66X4E5S.mjs → native-server-fn-handler-LII4MDRR.mjs} +8 -7
- package/dist/native-tree-D3PW64ZL.cjs +28 -0
- package/dist/{native-tree-3X23BT3N.mjs → native-tree-G6ZWS7IR.mjs} +5 -5
- package/dist/{navigation-delegate.d-nx6gtsY4.d.mts → navigation-delegate.d-B1ujRkYo.d.mts} +1 -1
- package/dist/{navigation-delegate.d-xsG4T1x-.d.ts → navigation-delegate.d-DJCC2jXF.d.ts} +1 -1
- package/dist/navigation.cjs +13 -11
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +12 -10
- package/dist/{nitro-SSFTPZMW.cjs → nitro-HKMVYIXY.cjs} +13 -13
- package/dist/{nitro-XTQ2HKDL.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 +62 -60
- package/dist/plugin.d.mts +4 -4
- package/dist/plugin.d.ts +4 -4
- package/dist/plugin.mjs +61 -59
- package/dist/query/client.cjs +20 -9
- package/dist/query/client.mjs +16 -5
- package/dist/{render-plan.d-gW0fwKz2.d.ts → render-plan.d-BxRbaxYA.d.ts} +1 -1
- package/dist/{render-plan.d-B5y3h97B.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 +4 -4
- package/dist/renderer-client.d.ts +4 -4
- package/dist/renderer-client.mjs +15 -16
- package/dist/request.cjs +2 -2
- package/dist/{request.d-B0ugAadD.d.ts → request.d-DG4TeXMM.d.mts} +7 -2
- package/dist/{request.d-DLq33nYo.d.mts → request.d-DRQgaXGG.d.ts} +7 -2
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering.d-DSeIV7yV.d.mts → route-rendering.d-BXtZKgqu.d.mts} +1 -1
- package/dist/{route-rendering.d-ytaqDQD6.d.ts → route-rendering.d-Db07UNVG.d.ts} +1 -1
- package/dist/router.cjs +4 -4
- package/dist/{router.d-Chd5cpe3.d.mts → router.d-B61kXqxJ.d.mts} +1 -1
- package/dist/{router.d-BaEAEGPg.d.ts → router.d-BC3hyjf0.d.ts} +1 -1
- package/dist/router.mjs +3 -3
- package/dist/routes.cjs +6 -6
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.mjs +5 -5
- package/dist/{rsc-pipeline-DPMYONEV.mjs → rsc-pipeline-LJ7YCGY6.mjs} +22 -22
- package/dist/{rsc-pipeline-XIUUMMG5.cjs → rsc-pipeline-VENBFYXW.cjs} +23 -23
- package/dist/{runtime-XIUJZTZ3.mjs → runtime-4DWUXZHS.mjs} +27 -27
- package/dist/{runtime-WD77S3C5.cjs → runtime-UNDTYGQS.cjs} +38 -38
- package/dist/{runtime.d-DpCs0eAO.d.mts → runtime.d-Cl6EBGmC.d.mts} +1 -1
- package/dist/{runtime.d-h2USyQsz.d.ts → runtime.d-SC95yDzr.d.ts} +1 -1
- 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 +5 -5
- package/dist/server-action-security.mjs +4 -4
- package/dist/server-fn.cjs +8 -7
- package/dist/server-fn.mjs +7 -6
- package/dist/server-plugins.cjs +7 -7
- package/dist/server-plugins.d.mts +3 -3
- package/dist/server-plugins.d.ts +3 -3
- package/dist/server-plugins.mjs +6 -6
- package/dist/server-query.cjs +9 -8
- package/dist/server-query.mjs +8 -7
- package/dist/server.cjs +101 -94
- package/dist/server.d.mts +13 -13
- package/dist/server.d.ts +13 -13
- package/dist/server.mjs +74 -67
- package/dist/{spa-router.d-DCQVtEaE.d.mts → spa-router.d-DrlXgDqY.d.mts} +4 -3
- package/dist/{spa-router.d-DpdJHs1q.d.ts → spa-router.d-DwM02Mwd.d.ts} +4 -3
- package/dist/testing.cjs +31 -31
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +23 -23
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-DmicwMvS.d.ts → utils.d-C6KXz3uB.d.ts} +1 -1
- package/dist/{utils.d-DKDZtAY5.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 +62 -60
- package/dist/vite.d.mts +10 -5
- package/dist/vite.d.ts +10 -5
- package/dist/vite.mjs +61 -59
- package/dist/workflows.cjs +7 -7
- package/dist/workflows.mjs +6 -6
- package/package.json +18 -1
- package/dist/analyzer-6EOYURMV.cjs +0 -16
- package/dist/chunk-D4XGKF67.cjs +0 -127
- 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-S77ZARTC.cjs +0 -18
- package/dist/native-tree-TAPKR7QJ.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-6JEXH7N6.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,13 +114,16 @@ 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";
|
|
@@ -124,7 +132,7 @@ import {
|
|
|
124
132
|
readRouteRenderingDirectiveFromFile,
|
|
125
133
|
resolveRouteRenderingConfig,
|
|
126
134
|
resolveRouteRenderingConfigFromFile
|
|
127
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-LQBV2Y37.mjs";
|
|
128
136
|
import {
|
|
129
137
|
HOISTED_HEAD_ELEMENT,
|
|
130
138
|
appMiddlewareMayHandlePath,
|
|
@@ -137,7 +145,7 @@ import {
|
|
|
137
145
|
layoutsCanCoverSamePage,
|
|
138
146
|
routeBoundaryCoversDirectory,
|
|
139
147
|
stripRouteGroups
|
|
140
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-HT2SZKXG.mjs";
|
|
141
149
|
import {
|
|
142
150
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
143
151
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -151,15 +159,15 @@ import {
|
|
|
151
159
|
listFarmBuiltInRoutePaths,
|
|
152
160
|
resolveFarmApiCatalogInput,
|
|
153
161
|
resolveFarmAppManifestInput
|
|
154
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-GNY7BO7R.mjs";
|
|
155
163
|
import {
|
|
156
164
|
FARM_DEFAULT_MCP_PATH,
|
|
157
165
|
createFarmDefaultMCPServer,
|
|
158
166
|
farmConfigMountsMCP
|
|
159
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-JA6RML7C.mjs";
|
|
160
168
|
import {
|
|
161
169
|
isFarmPreviewDeploymentEnvironment
|
|
162
|
-
} from "./chunk-
|
|
170
|
+
} from "./chunk-YSTKSZD2.mjs";
|
|
163
171
|
import {
|
|
164
172
|
FARM_NATIVE_SERVER_FN_PLUGIN
|
|
165
173
|
} from "./chunk-L4RTTTVE.mjs";
|
|
@@ -180,7 +188,7 @@ import {
|
|
|
180
188
|
withFarmSourceSnapshot,
|
|
181
189
|
withFarmSourceSnapshotOf,
|
|
182
190
|
withPackageClientBoundaryCache
|
|
183
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-A5F55ZFA.mjs";
|
|
184
192
|
import {
|
|
185
193
|
generateFarmDocsAdapterClientRuntime,
|
|
186
194
|
getFarmDocsAdapterConfigModule
|
|
@@ -192,7 +200,7 @@ import {
|
|
|
192
200
|
import {
|
|
193
201
|
nitroRouteRulesBelowBasePath,
|
|
194
202
|
routeRulesToNitroRouteRules
|
|
195
|
-
} from "./chunk-
|
|
203
|
+
} from "./chunk-YVVY276M.mjs";
|
|
196
204
|
import {
|
|
197
205
|
applyFarmCspHashesToHtml,
|
|
198
206
|
createFarmCspNonce
|
|
@@ -219,10 +227,10 @@ import {
|
|
|
219
227
|
mergeScheduledTasks,
|
|
220
228
|
prepareFarmCronForNitro,
|
|
221
229
|
toFarmCronCloudflareScheduledTasks
|
|
222
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-CSAIIMY3.mjs";
|
|
223
231
|
import {
|
|
224
232
|
resolveServerActionsConfig
|
|
225
|
-
} from "./chunk-
|
|
233
|
+
} from "./chunk-NLATR3T3.mjs";
|
|
226
234
|
import {
|
|
227
235
|
createBundledEnv
|
|
228
236
|
} from "./chunk-N33DLJBC.mjs";
|
|
@@ -231,28 +239,28 @@ import {
|
|
|
231
239
|
isFarmMarkdownPageFile,
|
|
232
240
|
parseMarkdownFrontmatter,
|
|
233
241
|
readFarmMarkdownRouteConfig
|
|
234
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-BGUTIQII.mjs";
|
|
235
243
|
import {
|
|
236
244
|
resolveFarmMdxComponentsModulePath,
|
|
237
245
|
resolveMdxConfig
|
|
238
246
|
} from "./chunk-UIJOLBUL.mjs";
|
|
239
247
|
import {
|
|
240
248
|
getFarmMarkdownAlternatePath
|
|
241
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-R5X7FDOG.mjs";
|
|
242
250
|
import {
|
|
243
251
|
withPlainDiagnostics
|
|
244
252
|
} from "./chunk-MGKWYPE3.mjs";
|
|
245
253
|
import {
|
|
246
254
|
applyFarmWorkflowVercelCrons,
|
|
247
255
|
prepareFarmWorkflowsForNitro
|
|
248
|
-
} from "./chunk-
|
|
256
|
+
} from "./chunk-3AJQFVWW.mjs";
|
|
249
257
|
import {
|
|
250
258
|
getFarmIntegrationPluginServerRuntime,
|
|
251
259
|
getIntegrationProviders
|
|
252
|
-
} from "./chunk-
|
|
260
|
+
} from "./chunk-5O3SK3ZC.mjs";
|
|
253
261
|
import {
|
|
254
262
|
FARM_INTEGRATION_API_BASE_PATH_KEY
|
|
255
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-CZOXZ6WQ.mjs";
|
|
256
264
|
import {
|
|
257
265
|
_collectFarmStorageModules
|
|
258
266
|
} from "./chunk-TJVUTGED.mjs";
|
|
@@ -260,10 +268,10 @@ import {
|
|
|
260
268
|
appendMiddlewareDirectory,
|
|
261
269
|
appendMiddlewareRoutePath,
|
|
262
270
|
compareMiddlewareRouteLocations
|
|
263
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-PKXGFQZS.mjs";
|
|
264
272
|
import {
|
|
265
273
|
APIRouteManager
|
|
266
|
-
} from "./chunk-
|
|
274
|
+
} from "./chunk-5WFPZG7K.mjs";
|
|
267
275
|
import {
|
|
268
276
|
readFarmI18nCatalogs
|
|
269
277
|
} from "./chunk-VO55MMBX.mjs";
|
|
@@ -284,14 +292,17 @@ import {
|
|
|
284
292
|
logger,
|
|
285
293
|
toPosixPath,
|
|
286
294
|
toViteModuleId
|
|
287
|
-
} from "./chunk-
|
|
295
|
+
} from "./chunk-Z3QXQN4U.mjs";
|
|
288
296
|
import {
|
|
289
297
|
resolveFarmAPIServerBasePath,
|
|
290
298
|
resolveFarmAPIServerRoutePath
|
|
291
299
|
} from "./chunk-2I6PUKWJ.mjs";
|
|
292
300
|
import {
|
|
293
301
|
FARM_VERSION
|
|
294
|
-
} from "./chunk-
|
|
302
|
+
} from "./chunk-H7QY7ZE4.mjs";
|
|
303
|
+
import {
|
|
304
|
+
FARM_VIDEO_PLAYER_PATH
|
|
305
|
+
} from "./chunk-AG27TI6Q.mjs";
|
|
295
306
|
import {
|
|
296
307
|
getFarmPresetRuntime,
|
|
297
308
|
resolveCloudflareProcessEnvFlags
|
|
@@ -301,7 +312,7 @@ import {
|
|
|
301
312
|
} from "./chunk-4O26BPUY.mjs";
|
|
302
313
|
import {
|
|
303
314
|
_runWithFarmCspNonce
|
|
304
|
-
} from "./chunk-
|
|
315
|
+
} from "./chunk-FCAYYLAE.mjs";
|
|
305
316
|
import {
|
|
306
317
|
applyFarmBasePath,
|
|
307
318
|
normalizeFarmBasePath,
|
|
@@ -310,18 +321,182 @@ import {
|
|
|
310
321
|
import {
|
|
311
322
|
compareRoutePatternSpecificity,
|
|
312
323
|
compareRouteSpecificity,
|
|
324
|
+
getRoutePatternShape,
|
|
313
325
|
getRoutePatternSpecificity
|
|
314
|
-
} from "./chunk-
|
|
326
|
+
} from "./chunk-5KAEGBIL.mjs";
|
|
315
327
|
|
|
316
328
|
// src/build/index.ts
|
|
317
|
-
import
|
|
329
|
+
import path17 from "path";
|
|
318
330
|
import { existsSync as existsSync4 } from "fs";
|
|
319
331
|
|
|
320
332
|
// src/nitro/universal-build.ts
|
|
321
333
|
import { randomBytes } from "crypto";
|
|
322
334
|
|
|
323
|
-
// src/nitro/
|
|
335
|
+
// src/nitro/static-range.ts
|
|
336
|
+
import { readFileSync, realpathSync } from "fs";
|
|
324
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";
|
|
325
500
|
var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
326
501
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
327
502
|
var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
|
|
@@ -334,7 +509,7 @@ async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
|
334
509
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
335
510
|
const name = hashedName(hash);
|
|
336
511
|
await fs5.mkdir(destinationDir, { recursive: true });
|
|
337
|
-
await fs5.writeFile(
|
|
512
|
+
await fs5.writeFile(path2.join(destinationDir, name), bytes);
|
|
338
513
|
return name;
|
|
339
514
|
} catch {
|
|
340
515
|
return null;
|
|
@@ -342,8 +517,8 @@ async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
|
342
517
|
}
|
|
343
518
|
async function resolveHashedClientCssHref(clientOutputDir) {
|
|
344
519
|
const name = await hashAndCopy(
|
|
345
|
-
|
|
346
|
-
|
|
520
|
+
path2.join(clientOutputDir, "farm-client.css"),
|
|
521
|
+
path2.join(clientOutputDir, "assets"),
|
|
347
522
|
(hash) => `farm-client-h${hash}.css`
|
|
348
523
|
);
|
|
349
524
|
return name ? `/assets/${name}` : "/farm-client.css";
|
|
@@ -373,21 +548,21 @@ async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
|
373
548
|
const fs5 = await import("fs/promises");
|
|
374
549
|
const shim = `export * from "./${entryName}";
|
|
375
550
|
`;
|
|
376
|
-
await fs5.writeFile(
|
|
551
|
+
await fs5.writeFile(path2.join(clientOutputDir, "farm-client.js"), shim);
|
|
377
552
|
return `/${entryName}`;
|
|
378
553
|
}
|
|
379
554
|
|
|
380
555
|
// src/nitro/universal-build.ts
|
|
381
556
|
import os from "os";
|
|
382
|
-
import
|
|
383
|
-
import { constants as fsConstants, existsSync as existsSync3, readFileSync, realpathSync as
|
|
557
|
+
import path16 from "path";
|
|
558
|
+
import { constants as fsConstants, existsSync as existsSync3, readFileSync as readFileSync2, realpathSync as realpathSync3, statSync } from "fs";
|
|
384
559
|
import { initSync as initModuleLexer, parse as lexModule } from "es-module-lexer";
|
|
385
560
|
import { fileURLToPath } from "url";
|
|
386
561
|
import { builtinModules, createRequire as createRequire2 } from "module";
|
|
387
562
|
import { isDeepStrictEqual } from "util";
|
|
388
563
|
|
|
389
564
|
// src/docs/compiler.ts
|
|
390
|
-
import
|
|
565
|
+
import path3 from "path";
|
|
391
566
|
var FARM_DOCS_COMPILED_ORIGIN = "https://farm-docs-build.invalid";
|
|
392
567
|
function normalizePathname(pathname) {
|
|
393
568
|
if (pathname === "/") return pathname;
|
|
@@ -450,8 +625,8 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
450
625
|
const pages = loadPages(contentDir, docs);
|
|
451
626
|
const basePath = normalizeFarmBasePath(options.basePath);
|
|
452
627
|
const absolutePaths = [
|
|
453
|
-
|
|
454
|
-
|
|
628
|
+
path3.resolve(options.root),
|
|
629
|
+
path3.resolve(contentDir),
|
|
455
630
|
docs.configPath || ""
|
|
456
631
|
];
|
|
457
632
|
const handler = createFarmDocsHandler(docs, {
|
|
@@ -574,7 +749,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
574
749
|
|
|
575
750
|
// src/nitro/client-module-preloads.ts
|
|
576
751
|
import fs from "fs/promises";
|
|
577
|
-
import
|
|
752
|
+
import path4 from "path";
|
|
578
753
|
var FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER = "__farm_client_module_preloads__";
|
|
579
754
|
var FARM_CLIENT_MODULE_PRELOADS_FILE = "client-module-preloads.json";
|
|
580
755
|
function collectFarmClientModulePreloads(bundle, options) {
|
|
@@ -612,7 +787,7 @@ function collectFarmClientModulePreloads(bundle, options) {
|
|
|
612
787
|
continue;
|
|
613
788
|
}
|
|
614
789
|
const moduleId = chunk.facadeModuleId.split("?")[0];
|
|
615
|
-
if (!
|
|
790
|
+
if (!path4.isAbsolute(moduleId)) continue;
|
|
616
791
|
const loaded = /* @__PURE__ */ new Set([...entryLoaded, chunk.fileName]);
|
|
617
792
|
modules[toViteModuleId(moduleId, options.root)] = [
|
|
618
793
|
chunk.fileName,
|
|
@@ -628,7 +803,7 @@ function createFarmClientModulePreloadPlugin(options) {
|
|
|
628
803
|
async generateBundle(_output, bundle) {
|
|
629
804
|
await fs.mkdir(options.buildDir, { recursive: true });
|
|
630
805
|
await fs.writeFile(
|
|
631
|
-
|
|
806
|
+
path4.join(options.buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE),
|
|
632
807
|
JSON.stringify(collectFarmClientModulePreloads(bundle, options))
|
|
633
808
|
);
|
|
634
809
|
}
|
|
@@ -637,7 +812,7 @@ function createFarmClientModulePreloadPlugin(options) {
|
|
|
637
812
|
async function readFarmClientModulePreloads(buildDir) {
|
|
638
813
|
try {
|
|
639
814
|
return JSON.parse(
|
|
640
|
-
await fs.readFile(
|
|
815
|
+
await fs.readFile(path4.join(buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE), "utf8")
|
|
641
816
|
);
|
|
642
817
|
} catch {
|
|
643
818
|
return null;
|
|
@@ -652,7 +827,7 @@ function encodeFarmBuildJSONPlaceholder(value) {
|
|
|
652
827
|
|
|
653
828
|
// src/nitro/client-route-table.ts
|
|
654
829
|
import fs2 from "fs/promises";
|
|
655
|
-
import
|
|
830
|
+
import path5 from "path";
|
|
656
831
|
var FARM_CLIENT_ROUTE_TABLE_MODULE = "farm-client-routes";
|
|
657
832
|
var FARM_CLIENT_ROUTE_TABLE_FILE = "client-route-table.json";
|
|
658
833
|
var FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER = "__farm_client_route_table__";
|
|
@@ -668,18 +843,52 @@ function createFarmClientRouteTable(clientPages) {
|
|
|
668
843
|
...page.pageShouldHydrate ? { loader: loaders++ } : {}
|
|
669
844
|
}));
|
|
670
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
|
+
}
|
|
671
880
|
function generateFarmClientRouteTableModule(table) {
|
|
672
881
|
return `export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
|
|
673
882
|
`;
|
|
674
883
|
}
|
|
675
884
|
async function writeFarmClientRouteTable(buildDir, table) {
|
|
676
885
|
await fs2.mkdir(buildDir, { recursive: true });
|
|
677
|
-
await fs2.writeFile(
|
|
886
|
+
await fs2.writeFile(path5.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), JSON.stringify(table));
|
|
678
887
|
}
|
|
679
888
|
async function readFarmClientRouteTable(buildDir) {
|
|
680
889
|
try {
|
|
681
890
|
return JSON.parse(
|
|
682
|
-
await fs2.readFile(
|
|
891
|
+
await fs2.readFile(path5.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), "utf8")
|
|
683
892
|
);
|
|
684
893
|
} catch {
|
|
685
894
|
return null;
|
|
@@ -688,7 +897,7 @@ async function readFarmClientRouteTable(buildDir) {
|
|
|
688
897
|
|
|
689
898
|
// src/docs/module-preloads.ts
|
|
690
899
|
import fs3 from "fs/promises";
|
|
691
|
-
import
|
|
900
|
+
import path6 from "path";
|
|
692
901
|
var FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER = "__farm_docs_module_preloads__";
|
|
693
902
|
var FARM_DOCS_MODULE_PRELOADS_FILE = "docs-module-preloads.json";
|
|
694
903
|
function normalizeModuleId(id) {
|
|
@@ -724,7 +933,7 @@ function collectFarmDocsModulePreloads(bundle, options) {
|
|
|
724
933
|
return value;
|
|
725
934
|
};
|
|
726
935
|
const pages = {};
|
|
727
|
-
const root = normalizeModuleId(
|
|
936
|
+
const root = normalizeModuleId(path6.resolve(options.root));
|
|
728
937
|
for (const [moduleId, chunk] of byModule) {
|
|
729
938
|
if (!/\.mdx?$/.test(moduleId) || !moduleId.startsWith(`${root}/`)) continue;
|
|
730
939
|
const own = [...withStaticImports(chunk.fileName, /* @__PURE__ */ new Set())].filter(
|
|
@@ -754,7 +963,7 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
754
963
|
});
|
|
755
964
|
await fs3.mkdir(options.buildDir, { recursive: true });
|
|
756
965
|
await fs3.writeFile(
|
|
757
|
-
|
|
966
|
+
path6.join(options.buildDir, FARM_DOCS_MODULE_PRELOADS_FILE),
|
|
758
967
|
JSON.stringify(manifest)
|
|
759
968
|
);
|
|
760
969
|
}
|
|
@@ -763,7 +972,7 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
763
972
|
async function readFarmDocsModulePreloads(buildDir) {
|
|
764
973
|
try {
|
|
765
974
|
return JSON.parse(
|
|
766
|
-
await fs3.readFile(
|
|
975
|
+
await fs3.readFile(path6.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
|
|
767
976
|
);
|
|
768
977
|
} catch {
|
|
769
978
|
return null;
|
|
@@ -774,10 +983,10 @@ function encodeFarmDocsModulePreloads(manifest) {
|
|
|
774
983
|
}
|
|
775
984
|
|
|
776
985
|
// src/route-runtime-manifest.ts
|
|
777
|
-
import
|
|
986
|
+
import path7 from "path";
|
|
778
987
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
779
988
|
async function createFarmRouteRuntimeManifest(options) {
|
|
780
|
-
const root =
|
|
989
|
+
const root = path7.resolve(options.root || options.config.root || process.cwd());
|
|
781
990
|
const routes = [];
|
|
782
991
|
for (const [pattern, entry] of options.routeManager.getRoutes()) {
|
|
783
992
|
const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
|
|
@@ -847,7 +1056,7 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
847
1056
|
}
|
|
848
1057
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
849
1058
|
const fs5 = await import("fs/promises");
|
|
850
|
-
const manifestPath =
|
|
1059
|
+
const manifestPath = path7.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
851
1060
|
await fs5.mkdir(directory, { recursive: true });
|
|
852
1061
|
await fs5.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
853
1062
|
`);
|
|
@@ -885,12 +1094,12 @@ function normalizeManifestSource(root, modulePath) {
|
|
|
885
1094
|
const queryIndex = modulePath.indexOf("?");
|
|
886
1095
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
887
1096
|
const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
|
|
888
|
-
const relativePath =
|
|
1097
|
+
const relativePath = path7.isAbsolute(filePath) ? path7.relative(root, filePath) : filePath;
|
|
889
1098
|
return `${relativePath.replace(/\\/g, "/")}${query}`;
|
|
890
1099
|
}
|
|
891
1100
|
|
|
892
1101
|
// src/nitro/vercel-route-runtime.ts
|
|
893
|
-
import
|
|
1102
|
+
import path8 from "path";
|
|
894
1103
|
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, basePath = "/") {
|
|
895
1104
|
const dynamicRoutes = manifest.routes.filter(
|
|
896
1105
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
@@ -910,8 +1119,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, b
|
|
|
910
1119
|
group.routes.push(route);
|
|
911
1120
|
groups.set(key, group);
|
|
912
1121
|
}
|
|
913
|
-
const functionsDir =
|
|
914
|
-
const baseFunctionDir =
|
|
1122
|
+
const functionsDir = path8.join(outputDir, "functions");
|
|
1123
|
+
const baseFunctionDir = path8.join(functionsDir, "__nitro.func");
|
|
915
1124
|
const destinations = /* @__PURE__ */ new Map();
|
|
916
1125
|
let groupIndex = 0;
|
|
917
1126
|
for (const [key, group] of groups) {
|
|
@@ -921,7 +1130,7 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, b
|
|
|
921
1130
|
}
|
|
922
1131
|
groupIndex += 1;
|
|
923
1132
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
924
|
-
const functionDir =
|
|
1133
|
+
const functionDir = path8.join(functionsDir, `${functionName}.func`);
|
|
925
1134
|
await fs5.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
926
1135
|
await configureVercelFunction(functionDir, group.config, fs5);
|
|
927
1136
|
destinations.set(key, `/${functionName}`);
|
|
@@ -961,7 +1170,7 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
961
1170
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
962
1171
|
}
|
|
963
1172
|
async function configureVercelFunction(functionDir, config, fs5) {
|
|
964
|
-
const configPath =
|
|
1173
|
+
const configPath = path8.join(functionDir, ".vc-config.json");
|
|
965
1174
|
const current = JSON.parse(await fs5.readFile(configPath, "utf8"));
|
|
966
1175
|
const next = {
|
|
967
1176
|
...current,
|
|
@@ -1005,7 +1214,7 @@ function escapeRegExp(value) {
|
|
|
1005
1214
|
}
|
|
1006
1215
|
|
|
1007
1216
|
// src/nitro/immutable-assets.ts
|
|
1008
|
-
import
|
|
1217
|
+
import path9 from "path";
|
|
1009
1218
|
var FARM_IMMUTABLE_ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
1010
1219
|
var FARM_IMMUTABLE_ASSET_MAX_AGE = 31536e3;
|
|
1011
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]?)$)[^/]+$";
|
|
@@ -1040,7 +1249,7 @@ function planFarmImmutableAssets(options) {
|
|
|
1040
1249
|
for (const [dir, files] of dirFiles) {
|
|
1041
1250
|
if (!routeDirs.has(dir) && files.every(isImmutable)) {
|
|
1042
1251
|
plan.publicAssets.push({
|
|
1043
|
-
dir:
|
|
1252
|
+
dir: path9.join(options.clientOutputDir, dir),
|
|
1044
1253
|
baseURL: `/${dir}`,
|
|
1045
1254
|
maxAge: FARM_IMMUTABLE_ASSET_MAX_AGE
|
|
1046
1255
|
});
|
|
@@ -1054,8 +1263,8 @@ async function listFarmClientOutputFiles(dir) {
|
|
|
1054
1263
|
const fs5 = await import("fs/promises");
|
|
1055
1264
|
const entries = await fs5.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
|
|
1056
1265
|
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
1057
|
-
const relative =
|
|
1058
|
-
return `/${relative.split(
|
|
1266
|
+
const relative = path9.relative(dir, path9.join(entry.parentPath, entry.name));
|
|
1267
|
+
return `/${relative.split(path9.sep).join("/")}`;
|
|
1059
1268
|
});
|
|
1060
1269
|
}
|
|
1061
1270
|
|
|
@@ -1076,8 +1285,8 @@ function buildFarmVercelRoutes(options) {
|
|
|
1076
1285
|
const sourceRoutes = filesystemIndex >= 0 ? presetRoutes.slice(0, filesystemIndex) : [];
|
|
1077
1286
|
const preservedSourceRoutes = sourceRoutes.filter((route) => route.continue !== true);
|
|
1078
1287
|
return [
|
|
1079
|
-
...preservedSourceRoutes,
|
|
1080
1288
|
...middlewareRoutes,
|
|
1289
|
+
...preservedSourceRoutes,
|
|
1081
1290
|
...canonicalSlashRoutes,
|
|
1082
1291
|
createFarmVercelImmutableAssetRoute(),
|
|
1083
1292
|
{ handle: "filesystem" },
|
|
@@ -1128,7 +1337,7 @@ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
|
|
|
1128
1337
|
}
|
|
1129
1338
|
|
|
1130
1339
|
// src/nitro/ssr-public-assets.ts
|
|
1131
|
-
import
|
|
1340
|
+
import path10 from "path";
|
|
1132
1341
|
var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
1133
1342
|
function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
1134
1343
|
if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
|
|
@@ -1137,8 +1346,8 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
|
1137
1346
|
relativePath = decodeURI(relativePath);
|
|
1138
1347
|
} catch {
|
|
1139
1348
|
}
|
|
1140
|
-
const fileName =
|
|
1141
|
-
|
|
1349
|
+
const fileName = path10.posix.normalize(
|
|
1350
|
+
path10.posix.join(path10.posix.dirname(chunkFileName), relativePath)
|
|
1142
1351
|
);
|
|
1143
1352
|
return fileName.startsWith("../") ? null : fileName;
|
|
1144
1353
|
}
|
|
@@ -1182,7 +1391,7 @@ function collectServerOnlySSRAssets(bundle) {
|
|
|
1182
1391
|
}
|
|
1183
1392
|
}
|
|
1184
1393
|
for (const fileName of serverOnly) {
|
|
1185
|
-
const name =
|
|
1394
|
+
const name = path10.posix.basename(fileName);
|
|
1186
1395
|
if (publicReferenceSources.some((source) => source.includes(name))) {
|
|
1187
1396
|
serverOnly.delete(fileName);
|
|
1188
1397
|
}
|
|
@@ -1200,7 +1409,7 @@ function assertServerReadSSRAssetsSupported(bundle, preset, root) {
|
|
|
1200
1409
|
const output = bundle[fileName];
|
|
1201
1410
|
const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
|
|
1202
1411
|
if (!original) return fileName;
|
|
1203
|
-
return
|
|
1412
|
+
return path10.relative(root, path10.resolve(root, original)).split(path10.sep).join("/");
|
|
1204
1413
|
});
|
|
1205
1414
|
throw new Error(
|
|
1206
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.`
|
|
@@ -1216,7 +1425,7 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1216
1425
|
},
|
|
1217
1426
|
transform(code, id) {
|
|
1218
1427
|
if (!code.includes("import.meta.url")) return null;
|
|
1219
|
-
const chunkFileName =
|
|
1428
|
+
const chunkFileName = path10.relative(ssrOutputDir, id.split("?", 1)[0]).split(path10.sep).join("/");
|
|
1220
1429
|
if (bundle[chunkFileName]?.type !== "chunk") return null;
|
|
1221
1430
|
let changed = false;
|
|
1222
1431
|
const transformed = replaceServerFileReferences(
|
|
@@ -1244,10 +1453,10 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1244
1453
|
|
|
1245
1454
|
// src/nitro/netlify-entry.ts
|
|
1246
1455
|
import { existsSync } from "fs";
|
|
1247
|
-
import
|
|
1456
|
+
import path11 from "path";
|
|
1248
1457
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
1249
|
-
const entry =
|
|
1250
|
-
|
|
1458
|
+
const entry = path11.join(
|
|
1459
|
+
path11.dirname(nitroRuntimeEntry),
|
|
1251
1460
|
"..",
|
|
1252
1461
|
"presets",
|
|
1253
1462
|
"netlify",
|
|
@@ -1259,7 +1468,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
1259
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.`
|
|
1260
1469
|
);
|
|
1261
1470
|
}
|
|
1262
|
-
return entry.split(
|
|
1471
|
+
return entry.split(path11.sep).join("/");
|
|
1263
1472
|
}
|
|
1264
1473
|
function createFarmNetlifyEntry(options) {
|
|
1265
1474
|
return `
|
|
@@ -1308,8 +1517,8 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
1308
1517
|
}
|
|
1309
1518
|
|
|
1310
1519
|
// src/build/strip-platform-config.ts
|
|
1311
|
-
import { realpathSync } from "fs";
|
|
1312
|
-
import
|
|
1520
|
+
import { realpathSync as realpathSync2 } from "fs";
|
|
1521
|
+
import path12 from "path";
|
|
1313
1522
|
var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
|
|
1314
1523
|
var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
|
|
1315
1524
|
function isConfigObject(node) {
|
|
@@ -1381,13 +1590,13 @@ function stripPlatformConfigSource(code, parse) {
|
|
|
1381
1590
|
}
|
|
1382
1591
|
function realPath(file) {
|
|
1383
1592
|
try {
|
|
1384
|
-
return
|
|
1593
|
+
return realpathSync2(file);
|
|
1385
1594
|
} catch {
|
|
1386
|
-
return
|
|
1595
|
+
return path12.resolve(file);
|
|
1387
1596
|
}
|
|
1388
1597
|
}
|
|
1389
1598
|
function farmStripPlatformConfigPlugin(configFiles) {
|
|
1390
|
-
const files = new Set(configFiles.flatMap((file) => [
|
|
1599
|
+
const files = new Set(configFiles.flatMap((file) => [path12.resolve(file), realPath(file)]));
|
|
1391
1600
|
return {
|
|
1392
1601
|
name: "farm:strip-platform-config",
|
|
1393
1602
|
// Before the TypeScript transform, so its import elision also drops imports only the
|
|
@@ -1397,9 +1606,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1397
1606
|
filter: { id: fileNamePattern(configFiles) },
|
|
1398
1607
|
async handler(code, id) {
|
|
1399
1608
|
const file = id.split("?", 1)[0];
|
|
1400
|
-
if (!files.has(
|
|
1609
|
+
if (!files.has(path12.resolve(file)) && !files.has(realPath(file))) return null;
|
|
1401
1610
|
const { parseAst } = await import("rolldown/parseAst");
|
|
1402
|
-
const extension =
|
|
1611
|
+
const extension = path12.extname(file).slice(1);
|
|
1403
1612
|
const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
|
|
1404
1613
|
const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
|
|
1405
1614
|
return stripped === null ? null : { code: stripped, map: null };
|
|
@@ -1410,7 +1619,7 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1410
1619
|
|
|
1411
1620
|
// src/build/markdown-precompile.ts
|
|
1412
1621
|
import { existsSync as existsSync2 } from "fs";
|
|
1413
|
-
import
|
|
1622
|
+
import path13 from "path";
|
|
1414
1623
|
import { pathToFileURL } from "url";
|
|
1415
1624
|
import { Worker } from "worker_threads";
|
|
1416
1625
|
var WORKER_SOURCE = `
|
|
@@ -1426,7 +1635,7 @@ import(workerData.runtime).then(async ({ compileFarmMarkdownPage }) => {
|
|
|
1426
1635
|
});
|
|
1427
1636
|
`;
|
|
1428
1637
|
function precompileFarmMarkdownPages(bodies, coreRoot) {
|
|
1429
|
-
const runtime = coreRoot ?
|
|
1638
|
+
const runtime = coreRoot ? path13.join(coreRoot, "dist", "internal", "app-markdown-runtime.mjs") : null;
|
|
1430
1639
|
if (bodies.length === 0 || !runtime || !existsSync2(runtime)) {
|
|
1431
1640
|
return { pages: Promise.resolve(/* @__PURE__ */ new Map()), dispose() {
|
|
1432
1641
|
} };
|
|
@@ -1463,7 +1672,7 @@ function precompileFarmMarkdownPages(bodies, coreRoot) {
|
|
|
1463
1672
|
|
|
1464
1673
|
// src/nitro/client-sourcemaps.ts
|
|
1465
1674
|
import fs4 from "fs/promises";
|
|
1466
|
-
import
|
|
1675
|
+
import path14 from "path";
|
|
1467
1676
|
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
1468
1677
|
function resolveFarmClientSourcemap(sourcemap) {
|
|
1469
1678
|
return sourcemap ? "hidden" : false;
|
|
@@ -1484,8 +1693,8 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
|
1484
1693
|
async writeBundle() {
|
|
1485
1694
|
await fs4.rm(options.outDir, { recursive: true, force: true });
|
|
1486
1695
|
for (const [fileName, source] of maps) {
|
|
1487
|
-
const target =
|
|
1488
|
-
await fs4.mkdir(
|
|
1696
|
+
const target = path14.join(options.outDir, fileName);
|
|
1697
|
+
await fs4.mkdir(path14.dirname(target), { recursive: true });
|
|
1489
1698
|
await fs4.writeFile(target, source);
|
|
1490
1699
|
}
|
|
1491
1700
|
}
|
|
@@ -1568,7 +1777,7 @@ async function readMiddlewareFileConfig(filePath) {
|
|
|
1568
1777
|
|
|
1569
1778
|
// src/nitro/vercel-edge-middleware.ts
|
|
1570
1779
|
import { createRequire, isBuiltin } from "module";
|
|
1571
|
-
import
|
|
1780
|
+
import path15 from "path";
|
|
1572
1781
|
import { gzipSync } from "zlib";
|
|
1573
1782
|
var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
|
|
1574
1783
|
var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
|
|
@@ -1623,21 +1832,21 @@ ${modules.join("\n")}
|
|
|
1623
1832
|
`;
|
|
1624
1833
|
}
|
|
1625
1834
|
async function resolveFarmCoreDir(root, fs5) {
|
|
1626
|
-
const runtimeEntry = createRequire(
|
|
1835
|
+
const runtimeEntry = createRequire(path15.join(root, "package.json")).resolve(
|
|
1627
1836
|
"@farm.js/core/internal/vercel-edge-middleware"
|
|
1628
1837
|
);
|
|
1629
|
-
return fs5.realpath(
|
|
1838
|
+
return fs5.realpath(path15.resolve(path15.dirname(runtimeEntry), "..", ".."));
|
|
1630
1839
|
}
|
|
1631
1840
|
function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
1632
1841
|
const streamStub = "\0farm-edge-node-stream";
|
|
1633
|
-
const corePrefix = coreDir +
|
|
1842
|
+
const corePrefix = coreDir + path15.sep;
|
|
1634
1843
|
return {
|
|
1635
1844
|
name: "farm-vercel-edge-node-modules",
|
|
1636
1845
|
resolveId(source, importer) {
|
|
1637
1846
|
if (!isBuiltin(source)) return null;
|
|
1638
1847
|
const name = source.replace(/^node:/, "").split("/")[0];
|
|
1639
1848
|
if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
|
|
1640
|
-
if (name === "stream" && importer &&
|
|
1849
|
+
if (name === "stream" && importer && path15.resolve(importer).startsWith(corePrefix)) {
|
|
1641
1850
|
return streamStub;
|
|
1642
1851
|
}
|
|
1643
1852
|
unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
|
|
@@ -1651,13 +1860,13 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
|
1651
1860
|
}
|
|
1652
1861
|
async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
1653
1862
|
const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs5 } = options;
|
|
1654
|
-
const functionDir =
|
|
1863
|
+
const functionDir = path15.join(
|
|
1655
1864
|
outputDir,
|
|
1656
1865
|
"functions",
|
|
1657
1866
|
`${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
|
|
1658
1867
|
);
|
|
1659
|
-
const entryPath =
|
|
1660
|
-
await fs5.mkdir(
|
|
1868
|
+
const entryPath = path15.join(buildDir, "vercel-edge-middleware-entry.mjs");
|
|
1869
|
+
await fs5.mkdir(path15.dirname(entryPath), { recursive: true });
|
|
1661
1870
|
await fs5.writeFile(
|
|
1662
1871
|
entryPath,
|
|
1663
1872
|
generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
|
|
@@ -1706,9 +1915,9 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
|
|
|
1706
1915
|
}
|
|
1707
1916
|
await fs5.rm(functionDir, { recursive: true, force: true });
|
|
1708
1917
|
await fs5.mkdir(functionDir, { recursive: true });
|
|
1709
|
-
await fs5.writeFile(
|
|
1918
|
+
await fs5.writeFile(path15.join(functionDir, "index.js"), code);
|
|
1710
1919
|
await fs5.writeFile(
|
|
1711
|
-
|
|
1920
|
+
path15.join(functionDir, ".vc-config.json"),
|
|
1712
1921
|
`${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
|
|
1713
1922
|
`
|
|
1714
1923
|
);
|
|
@@ -1730,7 +1939,7 @@ async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
|
|
|
1730
1939
|
try {
|
|
1731
1940
|
return {
|
|
1732
1941
|
[clientCssHref]: await fs5.readFile(
|
|
1733
|
-
|
|
1942
|
+
path16.join(clientOutputDir, clientCssHref.slice(1)),
|
|
1734
1943
|
"utf8"
|
|
1735
1944
|
)
|
|
1736
1945
|
};
|
|
@@ -1745,18 +1954,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1745
1954
|
);
|
|
1746
1955
|
}
|
|
1747
1956
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1748
|
-
var _dirname =
|
|
1957
|
+
var _dirname = path16.dirname(_filename);
|
|
1749
1958
|
function findFarmCoreRoot(from) {
|
|
1750
|
-
let dir =
|
|
1751
|
-
while (dir !==
|
|
1752
|
-
const manifest =
|
|
1959
|
+
let dir = path16.dirname(from);
|
|
1960
|
+
while (dir !== path16.dirname(dir)) {
|
|
1961
|
+
const manifest = path16.join(dir, "package.json");
|
|
1753
1962
|
if (existsSync3(manifest)) {
|
|
1754
1963
|
try {
|
|
1755
|
-
if (JSON.parse(
|
|
1964
|
+
if (JSON.parse(readFileSync2(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1756
1965
|
} catch {
|
|
1757
1966
|
}
|
|
1758
1967
|
}
|
|
1759
|
-
dir =
|
|
1968
|
+
dir = path16.dirname(dir);
|
|
1760
1969
|
}
|
|
1761
1970
|
return null;
|
|
1762
1971
|
}
|
|
@@ -1766,16 +1975,16 @@ function toModulePath(file) {
|
|
|
1766
1975
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1767
1976
|
}
|
|
1768
1977
|
function findInstalledPackageDir(name, from) {
|
|
1769
|
-
for (let dir = from; ; dir =
|
|
1770
|
-
const candidate =
|
|
1771
|
-
if (existsSync3(
|
|
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"))) {
|
|
1772
1981
|
try {
|
|
1773
|
-
return
|
|
1982
|
+
return realpathSync3(candidate);
|
|
1774
1983
|
} catch {
|
|
1775
1984
|
return null;
|
|
1776
1985
|
}
|
|
1777
1986
|
}
|
|
1778
|
-
if (dir ===
|
|
1987
|
+
if (dir === path16.dirname(dir)) return null;
|
|
1779
1988
|
}
|
|
1780
1989
|
}
|
|
1781
1990
|
function collectFarmDependencyDirs(root) {
|
|
@@ -1786,7 +1995,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1786
1995
|
seen.add(dir);
|
|
1787
1996
|
let manifest;
|
|
1788
1997
|
try {
|
|
1789
|
-
manifest = JSON.parse(
|
|
1998
|
+
manifest = JSON.parse(readFileSync2(path16.join(dir, "package.json"), "utf8"));
|
|
1790
1999
|
} catch {
|
|
1791
2000
|
return;
|
|
1792
2001
|
}
|
|
@@ -1794,10 +2003,10 @@ function collectFarmDependencyDirs(root) {
|
|
|
1794
2003
|
for (const name of Object.keys(manifest[field] ?? {})) queue.push({ name, from: dir });
|
|
1795
2004
|
}
|
|
1796
2005
|
};
|
|
1797
|
-
if (farmCoreRoot) visit(
|
|
2006
|
+
if (farmCoreRoot) visit(realpathSync3(farmCoreRoot));
|
|
1798
2007
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1799
2008
|
try {
|
|
1800
|
-
const manifest = JSON.parse(
|
|
2009
|
+
const manifest = JSON.parse(readFileSync2(path16.join(root, "package.json"), "utf8"));
|
|
1801
2010
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1802
2011
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1803
2012
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1864,17 +2073,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1864
2073
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1865
2074
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1866
2075
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1867
|
-
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
2076
|
+
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path16.sep).join("/");
|
|
1868
2077
|
}
|
|
1869
2078
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1870
2079
|
const nitroEntry = resolveNitroPackageEntry(root);
|
|
1871
|
-
const runtimeDir =
|
|
2080
|
+
const runtimeDir = path16.dirname(nitroEntry);
|
|
1872
2081
|
const nitroRequire = createRequire2(nitroEntry);
|
|
1873
2082
|
return {
|
|
1874
2083
|
...Object.fromEntries(
|
|
1875
2084
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1876
2085
|
`#nitro/runtime/${moduleName}`,
|
|
1877
|
-
|
|
2086
|
+
path16.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path16.sep).join("/")
|
|
1878
2087
|
])
|
|
1879
2088
|
),
|
|
1880
2089
|
// Farm's generated workflow and cron wrappers live under `.farm/` and
|
|
@@ -1883,7 +2092,7 @@ function resolveNitroInternalRuntimeAliases(root) {
|
|
|
1883
2092
|
...Object.fromEntries(
|
|
1884
2093
|
["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
|
|
1885
2094
|
specifier,
|
|
1886
|
-
nitroRequire.resolve(specifier).split(
|
|
2095
|
+
nitroRequire.resolve(specifier).split(path16.sep).join("/")
|
|
1887
2096
|
])
|
|
1888
2097
|
)
|
|
1889
2098
|
};
|
|
@@ -1907,7 +2116,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1907
2116
|
name: "farm-prerender-runtime-resolver",
|
|
1908
2117
|
async resolveId(id, _importer, options) {
|
|
1909
2118
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1910
|
-
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)) {
|
|
1911
2120
|
return null;
|
|
1912
2121
|
}
|
|
1913
2122
|
if (nitroEntry === void 0) {
|
|
@@ -1930,7 +2139,7 @@ function createFarmStorageModuleRegistration(config) {
|
|
|
1930
2139
|
const modules = _collectFarmStorageModules(config.storage);
|
|
1931
2140
|
if (modules.length === 0) return "";
|
|
1932
2141
|
const root = config.root || process.cwd();
|
|
1933
|
-
const projectRequire = createRequire2(
|
|
2142
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
1934
2143
|
let runtimeRequire = projectRequire;
|
|
1935
2144
|
try {
|
|
1936
2145
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1957,7 +2166,7 @@ ${loaders.join("\n")}
|
|
|
1957
2166
|
});` : "";
|
|
1958
2167
|
}
|
|
1959
2168
|
function resolveNitroPackageEntry(root) {
|
|
1960
|
-
const projectRequire = createRequire2(
|
|
2169
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
1961
2170
|
let runtimeRequire = projectRequire;
|
|
1962
2171
|
try {
|
|
1963
2172
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -2027,7 +2236,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
2027
2236
|
}
|
|
2028
2237
|
function hasReactDomEdgeServerBuild(root) {
|
|
2029
2238
|
try {
|
|
2030
|
-
createRequire2(
|
|
2239
|
+
createRequire2(path16.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
2031
2240
|
return true;
|
|
2032
2241
|
} catch {
|
|
2033
2242
|
return false;
|
|
@@ -2058,17 +2267,17 @@ function isNitroRollupExternal(id) {
|
|
|
2058
2267
|
var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
|
|
2059
2268
|
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
2060
2269
|
function isFarmCoreModule(file) {
|
|
2061
|
-
let dir =
|
|
2062
|
-
while (dir !==
|
|
2063
|
-
const manifest =
|
|
2270
|
+
let dir = path16.dirname(file.split("?", 1)[0]);
|
|
2271
|
+
while (dir !== path16.dirname(dir)) {
|
|
2272
|
+
const manifest = path16.join(dir, "package.json");
|
|
2064
2273
|
if (existsSync3(manifest)) {
|
|
2065
2274
|
try {
|
|
2066
|
-
return JSON.parse(
|
|
2275
|
+
return JSON.parse(readFileSync2(manifest, "utf8")).name === "@farm.js/core";
|
|
2067
2276
|
} catch {
|
|
2068
2277
|
return false;
|
|
2069
2278
|
}
|
|
2070
2279
|
}
|
|
2071
|
-
dir =
|
|
2280
|
+
dir = path16.dirname(dir);
|
|
2072
2281
|
}
|
|
2073
2282
|
return false;
|
|
2074
2283
|
}
|
|
@@ -2079,7 +2288,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
|
2079
2288
|
filter: { id: exactIdPattern(["@vercel/og"]) },
|
|
2080
2289
|
handler(source, importer) {
|
|
2081
2290
|
if (source !== "@vercel/og") return null;
|
|
2082
|
-
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]));
|
|
2083
2292
|
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
2084
2293
|
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
2085
2294
|
}
|
|
@@ -2100,14 +2309,14 @@ export class ImageResponse {
|
|
|
2100
2309
|
};
|
|
2101
2310
|
}
|
|
2102
2311
|
function readVercelOgManifest(file) {
|
|
2103
|
-
let dir =
|
|
2104
|
-
while (dir !==
|
|
2105
|
-
const manifestPath =
|
|
2312
|
+
let dir = path16.dirname(file.split("?", 1)[0]);
|
|
2313
|
+
while (dir !== path16.dirname(dir)) {
|
|
2314
|
+
const manifestPath = path16.join(dir, "package.json");
|
|
2106
2315
|
if (existsSync3(manifestPath)) {
|
|
2107
|
-
const manifest = JSON.parse(
|
|
2316
|
+
const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
|
|
2108
2317
|
return manifest.name === "@vercel/og" ? { dir, manifest } : null;
|
|
2109
2318
|
}
|
|
2110
|
-
dir =
|
|
2319
|
+
dir = path16.dirname(dir);
|
|
2111
2320
|
}
|
|
2112
2321
|
return null;
|
|
2113
2322
|
}
|
|
@@ -2115,7 +2324,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
|
|
|
2115
2324
|
const vercelOg = readVercelOgManifest(resolvedId);
|
|
2116
2325
|
const entry = vercelOg?.manifest.exports?.["."]?.[condition];
|
|
2117
2326
|
const file = typeof entry === "string" ? entry : entry?.default;
|
|
2118
|
-
return vercelOg && typeof file === "string" ?
|
|
2327
|
+
return vercelOg && typeof file === "string" ? path16.join(vercelOg.dir, file) : null;
|
|
2119
2328
|
}
|
|
2120
2329
|
function createEdgeMetadataImageRuntimePlugin({
|
|
2121
2330
|
condition,
|
|
@@ -2133,7 +2342,7 @@ function createEdgeMetadataImageRuntimePlugin({
|
|
|
2133
2342
|
if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
2134
2343
|
return null;
|
|
2135
2344
|
}
|
|
2136
|
-
const resolvedPath =
|
|
2345
|
+
const resolvedPath = path16.resolve(path16.dirname(importer.split("?", 1)[0]), source);
|
|
2137
2346
|
return { id: toPosixPath(resolvedPath), external: "absolute" };
|
|
2138
2347
|
}
|
|
2139
2348
|
};
|
|
@@ -2148,7 +2357,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
|
|
|
2148
2357
|
return null;
|
|
2149
2358
|
}
|
|
2150
2359
|
const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
|
|
2151
|
-
const encoded =
|
|
2360
|
+
const encoded = readFileSync2(path16.resolve(path16.dirname(file), request)).toString("base64");
|
|
2152
2361
|
return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
|
|
2153
2362
|
});
|
|
2154
2363
|
if (inlined !== code) return { code: inlined, map: null };
|
|
@@ -2167,13 +2376,13 @@ function createMetadataImageWasmPlugin() {
|
|
|
2167
2376
|
return null;
|
|
2168
2377
|
}
|
|
2169
2378
|
const requestPath = source.slice(0, -"?module".length);
|
|
2170
|
-
const resolvedPath =
|
|
2379
|
+
const resolvedPath = path16.isAbsolute(requestPath) ? requestPath : path16.resolve(path16.dirname(importer.split("?", 1)[0]), requestPath);
|
|
2171
2380
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
2172
2381
|
},
|
|
2173
2382
|
load(id) {
|
|
2174
2383
|
if (!id.startsWith(FARM_METADATA_IMAGE_WASM_PREFIX)) return null;
|
|
2175
2384
|
const wasmPath = id.slice(FARM_METADATA_IMAGE_WASM_PREFIX.length);
|
|
2176
|
-
const encoded =
|
|
2385
|
+
const encoded = readFileSync2(wasmPath).toString("base64");
|
|
2177
2386
|
return `
|
|
2178
2387
|
const encoded = ${JSON.stringify(encoded)};
|
|
2179
2388
|
const bytes = Uint8Array.from(atob(encoded), (character) => character.charCodeAt(0));
|
|
@@ -2192,11 +2401,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2192
2401
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
2193
2402
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
2194
2403
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
2195
|
-
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;
|
|
2196
2405
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
2197
2406
|
continue;
|
|
2198
2407
|
}
|
|
2199
|
-
if (
|
|
2408
|
+
if (path16.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
2200
2409
|
externalPackages.add(importId);
|
|
2201
2410
|
continue;
|
|
2202
2411
|
}
|
|
@@ -2208,15 +2417,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2208
2417
|
return externalPackages;
|
|
2209
2418
|
}
|
|
2210
2419
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
2211
|
-
const resolvedNitroEntry =
|
|
2212
|
-
const resolvedSSREntry =
|
|
2420
|
+
const resolvedNitroEntry = path16.resolve(nitroEntryPath);
|
|
2421
|
+
const resolvedSSREntry = path16.resolve(ssrOutputDir, ssrEntryFile);
|
|
2213
2422
|
return {
|
|
2214
2423
|
name: "farm-externalize-prebuilt-ssr",
|
|
2215
2424
|
resolveId(source, importer) {
|
|
2216
|
-
if (!importer ||
|
|
2425
|
+
if (!importer || path16.resolve(importer) !== resolvedNitroEntry) {
|
|
2217
2426
|
return null;
|
|
2218
2427
|
}
|
|
2219
|
-
const resolvedImport =
|
|
2428
|
+
const resolvedImport = path16.resolve(path16.dirname(importer), source);
|
|
2220
2429
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
2221
2430
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
2222
2431
|
}
|
|
@@ -2354,13 +2563,13 @@ function trimSlashes(value) {
|
|
|
2354
2563
|
function resolveBuildDocsContentDir(docs, root, srcDir) {
|
|
2355
2564
|
const configuredContentDir = docs.contentDir || docs.config.contentDir;
|
|
2356
2565
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
2357
|
-
const contentDir =
|
|
2566
|
+
const contentDir = path16.isAbsolute(configuredContentDir) ? configuredContentDir : path16.join(root, configuredContentDir);
|
|
2358
2567
|
return existsSync3(contentDir) ? contentDir : null;
|
|
2359
2568
|
}
|
|
2360
2569
|
const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
|
|
2361
|
-
const appDocsDir =
|
|
2570
|
+
const appDocsDir = path16.join(root, srcDir || "src", "app", entryDir);
|
|
2362
2571
|
if (existsSync3(appDocsDir)) return appDocsDir;
|
|
2363
|
-
const rootDocsDir =
|
|
2572
|
+
const rootDocsDir = path16.join(root, entryDir);
|
|
2364
2573
|
return existsSync3(rootDocsDir) ? rootDocsDir : null;
|
|
2365
2574
|
}
|
|
2366
2575
|
function hasProjectPostcssConfig(root) {
|
|
@@ -2377,7 +2586,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2377
2586
|
".postcssrc.mjs",
|
|
2378
2587
|
".postcssrc.ts"
|
|
2379
2588
|
];
|
|
2380
|
-
const projectRequire = createRequire2(
|
|
2589
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
2381
2590
|
return candidates.some((file) => {
|
|
2382
2591
|
try {
|
|
2383
2592
|
projectRequire.resolve(`./${file}`);
|
|
@@ -2400,7 +2609,7 @@ async function findFarmConfigPath(root) {
|
|
|
2400
2609
|
"config.mjs"
|
|
2401
2610
|
];
|
|
2402
2611
|
for (const candidate of candidates) {
|
|
2403
|
-
const resolvedPath =
|
|
2612
|
+
const resolvedPath = path16.join(root, candidate);
|
|
2404
2613
|
try {
|
|
2405
2614
|
await fs5.access(resolvedPath);
|
|
2406
2615
|
return resolvedPath;
|
|
@@ -2437,7 +2646,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2437
2646
|
discovered.push({
|
|
2438
2647
|
path: routePath,
|
|
2439
2648
|
directory,
|
|
2440
|
-
filePath:
|
|
2649
|
+
filePath: path16.join(dir, middlewareFile.name)
|
|
2441
2650
|
});
|
|
2442
2651
|
}
|
|
2443
2652
|
for (const entry of entries) {
|
|
@@ -2445,7 +2654,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2445
2654
|
continue;
|
|
2446
2655
|
}
|
|
2447
2656
|
await walk(
|
|
2448
|
-
|
|
2657
|
+
path16.join(dir, entry.name),
|
|
2449
2658
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
2450
2659
|
appendMiddlewareDirectory(directory, entry.name),
|
|
2451
2660
|
discovered
|
|
@@ -2493,14 +2702,19 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2493
2702
|
});
|
|
2494
2703
|
const routeRuntimeManifestResultPromise = Promise.allSettled([routeRuntimeManifestPromise]);
|
|
2495
2704
|
const pageRoutes = [];
|
|
2705
|
+
const searchPreserveRoutes = new Map(
|
|
2706
|
+
routeManager.getSearchPreserveRoutes().map((route) => [route.pattern, route])
|
|
2707
|
+
);
|
|
2496
2708
|
for (const [pattern, entry] of routeManager.getRoutes()) {
|
|
2497
2709
|
const markdownSourcePath = entry.markdownSourcePath || (isFarmMarkdownPageFile(entry.modulePath) ? entry.modulePath : void 0);
|
|
2710
|
+
const searchPreserve = searchPreserveRoutes.get(entry.pattern);
|
|
2498
2711
|
pageRoutes.push({
|
|
2499
2712
|
pattern,
|
|
2500
2713
|
...entry.directory ? { directory: entry.directory } : {},
|
|
2501
2714
|
modulePath: entry.modulePath,
|
|
2715
|
+
...searchPreserve ? { searchPreserve } : {},
|
|
2502
2716
|
...markdownSourcePath ? {
|
|
2503
|
-
source:
|
|
2717
|
+
source: readFileSync2(markdownSourcePath, "utf8"),
|
|
2504
2718
|
markdownSourcePath
|
|
2505
2719
|
} : {}
|
|
2506
2720
|
});
|
|
@@ -2524,32 +2738,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2524
2738
|
);
|
|
2525
2739
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
2526
2740
|
const fs5 = await import("fs/promises");
|
|
2527
|
-
const layoutRoutes = []
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2532
|
-
for (const entry of entries) {
|
|
2533
|
-
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
2534
|
-
layoutRoutes.push({
|
|
2535
|
-
pattern: routePrefix,
|
|
2536
|
-
modulePath: path15.join(dir, entry.name)
|
|
2537
|
-
});
|
|
2538
|
-
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
2539
|
-
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
2540
|
-
await findLayoutsForClient(path15.join(dir, entry.name), childPrefix);
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
} catch {
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
await findLayoutsForClient(appDir);
|
|
2547
|
-
const seenLayoutPatterns = new Set(layoutRoutes.map((layout) => layout.pattern));
|
|
2548
|
-
for (const [pattern, entry] of routeManager.getLayouts()) {
|
|
2549
|
-
if (seenLayoutPatterns.has(pattern)) continue;
|
|
2550
|
-
seenLayoutPatterns.add(pattern);
|
|
2551
|
-
layoutRoutes.push({ pattern, modulePath: entry.modulePath });
|
|
2552
|
-
}
|
|
2741
|
+
const layoutRoutes = Array.from(routeManager.getLayouts(), ([pattern, { modulePath }]) => ({
|
|
2742
|
+
pattern,
|
|
2743
|
+
modulePath
|
|
2744
|
+
}));
|
|
2553
2745
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
|
|
2554
2746
|
const isolatedClientBoundaryModules = routeManager.getIsolatedClientBoundaryModules(root);
|
|
2555
2747
|
const islandsErrors = routeManager.getIslandsErrors(root);
|
|
@@ -2562,7 +2754,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2562
2754
|
}
|
|
2563
2755
|
const hydrationPlanCache = routeManager.getRouteModuleHydrationPlans();
|
|
2564
2756
|
const sourceSnapshot = routeManager.takeBuildSourceSnapshot();
|
|
2565
|
-
const clientOutputDir =
|
|
2757
|
+
const clientOutputDir = path16.join(root, distDir, "client");
|
|
2566
2758
|
const [productionViteResult] = await productionViteResultPromise;
|
|
2567
2759
|
if (productionViteResult.status === "rejected") {
|
|
2568
2760
|
await routeRuntimeManifestResultPromise;
|
|
@@ -2670,6 +2862,9 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2670
2862
|
const { bundle: ssrBundle, entryFile: ssrEntryFile, configuredHeaderRoutes } = ssrResult;
|
|
2671
2863
|
assertServerReadSSRAssetsSupported(ssrBundle, preset, root);
|
|
2672
2864
|
await writeSSRAssetsToClient(ssrBundle, clientOutputDir);
|
|
2865
|
+
if (!rendererDisabled) {
|
|
2866
|
+
await writeFarmVideoPlayerToClient(clientOutputDir);
|
|
2867
|
+
}
|
|
2673
2868
|
if (config.docs.enabled) {
|
|
2674
2869
|
await copyFarmDocsFontAssetsToClient(root, clientOutputDir);
|
|
2675
2870
|
}
|
|
@@ -2692,10 +2887,10 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2692
2887
|
markdownPrecompile?.pages
|
|
2693
2888
|
);
|
|
2694
2889
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
2695
|
-
|
|
2890
|
+
path16.join(root, distDir),
|
|
2696
2891
|
routeRuntimeManifest
|
|
2697
2892
|
);
|
|
2698
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
2893
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path16.relative(root, runtimeManifestPath)}`);
|
|
2699
2894
|
} catch (error) {
|
|
2700
2895
|
if (lifecyclePluginManager) {
|
|
2701
2896
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -2753,24 +2948,34 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
2753
2948
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
2754
2949
|
continue;
|
|
2755
2950
|
}
|
|
2756
|
-
const filePath =
|
|
2757
|
-
await fs5.mkdir(
|
|
2951
|
+
const filePath = path16.join(outputDir, fileName);
|
|
2952
|
+
await fs5.mkdir(path16.dirname(filePath), { recursive: true });
|
|
2758
2953
|
await fs5.writeFile(filePath, output.source);
|
|
2759
2954
|
}
|
|
2760
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;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2761
2966
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
2762
2967
|
const fs5 = await import("fs/promises");
|
|
2763
2968
|
await Promise.all(
|
|
2764
2969
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
2765
|
-
const targetPath =
|
|
2766
|
-
await fs5.mkdir(
|
|
2970
|
+
const targetPath = path16.join(outputDir, url.replace(/^\/+/, ""));
|
|
2971
|
+
await fs5.mkdir(path16.dirname(targetPath), { recursive: true });
|
|
2767
2972
|
await fs5.copyFile(sourcePath, targetPath);
|
|
2768
2973
|
})
|
|
2769
2974
|
);
|
|
2770
2975
|
}
|
|
2771
2976
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
2772
2977
|
const fs5 = await import("fs/promises");
|
|
2773
|
-
const fontCssPath =
|
|
2978
|
+
const fontCssPath = path16.join(outputDir, "farm-fonts.css");
|
|
2774
2979
|
let fontCss = fontCssSource;
|
|
2775
2980
|
if (fontCss === void 0) {
|
|
2776
2981
|
try {
|
|
@@ -2779,7 +2984,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
2779
2984
|
return;
|
|
2780
2985
|
}
|
|
2781
2986
|
}
|
|
2782
|
-
const clientCssPath =
|
|
2987
|
+
const clientCssPath = path16.join(outputDir, "farm-client.css");
|
|
2783
2988
|
let clientCss = "";
|
|
2784
2989
|
try {
|
|
2785
2990
|
clientCss = await fs5.readFile(clientCssPath, "utf8");
|
|
@@ -2805,7 +3010,7 @@ var IncompleteClientBuildOutputError = class extends Error {
|
|
|
2805
3010
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
2806
3011
|
const fs5 = await import("fs/promises");
|
|
2807
3012
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
2808
|
-
const clientEntryPath =
|
|
3013
|
+
const clientEntryPath = path16.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
2809
3014
|
let clientEntrySize = 0;
|
|
2810
3015
|
try {
|
|
2811
3016
|
const clientEntry = await fs5.stat(clientEntryPath);
|
|
@@ -2815,8 +3020,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2815
3020
|
if (clientEntrySize === 0) {
|
|
2816
3021
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
2817
3022
|
}
|
|
2818
|
-
const clientCssPath =
|
|
2819
|
-
const globalsCssPath =
|
|
3023
|
+
const clientCssPath = path16.join(outputDir, "farm-client.css");
|
|
3024
|
+
const globalsCssPath = path16.join(root, srcDir, "app", "globals.css");
|
|
2820
3025
|
let expectsCss = false;
|
|
2821
3026
|
try {
|
|
2822
3027
|
const globalsCss = await fs5.readFile(globalsCssPath, "utf8");
|
|
@@ -2846,10 +3051,10 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
2846
3051
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
2847
3052
|
}
|
|
2848
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) {
|
|
2849
|
-
if (!mobile) await removeFarmMobileClientManifest(
|
|
3054
|
+
if (!mobile) await removeFarmMobileClientManifest(path16.dirname(outputDir));
|
|
2850
3055
|
const viteBuild = productionVite.build;
|
|
2851
3056
|
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2852
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
3057
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
2853
3058
|
const fs5 = await import("fs/promises");
|
|
2854
3059
|
const pluginManager = new PluginManager2({
|
|
2855
3060
|
config,
|
|
@@ -3108,16 +3313,33 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3108
3313
|
});
|
|
3109
3314
|
return { clientLayouts: clientLayouts2, clientRouteSlots: clientRouteSlots2 };
|
|
3110
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
|
+
}
|
|
3111
3332
|
logger.info(
|
|
3112
3333
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
3113
3334
|
);
|
|
3114
3335
|
const clientRouteTable = createFarmClientRouteTable(clientPages);
|
|
3115
|
-
|
|
3336
|
+
createFarmRouter(clientRouteTable.map((route) => ({ path: route.pattern, meta: route })));
|
|
3337
|
+
await writeFarmClientRouteTable(path16.dirname(outputDir), clientRouteTable);
|
|
3116
3338
|
const buildTarget = async (platform) => {
|
|
3117
|
-
const clientEntryRoot =
|
|
3339
|
+
const clientEntryRoot = path16.join(root, ".farm", "tmp");
|
|
3118
3340
|
await fs5.mkdir(clientEntryRoot, { recursive: true });
|
|
3119
|
-
const clientEntryDir = await fs5.mkdtemp(
|
|
3120
|
-
const clientEntryPath =
|
|
3341
|
+
const clientEntryDir = await fs5.mkdtemp(path16.join(clientEntryRoot, "client-entry-"));
|
|
3342
|
+
const clientEntryPath = path16.join(clientEntryDir, "farm-client-entry.tsx");
|
|
3121
3343
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
3122
3344
|
clientPages,
|
|
3123
3345
|
clientLayouts,
|
|
@@ -3151,15 +3373,15 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3151
3373
|
const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
|
|
3152
3374
|
await fs5.writeFile(clientEntryPath, clientEntry.entry);
|
|
3153
3375
|
await fs5.writeFile(
|
|
3154
|
-
|
|
3376
|
+
path16.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
|
|
3155
3377
|
generateFarmClientRouteTableModule(clientRouteTable)
|
|
3156
3378
|
);
|
|
3157
3379
|
if (clientEntry.router !== void 0) {
|
|
3158
|
-
await fs5.writeFile(
|
|
3380
|
+
await fs5.writeFile(path16.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
|
|
3159
3381
|
}
|
|
3160
3382
|
const clientInput = { [entryName]: clientEntryPath };
|
|
3161
3383
|
if (platform === "web" && canBootFarmIslandsClient(config)) {
|
|
3162
|
-
const clientBootPath =
|
|
3384
|
+
const clientBootPath = path16.join(clientEntryDir, "farm-client-boot.tsx");
|
|
3163
3385
|
await fs5.writeFile(
|
|
3164
3386
|
clientBootPath,
|
|
3165
3387
|
'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
|
|
@@ -3176,7 +3398,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3176
3398
|
if (hasScopedPostcssConfig) {
|
|
3177
3399
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
3178
3400
|
} else {
|
|
3179
|
-
const postcssConfigPath =
|
|
3401
|
+
const postcssConfigPath = path16.join(clientEntryDir, "postcss.config.cjs");
|
|
3180
3402
|
await fs5.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
3181
3403
|
postcssSearchPath = clientEntryDir;
|
|
3182
3404
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -3198,6 +3420,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3198
3420
|
// Preserve Farm's Vite 5 browser baseline when the production builder
|
|
3199
3421
|
// uses Vite 8, whose default target only covers newer browsers.
|
|
3200
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 } : {},
|
|
3201
3426
|
outDir: outputDir,
|
|
3202
3427
|
emptyOutDir: platform === "web",
|
|
3203
3428
|
// Never public: see resolveFarmClientSourcemap.
|
|
@@ -3232,24 +3457,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3232
3457
|
plugins: [
|
|
3233
3458
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
3234
3459
|
createFarmPrivateClientSourcemapsPlugin({
|
|
3235
|
-
outDir:
|
|
3236
|
-
|
|
3460
|
+
outDir: path16.join(
|
|
3461
|
+
path16.dirname(outputDir),
|
|
3237
3462
|
platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
|
|
3238
3463
|
)
|
|
3239
3464
|
}),
|
|
3240
3465
|
// The web client's preload manifests; the mobile client records its files instead.
|
|
3241
3466
|
platform === "mobile" ? createFarmMobileClientManifestPlugin({
|
|
3242
|
-
buildDir:
|
|
3467
|
+
buildDir: path16.dirname(outputDir),
|
|
3243
3468
|
entryName
|
|
3244
3469
|
}) : createFarmClientModulePreloadPlugin({
|
|
3245
3470
|
root,
|
|
3246
|
-
buildDir:
|
|
3471
|
+
buildDir: path16.dirname(outputDir),
|
|
3247
3472
|
entryName: "farm-client"
|
|
3248
3473
|
}),
|
|
3249
3474
|
...adapterOwnsDocsRuntime && platform === "web" ? [
|
|
3250
3475
|
createFarmDocsModulePreloadPlugin({
|
|
3251
3476
|
root,
|
|
3252
|
-
buildDir:
|
|
3477
|
+
buildDir: path16.dirname(outputDir),
|
|
3253
3478
|
importer: clientEntryPath,
|
|
3254
3479
|
entryName: "farm-client",
|
|
3255
3480
|
modules: [
|
|
@@ -3261,7 +3486,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3261
3486
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
3262
3487
|
...rendererVitePlugins,
|
|
3263
3488
|
...config.vite.plugins || [],
|
|
3264
|
-
farmServerOnlyEntriesPlugin({ platform }),
|
|
3489
|
+
farmServerOnlyEntriesPlugin({ platform, distDir: config.distDir || ".farm" }),
|
|
3265
3490
|
farmDocsClientConfigPlugin(
|
|
3266
3491
|
adapterOwnsDocsRuntime ? getFarmDocsAdapterConfigModule(config.docs) : void 0
|
|
3267
3492
|
),
|
|
@@ -3358,8 +3583,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3358
3583
|
mergeFarmProductionViteConfig(clientViteConfig, config.vite, { clientOutput: true })
|
|
3359
3584
|
);
|
|
3360
3585
|
if (platform === "mobile") {
|
|
3361
|
-
await fs5.rm(
|
|
3362
|
-
if (!await hasFarmMobileClientEntry(
|
|
3586
|
+
await fs5.rm(path16.join(outputDir, `${entryName}.css`), { force: true });
|
|
3587
|
+
if (!await hasFarmMobileClientEntry(path16.dirname(outputDir), outputDir)) {
|
|
3363
3588
|
throw new IncompleteClientBuildOutputError(
|
|
3364
3589
|
`${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
|
|
3365
3590
|
);
|
|
@@ -3378,15 +3603,6 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3378
3603
|
await buildTarget("web");
|
|
3379
3604
|
if (mobile) await buildTarget("mobile");
|
|
3380
3605
|
}
|
|
3381
|
-
function toBakedMarkdownSourcePath(root, filePath) {
|
|
3382
|
-
if (!filePath) return "";
|
|
3383
|
-
if (!path15.isAbsolute(filePath)) return filePath.split(path15.sep).join("/");
|
|
3384
|
-
const relative = path15.relative(root, filePath);
|
|
3385
|
-
if (!relative || relative.startsWith("..") || path15.isAbsolute(relative)) {
|
|
3386
|
-
return path15.basename(filePath);
|
|
3387
|
-
}
|
|
3388
|
-
return relative.split(path15.sep).join("/");
|
|
3389
|
-
}
|
|
3390
3606
|
function generateUniversalRouterStateRuntime(streamNavigations = false) {
|
|
3391
3607
|
return `
|
|
3392
3608
|
const FARM_PAGE_STATE_KEY = "__farmPageState";
|
|
@@ -3488,6 +3704,35 @@ function historyScrollKey(state, path) {
|
|
|
3488
3704
|
return readHistoryKey(state) || path;
|
|
3489
3705
|
}
|
|
3490
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
|
+
|
|
3491
3736
|
/*farm-router-end*/
|
|
3492
3737
|
function hasAbsoluteNavigationHref(href) {
|
|
3493
3738
|
return /^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(href) || href.startsWith("//");
|
|
@@ -3609,7 +3854,10 @@ function generateClientPageDirectorySource() {
|
|
|
3609
3854
|
return `function getFarmPageDirectory(pathname) {
|
|
3610
3855
|
const path = getFarmRoutePathname(pathname);
|
|
3611
3856
|
let matched = clientRouteMatcher.match(path);
|
|
3612
|
-
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
|
+
}
|
|
3613
3861
|
return matched ? matched.route.meta.directory || matched.route.meta.pattern : null;
|
|
3614
3862
|
}`;
|
|
3615
3863
|
}
|
|
@@ -4047,6 +4295,20 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
4047
4295
|
!clientNavigation?.signal.aborted;
|
|
4048
4296
|
},
|
|
4049
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
|
+
|
|
4050
4312
|
finishNavigation: function(navigation) {
|
|
4051
4313
|
if (this.activeNavigation?.id !== navigation.id) return;
|
|
4052
4314
|
this.activeNavigation = null;
|
|
@@ -4569,7 +4831,8 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
4569
4831
|
);
|
|
4570
4832
|
const appSetupPath = resolveFarmRendererAppSetup(root, renderer);
|
|
4571
4833
|
const rendererClientImports = isReactRenderer(renderer) ? `import React from "react";
|
|
4572
|
-
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)};
|
|
4573
4836
|
import __farmAppSetup from ${JSON.stringify(toPosixPath(appSetupPath))};
|
|
4574
4837
|
__farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
|
|
4575
4838
|
const providerClientCode = generateFarmIntegrationProviderClientCode(
|
|
@@ -4577,7 +4840,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
4577
4840
|
root,
|
|
4578
4841
|
renderer.componentExtensions ?? []
|
|
4579
4842
|
);
|
|
4580
|
-
const globalsCssPath =
|
|
4843
|
+
const globalsCssPath = path16.join(root, srcDir, "app", "globals.css");
|
|
4581
4844
|
const serverStyleModules = [];
|
|
4582
4845
|
const cssImport = [
|
|
4583
4846
|
...existsSync3(globalsCssPath) ? [globalsCssPath] : [],
|
|
@@ -4676,7 +4939,7 @@ function isFarmDocsPath() {
|
|
|
4676
4939
|
// Farm.js Client Runtime (no client components)
|
|
4677
4940
|
${cssImport}
|
|
4678
4941
|
${layoutImports}
|
|
4679
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, 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";
|
|
4680
4943
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4681
4944
|
${clientPluginEntry.imports}
|
|
4682
4945
|
${clientCachePersistence.imports}
|
|
@@ -4784,8 +5047,14 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4784
5047
|
if (!this.swapContent(html)) {
|
|
4785
5048
|
throw new Error("Farm could not swap the target document");
|
|
4786
5049
|
}
|
|
4787
|
-
|
|
4788
|
-
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;
|
|
4789
5058
|
if (options.scroll !== false) {
|
|
4790
5059
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
4791
5060
|
else window.scrollTo(0, 0);
|
|
@@ -4877,6 +5146,13 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4877
5146
|
const url = new URL(href, window.location.href);
|
|
4878
5147
|
if (isFarmExternalNavigationURL(url, window.location.origin)) return;
|
|
4879
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
|
+
}
|
|
4880
5156
|
|
|
4881
5157
|
const pathname = url.pathname + url.search;
|
|
4882
5158
|
if (this.readFreshPrefetch(pathname) !== undefined) return;
|
|
@@ -4955,7 +5231,8 @@ document.addEventListener("click", function(e) {
|
|
|
4955
5231
|
if (e.defaultPrevented) return;
|
|
4956
5232
|
|
|
4957
5233
|
e.preventDefault();
|
|
4958
|
-
|
|
5234
|
+
rememberFarmLinkLocale(anchor);
|
|
5235
|
+
spaRouter.navigate(href, readFarmLinkNavigateOptions(anchor));
|
|
4959
5236
|
});
|
|
4960
5237
|
|
|
4961
5238
|
// Link anchors on a page that does not hydrate prefetch through the router as Link would.
|
|
@@ -5048,7 +5325,7 @@ ${layoutImports}
|
|
|
5048
5325
|
${rendererClientImports}
|
|
5049
5326
|
${isolatedHydrationImport}
|
|
5050
5327
|
${providerClientCode.imports}
|
|
5051
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, 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";
|
|
5052
5329
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
5053
5330
|
import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
|
|
5054
5331
|
${clientPluginEntry.imports}
|
|
@@ -5218,7 +5495,7 @@ function reviveServerPageProps(serverProps) {
|
|
|
5218
5495
|
: serverProps;
|
|
5219
5496
|
}
|
|
5220
5497
|
|
|
5221
|
-
async function createMatchedHydrationRoute(matched, pathname, searchParams,
|
|
5498
|
+
async function createMatchedHydrationRoute(matched, pathname, searchParams, navigationPage, serverProps, layoutSource, hydrationContainer) {
|
|
5222
5499
|
const hydrateLayouts = hasHydratableLayout(pathname);
|
|
5223
5500
|
const params = matched.params;
|
|
5224
5501
|
let pageElement = null;
|
|
@@ -5255,24 +5532,30 @@ async function createMatchedHydrationRoute(matched, pathname, searchParams, serv
|
|
|
5255
5532
|
pageElement = React.createElement(Component, props);
|
|
5256
5533
|
}
|
|
5257
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.
|
|
5258
5537
|
const serverPage = document.getElementById("__farm_page__");
|
|
5259
|
-
const pageSource =
|
|
5538
|
+
const pageSource = navigationPage === undefined ? serverPage : navigationPage;
|
|
5260
5539
|
const serverTree = pageSource ? await createFarmServerTreePageElement(pageSource, pathname) : null;
|
|
5261
5540
|
// A payload-only page (islands mode) has no HTML to fall back to: fetch the whole document.
|
|
5262
|
-
if (
|
|
5541
|
+
if (
|
|
5542
|
+
!serverTree &&
|
|
5543
|
+
pageSource &&
|
|
5544
|
+
pageSource !== serverPage &&
|
|
5545
|
+
pageSource.querySelector('script[type="f/tree"][partial]')
|
|
5546
|
+
) {
|
|
5263
5547
|
return null;
|
|
5264
5548
|
}
|
|
5265
5549
|
pageElement = serverTree
|
|
5266
5550
|
? createLayoutPageBoundary(matched.route, serverTree)
|
|
5267
|
-
: createLayoutPageBoundary(
|
|
5268
|
-
matched.route,
|
|
5269
|
-
null,
|
|
5270
|
-
typeof serverHtml === "string" ? serverHtml : serverPage ? serverPage.innerHTML : "",
|
|
5271
|
-
);
|
|
5551
|
+
: createLayoutPageBoundary(matched.route, null, pageSource ? pageSource.innerHTML : "");
|
|
5272
5552
|
}
|
|
5273
5553
|
|
|
5274
5554
|
if (!pageElement) return null;
|
|
5275
|
-
if (!hydrateLayouts)
|
|
5555
|
+
if (!hydrateLayouts) {
|
|
5556
|
+
${isReactRenderer(renderer) ? "if (hydrationContainer) pageElement = restorePagePosition(React, hydrationContainer, pageElement);" : ""}
|
|
5557
|
+
return createFarmRouteState(pageElement, pathname, params, false);
|
|
5558
|
+
}
|
|
5276
5559
|
if (matched.route.pageShouldHydrate) {
|
|
5277
5560
|
pageElement = createLayoutPageBoundary(matched.route, pageElement);
|
|
5278
5561
|
}
|
|
@@ -5641,15 +5924,17 @@ async function hydrate() {
|
|
|
5641
5924
|
return;
|
|
5642
5925
|
}
|
|
5643
5926
|
const searchParams = searchParamsToObject(new URLSearchParams(window.location.search));
|
|
5927
|
+
const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
|
|
5644
5928
|
const routeState = await createMatchedHydrationRoute(
|
|
5645
5929
|
matched,
|
|
5646
5930
|
pathname,
|
|
5647
5931
|
searchParams,
|
|
5648
5932
|
undefined,
|
|
5649
5933
|
window.__FARM_PROPS__,
|
|
5934
|
+
undefined,
|
|
5935
|
+
shouldHydrate ? container : undefined,
|
|
5650
5936
|
);
|
|
5651
5937
|
if (!routeState) return;
|
|
5652
|
-
const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
|
|
5653
5938
|
const hydrationSession = await farmClientRuntime.beginHydration({
|
|
5654
5939
|
container,
|
|
5655
5940
|
mode: shouldHydrate ? "hydrate" : "render",
|
|
@@ -5898,9 +6183,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5898
6183
|
partialNavigationHeaders: function() {
|
|
5899
6184
|
const root = document.getElementById("root") || document.body;
|
|
5900
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);
|
|
5901
6191
|
return {
|
|
5902
6192
|
...(layouts.length ? { "F-Layouts": JSON.stringify(layouts) } : {}),
|
|
5903
|
-
...(
|
|
6193
|
+
...(rendersTree ? { "F-Render": "tree" } : {}),
|
|
5904
6194
|
};
|
|
5905
6195
|
},
|
|
5906
6196
|
` : ""}
|
|
@@ -6109,8 +6399,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6109
6399
|
// The history entry comes first, as on the client-render path: swapContent shows the
|
|
6110
6400
|
// page and its title, then waits for its islands, and a Back pressed meanwhile must
|
|
6111
6401
|
// leave the page on screen, not the one before it. Its islands also hydrate at their URL.
|
|
6112
|
-
|
|
6113
|
-
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;
|
|
6114
6410
|
let swappedHtml = html;
|
|
6115
6411
|
let swapped = await this.swapContent(
|
|
6116
6412
|
html,
|
|
@@ -6230,6 +6526,30 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6230
6526
|
const hydrateLayouts = hasHydratableLayout(newPathname);
|
|
6231
6527
|
const nextPage = newRoot.querySelector("#__farm_page__");
|
|
6232
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
|
+
}` : ""}
|
|
6233
6553
|
// If React already owns the shared layout, update that root. React keeps
|
|
6234
6554
|
// matching layout component instances and their state mounted.
|
|
6235
6555
|
if (matched && hydrateLayouts && reactRoot && reactRootContainer === currentRoot) {
|
|
@@ -6238,7 +6558,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6238
6558
|
matched,
|
|
6239
6559
|
newPathname,
|
|
6240
6560
|
searchParams,
|
|
6241
|
-
nextPage
|
|
6561
|
+
nextPage,
|
|
6242
6562
|
nextPageProps,
|
|
6243
6563
|
newRoot,
|
|
6244
6564
|
);
|
|
@@ -6283,6 +6603,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6283
6603
|
searchParams,
|
|
6284
6604
|
undefined,
|
|
6285
6605
|
nextPageProps,
|
|
6606
|
+
undefined,
|
|
6607
|
+
pageContainer,
|
|
6286
6608
|
);
|
|
6287
6609
|
if (!isNavigationCurrent()) return false;
|
|
6288
6610
|
if (routeState) {
|
|
@@ -6333,6 +6655,13 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6333
6655
|
const url = new URL(href, window.location.href);
|
|
6334
6656
|
if (isFarmExternalNavigationURL(url, window.location.origin)) return;
|
|
6335
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
|
+
}
|
|
6336
6665
|
prefetchFarmClientRouteTable();
|
|
6337
6666
|
|
|
6338
6667
|
// A prefetch warms an ordinary future navigation, which reads the bare
|
|
@@ -6421,7 +6750,8 @@ document.addEventListener("click", function(e) {
|
|
|
6421
6750
|
if (e.defaultPrevented) return;
|
|
6422
6751
|
|
|
6423
6752
|
e.preventDefault();
|
|
6424
|
-
|
|
6753
|
+
rememberFarmLinkLocale(anchor);
|
|
6754
|
+
spaRouter.navigate(href, readFarmLinkNavigateOptions(anchor));
|
|
6425
6755
|
});
|
|
6426
6756
|
|
|
6427
6757
|
// Initial hydration
|
|
@@ -6434,7 +6764,7 @@ void hydrate();
|
|
|
6434
6764
|
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime, sourceSnapshot) {
|
|
6435
6765
|
const viteBuild = productionVite.build;
|
|
6436
6766
|
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
6437
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
6767
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
6438
6768
|
const fs5 = await import("fs/promises");
|
|
6439
6769
|
const pluginManager = new PluginManager2({
|
|
6440
6770
|
config,
|
|
@@ -6450,9 +6780,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6450
6780
|
buildLifetime: rendererBuildLifetime
|
|
6451
6781
|
});
|
|
6452
6782
|
if (!hasScopedPostcssConfig) {
|
|
6453
|
-
postcssConfigDir = await fs5.mkdtemp(
|
|
6783
|
+
postcssConfigDir = await fs5.mkdtemp(path16.join(os.tmpdir(), "farm-postcss-"));
|
|
6454
6784
|
await fs5.writeFile(
|
|
6455
|
-
|
|
6785
|
+
path16.join(postcssConfigDir, "postcss.config.cjs"),
|
|
6456
6786
|
"module.exports = { plugins: [] };\n"
|
|
6457
6787
|
);
|
|
6458
6788
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -6537,7 +6867,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6537
6867
|
const appDirs = getFarmAppDirectories(config);
|
|
6538
6868
|
let openAPIReference = null;
|
|
6539
6869
|
if (config.openapi.enabled && config.openapi.route) {
|
|
6540
|
-
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-
|
|
6870
|
+
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-YO2RHDYU.mjs");
|
|
6541
6871
|
const openAPIManager = new OpenAPIManager(appDirs, config.openapi, {
|
|
6542
6872
|
mode: "production",
|
|
6543
6873
|
apiBaseURL: config.api.baseURL,
|
|
@@ -6795,7 +7125,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6795
7125
|
createVercelOgFontInlinePlugin(edgeMetadataImageRuntime.runtime)
|
|
6796
7126
|
] : [],
|
|
6797
7127
|
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
6798
|
-
farmServerOnlyEntriesPlugin(),
|
|
7128
|
+
farmServerOnlyEntriesPlugin({ distDir: config.distDir || ".farm" }),
|
|
6799
7129
|
farmIslandContainersPlugin(config),
|
|
6800
7130
|
farmPlugin(
|
|
6801
7131
|
{
|
|
@@ -6883,7 +7213,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6883
7213
|
}
|
|
6884
7214
|
function readFarmAppPackageIdentity(root) {
|
|
6885
7215
|
try {
|
|
6886
|
-
return JSON.parse(
|
|
7216
|
+
return JSON.parse(readFileSync2(path16.join(root, "package.json"), "utf8"));
|
|
6887
7217
|
} catch {
|
|
6888
7218
|
return {};
|
|
6889
7219
|
}
|
|
@@ -7159,6 +7489,10 @@ function useFarmNodePageResponse(ResponseClass) {
|
|
|
7159
7489
|
// Web body the way reading response.body would.
|
|
7160
7490
|
const farmLazyBufferedHtml = new WeakMap();
|
|
7161
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
|
+
|
|
7162
7496
|
function hasFarmContentType(headers) {
|
|
7163
7497
|
if (!headers) return false;
|
|
7164
7498
|
if (typeof headers.has === "function") return headers.has("content-type");
|
|
@@ -7266,7 +7600,8 @@ async function applyFarmPreloadBudget(response, pathname, request) {
|
|
|
7266
7600
|
// formatting), but do not consume and re-encode a proven preload-free body.
|
|
7267
7601
|
const ownedHtml = hasNoHtmlPreloads ? undefined : getFarmOwnedBufferedHtml(response);
|
|
7268
7602
|
const html = hasNoHtmlPreloads ? "" : (ownedHtml ?? await response.text());
|
|
7269
|
-
const managed = manageFarmDocumentPreloads(html, linkHeader, farmPreloadConfig
|
|
7603
|
+
const managed = manageFarmDocumentPreloads(html, linkHeader, farmPreloadConfig,
|
|
7604
|
+
ownedHtml === undefined ? undefined : farmPreloadShells.get(response));
|
|
7270
7605
|
// A remembered document the budget left unchanged keeps its unread body.
|
|
7271
7606
|
const reusesBody = hasNoHtmlPreloads || (ownedHtml !== undefined && managed.html === html);
|
|
7272
7607
|
if (ownedHtml !== undefined && !reusesBody && !isLazyPage) {
|
|
@@ -7306,6 +7641,10 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
|
|
|
7306
7641
|
}
|
|
7307
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 = []) {
|
|
7308
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) : "";
|
|
7309
7648
|
const farmIslandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
|
|
7310
7649
|
const farmClientBoot = canBootFarmIslandsClient(config);
|
|
7311
7650
|
const farmMobileClient = shouldBuildFarmMobileClient(config);
|
|
@@ -7339,7 +7678,8 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
|
|
|
7339
7678
|
);
|
|
7340
7679
|
const hasReactSyncRender = isReactRenderer(config.renderer);
|
|
7341
7680
|
const rendererServerImports = isReactRenderer(config.renderer) ? `import * as React from "react";
|
|
7342
|
-
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)}`;
|
|
7343
7683
|
const routeClientGraphServerRuntime = hasIsolatedClientGraphRuntime ? `function wrapFarmRouteClientGraph(element) {
|
|
7344
7684
|
return wrapFarmIsolatedClientGraph(React, element);
|
|
7345
7685
|
}
|
|
@@ -7568,7 +7908,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7568
7908
|
pattern: ${JSON.stringify(layout.pattern)},
|
|
7569
7909
|
module: ${varName},
|
|
7570
7910
|
shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)},
|
|
7571
|
-
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," : ""}
|
|
7572
7914
|
}`);
|
|
7573
7915
|
});
|
|
7574
7916
|
const slotOwnerCounts = new Map(routeSlots.map((slot) => [slot.ownerPattern, 0]));
|
|
@@ -7684,6 +8026,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7684
8026
|
const notFoundImport = notFoundPath ? `import * as CustomNotFound from ${toVirtualEntryImportSpecifier(notFoundPath)};` : "";
|
|
7685
8027
|
const apiRouteHelpersImport = apiRoutes.length > 0 ? `import { mergePluginAPIRoutes, getAllowedAPIRouteMethods, invokeAPIRouteEndpoint, createStaticAPIRouteMatcherAtBasePath, resolveAPIRouteEndpoint } from "@farm.js/core/api/runtime";` : "";
|
|
7686
8028
|
const productionRuntimeImport = `import {
|
|
8029
|
+
_getRequestCookieReadCount,
|
|
7687
8030
|
_getRequestReadCount,
|
|
7688
8031
|
_runWithAfterRequest,
|
|
7689
8032
|
_resolveCurrentCspNonce,
|
|
@@ -7713,7 +8056,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7713
8056
|
createDefaultErrorMarkup,
|
|
7714
8057
|
createFarmInstrumentationLifecycle,
|
|
7715
8058
|
createFarmLayoutSelector,
|
|
8059
|
+
createFarmLayoutBoundary,${config.docs?.enabled ? "\n createFarmDocsLayoutTree,\n farmDocsLayoutsWrapPage,\n placeFarmDocsLayoutRoot," : ""}
|
|
7716
8060
|
isInFarmRouteGroupScope,
|
|
8061
|
+
routeBoundaryCoversDirectory,
|
|
7717
8062
|
createFarmCacheKey,
|
|
7718
8063
|
createFarmMetadataRouteResponse,
|
|
7719
8064
|
createFarmAgentRobots,
|
|
@@ -7794,7 +8139,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7794
8139
|
createFarmDeploymentMismatchResponse,
|
|
7795
8140
|
FARM_DEPLOYMENT_ID_HEADER,
|
|
7796
8141
|
getFarmDeploymentMismatch,
|
|
7797
|
-
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," : ""}
|
|
7798
8143
|
} from "@farm.js/core/internal/production-runtime";${farmMobileClient ? `
|
|
7799
8144
|
import { _applyFarmMobileShellClient } from "@farm.js/core/internal/production-runtime";
|
|
7800
8145
|
// The mobile client documents load when a mobile shell asks for them (RFC 0004, 7.2), filled in
|
|
@@ -7881,7 +8226,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
7881
8226
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
7882
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;";
|
|
7883
8228
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
7884
|
-
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;
|
|
7885
8230
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
7886
8231
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
7887
8232
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -8426,7 +8771,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
8426
8771
|
|
|
8427
8772
|
// API routes bundled at build time
|
|
8428
8773
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
8429
|
-
]${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 })` : ""};
|
|
8430
8775
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
8431
8776
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
8432
8777
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -8448,7 +8793,10 @@ function fetchFarmInnerRequest(request, context) {
|
|
|
8448
8793
|
const farmLocalAPIBasePath = ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))};
|
|
8449
8794
|
// Deployment skew protection (see the deployment docs): documents embed this ID, page responses
|
|
8450
8795
|
// name it, and a page request from a browser holding another deployment's page is refused.
|
|
8451
|
-
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);` : ""}
|
|
8452
8800
|
const farmDeploymentCookiePath = ${JSON.stringify(config.basePath || "/")};
|
|
8453
8801
|
// Reports a failure Farm answers itself (an API or integration route's 500) to the plugin
|
|
8454
8802
|
// runtime request.
|
|
@@ -8574,7 +8922,8 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
8574
8922
|
';window.__FARM_INTEGRATION_API_MANIFEST__=' +
|
|
8575
8923
|
serializeFarmInlineValue(integrationManifest) +
|
|
8576
8924
|
';window.__FARM_ROUTE_SLOTS__=' + serializedRouteSlots +
|
|
8577
|
-
';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';'
|
|
8925
|
+
';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';'${searchPreserveRoutesSource ? ` +
|
|
8926
|
+
'window[Symbol.for("farm.searchPreserveRoutes")]=' + serializeFarmInlineValue(farmSearchPreserveRoutes) + ';'` : ""};
|
|
8578
8927
|
// The client boots at the canonical path when the script below moves it there.
|
|
8579
8928
|
const bootRoutes = getFarmClientBootRoutes(
|
|
8580
8929
|
typeof canonicalPath === "string" && canonicalPath.startsWith("/")
|
|
@@ -8666,6 +9015,13 @@ function createFarmFlushToken() {
|
|
|
8666
9015
|
}
|
|
8667
9016
|
|
|
8668
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;
|
|
8669
9025
|
let element = null;
|
|
8670
9026
|
for (let index = keptCount - 1; index >= 0; index--) {
|
|
8671
9027
|
const Layout = layouts[index].module.default;
|
|
@@ -9474,6 +9830,7 @@ function renderFarmI18nAlternateLinks(requestPath, snapshot, request, metadata)
|
|
|
9474
9830
|
return renderFarmLocaleAlternateLinks(routePathname, snapshot, {
|
|
9475
9831
|
metadataBase: metadata ? metadata.metadataBase : undefined,
|
|
9476
9832
|
origin: request ? resolveFarmI18nAlternateOrigin(request) : undefined,
|
|
9833
|
+
languages: metadata && metadata.alternates ? metadata.alternates.languages : undefined,
|
|
9477
9834
|
});
|
|
9478
9835
|
}
|
|
9479
9836
|
|
|
@@ -10369,9 +10726,10 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10369
10726
|
|
|
10370
10727
|
const pathname = getFarmRoutePathname(new URL(request.url).pathname);
|
|
10371
10728
|
const applicableLayouts = getApplicableLayouts(pathname);
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
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);
|
|
10375
10733
|
|
|
10376
10734
|
const source = await response.text();
|
|
10377
10735
|
const bodyMatch = source.match(/<body([^>]*)>([\\s\\S]*?)<\\/body>/i);
|
|
@@ -10385,39 +10743,34 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10385
10743
|
|
|
10386
10744
|
const matchedRoute = matchPageRoute(pathname);
|
|
10387
10745
|
const params = matchedRoute?.params || {};
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
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"},
|
|
10403
10763
|
});
|
|
10404
10764
|
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
wrappedElement = React.createElement(LayoutComponent, {
|
|
10409
|
-
children: wrappedElement,
|
|
10410
|
-
params,
|
|
10411
|
-
});
|
|
10412
|
-
}
|
|
10413
|
-
}
|
|
10414
|
-
|
|
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);
|
|
10415
10768
|
const renderedRoot = await renderFarmElement(
|
|
10416
10769
|
ReactDOMServer,
|
|
10417
10770
|
React.createElement(
|
|
10418
10771
|
"div",
|
|
10419
10772
|
{ id: "root" },
|
|
10420
|
-
wrapFarmRouteClientGraph(
|
|
10773
|
+
shouldHydrateLayout ? wrapFarmRouteClientGraph(rootElement) : rootElement,
|
|
10421
10774
|
),
|
|
10422
10775
|
);
|
|
10423
10776
|
let rootMarkup = renderedRoot.html;
|
|
@@ -10425,6 +10778,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10425
10778
|
rootMarkup = await new Response(renderedRoot.stream).text();
|
|
10426
10779
|
if (renderedRoot.streamErrors.length > 0) throw renderedRoot.streamErrors[0];
|
|
10427
10780
|
}
|
|
10781
|
+
// A root layout that renders the document gives #root its body; the docs runtime keeps its own.
|
|
10782
|
+
rootMarkup = placeFarmDocsLayoutRoot(rootMarkup);
|
|
10428
10783
|
let html = source.replace(
|
|
10429
10784
|
bodyMatch[0],
|
|
10430
10785
|
// Function replacement: rendered markup may contain $-sequences ($&, $', $$).
|
|
@@ -10496,7 +10851,6 @@ function getPPRShellBypassReason(request, middlewareData, middlewareContext) {
|
|
|
10496
10851
|
if (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce) return "csp-nonce";
|
|
10497
10852
|
const method = request.method.toUpperCase();
|
|
10498
10853
|
if (method !== "GET" && method !== "HEAD") return "method";
|
|
10499
|
-
if (withoutFarmDeploymentCookie(request.headers.get("cookie"))) return "cookie";
|
|
10500
10854
|
if (request.headers.get("authorization")) return "authorization";
|
|
10501
10855
|
if (request.headers.get("x-farm-intercept-from")) return "route-interception";
|
|
10502
10856
|
if (request.headers.get("x-farm-ppr-refresh")) return "refresh";
|
|
@@ -10528,13 +10882,9 @@ function getPPRHeaders(status, config) {
|
|
|
10528
10882
|
|
|
10529
10883
|
if (status === "bypass") {
|
|
10530
10884
|
headers["Cache-Control"] = "private, no-store";
|
|
10531
|
-
return headers;
|
|
10532
|
-
}
|
|
10533
|
-
|
|
10534
|
-
if (typeof config.revalidate === "number" && config.revalidate > 0) {
|
|
10535
|
-
headers["Cache-Control"] = \`s-maxage=\${config.revalidate}, stale-while-revalidate\`;
|
|
10536
10885
|
}
|
|
10537
|
-
|
|
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.
|
|
10538
10888
|
return headers;
|
|
10539
10889
|
}
|
|
10540
10890
|
|
|
@@ -10555,13 +10905,10 @@ function getRouteSharedCacheControl(route, pprCanCache) {
|
|
|
10555
10905
|
return resolveRouteSharedCacheControl(resolveRouteRenderingView(route), pprCanCache);
|
|
10556
10906
|
}
|
|
10557
10907
|
|
|
10908
|
+
// { html, cookieIndependent }: cookieIndependent marks a shell whose render read no cookies.
|
|
10558
10909
|
async function getCachedPPRShell(cacheKey) {
|
|
10559
10910
|
const entry = await pprShellCache.getEntryAsync(cacheKey);
|
|
10560
|
-
|
|
10561
|
-
return null;
|
|
10562
|
-
}
|
|
10563
|
-
|
|
10564
|
-
return entry.value.html;
|
|
10911
|
+
return entry ? entry.value : null;
|
|
10565
10912
|
}
|
|
10566
10913
|
|
|
10567
10914
|
/**
|
|
@@ -11231,7 +11578,10 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11231
11578
|
}
|
|
11232
11579
|
: matchedRoute` : "matchedRoute"};
|
|
11233
11580
|
emitFarmEvent({ type: "route.matched", pathname, route: route.pattern, params });
|
|
11234
|
-
|
|
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
|
+
|
|
11235
11585
|
try {
|
|
11236
11586
|
${farmIslandsMode ? `// Islands mode: the layouts the navigating browser keeps, decided before the shell cache
|
|
11237
11587
|
// so a PPR route caches each segment under its own key. A static page, a layout that
|
|
@@ -11253,7 +11603,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11253
11603
|
? getPPRShellBypassReason(request, middlewareData, middlewareContext)
|
|
11254
11604
|
: undefined;
|
|
11255
11605
|
let pprCanCache = pprConfig.enabled && !pprBypassReason;
|
|
11256
|
-
|
|
11606
|
+
let pprCacheKey = pprCanCache
|
|
11257
11607
|
? getPPRShellCacheKey(
|
|
11258
11608
|
url,
|
|
11259
11609
|
farmLocaleResolution?.locale,
|
|
@@ -11269,8 +11619,18 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11269
11619
|
emitFarmEvent({ type: "ppr.refresh.start", route: pathname });
|
|
11270
11620
|
}
|
|
11271
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
|
+
}
|
|
11272
11632
|
if (pprCacheKey) {
|
|
11273
|
-
const cachedPPRShell =
|
|
11633
|
+
const cachedPPRShell = cachedPPRShellEntry?.html;
|
|
11274
11634
|
if (cachedPPRShell) {
|
|
11275
11635
|
emitFarmEvent({ type: "ppr.shell.hit", route: pathname, key: pprCacheKey });
|
|
11276
11636
|
emitFarmEvent({
|
|
@@ -11280,25 +11640,46 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11280
11640
|
status: 200,
|
|
11281
11641
|
durationMs: Date.now() - requestStartTime,
|
|
11282
11642
|
});
|
|
11283
|
-
|
|
11643
|
+
const response = rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(cachedPPRShell, {
|
|
11284
11644
|
status: 200,
|
|
11285
11645
|
headers: {
|
|
11286
11646
|
"Content-Type": "text/html; charset=utf-8",
|
|
11287
|
-
"x-farm-preload-buffered":
|
|
11647
|
+
"x-farm-preload-buffered": "1",
|
|
11288
11648
|
...(farmFontPreloadHeader ? { "Link": farmFontPreloadHeader } : {}),
|
|
11289
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
|
+
: {}),
|
|
11290
11659
|
// A segment is one navigation's answer, never a CDN entry: some CDNs ignore Vary.
|
|
11291
11660
|
...(farmKeptLayouts
|
|
11292
11661
|
? { "Cache-Control": "private, no-store", "Vary": "F-Layouts" }
|
|
11293
11662
|
: {}),
|
|
11294
11663
|
},
|
|
11295
11664
|
}), middlewareHeaders), cachedPPRShell);
|
|
11665
|
+
farmPreloadShells.set(response, cachedPPRShellEntry);
|
|
11666
|
+
return response;
|
|
11296
11667
|
}
|
|
11297
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
|
+
}
|
|
11298
11678
|
}
|
|
11299
11679
|
|
|
11300
11680
|
// Reads from here on belong to the page render, not to middleware.
|
|
11301
11681
|
const requestReadsBeforeRender = _getRequestReadCount();
|
|
11682
|
+
const requestCookieReadsBeforeRender = _getRequestCookieReadCount();
|
|
11302
11683
|
// A swr or cache route rule stores this page by URL for every visitor. Nitro hands Farm the
|
|
11303
11684
|
// request without its cookies, Authorization, or any header the rule does not key on, so a
|
|
11304
11685
|
// render that reads nothing of the request is that shared page, whatever its route config.
|
|
@@ -11620,6 +12001,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11620
12001
|
pageElement,
|
|
11621
12002
|
);
|
|
11622
12003
|
|
|
12004
|
+
${isReactRenderer(config.renderer) ? "if (route.shouldHydrate && !shouldHydrateLayout) pageElement = markPagePosition(React, pageElement);" : ""}
|
|
11623
12005
|
// Wrap with layouts (from innermost to outermost)
|
|
11624
12006
|
// Layouts are sorted by depth (root first), so we process in reverse
|
|
11625
12007
|
let wrappedElement = pageElement;
|
|
@@ -11675,19 +12057,13 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11675
12057
|
params,
|
|
11676
12058
|
...slotProps,
|
|
11677
12059
|
});
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
"data-farm-layout-key":
|
|
11686
|
-
farmLayoutKeyOf && !shouldHydrateLayout
|
|
11687
|
-
? farmLayoutKeyOf(layout.pattern, params)
|
|
11688
|
-
: undefined,
|
|
11689
|
-
style: { display: "contents" },
|
|
11690
|
-
},
|
|
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,
|
|
11691
12067
|
wrappedElement,
|
|
11692
12068
|
);
|
|
11693
12069
|
}
|
|
@@ -11697,6 +12073,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11697
12073
|
wrappedElement = wrapFarmRouteClientGraph(wrappedElement);
|
|
11698
12074
|
}
|
|
11699
12075
|
|
|
12076
|
+
${isReactRenderer(config.renderer) ? "if (route.shouldHydrate && !shouldHydrateLayout) wrappedElement = markLayoutPosition(React, wrappedElement);" : ""}
|
|
11700
12077
|
wrappedElement = wrapWithFarmIntegrationProviders(wrappedElement);
|
|
11701
12078
|
return renderFarmElement(ReactDOMServer, wrappedElement, route.pattern, farmFlushToken);
|
|
11702
12079
|
};
|
|
@@ -11785,6 +12162,16 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11785
12162
|
emitFarmEvent({ type: "ppr.shell.bypass", route: pathname, reason: "request-read" });
|
|
11786
12163
|
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "request-read" });
|
|
11787
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
|
+
}
|
|
11788
12175
|
|
|
11789
12176
|
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(config.agent?.jsonLd ?? false)} });
|
|
11790
12177
|
const title = renderedMetadata.title;
|
|
@@ -12130,23 +12517,24 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
12130
12517
|
pprCacheKey &&
|
|
12131
12518
|
request.method.toUpperCase() !== "HEAD"
|
|
12132
12519
|
) {
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
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
|
+
}
|
|
12150
12538
|
}
|
|
12151
12539
|
|
|
12152
12540
|
if (pprBypassReason === "refresh") {
|
|
@@ -12174,6 +12562,19 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
12174
12562
|
), middlewareHeaders), fullHtml);
|
|
12175
12563
|
}
|
|
12176
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
|
+
|
|
12177
12578
|
if (isFarmRedirectError(error)) {
|
|
12178
12579
|
const redirect = getFarmRedirectError(error);
|
|
12179
12580
|
const redirectUrl =
|
|
@@ -12214,6 +12615,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
12214
12615
|
emitFarmEvent({ type: "render.error", route: pathname, error });
|
|
12215
12616
|
console.error("SSR Error:", error);
|
|
12216
12617
|
return renderFarmErrorResponse(error, routePathname, params);
|
|
12618
|
+
} finally {
|
|
12619
|
+
pprShellWrite?.release();
|
|
12217
12620
|
}
|
|
12218
12621
|
}
|
|
12219
12622
|
|
|
@@ -12253,7 +12656,13 @@ ${servesDefaultMCP ? `
|
|
|
12253
12656
|
...(middlewareData?.size ? { middleware: { data: middlewareData } } : {}),
|
|
12254
12657
|
});
|
|
12255
12658
|
|
|
12256
|
-
|
|
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
|
+
);
|
|
12257
12666
|
for (let i = applicableLayouts.length - 1; i >= 0; i--) {
|
|
12258
12667
|
const LayoutComponent = applicableLayouts[i].module.default;
|
|
12259
12668
|
if (LayoutComponent) {
|
|
@@ -12929,8 +13338,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12929
13338
|
const isVercel = preset === "vercel";
|
|
12930
13339
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
12931
13340
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
12932
|
-
const runtimeServerOutputDir = isVercel ?
|
|
12933
|
-
const ssrOutputDir =
|
|
13341
|
+
const runtimeServerOutputDir = isVercel ? path16.join(outputDir, "functions", "__nitro.func") : path16.join(outputDir, "server");
|
|
13342
|
+
const ssrOutputDir = path16.join(root, distDir, "ssr");
|
|
12934
13343
|
const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
|
|
12935
13344
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
12936
13345
|
(image) => image.sourceType === "module"
|
|
@@ -13063,9 +13472,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
13063
13472
|
resolveHashedClientCssHref(clientOutputDir),
|
|
13064
13473
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
13065
13474
|
resolveClientBootSrc(clientOutputDir),
|
|
13066
|
-
readFarmDocsModulePreloads(
|
|
13067
|
-
readFarmClientModulePreloads(
|
|
13068
|
-
readFarmClientRouteTable(
|
|
13475
|
+
readFarmDocsModulePreloads(path16.join(root, distDir)),
|
|
13476
|
+
readFarmClientModulePreloads(path16.join(root, distDir)),
|
|
13477
|
+
readFarmClientRouteTable(path16.join(root, distDir))
|
|
13069
13478
|
]);
|
|
13070
13479
|
let nativeStylesheets;
|
|
13071
13480
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
@@ -13073,7 +13482,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
13073
13482
|
const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
|
|
13074
13483
|
const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
|
|
13075
13484
|
await finalizeFarmMobileClient({
|
|
13076
|
-
buildDir:
|
|
13485
|
+
buildDir: path16.join(root, distDir),
|
|
13077
13486
|
clientOutputDir,
|
|
13078
13487
|
webEntry: clientJsSrc,
|
|
13079
13488
|
webBoot: clientBootSrc,
|
|
@@ -13115,12 +13524,12 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
13115
13524
|
await fs5.mkdir(ssrOutputDir, { recursive: true });
|
|
13116
13525
|
await Promise.all(
|
|
13117
13526
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
13118
|
-
const filePath =
|
|
13119
|
-
await fs5.mkdir(
|
|
13527
|
+
const filePath = path16.join(ssrOutputDir, fileName);
|
|
13528
|
+
await fs5.mkdir(path16.dirname(filePath), { recursive: true });
|
|
13120
13529
|
await fs5.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
13121
13530
|
})
|
|
13122
13531
|
);
|
|
13123
|
-
const nitroEntryPath =
|
|
13532
|
+
const nitroEntryPath = path16.join(ssrOutputDir, "nitro-entry.mjs");
|
|
13124
13533
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
13125
13534
|
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
13126
13535
|
const nitroEntryCode = `
|
|
@@ -13338,20 +13747,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
13338
13747
|
);
|
|
13339
13748
|
}
|
|
13340
13749
|
await fs5.writeFile(
|
|
13341
|
-
|
|
13750
|
+
path16.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
|
|
13342
13751
|
FARM_DESKTOP_ENV_MODULE_SOURCE
|
|
13343
13752
|
);
|
|
13344
13753
|
}
|
|
13345
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
13754
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path16.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
13346
13755
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
13347
13756
|
await fs5.writeFile(
|
|
13348
|
-
|
|
13757
|
+
path16.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
13349
13758
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
13350
13759
|
);
|
|
13351
13760
|
await fs5.writeFile(
|
|
13352
13761
|
farmNodeServerEntryPath,
|
|
13353
13762
|
createFarmNodeServerEntry({
|
|
13354
|
-
nitroEntryFile:
|
|
13763
|
+
nitroEntryFile: path16.basename(nitroEntryPath),
|
|
13355
13764
|
nodeAdapterModule,
|
|
13356
13765
|
server: config.server,
|
|
13357
13766
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
|
|
@@ -13359,12 +13768,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
13359
13768
|
})
|
|
13360
13769
|
);
|
|
13361
13770
|
}
|
|
13362
|
-
const farmBunServerEntryPath = preset === "bun" ?
|
|
13771
|
+
const farmBunServerEntryPath = preset === "bun" ? path16.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
13363
13772
|
if (farmBunServerEntryPath) {
|
|
13364
13773
|
await fs5.writeFile(
|
|
13365
13774
|
farmBunServerEntryPath,
|
|
13366
13775
|
createFarmBunServerEntry({
|
|
13367
|
-
nitroEntryFile:
|
|
13776
|
+
nitroEntryFile: path16.basename(nitroEntryPath),
|
|
13368
13777
|
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
13369
13778
|
server: config.server,
|
|
13370
13779
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
|
|
@@ -13372,7 +13781,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13372
13781
|
})
|
|
13373
13782
|
);
|
|
13374
13783
|
}
|
|
13375
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
13784
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path16.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
13376
13785
|
if (farmNetlifyEntryPath) {
|
|
13377
13786
|
await fs5.writeFile(
|
|
13378
13787
|
farmNetlifyEntryPath,
|
|
@@ -13381,7 +13790,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13381
13790
|
})
|
|
13382
13791
|
);
|
|
13383
13792
|
}
|
|
13384
|
-
const farmCloudflareEnvPath = preset === "cloudflare-pages" ?
|
|
13793
|
+
const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path16.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
|
|
13385
13794
|
if (farmCloudflareEnvPath) {
|
|
13386
13795
|
await fs5.writeFile(
|
|
13387
13796
|
farmCloudflareEnvPath,
|
|
@@ -13455,7 +13864,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13455
13864
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
13456
13865
|
serverDir: false,
|
|
13457
13866
|
serverEntry: false,
|
|
13458
|
-
buildDir:
|
|
13867
|
+
buildDir: path16.join(root, distDir, ".nitro"),
|
|
13459
13868
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
13460
13869
|
compatibilityDate: "2024-12-01",
|
|
13461
13870
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -13549,7 +13958,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13549
13958
|
if (pluginManager) {
|
|
13550
13959
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
13551
13960
|
}
|
|
13552
|
-
const expectedServerDir =
|
|
13961
|
+
const expectedServerDir = path16.join(outputDir, "server");
|
|
13553
13962
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
13554
13963
|
(key) => key !== "external" && key !== "plugins"
|
|
13555
13964
|
);
|
|
@@ -13564,10 +13973,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
13564
13973
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
13565
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(
|
|
13566
13975
|
nitroConfig.handlers?.some(
|
|
13567
|
-
(handler) =>
|
|
13976
|
+
(handler) => path16.resolve(handler?.handler || "") === nitroEntryPath
|
|
13568
13977
|
)
|
|
13569
13978
|
);
|
|
13570
|
-
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);
|
|
13571
13980
|
const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
|
|
13572
13981
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
13573
13982
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
@@ -13577,16 +13986,23 @@ function toFarmNodeResponse(request, response) {
|
|
|
13577
13986
|
const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
|
|
13578
13987
|
const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
|
|
13579
13988
|
const ssrRollupPlugin = canReusePrebuiltSSR ? prebuiltSSRPlugin : createServerReadSSRAssetsPlugin(ssrBundle, ssrOutputDir);
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
nitroConfig.rollupConfig
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
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
|
+
};
|
|
13590
14006
|
nitroConfig.minify = useFarmServerMinifier ? false : shouldMinify;
|
|
13591
14007
|
const nitroInstance = await nitroBuilder.createNitro(nitroConfig);
|
|
13592
14008
|
let prerenderOrder = /* @__PURE__ */ new Map();
|
|
@@ -13689,8 +14105,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13689
14105
|
};
|
|
13690
14106
|
prerendererConfig.output = {
|
|
13691
14107
|
...prerendererConfig.output,
|
|
13692
|
-
serverDir:
|
|
13693
|
-
prerendererConfig.buildDir ??
|
|
14108
|
+
serverDir: path16.join(
|
|
14109
|
+
prerendererConfig.buildDir ?? path16.join(root, distDir, ".nitro"),
|
|
13694
14110
|
"prerender"
|
|
13695
14111
|
)
|
|
13696
14112
|
};
|
|
@@ -13709,7 +14125,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13709
14125
|
const prerenderServerDir = prerenderer.options.output.serverDir;
|
|
13710
14126
|
await copyPrebuiltSSRBundle(
|
|
13711
14127
|
ssrBundle,
|
|
13712
|
-
|
|
14128
|
+
path16.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
13713
14129
|
null,
|
|
13714
14130
|
fs5
|
|
13715
14131
|
);
|
|
@@ -13785,7 +14201,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13785
14201
|
const copyResults = await Promise.allSettled([
|
|
13786
14202
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
13787
14203
|
prebuiltSSRFilesResult.value,
|
|
13788
|
-
|
|
14204
|
+
path16.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
13789
14205
|
fs5
|
|
13790
14206
|
) : Promise.resolve(),
|
|
13791
14207
|
runtimeCopyPromise
|
|
@@ -13795,14 +14211,14 @@ function toFarmNodeResponse(request, response) {
|
|
|
13795
14211
|
);
|
|
13796
14212
|
if (failedCopy) throw failedCopy.reason;
|
|
13797
14213
|
if (canReusePrebuiltSSR) {
|
|
13798
|
-
await registerPrebuiltSSRPackageImport(
|
|
14214
|
+
await registerPrebuiltSSRPackageImport(path16.join(outputDir, "server"), ssrEntryFile, fs5);
|
|
13799
14215
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
13800
14216
|
}
|
|
13801
14217
|
if (useRolldownBuilder) {
|
|
13802
14218
|
logger.info("\u26A1 Built the Node adapter with Rolldown");
|
|
13803
14219
|
}
|
|
13804
14220
|
if (preset === "node-server" && !desktopServerEntry) {
|
|
13805
|
-
await installFarmCompileCacheLauncher(
|
|
14221
|
+
await installFarmCompileCacheLauncher(path16.join(outputDir, "server"), fs5);
|
|
13806
14222
|
}
|
|
13807
14223
|
if (preset.startsWith("cloudflare")) {
|
|
13808
14224
|
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs5);
|
|
@@ -13825,7 +14241,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13825
14241
|
routeRuntimeManifest,
|
|
13826
14242
|
farmCron.provider === "host" ? farmCron.jobs : [],
|
|
13827
14243
|
{
|
|
13828
|
-
buildDir:
|
|
14244
|
+
buildDir: path16.join(root, distDir),
|
|
13829
14245
|
middlewareRoutes: edgeMiddlewareRoutes,
|
|
13830
14246
|
guardedPages: edgeGuardedPrerenderRoutes
|
|
13831
14247
|
},
|
|
@@ -13839,16 +14255,16 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
13839
14255
|
return {
|
|
13840
14256
|
dir: outputDir,
|
|
13841
14257
|
...preset === "node-server" ? {
|
|
13842
|
-
serverDir:
|
|
13843
|
-
publicDir:
|
|
14258
|
+
serverDir: path16.join(outputDir, "server"),
|
|
14259
|
+
publicDir: path16.join(outputDir, "public")
|
|
13844
14260
|
} : isVercel ? {
|
|
13845
|
-
serverDir:
|
|
13846
|
-
publicDir:
|
|
14261
|
+
serverDir: path16.join(outputDir, "functions", "__nitro.func"),
|
|
14262
|
+
publicDir: path16.join(outputDir, "static")
|
|
13847
14263
|
} : {}
|
|
13848
14264
|
};
|
|
13849
14265
|
}
|
|
13850
14266
|
async function populateCloudflareProcessEnv(serverDir, fs5) {
|
|
13851
|
-
const wranglerPath =
|
|
14267
|
+
const wranglerPath = path16.join(serverDir, "wrangler.json");
|
|
13852
14268
|
let source;
|
|
13853
14269
|
try {
|
|
13854
14270
|
source = await fs5.readFile(wranglerPath, "utf8");
|
|
@@ -13876,8 +14292,8 @@ async function writeSSRBundleFiles(files, targetDir, fs5) {
|
|
|
13876
14292
|
await fs5.rm(targetDir, { recursive: true, force: true });
|
|
13877
14293
|
await Promise.all(
|
|
13878
14294
|
files.map(async ({ fileName, contents }) => {
|
|
13879
|
-
const targetPath =
|
|
13880
|
-
await fs5.mkdir(
|
|
14295
|
+
const targetPath = path16.join(targetDir, fileName);
|
|
14296
|
+
await fs5.mkdir(path16.dirname(targetPath), { recursive: true });
|
|
13881
14297
|
await fs5.writeFile(targetPath, contents);
|
|
13882
14298
|
})
|
|
13883
14299
|
);
|
|
@@ -13886,8 +14302,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs5) {
|
|
|
13886
14302
|
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs5);
|
|
13887
14303
|
}
|
|
13888
14304
|
async function installFarmCompileCacheLauncher(serverDir, fs5) {
|
|
13889
|
-
const entryPath =
|
|
13890
|
-
const serverPath =
|
|
14305
|
+
const entryPath = path16.join(serverDir, "index.mjs");
|
|
14306
|
+
const serverPath = path16.join(serverDir, FARM_SERVER_MODULE_FILE);
|
|
13891
14307
|
const entry = await fs5.readFile(entryPath, "utf8").catch((error) => {
|
|
13892
14308
|
if (error.code === "ENOENT") return null;
|
|
13893
14309
|
throw error;
|
|
@@ -13896,17 +14312,18 @@ async function installFarmCompileCacheLauncher(serverDir, fs5) {
|
|
|
13896
14312
|
if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
|
|
13897
14313
|
await fs5.rename(entryPath, serverPath);
|
|
13898
14314
|
await fs5.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
|
|
13899
|
-
await fs5.rm(
|
|
14315
|
+
await fs5.rm(path16.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
|
|
13900
14316
|
return true;
|
|
13901
14317
|
}
|
|
13902
14318
|
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs5) {
|
|
13903
|
-
const packagePath =
|
|
14319
|
+
const packagePath = path16.join(serverDir, "package.json");
|
|
13904
14320
|
const packageJSON = await fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13905
14321
|
if (error.code === "ENOENT") return { type: "module" };
|
|
13906
14322
|
throw error;
|
|
13907
14323
|
});
|
|
13908
14324
|
const existingImports = packageJSON.imports && typeof packageJSON.imports === "object" ? packageJSON.imports : {};
|
|
13909
14325
|
const outputEntry = `${FARM_SSR_OUTPUT_DIR}/${ssrEntryFile}`.replace(/\\/g, "/");
|
|
14326
|
+
packageJSON.type ?? (packageJSON.type = "module");
|
|
13910
14327
|
packageJSON.imports = {
|
|
13911
14328
|
...existingImports,
|
|
13912
14329
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
@@ -13929,18 +14346,18 @@ async function moveVercelOutputPath(src, dest, fs5) {
|
|
|
13929
14346
|
await fs5.rm(src, { recursive: true, force: true });
|
|
13930
14347
|
}
|
|
13931
14348
|
async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
|
|
13932
|
-
const serverDir =
|
|
13933
|
-
const functionsDir =
|
|
13934
|
-
const nitroFuncDir =
|
|
13935
|
-
const staticDir =
|
|
13936
|
-
const publicDir =
|
|
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");
|
|
13937
14354
|
await fs5.mkdir(nitroFuncDir, { recursive: true });
|
|
13938
14355
|
const serverContents = await fs5.readdir(serverDir).catch((error) => {
|
|
13939
14356
|
if (error.code === "ENOENT") return [];
|
|
13940
14357
|
throw error;
|
|
13941
14358
|
});
|
|
13942
14359
|
for (const file of serverContents) {
|
|
13943
|
-
await moveVercelOutputPath(
|
|
14360
|
+
await moveVercelOutputPath(path16.join(serverDir, file), path16.join(nitroFuncDir, file), fs5);
|
|
13944
14361
|
}
|
|
13945
14362
|
if (serverContents.length > 0) await fs5.rm(serverDir, { recursive: true, force: true });
|
|
13946
14363
|
try {
|
|
@@ -13950,7 +14367,7 @@ async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflo
|
|
|
13950
14367
|
}
|
|
13951
14368
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5);
|
|
13952
14369
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs5);
|
|
13953
|
-
const configPath =
|
|
14370
|
+
const configPath = path16.join(outputDir, "config.json");
|
|
13954
14371
|
const configContent = await fs5.readFile(configPath, "utf-8");
|
|
13955
14372
|
const vercelConfig = JSON.parse(configContent);
|
|
13956
14373
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
@@ -13994,7 +14411,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
|
|
|
13994
14411
|
mainRoot,
|
|
13995
14412
|
root,
|
|
13996
14413
|
config.srcDir,
|
|
13997
|
-
|
|
14414
|
+
path16.join(nitroFuncDir, "farm-docs-content"),
|
|
13998
14415
|
fs5
|
|
13999
14416
|
);
|
|
14000
14417
|
for (const [index, docsRoot] of extraRoots.entries()) {
|
|
@@ -14002,7 +14419,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
|
|
|
14002
14419
|
docsRoot,
|
|
14003
14420
|
root,
|
|
14004
14421
|
config.srcDir,
|
|
14005
|
-
|
|
14422
|
+
path16.join(nitroFuncDir, "farm-docs-roots", String(index)),
|
|
14006
14423
|
fs5
|
|
14007
14424
|
);
|
|
14008
14425
|
}
|
|
@@ -14020,18 +14437,18 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
|
|
|
14020
14437
|
);
|
|
14021
14438
|
}
|
|
14022
14439
|
await fs5.rm(bundledContentDir, { recursive: true, force: true });
|
|
14023
|
-
await fs5.mkdir(
|
|
14440
|
+
await fs5.mkdir(path16.dirname(bundledContentDir), { recursive: true });
|
|
14024
14441
|
await fs5.cp(docsContentDir, bundledContentDir, {
|
|
14025
14442
|
recursive: true,
|
|
14026
14443
|
force: true,
|
|
14027
14444
|
dereference: true
|
|
14028
14445
|
});
|
|
14029
14446
|
await fs5.writeFile(
|
|
14030
|
-
|
|
14447
|
+
path16.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
14031
14448
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
14032
14449
|
`
|
|
14033
14450
|
);
|
|
14034
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
14451
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path16.relative(root, docsContentDir)}`);
|
|
14035
14452
|
}
|
|
14036
14453
|
function resolveServerFunctionPlatform(preset) {
|
|
14037
14454
|
return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
|
|
@@ -14048,7 +14465,7 @@ function platformFieldAllows(field, value) {
|
|
|
14048
14465
|
}
|
|
14049
14466
|
async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
14050
14467
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
14051
|
-
const projectRequire = createRequire2(
|
|
14468
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
14052
14469
|
let sharpRequire = projectRequire;
|
|
14053
14470
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
14054
14471
|
try {
|
|
@@ -14058,10 +14475,10 @@ async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
|
14058
14475
|
}
|
|
14059
14476
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
14060
14477
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
14061
|
-
const stageRoot =
|
|
14478
|
+
const stageRoot = path16.join(root, distDir, "tmp");
|
|
14062
14479
|
await fs5.mkdir(stageRoot, { recursive: true });
|
|
14063
|
-
const stageDir = await fs5.mkdtemp(
|
|
14064
|
-
const targetNodeModules =
|
|
14480
|
+
const stageDir = await fs5.mkdtemp(path16.join(stageRoot, "sharp-runtime-"));
|
|
14481
|
+
const targetNodeModules = path16.join(stageDir, "node_modules");
|
|
14065
14482
|
function copyPackage(packageName, parentRequire) {
|
|
14066
14483
|
const activeCopy = packageCopies.get(packageName);
|
|
14067
14484
|
if (activeCopy) return activeCopy;
|
|
@@ -14074,10 +14491,10 @@ async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
|
14074
14491
|
if (!packageJsonPath) return;
|
|
14075
14492
|
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
14076
14493
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
14077
|
-
const packageDir =
|
|
14078
|
-
const targetDir =
|
|
14494
|
+
const packageDir = path16.dirname(packageJsonPath);
|
|
14495
|
+
const targetDir = path16.join(targetNodeModules, ...packageName.split("/"));
|
|
14079
14496
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
14080
|
-
await fs5.mkdir(
|
|
14497
|
+
await fs5.mkdir(path16.dirname(targetDir), { recursive: true });
|
|
14081
14498
|
const packageRequire = createRequire2(packageJsonPath);
|
|
14082
14499
|
const dependencies = {
|
|
14083
14500
|
...packageJson.dependencies,
|
|
@@ -14112,8 +14529,8 @@ async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
|
14112
14529
|
};
|
|
14113
14530
|
}
|
|
14114
14531
|
async function installStagedSharpRuntime(staged, nitroFuncDir, fs5) {
|
|
14115
|
-
const stagedNodeModules =
|
|
14116
|
-
const targetNodeModules =
|
|
14532
|
+
const stagedNodeModules = path16.join(staged.stageDir, "node_modules");
|
|
14533
|
+
const targetNodeModules = path16.join(nitroFuncDir, "node_modules");
|
|
14117
14534
|
try {
|
|
14118
14535
|
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs5);
|
|
14119
14536
|
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
@@ -14141,8 +14558,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs5) {
|
|
|
14141
14558
|
const entries = await fs5.readdir(sourceDir, { withFileTypes: true });
|
|
14142
14559
|
await settleAllOrThrow(
|
|
14143
14560
|
entries.map(async (entry) => {
|
|
14144
|
-
const sourcePath =
|
|
14145
|
-
const targetPath =
|
|
14561
|
+
const sourcePath = path16.join(sourceDir, entry.name);
|
|
14562
|
+
const targetPath = path16.join(targetDir, entry.name);
|
|
14146
14563
|
try {
|
|
14147
14564
|
await fs5.rename(sourcePath, targetPath);
|
|
14148
14565
|
return;
|
|
@@ -14169,13 +14586,13 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs5) {
|
|
|
14169
14586
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
14170
14587
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
14171
14588
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
14172
|
-
const file = generated.modulePath ? toPosixPath(
|
|
14589
|
+
const file = generated.modulePath ? toPosixPath(path16.relative(root, generated.modulePath)) : "";
|
|
14173
14590
|
throw new Error(
|
|
14174
14591
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
14175
14592
|
);
|
|
14176
14593
|
}
|
|
14177
14594
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
14178
|
-
const projectRequire = createRequire2(
|
|
14595
|
+
const projectRequire = createRequire2(path16.join(root, "package.json"));
|
|
14179
14596
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
14180
14597
|
if (packageJsonPath) return packageJsonPath;
|
|
14181
14598
|
try {
|
|
@@ -14188,9 +14605,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs5) {
|
|
|
14188
14605
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
14189
14606
|
if (!packageJsonPath) return;
|
|
14190
14607
|
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
14191
|
-
const packageDir =
|
|
14192
|
-
const targetDir =
|
|
14193
|
-
await fs5.mkdir(
|
|
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 });
|
|
14194
14611
|
await fs5.cp(packageDir, targetDir, {
|
|
14195
14612
|
recursive: true,
|
|
14196
14613
|
force: true,
|
|
@@ -14206,7 +14623,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs5) {
|
|
|
14206
14623
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
14207
14624
|
}
|
|
14208
14625
|
async function readNitroOutputPackage(outputDir, fs5) {
|
|
14209
|
-
const packagePath =
|
|
14626
|
+
const packagePath = path16.join(outputDir, "package.json");
|
|
14210
14627
|
return fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
14211
14628
|
if (error.code === "ENOENT") return {};
|
|
14212
14629
|
throw error;
|
|
@@ -14215,7 +14632,7 @@ async function readNitroOutputPackage(outputDir, fs5) {
|
|
|
14215
14632
|
async function writeNitroOutputPackage(outputDir, packageJson, fs5) {
|
|
14216
14633
|
await fs5.mkdir(outputDir, { recursive: true });
|
|
14217
14634
|
await fs5.writeFile(
|
|
14218
|
-
|
|
14635
|
+
path16.join(outputDir, "package.json"),
|
|
14219
14636
|
`${JSON.stringify(packageJson, null, 2)}
|
|
14220
14637
|
`
|
|
14221
14638
|
);
|
|
@@ -14231,60 +14648,63 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
14231
14648
|
}
|
|
14232
14649
|
}
|
|
14233
14650
|
try {
|
|
14234
|
-
let directory =
|
|
14235
|
-
while (directory !==
|
|
14236
|
-
const candidate =
|
|
14651
|
+
let directory = path16.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
14652
|
+
while (directory !== path16.dirname(directory)) {
|
|
14653
|
+
const candidate = path16.join(directory, "package.json");
|
|
14237
14654
|
if (existsSync3(candidate)) {
|
|
14238
14655
|
try {
|
|
14239
|
-
const manifest = JSON.parse(
|
|
14656
|
+
const manifest = JSON.parse(readFileSync2(candidate, "utf8"));
|
|
14240
14657
|
if (manifest.name === packageName) return candidate;
|
|
14241
14658
|
} catch {
|
|
14242
14659
|
}
|
|
14243
14660
|
}
|
|
14244
|
-
if (
|
|
14245
|
-
directory =
|
|
14661
|
+
if (path16.basename(directory) === "node_modules") break;
|
|
14662
|
+
directory = path16.dirname(directory);
|
|
14246
14663
|
}
|
|
14247
14664
|
} catch {
|
|
14248
14665
|
}
|
|
14249
14666
|
return null;
|
|
14250
14667
|
}
|
|
14251
14668
|
async function resolveProjectInstalledPackageDir(root, packageName, fs5) {
|
|
14252
|
-
let directory =
|
|
14669
|
+
let directory = path16.resolve(root);
|
|
14253
14670
|
while (true) {
|
|
14254
|
-
const candidate =
|
|
14671
|
+
const candidate = path16.join(directory, "node_modules", ...packageName.split("/"));
|
|
14255
14672
|
try {
|
|
14256
14673
|
const packageDir = await fs5.realpath(candidate);
|
|
14257
|
-
if ((await fs5.stat(
|
|
14674
|
+
if ((await fs5.stat(path16.join(packageDir, "package.json"))).isFile()) return packageDir;
|
|
14258
14675
|
} catch {
|
|
14259
14676
|
}
|
|
14260
|
-
const parent =
|
|
14677
|
+
const parent = path16.dirname(directory);
|
|
14261
14678
|
if (parent === directory) return null;
|
|
14262
14679
|
directory = parent;
|
|
14263
14680
|
}
|
|
14264
14681
|
}
|
|
14682
|
+
var PRISMA_RUNTIME_GENERATE_ONLY_FILE = /^query_(?:engine|compiler)_bg\.|\.map$|\.d\.m?ts$/;
|
|
14265
14683
|
async function copyPrismaClientForVercel(root, nitroFuncDir, fs5) {
|
|
14266
14684
|
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs5);
|
|
14267
14685
|
if (!prismaClientDir) return;
|
|
14268
|
-
const generatedClientDir =
|
|
14686
|
+
const generatedClientDir = path16.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
14269
14687
|
try {
|
|
14270
14688
|
await fs5.access(generatedClientDir);
|
|
14271
14689
|
} catch {
|
|
14272
14690
|
return;
|
|
14273
14691
|
}
|
|
14274
|
-
const targetNodeModules =
|
|
14275
|
-
const targetPrismaScopeDir =
|
|
14276
|
-
const targetGeneratedDir =
|
|
14277
|
-
const targetClientDir =
|
|
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");
|
|
14278
14697
|
await fs5.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
14279
14698
|
await fs5.cp(prismaClientDir, targetClientDir, {
|
|
14280
14699
|
recursive: true,
|
|
14281
|
-
force: true
|
|
14700
|
+
force: true,
|
|
14701
|
+
filter: (source) => path16.dirname(source) !== runtimeDir || !PRISMA_RUNTIME_GENERATE_ONLY_FILE.test(path16.basename(source))
|
|
14282
14702
|
});
|
|
14283
14703
|
await fs5.cp(generatedClientDir, targetGeneratedDir, {
|
|
14284
14704
|
recursive: true,
|
|
14285
14705
|
force: true
|
|
14286
14706
|
});
|
|
14287
|
-
const clientPackagePath =
|
|
14707
|
+
const clientPackagePath = path16.join(prismaClientDir, "package.json");
|
|
14288
14708
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
14289
14709
|
readNitroOutputPackage(nitroFuncDir, fs5),
|
|
14290
14710
|
fs5.readFile(clientPackagePath, "utf-8")
|
|
@@ -14471,9 +14891,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
14471
14891
|
} else {
|
|
14472
14892
|
const { build: legacyViteBuild } = await import("vite");
|
|
14473
14893
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
14474
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
14894
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path17.join(root, distDir, "client"));
|
|
14475
14895
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
14476
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
14896
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path17.join(root, distDir, "server"));
|
|
14477
14897
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
14478
14898
|
await buildNitro(
|
|
14479
14899
|
config,
|
|
@@ -14553,7 +14973,10 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14553
14973
|
// resolves as it does in the server build. Module-entry packages load pre-bundled, as in
|
|
14554
14974
|
// `farm dev`: unbundled, lucide-react alone is ~1,750 modules through the module runner,
|
|
14555
14975
|
// which a docs build waited on after its bundles.
|
|
14556
|
-
farmServerOnlyEntriesPlugin({
|
|
14976
|
+
farmServerOnlyEntriesPlugin({
|
|
14977
|
+
prebundleServerPackages: true,
|
|
14978
|
+
distDir: config.distDir || ".farm"
|
|
14979
|
+
})
|
|
14557
14980
|
],
|
|
14558
14981
|
server: {
|
|
14559
14982
|
middlewareMode: true,
|
|
@@ -14575,8 +14998,8 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14575
14998
|
root,
|
|
14576
14999
|
// Vite keys its pre-bundled dependencies on the config, mode included, so this server and
|
|
14577
15000
|
// `farm dev` sharing one cache would each rebuild it after the other ran.
|
|
14578
|
-
cacheDir:
|
|
14579
|
-
|
|
15001
|
+
cacheDir: path17.join(
|
|
15002
|
+
path17.resolve(root, viteConfig.cacheDir ?? path17.join("node_modules", ".vite")),
|
|
14580
15003
|
"farm-build"
|
|
14581
15004
|
),
|
|
14582
15005
|
configFile: false,
|
|
@@ -14615,7 +15038,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14615
15038
|
farmPlugin,
|
|
14616
15039
|
farmServerOnlyEntriesPlugin
|
|
14617
15040
|
} = await import("./vite.mjs");
|
|
14618
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
15041
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
14619
15042
|
const pluginManager = new PluginManager2({
|
|
14620
15043
|
config,
|
|
14621
15044
|
isDev: false,
|
|
@@ -14633,7 +15056,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14633
15056
|
},
|
|
14634
15057
|
plugins: [
|
|
14635
15058
|
farmI18nClientBridgePlugin(),
|
|
14636
|
-
farmServerOnlyEntriesPlugin(),
|
|
15059
|
+
farmServerOnlyEntriesPlugin({ distDir: config.distDir || ".farm" }),
|
|
14637
15060
|
farmIslandContainersPlugin(config),
|
|
14638
15061
|
farmPlugin(config, pluginManager),
|
|
14639
15062
|
farmEnvironmentFunctionsPlugin(config)
|
|
@@ -14643,7 +15066,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14643
15066
|
}
|
|
14644
15067
|
async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
14645
15068
|
const { farmI18nClientBridgePlugin, farmIslandContainersPlugin, farmPlugin } = await import("./vite.mjs");
|
|
14646
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
15069
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-FD4S2QEJ.mjs");
|
|
14647
15070
|
const pluginManager = new PluginManager2({
|
|
14648
15071
|
config,
|
|
14649
15072
|
isDev: false,
|
|
@@ -14676,16 +15099,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14676
15099
|
});
|
|
14677
15100
|
}
|
|
14678
15101
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
14679
|
-
const appDir =
|
|
15102
|
+
const appDir = path17.join(root, srcDir, "app");
|
|
14680
15103
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
14681
|
-
const candidate =
|
|
15104
|
+
const candidate = path17.join(appDir, `page${extension}`);
|
|
14682
15105
|
if (existsSync4(candidate)) return candidate;
|
|
14683
15106
|
}
|
|
14684
|
-
return
|
|
15107
|
+
return path17.join(appDir, "page.tsx");
|
|
14685
15108
|
}
|
|
14686
15109
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
14687
15110
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
14688
|
-
import("./nitro-
|
|
15111
|
+
import("./nitro-RHLKLYXH.mjs"),
|
|
14689
15112
|
import("nitro/builder")
|
|
14690
15113
|
]);
|
|
14691
15114
|
let nitroConfig = await createNitroConfig(
|
|
@@ -14699,18 +15122,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14699
15122
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
14700
15123
|
}
|
|
14701
15124
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
14702
|
-
const serverOutputDir =
|
|
14703
|
-
const publicOutputDir =
|
|
15125
|
+
const serverOutputDir = path17.join(outputDir, "server");
|
|
15126
|
+
const publicOutputDir = path17.join(outputDir, "public");
|
|
14704
15127
|
const { mkdir, cp } = await import("fs/promises");
|
|
14705
15128
|
await mkdir(serverOutputDir, { recursive: true });
|
|
14706
15129
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14707
|
-
const clientDir =
|
|
15130
|
+
const clientDir = path17.join(root, distDir, "client");
|
|
14708
15131
|
try {
|
|
14709
15132
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14710
15133
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
14711
15134
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
14712
|
-
const manifestPath =
|
|
14713
|
-
const assetsDir =
|
|
15135
|
+
const manifestPath = path17.join(publicOutputDir, "farm-client-manifest.json");
|
|
15136
|
+
const assetsDir = path17.join(publicOutputDir, "assets");
|
|
14714
15137
|
const manifestExists = await import("fs/promises").then(
|
|
14715
15138
|
(fs5) => fs5.access(manifestPath).then(() => true).catch(() => false)
|
|
14716
15139
|
);
|
|
@@ -14726,8 +15149,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14726
15149
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
14727
15150
|
throw error;
|
|
14728
15151
|
}
|
|
14729
|
-
const serverDir =
|
|
14730
|
-
const nitroServerDir =
|
|
15152
|
+
const serverDir = path17.join(root, distDir, "server");
|
|
15153
|
+
const nitroServerDir = path17.join(root, distDir, ".nitro", "server", "farm");
|
|
14731
15154
|
try {
|
|
14732
15155
|
await mkdir(nitroServerDir, { recursive: true });
|
|
14733
15156
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -14736,7 +15159,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14736
15159
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
14737
15160
|
}
|
|
14738
15161
|
const nitro = await createNitro(nitroConfig);
|
|
14739
|
-
const registryPath =
|
|
15162
|
+
const registryPath = path17.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
14740
15163
|
try {
|
|
14741
15164
|
const { farmRegistry } = await import(
|
|
14742
15165
|
/* @vite-ignore */
|
|
@@ -14753,7 +15176,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14753
15176
|
}
|
|
14754
15177
|
farmRegistry.routePaths = routePaths;
|
|
14755
15178
|
try {
|
|
14756
|
-
const clientManifestPath =
|
|
15179
|
+
const clientManifestPath = path17.join(root, distDir, "client", "farm-client-manifest.json");
|
|
14757
15180
|
const { readFile } = await import("fs/promises");
|
|
14758
15181
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
14759
15182
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|