@farm.js/core 0.1.73 → 0.1.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-mcp-handler-VBCA3WZ6.cjs → agent-mcp-handler-73SGWVZT.cjs} +9 -9
- package/dist/{agent-mcp-handler-RK7LDYEL.mjs → agent-mcp-handler-PJKZHYSA.mjs} +8 -8
- package/dist/{agent-mcp.d-D_gHjCAE.d.ts → agent-mcp.d-Djvao5eV.d.ts} +24 -2
- package/dist/{agent-mcp.d-PvEf-1mi.d.mts → agent-mcp.d-wA13pwmS.d.mts} +24 -2
- package/dist/agent-runtime.cjs +9 -9
- package/dist/agent-runtime.d.mts +4 -4
- package/dist/agent-runtime.d.ts +4 -4
- package/dist/agent-runtime.mjs +8 -8
- package/dist/analyzer-23GCBYFI.cjs +16 -0
- package/dist/{analyzer-MFYCJT75.mjs → analyzer-LJHMFCDW.mjs} +2 -2
- package/dist/api/client.cjs +4 -4
- package/dist/api/client.d.mts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.mjs +3 -3
- package/dist/api/client.native.cjs +6 -6
- package/dist/api/client.native.d.mts +4 -4
- package/dist/api/client.native.d.ts +4 -4
- package/dist/api/client.native.mjs +3 -3
- package/dist/api/node.cjs +14 -13
- package/dist/api/node.d.mts +6 -6
- package/dist/api/node.d.ts +6 -6
- package/dist/api/node.mjs +13 -12
- package/dist/api/route-manager.cjs +23 -21
- package/dist/api/route-manager.d.mts +9 -7
- package/dist/api/route-manager.d.ts +9 -7
- package/dist/api/route-manager.mjs +22 -20
- package/dist/api/runtime.cjs +13 -12
- package/dist/api/runtime.d.mts +5 -5
- package/dist/api/runtime.d.ts +5 -5
- package/dist/api/runtime.mjs +12 -11
- package/dist/{api-client.d-Bp35zMqR.d.mts → api-client.d-CyVmI4Di.d.mts} +2 -2
- package/dist/{api-client.d-CFI_xL0V.d.ts → api-client.d-DrTM7BdH.d.ts} +2 -2
- package/dist/api.cjs +26 -24
- package/dist/api.d.mts +9 -9
- package/dist/api.d.ts +9 -9
- package/dist/api.mjs +25 -23
- package/dist/{app-manifest.d-BpVTg43i.d.ts → app-manifest.d-BukcP_EV.d.ts} +10 -1
- package/dist/{app-manifest.d-CN7cEWHX.d.mts → app-manifest.d-DIuqSi9k.d.mts} +10 -1
- package/dist/app-markdown.cjs +11 -7
- package/dist/app-markdown.d.mts +6 -6
- package/dist/app-markdown.d.ts +6 -6
- package/dist/app-markdown.mjs +10 -6
- package/dist/{app.d-DO4PTCWm.d.ts → app.d-BQqmM6Gy.d.ts} +55 -4
- package/dist/{app.d-BFWzAdTe.d.mts → app.d-YVuFb10p.d.mts} +55 -4
- package/dist/{base-path.d-BJ3SYpB8.d.mts → base-path.d-m7wvRMnG.d.mts} +15 -1
- package/dist/{base-path.d-BJ3SYpB8.d.ts → base-path.d-m7wvRMnG.d.ts} +15 -1
- package/dist/cache.cjs +2 -2
- package/dist/cache.d.mts +22 -1
- package/dist/cache.d.ts +22 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chunk-JYNNIGQO.cjs → chunk-25JGHAGH.cjs} +11 -1
- package/dist/{chunk-GWXZS7K5.mjs → chunk-2LKUR5QJ.mjs} +1 -1
- package/dist/{chunk-Z3IN6GEX.mjs → chunk-2NQ3S2SJ.mjs} +69 -12
- package/dist/chunk-2PJVEL56.cjs +90 -0
- package/dist/{chunk-HDPT6OYE.cjs → chunk-2RSVYJT6.cjs} +28 -4
- package/dist/{chunk-HGB4PM2C.cjs → chunk-2YJ4DHTD.cjs} +104 -32
- package/dist/{chunk-MGZVDX4R.mjs → chunk-3AJQFVWW.mjs} +3 -3
- package/dist/{chunk-E3HDJCWF.mjs → chunk-3GMD2E4Q.mjs} +3 -3
- package/dist/{chunk-JWY66PID.cjs → chunk-42EUEYW6.cjs} +21 -13
- package/dist/{chunk-255J7K4X.mjs → chunk-47R7CX4A.mjs} +6 -6
- package/dist/chunk-4PWGLPL6.mjs +284 -0
- package/dist/{chunk-7S7AAK2D.mjs → chunk-4QBFYEDC.mjs} +2 -1
- package/dist/{chunk-6O6PAZZR.mjs → chunk-4T2RB4JA.mjs} +5 -5
- package/dist/{chunk-XGTFLG73.cjs → chunk-4VLXQ55O.cjs} +37 -25
- package/dist/{chunk-KTDG4THT.cjs → chunk-4ZSZI6XL.cjs} +17 -17
- package/dist/{chunk-XGJVRPYL.cjs → chunk-52LTENRE.cjs} +3 -3
- package/dist/{chunk-QIXEU2WV.cjs → chunk-5AMH6AFA.cjs} +5 -3
- package/dist/{chunk-AYP2YFVN.mjs → chunk-5KAEGBIL.mjs} +75 -42
- package/dist/{chunk-WW3LRNQV.mjs → chunk-5O3SK3ZC.mjs} +5 -5
- package/dist/{chunk-GPO3LJDJ.cjs → chunk-5QZT2EQN.cjs} +2 -2
- package/dist/{chunk-RLFGKJQ6.mjs → chunk-5WFPZG7K.mjs} +20 -8
- package/dist/chunk-5XD2ULJG.mjs +114 -0
- package/dist/{chunk-4HGLJOXZ.cjs → chunk-62DZHPDK.cjs} +16 -11
- package/dist/{chunk-YXIQYWOK.cjs → chunk-63EFR2WF.cjs} +27 -8
- package/dist/{chunk-2RCCFB2Y.cjs → chunk-6B44ZU5P.cjs} +11 -11
- package/dist/{chunk-HFUOLILA.cjs → chunk-6D3CJFNU.cjs} +37 -21
- package/dist/{chunk-JX5VOLAV.cjs → chunk-6DBBMQWT.cjs} +38 -38
- package/dist/{chunk-FRO4BB2T.mjs → chunk-6MATGOEF.mjs} +1 -1
- package/dist/{chunk-CLEWORVY.cjs → chunk-7564NP5Z.cjs} +40 -43
- package/dist/{chunk-7H45IJWO.mjs → chunk-7DBJ2SWK.mjs} +1 -1
- package/dist/chunk-7E4FDO5X.mjs +265 -0
- package/dist/{chunk-FPBOAG6N.cjs → chunk-7EOSFIPN.cjs} +3 -3
- package/dist/{chunk-ICFPTHXM.mjs → chunk-7FQFK3OA.mjs} +7 -3
- package/dist/{chunk-TUOO6IK3.mjs → chunk-7H2TXT2K.mjs} +11 -1
- package/dist/{chunk-A4PWGL46.mjs → chunk-7KDCVSTR.mjs} +4 -4
- package/dist/{chunk-GPICBTDV.cjs → chunk-7Q2YWZF7.cjs} +6 -6
- package/dist/{chunk-CFG4QERR.cjs → chunk-7Q7UB4TL.cjs} +2 -2
- package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
- package/dist/chunk-A3LNXQJJ.cjs +265 -0
- package/dist/{chunk-IBVN7SW5.mjs → chunk-A5F55ZFA.mjs} +472 -143
- package/dist/{chunk-S6O2L47H.mjs → chunk-AG27TI6Q.mjs} +67 -5
- package/dist/{chunk-DC2AXGNZ.mjs → chunk-AM2M56SL.mjs} +1 -1
- package/dist/{chunk-JRHGJVJH.mjs → chunk-B5QRNCIE.mjs} +1 -1
- package/dist/{chunk-OIP62QEL.mjs → chunk-BGUTIQII.mjs} +24 -9
- package/dist/{chunk-DMAP4RND.cjs → chunk-BNCKXPCU.cjs} +98 -16
- package/dist/{chunk-TDCP3Z4T.cjs → chunk-BNTRXJL4.cjs} +3 -3
- package/dist/{chunk-BPAXGCKX.mjs → chunk-BRNPLD22.mjs} +30 -17
- package/dist/{chunk-JZGL2PIH.mjs → chunk-CDT7CGQT.mjs} +2 -2
- package/dist/{chunk-FEFCISOX.cjs → chunk-CEVXKJKF.cjs} +2 -2
- package/dist/{chunk-YZLEOMMA.mjs → chunk-CF74ABRI.mjs} +10 -10
- package/dist/chunk-CIY74JLV.cjs +134 -0
- package/dist/{chunk-FETMUBIA.mjs → chunk-CLM73YYD.mjs} +2 -2
- package/dist/{chunk-ME7RVELR.mjs → chunk-CSAIIMY3.mjs} +21 -2
- package/dist/{chunk-YAEN3L2F.cjs → chunk-CYNQPKA4.cjs} +23 -4
- package/dist/{chunk-M53MIIXY.mjs → chunk-CZOXZ6WQ.mjs} +1 -1
- package/dist/{chunk-Y2LU4LE5.mjs → chunk-DASQJ5UD.mjs} +2 -2
- package/dist/{chunk-WVQNXXNE.cjs → chunk-DD22NQFX.cjs} +2 -2
- package/dist/{chunk-OBYM5S5G.mjs → chunk-DUSTJ6A5.mjs} +20 -17
- package/dist/{chunk-ZFEJ2SF2.cjs → chunk-DZ3AZ7UK.cjs} +52 -52
- package/dist/{chunk-6YFC3ZFX.mjs → chunk-DZXD6CYJ.mjs} +1 -1
- package/dist/{chunk-AZ6IW6SF.mjs → chunk-EMTN5ABC.mjs} +1 -1
- package/dist/{chunk-AQIO3RNL.mjs → chunk-ERT6HQAI.mjs} +8 -3
- package/dist/{chunk-JDO346NV.mjs → chunk-F35C3TJZ.mjs} +1 -1
- package/dist/{chunk-ODBM54RT.cjs → chunk-F4ID7BGO.cjs} +33 -30
- package/dist/{chunk-C7GJDVN4.mjs → chunk-F7MJWW6A.mjs} +1 -1
- package/dist/{chunk-5OFNUETM.mjs → chunk-FCAYYLAE.mjs} +27 -3
- package/dist/{chunk-PWKAX5MS.cjs → chunk-FDZZ6K3N.cjs} +6 -6
- package/dist/{chunk-MHLNWRCJ.cjs → chunk-FE6KYDHC.cjs} +3 -3
- package/dist/{chunk-PTLXHRJZ.mjs → chunk-FLMALEY2.mjs} +37 -4
- package/dist/{chunk-IHTDLCDJ.cjs → chunk-G7B6NU4X.cjs} +23 -10
- package/dist/{chunk-JZQS3ZOI.mjs → chunk-GAAK3HDZ.mjs} +36 -7
- package/dist/{chunk-QMNWKQL4.cjs → chunk-GC5ROI3A.cjs} +4 -4
- package/dist/{chunk-JXIYH2NO.cjs → chunk-GCJ4GNMC.cjs} +4 -4
- package/dist/{chunk-WX63N6C5.mjs → chunk-GFXKO4UW.mjs} +106 -37
- package/dist/{chunk-CYRIIVD4.mjs → chunk-GLF44JKY.mjs} +3 -3
- package/dist/{chunk-GUZC226X.mjs → chunk-GLVDXRG2.mjs} +1 -1
- package/dist/{chunk-GZOKWJIW.mjs → chunk-GNY7BO7R.mjs} +18 -11
- package/dist/{chunk-OWQV6MLM.cjs → chunk-GYJT2U7J.cjs} +2 -1
- package/dist/{chunk-MBCRWU3P.cjs → chunk-H7OFZJCV.cjs} +8 -8
- package/dist/{chunk-JMOCMXTQ.mjs → chunk-H7QY7ZE4.mjs} +1 -1
- package/dist/{chunk-5LOARKDP.cjs → chunk-HFJLMALC.cjs} +42 -30
- package/dist/{chunk-CROAFCMW.mjs → chunk-HONTCUK6.mjs} +1 -1
- package/dist/{chunk-7PJARAQQ.mjs → chunk-HQ2VAJLW.mjs} +1 -1
- package/dist/{chunk-SVQX5HYW.mjs → chunk-HT2SZKXG.mjs} +92 -10
- package/dist/{chunk-7GMBETHM.mjs → chunk-HV2WZFUW.mjs} +1 -1
- package/dist/{chunk-DMXMIE2C.cjs → chunk-HVJ7IACB.cjs} +15 -7
- package/dist/{chunk-S7MWSFFP.cjs → chunk-IBEHVSU4.cjs} +2 -2
- package/dist/{chunk-QGCSUC5O.mjs → chunk-IDOUCM2X.mjs} +521 -296
- package/dist/{chunk-FN5UEC7I.mjs → chunk-IG2JE6WJ.mjs} +1 -1
- package/dist/{chunk-MQ4DYVFS.cjs → chunk-IIHZ2BEE.cjs} +3 -3
- package/dist/{chunk-TAU3OF5B.cjs → chunk-IK33N2AN.cjs} +1373 -694
- package/dist/{chunk-UVQRMUAR.cjs → chunk-IVBDRAOR.cjs} +1 -1
- package/dist/{chunk-2AFW7673.cjs → chunk-IXO6O2EL.cjs} +8 -7
- package/dist/{chunk-U7VH3Q5E.cjs → chunk-IYFBLWXU.cjs} +56 -25
- package/dist/{chunk-NDDRTFN4.mjs → chunk-J7EUGGTY.mjs} +2 -2
- package/dist/{chunk-UVZMSRHF.mjs → chunk-JA6RML7C.mjs} +3 -3
- package/dist/{chunk-CL52PD6D.cjs → chunk-JHZ6HULQ.cjs} +12 -9
- package/dist/{chunk-HTXKSREF.cjs → chunk-JNZDTE75.cjs} +532 -203
- package/dist/{chunk-VT25ERQK.mjs → chunk-JRBWBMP2.mjs} +24 -5
- package/dist/{chunk-4CTCSKAF.mjs → chunk-K6DXKHFE.mjs} +1 -1
- package/dist/{chunk-AXVRUDMB.cjs → chunk-K6PGK7DC.cjs} +2 -2
- package/dist/{chunk-TY5KCYDE.mjs → chunk-KHS3T3E5.mjs} +20 -8
- package/dist/{chunk-ILQ5DKYF.cjs → chunk-KPYQ32BA.cjs} +2 -2
- package/dist/{chunk-CSLHNBPS.cjs → chunk-KQS27YN7.cjs} +6 -6
- package/dist/{chunk-XI3OXOMK.mjs → chunk-KUXEII7V.mjs} +1 -1
- package/dist/{chunk-CA7DNRHO.cjs → chunk-L6E5BSNU.cjs} +3 -3
- package/dist/{chunk-VNBDN5W2.cjs → chunk-L7Y65BQU.cjs} +128 -59
- package/dist/{chunk-73K53YPP.mjs → chunk-LPXJEZJK.mjs} +30 -14
- package/dist/{chunk-B67CW2LM.mjs → chunk-LQBV2Y37.mjs} +34 -37
- package/dist/chunk-LQWIIBI2.cjs +86 -0
- package/dist/chunk-LXTYJ2HW.mjs +139 -0
- package/dist/{chunk-I4KPA2C6.mjs → chunk-MFU7SXAB.mjs} +10 -2
- package/dist/{chunk-YTVSWXEZ.cjs → chunk-ML4TOUZP.cjs} +76 -43
- package/dist/{chunk-E46NXBNJ.mjs → chunk-NLATR3T3.mjs} +12 -7
- package/dist/{chunk-OXNZUCHN.cjs → chunk-NPGXX7HN.cjs} +37 -37
- package/dist/chunk-NRWEY2CM.mjs +25 -0
- package/dist/{chunk-VPETSSWN.cjs → chunk-NSNQLBHR.cjs} +2 -2
- package/dist/chunk-NU5XLYRN.cjs +139 -0
- package/dist/chunk-NUWUEXUD.mjs +55 -0
- package/dist/{chunk-53EHWHT2.cjs → chunk-O4JYMU5N.cjs} +35 -22
- package/dist/{chunk-TNYC3TYP.mjs → chunk-O7JEFGUV.mjs} +2 -2
- package/dist/{chunk-62ZRA7XU.mjs → chunk-OCLCA3X3.mjs} +1 -1
- package/dist/{chunk-MJEKMT6B.mjs → chunk-OFIFRB62.mjs} +917 -238
- package/dist/{chunk-OB45EAQL.mjs → chunk-OVUU2RCQ.mjs} +4 -3
- package/dist/{chunk-YZK64PZT.cjs → chunk-OZARLCYQ.cjs} +1742 -898
- package/dist/{chunk-W44X6IC2.cjs → chunk-PBJ7MEOV.cjs} +13 -9
- package/dist/{chunk-2W4GNXGX.cjs → chunk-PBQGIA27.cjs} +2 -2
- package/dist/{chunk-B6RBJJ5G.mjs → chunk-PDACTAVX.mjs} +16 -3
- package/dist/{chunk-DQ2DI3Y7.mjs → chunk-PE2LEWXA.mjs} +6 -3
- package/dist/{chunk-LGR7565L.cjs → chunk-PG7J7XYT.cjs} +39 -24
- package/dist/{chunk-MMK4MZUN.mjs → chunk-PKXGFQZS.mjs} +1 -1
- package/dist/{chunk-YBY34UHB.mjs → chunk-PL7MCYYD.mjs} +47 -16
- package/dist/chunk-PWHF2C6A.mjs +134 -0
- package/dist/{chunk-DZHTNSQ5.cjs → chunk-Q2EKSSEG.cjs} +21 -21
- package/dist/{chunk-SPP3EZTJ.cjs → chunk-QDHR54S6.cjs} +139 -69
- package/dist/{chunk-REK6HZSU.mjs → chunk-QGYHE6VJ.mjs} +1565 -721
- package/dist/{chunk-ZOYKJBP5.cjs → chunk-QKW6DLDT.cjs} +2 -2
- package/dist/{chunk-Y5LEPEVH.mjs → chunk-QSLGE2ZC.mjs} +1 -1
- package/dist/{chunk-FSODPZRT.cjs → chunk-QUEYL2WM.cjs} +10 -10
- package/dist/{chunk-ZDAEHG2O.cjs → chunk-QYOAGT3E.cjs} +3 -3
- package/dist/{chunk-CPMME66W.mjs → chunk-R5X7FDOG.mjs} +73 -1
- package/dist/{chunk-O47W53D3.cjs → chunk-RDADQG5S.cjs} +7 -77
- package/dist/chunk-RDSHEHBA.mjs +82 -0
- package/dist/{chunk-C6CUUBY5.cjs → chunk-RHI67C2V.cjs} +5 -5
- package/dist/chunk-RK3YYUX6.cjs +114 -0
- package/dist/{chunk-K3RU5MOR.mjs → chunk-RK4MGL6Q.mjs} +1 -1
- package/dist/{chunk-LRB5OVRT.cjs → chunk-RKQOMG2X.cjs} +2 -2
- package/dist/chunk-RQRTH57V.cjs +82 -0
- package/dist/{chunk-HY6IVQ54.mjs → chunk-S7QEQCVV.mjs} +2 -2
- package/dist/{chunk-EGIY4A7V.cjs → chunk-SFSTZ7TB.cjs} +8 -8
- package/dist/{chunk-4Z3YLMSW.cjs → chunk-SX535SU5.cjs} +12 -12
- package/dist/{chunk-NLBK37HI.cjs → chunk-SXXSQVKK.cjs} +4 -4
- package/dist/{chunk-JZBU7V4D.mjs → chunk-SYPEMXW2.mjs} +126 -56
- package/dist/{chunk-5CFHQ7HM.mjs → chunk-TFEODQLG.mjs} +1 -1
- package/dist/{chunk-3GNVIYPO.cjs → chunk-TZ2YPXLB.cjs} +7 -7
- package/dist/{chunk-OEL5EPOJ.mjs → chunk-UD6KTSJS.mjs} +6 -76
- package/dist/{chunk-2EVESLP3.mjs → chunk-UJIBSFUE.mjs} +4 -4
- package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
- package/dist/chunk-UNOXV37V.cjs +55 -0
- package/dist/{chunk-TXE4SAMV.mjs → chunk-UOE6ZZZP.mjs} +1 -1
- package/dist/{chunk-OAEDVXVE.mjs → chunk-URQW27KO.mjs} +14 -6
- package/dist/chunk-VDQZV6BX.mjs +17 -0
- package/dist/chunk-VJ6L7TII.cjs +284 -0
- package/dist/{chunk-TPYAYFMF.cjs → chunk-VJI2LWTL.cjs} +2 -2
- package/dist/chunk-VWIW47FW.cjs +25 -0
- package/dist/{chunk-CKQAQFF6.mjs → chunk-WGNGM6MJ.mjs} +2 -2
- package/dist/{chunk-ROCF6UQD.cjs → chunk-WHCNJVYU.cjs} +74 -17
- package/dist/{chunk-4YHGQDTT.cjs → chunk-WJ5CCQBM.cjs} +35 -28
- package/dist/chunk-WKVYF2B5.cjs +17 -0
- package/dist/{chunk-5PDMBWAF.cjs → chunk-WRWJ7IWT.cjs} +7 -7
- package/dist/{chunk-ACGBXN3U.cjs → chunk-WW62HKA2.cjs} +55 -26
- package/dist/{chunk-XVSBALOY.cjs → chunk-X3Y6JWJG.cjs} +3 -3
- package/dist/{chunk-PXAHSCR6.cjs → chunk-XGDI4OUB.cjs} +103 -21
- package/dist/{chunk-4P5634G6.cjs → chunk-XRFGOYXG.cjs} +16 -11
- package/dist/{chunk-42KMUIWZ.cjs → chunk-XX6ZA2IO.cjs} +3 -3
- package/dist/{chunk-6IOZPJ3I.cjs → chunk-Y3DO7BIJ.cjs} +69 -7
- package/dist/{chunk-L5JDKFMQ.cjs → chunk-YBXIVQCE.cjs} +4 -4
- package/dist/{chunk-462MUII7.mjs → chunk-YCNKS6SD.mjs} +12 -12
- package/dist/{chunk-XUSJVHHD.cjs → chunk-YL7BKHYE.cjs} +935 -710
- package/dist/{chunk-7PPLTD3P.cjs → chunk-YN7G22MP.cjs} +6 -6
- package/dist/{chunk-TU6VAH4V.cjs → chunk-YRXPDKMM.cjs} +10 -10
- package/dist/{chunk-IXZSBO76.mjs → chunk-YSTKSZD2.mjs} +1 -1
- package/dist/{chunk-QDWMCFTH.mjs → chunk-YT2ZMLXK.mjs} +1 -1
- package/dist/{chunk-QEJWNXRI.cjs → chunk-YTNE4KGC.cjs} +3 -3
- package/dist/{chunk-E7QOEV5Z.cjs → chunk-YUCU6XB4.cjs} +4 -4
- package/dist/{chunk-NLRAQXAA.mjs → chunk-YVVY276M.mjs} +1 -1
- package/dist/{chunk-SUQACHER.mjs → chunk-Z2FFLTF5.mjs} +3 -3
- package/dist/{chunk-JSDV2NUN.mjs → chunk-Z3QXQN4U.mjs} +1 -1
- package/dist/{chunk-EYPSKXO4.mjs → chunk-Z4IRG4RG.mjs} +96 -9
- package/dist/{chunk-GJ7QVFAG.mjs → chunk-ZEWWZJPZ.mjs} +3 -1
- package/dist/chunk-ZIAWO6BC.mjs +86 -0
- package/dist/{chunk-JWLRBDDC.cjs → chunk-ZIOFRBIU.cjs} +100 -13
- package/dist/{chunk-3OJNNCDL.cjs → chunk-ZNXU4E6A.cjs} +8 -8
- package/dist/{chunk-RLEALQEN.mjs → chunk-ZO6TOLHL.mjs} +87 -5
- package/dist/{chunk-KDOZORJD.cjs → chunk-ZPCZWEU3.cjs} +24 -24
- package/dist/{chunk-QKEZLYON.cjs → chunk-ZV76IQG7.cjs} +2 -2
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/{client-component.d-C71rMuHF.d.mts → client-component.d-BeqVuqy2.d.mts} +80 -3
- package/dist/{client-component.d-sF-Znk0j.d.ts → client-component.d-CZ1NpHAY.d.ts} +80 -3
- package/dist/{client-plugins.d-B-Gd9mWR.d.mts → client-plugins.d-ChceYO9t.d.mts} +42 -8
- package/dist/{client-plugins.d-MFibjgBg.d.ts → client-plugins.d-D9kWC0QB.d.ts} +42 -8
- package/dist/client-plugins.d.mts +4 -4
- package/dist/client-plugins.d.ts +4 -4
- package/dist/client.cjs +17 -14
- package/dist/client.d.mts +11 -11
- package/dist/client.d.ts +11 -11
- package/dist/client.mjs +16 -13
- package/dist/config.d.mts +4 -4
- package/dist/config.d.ts +4 -4
- package/dist/cron.cjs +8 -4
- package/dist/cron.d.mts +11 -2
- package/dist/cron.d.ts +11 -2
- package/dist/cron.mjs +9 -5
- package/dist/desktop.d.mts +5 -5
- package/dist/desktop.d.ts +5 -5
- package/dist/{devtools-TDIJ6HVC.mjs → devtools-B3W3DLPG.mjs} +20 -19
- package/dist/{devtools-6K4QXFRL.cjs → devtools-T5I2WHRX.cjs} +22 -21
- package/dist/docs.cjs +29 -22
- package/dist/docs.d.mts +20 -6
- package/dist/docs.d.ts +20 -6
- package/dist/docs.mjs +28 -21
- package/dist/{endpoint.d-BkMSCRf6.d.mts → endpoint.d-BXbBpKoh.d.mts} +42 -1
- package/dist/{endpoint.d-BgHn0lhl.d.ts → endpoint.d-Dx_1k6Du.d.ts} +42 -1
- package/dist/environment/vite.cjs +6 -6
- package/dist/environment/vite.mjs +5 -5
- package/dist/headers.cjs +3 -3
- package/dist/{headers.d-uQ6BR59u.d.ts → headers.d-Aux4JVnm.d.ts} +1 -1
- package/dist/{headers.d-BUxGJTsj.d.mts → headers.d-BawakaPv.d.mts} +1 -1
- package/dist/headers.mjs +2 -2
- package/dist/i18n/client.cjs +15 -16
- package/dist/i18n/client.mjs +5 -6
- package/dist/i18n/index.cjs +4 -4
- package/dist/i18n/index.mjs +3 -3
- package/dist/i18n/server.cjs +5 -5
- package/dist/i18n/server.mjs +4 -4
- package/dist/image/server.cjs +5 -4
- package/dist/image/server.d.mts +5 -1
- package/dist/image/server.d.ts +5 -1
- package/dist/image/server.mjs +4 -3
- package/dist/image/sharp.cjs +53 -89
- package/dist/image/sharp.d.mts +2 -1
- package/dist/image/sharp.d.ts +2 -1
- package/dist/image/sharp.mjs +50 -86
- package/dist/index.cjs +113 -96
- package/dist/{index.d-CuWOJ-un.d.mts → index.d-Ccq42CPU.d.mts} +1 -1
- package/dist/{index.d-BCGfxCXY.d.ts → index.d-r1MLpgeE.d.ts} +1 -1
- package/dist/index.d.mts +64 -30
- package/dist/index.d.ts +64 -30
- package/dist/index.mjs +111 -94
- package/dist/integrations/orm.d.mts +4 -4
- package/dist/integrations/orm.d.ts +4 -4
- package/dist/integrations.cjs +9 -9
- package/dist/integrations.d.mts +4 -4
- package/dist/integrations.d.ts +4 -4
- package/dist/integrations.mjs +8 -8
- package/dist/internal/app-markdown-runtime.cjs +10 -6
- package/dist/internal/app-markdown-runtime.d.mts +17 -6
- package/dist/internal/app-markdown-runtime.d.ts +17 -6
- package/dist/internal/app-markdown-runtime.mjs +9 -5
- package/dist/internal/build-runtime.cjs +71 -67
- package/dist/internal/build-runtime.d.mts +6 -6
- package/dist/internal/build-runtime.d.ts +6 -6
- package/dist/internal/build-runtime.mjs +70 -66
- package/dist/internal/cli-runtime.cjs +35 -34
- package/dist/internal/cli-runtime.mjs +34 -33
- package/dist/internal/client-error-overlay.cjs +6 -6
- package/dist/internal/client-error-overlay.mjs +2 -2
- package/dist/internal/client-runtime.cjs +28 -3
- package/dist/internal/client-runtime.d.mts +45 -12
- package/dist/internal/client-runtime.d.ts +45 -12
- package/dist/internal/client-runtime.mjs +28 -3
- package/dist/internal/compression-runtime.d.mts +4 -4
- package/dist/internal/compression-runtime.d.ts +4 -4
- package/dist/internal/config-runtime.cjs +22 -21
- package/dist/internal/config-runtime.d.mts +6 -6
- package/dist/internal/config-runtime.d.ts +6 -6
- package/dist/internal/config-runtime.mjs +21 -20
- package/dist/internal/form-actions.cjs +7 -6
- package/dist/internal/form-actions.d.mts +2 -2
- package/dist/internal/form-actions.d.ts +2 -2
- package/dist/internal/form-actions.mjs +6 -5
- package/dist/internal/infra-analytics-runtime.cjs +15 -15
- package/dist/internal/infra-analytics-runtime.mjs +13 -13
- package/dist/internal/islands-server.cjs +2 -2
- package/dist/internal/islands-server.mjs +1 -1
- package/dist/internal/metadata-image-runtime.cjs +4 -4
- package/dist/internal/metadata-image-runtime.mjs +3 -3
- package/dist/internal/native-server-fns.cjs +5 -5
- package/dist/internal/native-server-fns.mjs +4 -4
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +73 -40
- package/dist/internal/production-runtime.d.mts +133 -15
- package/dist/internal/production-runtime.d.ts +133 -15
- package/dist/internal/production-runtime.mjs +76 -43
- package/dist/internal/react-cache.cjs +3 -3
- package/dist/internal/react-cache.mjs +1 -1
- package/dist/internal/start-manifest.cjs +54 -0
- package/dist/internal/start-manifest.d.mts +43 -0
- package/dist/internal/start-manifest.d.ts +43 -0
- package/dist/internal/start-manifest.mjs +54 -0
- package/dist/internal/vercel-edge-middleware.cjs +8 -8
- package/dist/internal/vercel-edge-middleware.mjs +7 -7
- package/dist/{lifecycle.d-keQs5Swc.d.mts → lifecycle.d-OtGWAvJT.d.mts} +4 -0
- package/dist/{lifecycle.d-keQs5Swc.d.ts → lifecycle.d-OtGWAvJT.d.ts} +4 -0
- package/dist/manager-R7FV4A56.cjs +18 -0
- package/dist/{manager-JIA66YJ2.mjs → manager-YO2RHDYU.mjs} +7 -4
- package/dist/markdown.cjs +5 -5
- package/dist/markdown.d.mts +4 -4
- package/dist/markdown.d.ts +4 -4
- package/dist/markdown.mjs +4 -4
- package/dist/middleware.cjs +14 -14
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/middleware.mjs +13 -13
- package/dist/{mount.d-BIYmcGGg.d.mts → mount.d-BomEt2kV.d.mts} +1 -1
- package/dist/{mount.d-q8k0cJV0.d.ts → mount.d-Ca8eb9GB.d.ts} +1 -1
- package/dist/{native-server-fn-handler-QRTXGZA4.cjs → native-server-fn-handler-IWNKQEXK.cjs} +10 -8
- package/dist/{native-server-fn-handler-EP5AFJYE.mjs → native-server-fn-handler-LII4MDRR.mjs} +9 -7
- package/dist/native-tree-D3PW64ZL.cjs +28 -0
- package/dist/{native-tree-OYGKP2NZ.mjs → native-tree-G6ZWS7IR.mjs} +5 -5
- package/dist/{navigation-delegate.d-CYBUupsv.d.mts → navigation-delegate.d-B1ujRkYo.d.mts} +1 -1
- package/dist/{navigation-delegate.d-Btfs6Uoa.d.ts → navigation-delegate.d-DJCC2jXF.d.ts} +1 -1
- package/dist/navigation.cjs +13 -11
- package/dist/navigation.d.mts +7 -7
- package/dist/navigation.d.ts +7 -7
- package/dist/navigation.mjs +12 -10
- package/dist/{nitro-2LMOMIST.cjs → nitro-HKMVYIXY.cjs} +13 -13
- package/dist/{nitro-72TFIGGO.mjs → nitro-RHLKLYXH.mjs} +8 -8
- package/dist/{plugin-5PIQQVRP.cjs → plugin-5BNPYCER.cjs} +2 -2
- package/dist/{plugin-QZT747YW.mjs → plugin-FD4S2QEJ.mjs} +1 -1
- package/dist/plugin.cjs +65 -60
- package/dist/plugin.d.mts +7 -7
- package/dist/plugin.d.ts +7 -7
- package/dist/plugin.mjs +64 -59
- package/dist/query/client.cjs +20 -9
- package/dist/query/client.mjs +16 -5
- package/dist/{render-plan.d-0FHusf1D.d.ts → render-plan.d-BxRbaxYA.d.ts} +1 -1
- package/dist/{render-plan.d-BlyxqKMu.d.mts → render-plan.d-CFod_Zf-.d.mts} +1 -1
- package/dist/renderer/react/server.cjs +9 -1
- package/dist/renderer/react/server.d.mts +9 -1
- package/dist/renderer/react/server.d.ts +9 -1
- package/dist/renderer/react/server.mjs +8 -0
- package/dist/renderer-client.cjs +25 -26
- package/dist/renderer-client.d.mts +7 -7
- package/dist/renderer-client.d.ts +7 -7
- package/dist/renderer-client.mjs +15 -16
- package/dist/request.cjs +2 -2
- package/dist/{request.d-CPdVjssg.d.ts → request.d-DG4TeXMM.d.mts} +14 -2
- package/dist/{request.d-CX-gks1l.d.mts → request.d-DRQgaXGG.d.ts} +14 -2
- package/dist/request.d.mts +5 -5
- package/dist/request.d.ts +5 -5
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering.d-CcvZ_4N2.d.mts → route-rendering.d-BXtZKgqu.d.mts} +1 -1
- package/dist/{route-rendering.d-DcOoSNoG.d.ts → route-rendering.d-Db07UNVG.d.ts} +1 -1
- package/dist/{route.d-DrXkpvcg.d.mts → route.d-Cd4Fi6BA.d.ts} +3 -1
- package/dist/{route.d-hs-_cyHn.d.ts → route.d-ShmtqqVQ.d.mts} +3 -1
- package/dist/router.cjs +4 -4
- package/dist/{router.d-C8RHma4A.d.mts → router.d-B61kXqxJ.d.mts} +1 -1
- package/dist/{router.d-D2QnK8cM.d.ts → router.d-BC3hyjf0.d.ts} +1 -1
- package/dist/router.mjs +3 -3
- package/dist/routes.cjs +7 -5
- package/dist/routes.d.mts +4 -4
- package/dist/routes.d.ts +4 -4
- package/dist/routes.mjs +6 -4
- package/dist/{rsc-pipeline-LC2FBZAR.mjs → rsc-pipeline-LJ7YCGY6.mjs} +24 -23
- package/dist/{rsc-pipeline-NTAM65NT.cjs → rsc-pipeline-VENBFYXW.cjs} +25 -24
- package/dist/{runtime-MWAC7NWR.mjs → runtime-4DWUXZHS.mjs} +29 -29
- package/dist/{runtime-U4PAMTVH.cjs → runtime-UNDTYGQS.cjs} +40 -40
- package/dist/{runtime.d-BQUHHq8M.d.mts → runtime.d-Cl6EBGmC.d.mts} +3 -3
- package/dist/{runtime.d-1l_1bLrL.d.ts → runtime.d-SC95yDzr.d.ts} +3 -3
- package/dist/safe-fetch.cjs +15 -0
- package/dist/safe-fetch.d.mts +61 -0
- package/dist/safe-fetch.d.ts +61 -0
- package/dist/safe-fetch.mjs +15 -0
- package/dist/{schema-dev-notice-C2JINRZI.mjs → schema-dev-notice-CA55V57L.mjs} +2 -2
- package/dist/{schema-dev-notice-X7GG7QVB.cjs → schema-dev-notice-RWA2UTR6.cjs} +3 -3
- package/dist/server-action-security.cjs +7 -5
- package/dist/server-action-security.d.mts +11 -3
- package/dist/server-action-security.d.ts +11 -3
- package/dist/server-action-security.mjs +6 -4
- package/dist/server-fn-client.d.mts +3 -3
- package/dist/server-fn-client.d.ts +3 -3
- package/dist/server-fn.cjs +9 -7
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-fn.mjs +8 -6
- package/dist/server-plugins.cjs +8 -8
- package/dist/server-plugins.d.mts +53 -9
- package/dist/server-plugins.d.ts +53 -9
- package/dist/server-plugins.mjs +7 -7
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.cjs +10 -8
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server-query.mjs +9 -7
- package/dist/server.cjs +105 -103
- package/dist/server.d.mts +17 -17
- package/dist/server.d.ts +17 -17
- package/dist/server.mjs +78 -76
- package/dist/{spa-router.d-BzPdi48R.d.mts → spa-router.d-DrlXgDqY.d.mts} +13 -6
- package/dist/{spa-router.d-BJtXNeqo.d.ts → spa-router.d-DwM02Mwd.d.ts} +13 -6
- package/dist/testing.cjs +34 -32
- package/dist/testing.d.mts +4 -4
- package/dist/testing.d.ts +4 -4
- package/dist/testing.mjs +26 -24
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-DquC6qxy.d.ts → utils.d-C6KXz3uB.d.ts} +1 -1
- package/dist/{utils.d-B4ZW-6z6.d.mts → utils.d-CHzxAshz.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +65 -60
- package/dist/vite.d.mts +18 -8
- package/dist/vite.d.ts +18 -8
- package/dist/vite.mjs +64 -59
- package/dist/workflows.cjs +7 -7
- package/dist/workflows.mjs +6 -6
- package/package.json +18 -1
- package/dist/analyzer-V5ZMRIIY.cjs +0 -16
- package/dist/chunk-6I4BFRE7.cjs +0 -51
- package/dist/chunk-D4XGKF67.cjs +0 -127
- package/dist/chunk-EIVGPQN5.mjs +0 -51
- package/dist/chunk-MFQGU5CC.mjs +0 -127
- package/dist/chunk-NCIAP562.mjs +0 -27
- package/dist/chunk-QQ44FYRO.cjs +0 -27
- package/dist/chunk-RI3EVPKD.cjs +0 -57
- package/dist/manager-JOHU6BQI.cjs +0 -15
- package/dist/native-tree-R6CQMDTI.cjs +0 -28
|
@@ -15,29 +15,146 @@ import {
|
|
|
15
15
|
PROGRAMMATIC_ROUTE_FILE_NAMES,
|
|
16
16
|
getProgrammaticRouteDefinitionSource,
|
|
17
17
|
parseProgrammaticRouteModuleId
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-DZXD6CYJ.mjs";
|
|
19
19
|
import {
|
|
20
20
|
logger
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-Z3QXQN4U.mjs";
|
|
22
22
|
import {
|
|
23
23
|
FARM_VERSION
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-H7QY7ZE4.mjs";
|
|
25
25
|
|
|
26
26
|
// src/environment-vite.ts
|
|
27
27
|
import { existsSync, readFileSync, realpathSync } from "fs";
|
|
28
|
-
import
|
|
28
|
+
import path8 from "path";
|
|
29
|
+
|
|
30
|
+
// src/diagnostics.ts
|
|
31
|
+
import { TraceMap, originalPositionFor } from "@jridgewell/trace-mapping";
|
|
32
|
+
import path from "path";
|
|
33
|
+
var BOUNDARY_DOCS = "/docs/environment-functions#boundary-diagnostics";
|
|
34
|
+
var FARM_DIAGNOSTIC_RULES = {
|
|
35
|
+
CLIENT_SERVER_ENV: {
|
|
36
|
+
severity: "warning",
|
|
37
|
+
fix: "Read it on the server (a server function, API route, or server component), or declare it in env.public in farm.config.ts and read it through publicEnv.",
|
|
38
|
+
docs: BOUNDARY_DOCS
|
|
39
|
+
},
|
|
40
|
+
CLIENT_PROCESS_ENV_PUBLIC: {
|
|
41
|
+
severity: "warning",
|
|
42
|
+
fix: 'Read it through publicEnv from "@farm.js/core/env".',
|
|
43
|
+
docs: BOUNDARY_DOCS
|
|
44
|
+
},
|
|
45
|
+
CLIENT_NODE_BUILTIN: {
|
|
46
|
+
severity: "warning",
|
|
47
|
+
fix: "Move the import into server-only code, or import it lazily inside a function that runs only on the server.",
|
|
48
|
+
docs: BOUNDARY_DOCS
|
|
49
|
+
},
|
|
50
|
+
CLIENT_SERVER_FUNCTION: {
|
|
51
|
+
severity: "error",
|
|
52
|
+
fix: "Add @farm.js/plugin/rsc and set experimental.serverActions: true so client imports become server references, or call it from server code, or expose an API route and call it with createAPIClient.",
|
|
53
|
+
docs: BOUNDARY_DOCS
|
|
54
|
+
},
|
|
55
|
+
CLIENT_SERVER_ONLY_IMPORT: {
|
|
56
|
+
severity: "error",
|
|
57
|
+
fix: "Move what the client needs out of that module, or call it from a server component, server function, or API route.",
|
|
58
|
+
docs: BOUNDARY_DOCS
|
|
59
|
+
},
|
|
60
|
+
CLIENT_SERVER_ONLY_ENTRY: {
|
|
61
|
+
severity: "error",
|
|
62
|
+
fix: "Use it from an API route or another server module.",
|
|
63
|
+
docs: BOUNDARY_DOCS
|
|
64
|
+
},
|
|
65
|
+
CLIENT_ROUTES_FILE: {
|
|
66
|
+
severity: "error",
|
|
67
|
+
fix: "Import the component, server function, or helper from its own module instead of from the module that defines routes.",
|
|
68
|
+
docs: BOUNDARY_DOCS
|
|
69
|
+
},
|
|
70
|
+
CLIENT_ROUTE_SERVER_IMPORT: {
|
|
71
|
+
severity: "error",
|
|
72
|
+
fix: "Keep server-only imports in the routes file, or in modules only its guard, data, and API handlers use.",
|
|
73
|
+
docs: BOUNDARY_DOCS
|
|
74
|
+
},
|
|
75
|
+
SERVER_CLIENT_ONLY_IMPORT: {
|
|
76
|
+
severity: "error",
|
|
77
|
+
fix: 'Add "use client" to this module, or import the package from a "use client" module.',
|
|
78
|
+
docs: BOUNDARY_DOCS
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var FARM_DOCS_ORIGIN = "https://farmjs.dev";
|
|
82
|
+
function createFarmDiagnostic(code, file, message, location) {
|
|
83
|
+
const rule = FARM_DIAGNOSTIC_RULES[code];
|
|
84
|
+
return {
|
|
85
|
+
code,
|
|
86
|
+
severity: rule.severity,
|
|
87
|
+
file: file.split("?", 1)[0].replace(/\\/g, "/"),
|
|
88
|
+
...location,
|
|
89
|
+
message,
|
|
90
|
+
fix: rule.fix,
|
|
91
|
+
docs: FARM_DOCS_ORIGIN + rule.docs
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function formatFarmDiagnostic(diagnostic, root) {
|
|
95
|
+
let file = diagnostic.file;
|
|
96
|
+
if (root) {
|
|
97
|
+
const relative = path.relative(root, file).replace(/\\/g, "/");
|
|
98
|
+
if (relative && !relative.startsWith("../") && !path.isAbsolute(relative)) file = relative;
|
|
99
|
+
}
|
|
100
|
+
const position = diagnostic.line === void 0 ? "" : `:${diagnostic.line}:${diagnostic.column ?? 1}`;
|
|
101
|
+
return [
|
|
102
|
+
`${file}${position} - ${diagnostic.severity} ${diagnostic.code}: ${diagnostic.message}`,
|
|
103
|
+
` fix: ${diagnostic.fix}`,
|
|
104
|
+
` docs: ${diagnostic.docs}`
|
|
105
|
+
].join("\n");
|
|
106
|
+
}
|
|
107
|
+
function createFarmSourceLocator(code, getCombinedSourcemap) {
|
|
108
|
+
let trace2;
|
|
109
|
+
let lineStarts;
|
|
110
|
+
return (offset) => {
|
|
111
|
+
if (trace2 === void 0) {
|
|
112
|
+
try {
|
|
113
|
+
const map = getCombinedSourcemap();
|
|
114
|
+
trace2 = map ? new TraceMap(map) : null;
|
|
115
|
+
} catch {
|
|
116
|
+
trace2 = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!trace2) return void 0;
|
|
120
|
+
if (!lineStarts) {
|
|
121
|
+
lineStarts = [0];
|
|
122
|
+
for (let index = code.indexOf("\n"); index !== -1; index = code.indexOf("\n", index + 1)) {
|
|
123
|
+
lineStarts.push(index + 1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let low = 0;
|
|
127
|
+
let high = lineStarts.length - 1;
|
|
128
|
+
while (low < high) {
|
|
129
|
+
const middle = low + high + 1 >> 1;
|
|
130
|
+
if (lineStarts[middle] <= offset) low = middle;
|
|
131
|
+
else high = middle - 1;
|
|
132
|
+
}
|
|
133
|
+
const original = originalPositionFor(trace2, {
|
|
134
|
+
line: low + 1,
|
|
135
|
+
column: offset - lineStarts[low]
|
|
136
|
+
});
|
|
137
|
+
return original.line === null ? void 0 : { line: original.line, column: (original.column ?? 0) + 1 };
|
|
138
|
+
};
|
|
139
|
+
}
|
|
29
140
|
|
|
30
141
|
// src/islands-react-server-exports.ts
|
|
31
142
|
import fs2 from "fs";
|
|
32
|
-
import
|
|
143
|
+
import path3 from "path";
|
|
33
144
|
import { parseAst } from "rolldown/parseAst";
|
|
145
|
+
import { parseSync } from "rolldown/utils";
|
|
34
146
|
|
|
35
147
|
// src/utils/source-snapshot.ts
|
|
36
148
|
import fs from "fs";
|
|
149
|
+
import path2 from "path";
|
|
37
150
|
var snapshot;
|
|
151
|
+
var base;
|
|
38
152
|
var volatile;
|
|
39
153
|
var trace;
|
|
40
|
-
function
|
|
154
|
+
function farmSourceSnapshotPathKey(file, paths = path2) {
|
|
155
|
+
return paths.resolve(file);
|
|
156
|
+
}
|
|
157
|
+
function getFarmSourceStamp(file) {
|
|
41
158
|
try {
|
|
42
159
|
const stat = fs.statSync(file);
|
|
43
160
|
return `${stat.mtimeMs}:${stat.size}`;
|
|
@@ -46,7 +163,12 @@ function stampOf(file) {
|
|
|
46
163
|
}
|
|
47
164
|
}
|
|
48
165
|
var FarmSourceSnapshotStore = class {
|
|
49
|
-
|
|
166
|
+
/**
|
|
167
|
+
* `tracked: false` keeps entries for a process that edits no sources while it runs, a production
|
|
168
|
+
* build: nothing is stamped, so each plan does not stat every file the snapshot holds.
|
|
169
|
+
*/
|
|
170
|
+
constructor(tracked = true) {
|
|
171
|
+
this.tracked = tracked;
|
|
50
172
|
this.entries = /* @__PURE__ */ new Map();
|
|
51
173
|
this.stamps = /* @__PURE__ */ new Map();
|
|
52
174
|
}
|
|
@@ -59,7 +181,7 @@ var FarmSourceSnapshotStore = class {
|
|
|
59
181
|
const changed = /* @__PURE__ */ new Map();
|
|
60
182
|
for (const file of edited) changed.set(file, void 0);
|
|
61
183
|
for (const [file, stamp] of this.stamps) {
|
|
62
|
-
if (
|
|
184
|
+
if (getFarmSourceStamp(file) !== stamp) changed.set(file, void 0);
|
|
63
185
|
}
|
|
64
186
|
if (changed.size === 0) return changed;
|
|
65
187
|
const replaced = /* @__PURE__ */ new Set();
|
|
@@ -85,10 +207,11 @@ var FarmSourceSnapshotStore = class {
|
|
|
85
207
|
}
|
|
86
208
|
/** Records the stamp of every file an entry read that has none yet. */
|
|
87
209
|
stamp() {
|
|
210
|
+
if (!this.tracked) return;
|
|
88
211
|
for (const entries of this.entries.values()) {
|
|
89
212
|
for (const entry of entries.values()) {
|
|
90
213
|
for (const file of entry.files) {
|
|
91
|
-
if (!this.stamps.has(file)) this.stamps.set(file,
|
|
214
|
+
if (!this.stamps.has(file)) this.stamps.set(file, getFarmSourceStamp(file));
|
|
92
215
|
}
|
|
93
216
|
}
|
|
94
217
|
}
|
|
@@ -112,11 +235,20 @@ function withFarmSourceSnapshot(operation, store) {
|
|
|
112
235
|
store?.stamp();
|
|
113
236
|
}
|
|
114
237
|
}
|
|
238
|
+
function withFarmSourceSnapshotOf(store, operation) {
|
|
239
|
+
if (snapshot) return operation();
|
|
240
|
+
base = store.entries;
|
|
241
|
+
try {
|
|
242
|
+
return withFarmSourceSnapshot(operation);
|
|
243
|
+
} finally {
|
|
244
|
+
base = void 0;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
115
247
|
function memoizeInFarmSourceSnapshot(scope, key, compute, lasting) {
|
|
116
248
|
if (!snapshot) return compute();
|
|
117
249
|
let entries = snapshot.get(scope);
|
|
118
250
|
if (!entries) snapshot.set(scope, entries = /* @__PURE__ */ new Map());
|
|
119
|
-
const memoized = entries.get(key);
|
|
251
|
+
const memoized = entries.get(key) ?? base?.get(scope)?.get(key);
|
|
120
252
|
if (memoized) {
|
|
121
253
|
if (trace) for (const file of memoized.files) trace.add(file);
|
|
122
254
|
return memoized.value;
|
|
@@ -165,10 +297,10 @@ function packageNameOf(specifier) {
|
|
|
165
297
|
return { name, subpath: parts.slice(name.startsWith("@") ? 2 : 1).join("/") };
|
|
166
298
|
}
|
|
167
299
|
function findPackageDirectory(importer, name) {
|
|
168
|
-
for (let current =
|
|
169
|
-
const directory =
|
|
170
|
-
if (fs2.existsSync(
|
|
171
|
-
if (
|
|
300
|
+
for (let current = path3.dirname(importer); ; current = path3.dirname(current)) {
|
|
301
|
+
const directory = path3.join(current, "node_modules", name);
|
|
302
|
+
if (fs2.existsSync(path3.join(directory, "package.json"))) return fs2.realpathSync(directory);
|
|
303
|
+
if (path3.dirname(current) === current) return null;
|
|
172
304
|
}
|
|
173
305
|
}
|
|
174
306
|
function pickTarget(value, conditions) {
|
|
@@ -225,12 +357,12 @@ function resolveFarmReactServerExport(importer, specifier) {
|
|
|
225
357
|
if (cache.has(key)) return cache.get(key);
|
|
226
358
|
let resolved = null;
|
|
227
359
|
try {
|
|
228
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
360
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
229
361
|
const entry = exportEntry(manifest.exports, parsed.subpath);
|
|
230
362
|
const server = pickTarget(entry, SERVER_CONDITIONS);
|
|
231
363
|
const fallback = pickTarget(entry, DEFAULT_CONDITIONS);
|
|
232
364
|
if (server && server !== fallback && server.startsWith("./")) {
|
|
233
|
-
const file =
|
|
365
|
+
const file = path3.resolve(directory, server);
|
|
234
366
|
if (fs2.existsSync(file)) resolved = file;
|
|
235
367
|
}
|
|
236
368
|
} catch {
|
|
@@ -239,6 +371,10 @@ function resolveFarmReactServerExport(importer, specifier) {
|
|
|
239
371
|
cache.set(key, resolved);
|
|
240
372
|
return resolved;
|
|
241
373
|
}
|
|
374
|
+
function parseLang(file) {
|
|
375
|
+
const extension = path3.extname(file).slice(1);
|
|
376
|
+
return extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
|
|
377
|
+
}
|
|
242
378
|
var parsedModules = /* @__PURE__ */ new Map();
|
|
243
379
|
function readModule(file) {
|
|
244
380
|
let stat;
|
|
@@ -253,9 +389,7 @@ function readModule(file) {
|
|
|
253
389
|
let program = null;
|
|
254
390
|
try {
|
|
255
391
|
const code = fs2.readFileSync(file, "utf8");
|
|
256
|
-
|
|
257
|
-
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
|
|
258
|
-
program = parseAst(code, { lang });
|
|
392
|
+
program = parseAst(code, { lang: parseLang(file) });
|
|
259
393
|
} catch {
|
|
260
394
|
program = null;
|
|
261
395
|
}
|
|
@@ -270,13 +404,13 @@ function isClientModule(program) {
|
|
|
270
404
|
return false;
|
|
271
405
|
}
|
|
272
406
|
function resolveRelative(from, specifier) {
|
|
273
|
-
const
|
|
407
|
+
const base2 = path3.resolve(path3.dirname(from), specifier);
|
|
274
408
|
for (const extension of SCRIPT_EXTENSIONS) {
|
|
275
|
-
const file = `${
|
|
409
|
+
const file = `${base2}${extension}`;
|
|
276
410
|
if (fs2.existsSync(file) && fs2.statSync(file).isFile()) return file;
|
|
277
411
|
}
|
|
278
412
|
for (const index of INDEX_FILES) {
|
|
279
|
-
const file =
|
|
413
|
+
const file = path3.join(base2, index);
|
|
280
414
|
if (fs2.existsSync(file)) return file;
|
|
281
415
|
}
|
|
282
416
|
return null;
|
|
@@ -290,10 +424,10 @@ function resolveFarmPackageDefaultEntry(importer, specifier, conditions = ["brow
|
|
|
290
424
|
const directory = findPackageDirectory(importer, parsed.name);
|
|
291
425
|
if (!directory) return null;
|
|
292
426
|
try {
|
|
293
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
427
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
294
428
|
const target = pickTarget(exportEntry(manifest.exports, parsed.subpath), conditions) ?? (!parsed.subpath ? manifest.module ?? manifest.main ?? "index.js" : parsed.subpath);
|
|
295
429
|
return resolveRelative(
|
|
296
|
-
|
|
430
|
+
path3.join(directory, "package.json"),
|
|
297
431
|
`./${String(target).replace(/^\.\//, "")}`
|
|
298
432
|
);
|
|
299
433
|
} catch {
|
|
@@ -372,7 +506,7 @@ function isFarmClientExport(file, name) {
|
|
|
372
506
|
function isFarmPackageClientExport(importer, specifier, name) {
|
|
373
507
|
return memoizeInFarmSourceSnapshot(
|
|
374
508
|
"package-client-export",
|
|
375
|
-
`${
|
|
509
|
+
`${farmSourceSnapshotPathKey(path3.dirname(importer))}\0${specifier}\0${name}`,
|
|
376
510
|
() => {
|
|
377
511
|
const entry = resolveFarmPackageDefaultEntry(importer, specifier);
|
|
378
512
|
return !entry || traceFarmExport(entry, name) !== "server";
|
|
@@ -380,13 +514,14 @@ function isFarmPackageClientExport(importer, specifier, name) {
|
|
|
380
514
|
);
|
|
381
515
|
}
|
|
382
516
|
function parseCode(code, file) {
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
517
|
+
const lang = parseLang(file);
|
|
518
|
+
return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => {
|
|
519
|
+
try {
|
|
520
|
+
return parseAst(code, { lang });
|
|
521
|
+
} catch {
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
390
525
|
}
|
|
391
526
|
function namespaceMembers(program, local) {
|
|
392
527
|
const members = /* @__PURE__ */ new Set();
|
|
@@ -582,6 +717,66 @@ function staticImportSources(program) {
|
|
|
582
717
|
}
|
|
583
718
|
return sources;
|
|
584
719
|
}
|
|
720
|
+
var GAP = String.raw`(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n\r\u2028\u2029]*)*`;
|
|
721
|
+
var EMPTY_EXPORT_LIST = new RegExp(String.raw`\bexport${GAP}\{${GAP}\}`);
|
|
722
|
+
function scanFarmStaticImports(code, lang) {
|
|
723
|
+
let result;
|
|
724
|
+
try {
|
|
725
|
+
result = parseSync("file.js", code, { lang, preserveParens: false });
|
|
726
|
+
} catch {
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
if (result.errors.length > 0) return null;
|
|
730
|
+
const fromProgram = () => {
|
|
731
|
+
const program = result.program;
|
|
732
|
+
return { sources: staticImportSources(program), client: isClientModule(program) };
|
|
733
|
+
};
|
|
734
|
+
const statements = [];
|
|
735
|
+
for (const entry of result.module.staticImports) {
|
|
736
|
+
if (entry.entries.some((binding) => binding.isType)) return fromProgram();
|
|
737
|
+
statements.push({ start: entry.start, source: entry.moduleRequest.value });
|
|
738
|
+
}
|
|
739
|
+
const imported = new Set(statements.map((statement) => statement.start));
|
|
740
|
+
for (const entry of result.module.staticExports) {
|
|
741
|
+
if (entry.entries.some((binding) => binding.isType)) return fromProgram();
|
|
742
|
+
const request = entry.entries[0]?.moduleRequest;
|
|
743
|
+
if (request && !imported.has(entry.start) && request.start >= entry.start && request.end <= entry.end) {
|
|
744
|
+
statements.push({ start: entry.start, source: request.value });
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (EMPTY_EXPORT_LIST.test(code)) return fromProgram();
|
|
748
|
+
statements.sort((left, right) => left.start - right.start);
|
|
749
|
+
const prologueEnd = statements[0]?.start ?? code.length;
|
|
750
|
+
if (code.slice(0, prologueEnd).includes("use client")) return fromProgram();
|
|
751
|
+
return { sources: statements.map((statement) => statement.source), client: false };
|
|
752
|
+
}
|
|
753
|
+
var scannedModules = /* @__PURE__ */ new Map();
|
|
754
|
+
function readModuleImports(file) {
|
|
755
|
+
let stat;
|
|
756
|
+
try {
|
|
757
|
+
stat = fs2.statSync(file);
|
|
758
|
+
} catch {
|
|
759
|
+
return null;
|
|
760
|
+
}
|
|
761
|
+
noteFarmSourceRead(file);
|
|
762
|
+
const cached = scannedModules.get(file);
|
|
763
|
+
if (cached && cached.size === stat.size && cached.mtimeMs === stat.mtimeMs) return cached.imports;
|
|
764
|
+
const parsed = parsedModules.get(file);
|
|
765
|
+
let imports;
|
|
766
|
+
if (parsed && parsed.size === stat.size && parsed.mtimeMs === stat.mtimeMs) {
|
|
767
|
+
imports = parsed.program ? { sources: staticImportSources(parsed.program), client: isClientModule(parsed.program) } : null;
|
|
768
|
+
} else {
|
|
769
|
+
let code;
|
|
770
|
+
try {
|
|
771
|
+
code = fs2.readFileSync(file, "utf8");
|
|
772
|
+
} catch {
|
|
773
|
+
code = void 0;
|
|
774
|
+
}
|
|
775
|
+
imports = code === void 0 ? null : scanFarmStaticImports(code, parseLang(file));
|
|
776
|
+
}
|
|
777
|
+
scannedModules.set(file, { size: stat.size, mtimeMs: stat.mtimeMs, imports });
|
|
778
|
+
return imports;
|
|
779
|
+
}
|
|
585
780
|
var clientOnlyFreeFiles = /* @__PURE__ */ new Set();
|
|
586
781
|
function invalidateFarmClientOnlyScan() {
|
|
587
782
|
clientOnlyFreeFiles.clear();
|
|
@@ -593,28 +788,34 @@ function resolveServerEntry(importer, specifier) {
|
|
|
593
788
|
}
|
|
594
789
|
return resolveFarmReactServerExport(importer, specifier) ?? resolveFarmPackageDefaultEntry(importer, specifier, DEFAULT_CONDITIONS);
|
|
595
790
|
}
|
|
596
|
-
function walkToClientOnly(file, seen) {
|
|
791
|
+
function walkToClientOnly(file, seen, resolved) {
|
|
597
792
|
if (seen.has(file) || clientOnlyFreeFiles.has(file)) return null;
|
|
598
793
|
seen.add(file);
|
|
599
|
-
const
|
|
600
|
-
if (!
|
|
601
|
-
for (const source of
|
|
794
|
+
const imports = readModuleImports(file);
|
|
795
|
+
if (!imports || imports.client) return null;
|
|
796
|
+
for (const source of imports.sources) {
|
|
602
797
|
if (source === CLIENT_ONLY_PACKAGE) return [file];
|
|
603
|
-
const
|
|
604
|
-
|
|
798
|
+
const key = `${path3.dirname(file)}\0${source}`;
|
|
799
|
+
let child = resolved.get(key);
|
|
800
|
+
if (child === void 0) {
|
|
801
|
+
child = source.startsWith(".") ? resolveRelative(file, source) : resolveServerEntry(file, source);
|
|
802
|
+
resolved.set(key, child);
|
|
803
|
+
}
|
|
804
|
+
const chain = child && walkToClientOnly(child, seen, resolved);
|
|
605
805
|
if (chain) return [file, ...chain];
|
|
606
806
|
}
|
|
607
807
|
return null;
|
|
608
808
|
}
|
|
609
809
|
function findFarmClientOnlyImport(code, file) {
|
|
610
810
|
if (!code.includes("import") && !code.includes("export")) return null;
|
|
611
|
-
const
|
|
612
|
-
if (!
|
|
613
|
-
|
|
811
|
+
const imports = scanFarmStaticImports(code, parseLang(file));
|
|
812
|
+
if (!imports) return null;
|
|
813
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
814
|
+
for (const specifier of imports.sources) {
|
|
614
815
|
const entry = resolveServerEntry(file, specifier);
|
|
615
816
|
if (!entry) continue;
|
|
616
817
|
const seen = /* @__PURE__ */ new Set();
|
|
617
|
-
const chain = walkToClientOnly(entry, seen);
|
|
818
|
+
const chain = walkToClientOnly(entry, seen, resolved);
|
|
618
819
|
if (chain) return { specifier, chain };
|
|
619
820
|
for (const walked of seen) clientOnlyFreeFiles.add(walked);
|
|
620
821
|
}
|
|
@@ -656,15 +857,85 @@ var IMPORT_SPECIFIER = /(?:\bfrom\s*|\bimport\s*\(?\s*)["']([^"'./][^"']*)["']/g
|
|
|
656
857
|
var STYLESHEET_IMPORT = /(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)["'][^"']+\.(?:css|scss|sass|less|styl)["']/;
|
|
657
858
|
var MAX_SCANNED_FILES = 2e3;
|
|
658
859
|
var packageScans = /* @__PURE__ */ new Map();
|
|
860
|
+
var PACKAGE_SCAN_CACHE_SCHEMA = 1;
|
|
861
|
+
var packageScanStamps = /* @__PURE__ */ new Map();
|
|
862
|
+
var packageScanCache;
|
|
863
|
+
function stampScannedPath(directory, target) {
|
|
864
|
+
try {
|
|
865
|
+
const stat = fs2.statSync(target, { throwIfNoEntry: false });
|
|
866
|
+
if (!stat) return void 0;
|
|
867
|
+
return [path3.relative(directory, target), stat.size, stat.mtimeMs, stat.ctimeMs];
|
|
868
|
+
} catch {
|
|
869
|
+
return void 0;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function isUnchangedScanStamp(directory, stamp) {
|
|
873
|
+
const current = stampScannedPath(directory, path3.join(directory, stamp[0]));
|
|
874
|
+
return current !== void 0 && current[1] === stamp[1] && current[2] === stamp[2] && current[3] === stamp[3];
|
|
875
|
+
}
|
|
876
|
+
function usePackageScanCacheFile(file) {
|
|
877
|
+
if (packageScanCache?.file === file) return;
|
|
878
|
+
const stored = /* @__PURE__ */ new Map();
|
|
879
|
+
try {
|
|
880
|
+
const value = JSON.parse(fs2.readFileSync(file, "utf8"));
|
|
881
|
+
if (value?.schema === PACKAGE_SCAN_CACHE_SCHEMA && value.farm === FARM_VERSION && value.scans && typeof value.scans === "object") {
|
|
882
|
+
for (const [directory, scan] of Object.entries(value.scans)) {
|
|
883
|
+
if (isStoredPackageScan(scan)) stored.set(directory, scan);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
} catch {
|
|
887
|
+
}
|
|
888
|
+
packageScanCache = { file, stored, dirty: false };
|
|
889
|
+
}
|
|
890
|
+
function isStoredPackageScan(value) {
|
|
891
|
+
const scan = value;
|
|
892
|
+
return !!scan && Array.isArray(scan.imports) && scan.imports.every((item) => typeof item === "string") && typeof scan.stylesheets === "boolean" && Array.isArray(scan.paths) && scan.paths.every(
|
|
893
|
+
(stamp) => Array.isArray(stamp) && stamp.length === 4 && typeof stamp[0] === "string" && stamp.slice(1).every((part) => typeof part === "number")
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
function persistPackageScanCache() {
|
|
897
|
+
const cache2 = packageScanCache;
|
|
898
|
+
if (!cache2?.dirty) return;
|
|
899
|
+
const scans = {};
|
|
900
|
+
for (const [directory, paths] of packageScanStamps) {
|
|
901
|
+
const scan = packageScans.get(directory);
|
|
902
|
+
if (scan)
|
|
903
|
+
scans[directory] = { imports: [...scan.imports], stylesheets: scan.stylesheets, paths };
|
|
904
|
+
}
|
|
905
|
+
const temporary = `${cache2.file}.${process.pid}.${Date.now()}.tmp`;
|
|
906
|
+
try {
|
|
907
|
+
fs2.mkdirSync(path3.dirname(cache2.file), { recursive: true });
|
|
908
|
+
fs2.writeFileSync(
|
|
909
|
+
temporary,
|
|
910
|
+
JSON.stringify({ schema: PACKAGE_SCAN_CACHE_SCHEMA, farm: FARM_VERSION, scans })
|
|
911
|
+
);
|
|
912
|
+
fs2.renameSync(temporary, cache2.file);
|
|
913
|
+
cache2.dirty = false;
|
|
914
|
+
} catch {
|
|
915
|
+
try {
|
|
916
|
+
fs2.rmSync(temporary, { force: true });
|
|
917
|
+
} catch {
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
659
921
|
function scanPackage(directory) {
|
|
660
922
|
const cached = packageScans.get(directory);
|
|
661
923
|
if (cached) return cached;
|
|
924
|
+
const stored = packageScanCache?.stored.get(directory);
|
|
925
|
+
if (stored && stored.paths.every((stamp) => isUnchangedScanStamp(directory, stamp))) {
|
|
926
|
+
const scan2 = { imports: new Set(stored.imports), stylesheets: stored.stylesheets };
|
|
927
|
+
packageScans.set(directory, scan2);
|
|
928
|
+
packageScanStamps.set(directory, stored.paths);
|
|
929
|
+
return scan2;
|
|
930
|
+
}
|
|
662
931
|
const scan = { imports: /* @__PURE__ */ new Set(), stylesheets: false };
|
|
932
|
+
const stamps = [];
|
|
663
933
|
const pending = [directory];
|
|
664
934
|
let scanned = 0;
|
|
665
935
|
while (pending.length > 0 && scanned < MAX_SCANNED_FILES) {
|
|
666
936
|
const current = pending.pop();
|
|
667
937
|
let entries;
|
|
938
|
+
stamps.push(stampScannedPath(directory, current));
|
|
668
939
|
try {
|
|
669
940
|
entries = fs2.readdirSync(current, { withFileTypes: true });
|
|
670
941
|
} catch {
|
|
@@ -672,10 +943,11 @@ function scanPackage(directory) {
|
|
|
672
943
|
}
|
|
673
944
|
for (const entry of entries) {
|
|
674
945
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
675
|
-
const file =
|
|
946
|
+
const file = path3.join(current, entry.name);
|
|
676
947
|
if (entry.isDirectory()) pending.push(file);
|
|
677
948
|
else if (/\.(?:[cm]?js|jsx)$/.test(entry.name) && scanned++ < MAX_SCANNED_FILES) {
|
|
678
949
|
let code;
|
|
950
|
+
stamps.push(stampScannedPath(directory, file));
|
|
679
951
|
try {
|
|
680
952
|
code = fs2.readFileSync(file, "utf8");
|
|
681
953
|
} catch {
|
|
@@ -687,6 +959,10 @@ function scanPackage(directory) {
|
|
|
687
959
|
}
|
|
688
960
|
}
|
|
689
961
|
packageScans.set(directory, scan);
|
|
962
|
+
if (stamps.every((stamp) => stamp !== void 0)) {
|
|
963
|
+
packageScanStamps.set(directory, stamps);
|
|
964
|
+
if (packageScanCache) packageScanCache.dirty = true;
|
|
965
|
+
}
|
|
690
966
|
return scan;
|
|
691
967
|
}
|
|
692
968
|
function findFarmServerBundledPackage(importer, specifier) {
|
|
@@ -697,8 +973,8 @@ function findFarmServerBundledPackage(importer, specifier) {
|
|
|
697
973
|
const directory = findPackageDirectory(importer, parsed.name);
|
|
698
974
|
if (!directory) return null;
|
|
699
975
|
try {
|
|
700
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
701
|
-
if (manifest.exports === void 0 && manifest.type !== "module" && typeof manifest.module === "string" && typeof manifest.main === "string" &&
|
|
976
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
977
|
+
if (manifest.exports === void 0 && manifest.type !== "module" && typeof manifest.module === "string" && typeof manifest.main === "string" && path3.resolve(directory, manifest.main) !== path3.resolve(directory, manifest.module)) {
|
|
702
978
|
return { name: parsed.name, prebundle: isSelfContainedPackage(manifest, importer) };
|
|
703
979
|
}
|
|
704
980
|
} catch {
|
|
@@ -719,7 +995,7 @@ function findFarmPackageManifest(importer, specifier) {
|
|
|
719
995
|
if (!directory) return null;
|
|
720
996
|
let names;
|
|
721
997
|
try {
|
|
722
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
998
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
723
999
|
names = new Set(Object.keys(manifest.dependencies ?? {}));
|
|
724
1000
|
} catch {
|
|
725
1001
|
return null;
|
|
@@ -1326,13 +1602,13 @@ function toModuleFile(file) {
|
|
|
1326
1602
|
|
|
1327
1603
|
// src/utils/client-component.ts
|
|
1328
1604
|
import fs6 from "fs";
|
|
1329
|
-
import
|
|
1605
|
+
import path7 from "path";
|
|
1330
1606
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1331
1607
|
|
|
1332
1608
|
// src/islands-package-references.ts
|
|
1333
1609
|
import { createHash } from "crypto";
|
|
1334
1610
|
import fs3 from "fs";
|
|
1335
|
-
import
|
|
1611
|
+
import path4 from "path";
|
|
1336
1612
|
import { parseAst as parseAst2 } from "rolldown/parseAst";
|
|
1337
1613
|
var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
1338
1614
|
var moduleName = (node) => {
|
|
@@ -1340,7 +1616,7 @@ var moduleName = (node) => {
|
|
|
1340
1616
|
return typeof name === "string" ? name : null;
|
|
1341
1617
|
};
|
|
1342
1618
|
function parse(code, file) {
|
|
1343
|
-
const extension =
|
|
1619
|
+
const extension = path4.extname(file).slice(1);
|
|
1344
1620
|
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
|
|
1345
1621
|
return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => parseAs(code, lang));
|
|
1346
1622
|
}
|
|
@@ -1457,18 +1733,18 @@ function parseFarmResolveFrom(id, importer) {
|
|
|
1457
1733
|
const rest = id.slice(FARM_RESOLVE_FROM_PREFIX.length);
|
|
1458
1734
|
const separator = rest.indexOf(":");
|
|
1459
1735
|
if (separator <= 0) return null;
|
|
1460
|
-
const directory =
|
|
1461
|
-
|
|
1736
|
+
const directory = path4.resolve(
|
|
1737
|
+
path4.dirname(importer),
|
|
1462
1738
|
decodeURIComponent(rest.slice(0, separator))
|
|
1463
1739
|
);
|
|
1464
1740
|
return {
|
|
1465
1741
|
specifier: rest.slice(separator + 1),
|
|
1466
|
-
importer:
|
|
1742
|
+
importer: path4.join(directory, "__farm_client_reference__.js")
|
|
1467
1743
|
};
|
|
1468
1744
|
}
|
|
1469
1745
|
function farmPackageClientReferencePath(root, specifier, exportName, scope) {
|
|
1470
1746
|
const directory = specifier.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
|
|
1471
|
-
return
|
|
1747
|
+
return path4.join(
|
|
1472
1748
|
root,
|
|
1473
1749
|
".farm",
|
|
1474
1750
|
"client-references",
|
|
@@ -1482,22 +1758,22 @@ function specifierPackage(specifier) {
|
|
|
1482
1758
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
1483
1759
|
}
|
|
1484
1760
|
function packageLookup(directory, packageName) {
|
|
1485
|
-
for (let current = directory; ; current =
|
|
1486
|
-
if (
|
|
1487
|
-
const candidate =
|
|
1761
|
+
for (let current = directory; ; current = path4.dirname(current)) {
|
|
1762
|
+
if (path4.basename(current) !== "node_modules") {
|
|
1763
|
+
const candidate = path4.join(current, "node_modules", packageName);
|
|
1488
1764
|
try {
|
|
1489
1765
|
return { from: current, real: fs3.realpathSync(candidate) };
|
|
1490
1766
|
} catch {
|
|
1491
1767
|
}
|
|
1492
1768
|
}
|
|
1493
|
-
if (
|
|
1769
|
+
if (path4.dirname(current) === current) return null;
|
|
1494
1770
|
}
|
|
1495
1771
|
}
|
|
1496
1772
|
function referenceResolveFrom(root, specifier, importer) {
|
|
1497
1773
|
const packageName = specifierPackage(specifier);
|
|
1498
|
-
const own = packageLookup(
|
|
1774
|
+
const own = packageLookup(path4.dirname(importer), packageName);
|
|
1499
1775
|
if (!own) return null;
|
|
1500
|
-
const app = packageLookup(
|
|
1776
|
+
const app = packageLookup(path4.join(root, ".farm", "client-references"), packageName);
|
|
1501
1777
|
if (app?.real === own.real) return null;
|
|
1502
1778
|
try {
|
|
1503
1779
|
return fs3.realpathSync(own.from);
|
|
@@ -1507,11 +1783,11 @@ function referenceResolveFrom(root, specifier, importer) {
|
|
|
1507
1783
|
}
|
|
1508
1784
|
function ensureFarmPackageClientReference(root, specifier, exportName, importer) {
|
|
1509
1785
|
const resolveFrom = importer ? referenceResolveFrom(root, specifier, importer) : null;
|
|
1510
|
-
const scope = resolveFrom ? `__from__${createHash("sha256").update(
|
|
1786
|
+
const scope = resolveFrom ? `__from__${createHash("sha256").update(path4.relative(root, resolveFrom).split(path4.sep).join("/")).digest("hex").slice(0, 8)}` : void 0;
|
|
1511
1787
|
const file = farmPackageClientReferencePath(root, specifier, exportName, scope);
|
|
1512
1788
|
const target = JSON.stringify(
|
|
1513
1789
|
resolveFrom ? `${FARM_RESOLVE_FROM_PREFIX}${encodeURIComponent(
|
|
1514
|
-
|
|
1790
|
+
path4.relative(path4.dirname(file), resolveFrom).split(path4.sep).join("/")
|
|
1515
1791
|
)}:${specifier}` : specifier
|
|
1516
1792
|
);
|
|
1517
1793
|
const source = [
|
|
@@ -1530,7 +1806,7 @@ function ensureFarmPackageClientReference(root, specifier, exportName, importer)
|
|
|
1530
1806
|
} catch {
|
|
1531
1807
|
}
|
|
1532
1808
|
if (current !== source) {
|
|
1533
|
-
fs3.mkdirSync(
|
|
1809
|
+
fs3.mkdirSync(path4.dirname(file), { recursive: true });
|
|
1534
1810
|
fs3.writeFileSync(file, source);
|
|
1535
1811
|
}
|
|
1536
1812
|
return file;
|
|
@@ -1542,18 +1818,18 @@ function writeIfChanged(file, source) {
|
|
|
1542
1818
|
} catch {
|
|
1543
1819
|
}
|
|
1544
1820
|
if (current !== source) {
|
|
1545
|
-
fs3.mkdirSync(
|
|
1821
|
+
fs3.mkdirSync(path4.dirname(file), { recursive: true });
|
|
1546
1822
|
fs3.writeFileSync(file, source);
|
|
1547
1823
|
}
|
|
1548
1824
|
}
|
|
1549
1825
|
function owningPackage(file) {
|
|
1550
|
-
for (let current =
|
|
1826
|
+
for (let current = path4.dirname(file); ; current = path4.dirname(current)) {
|
|
1551
1827
|
try {
|
|
1552
|
-
const manifest = JSON.parse(fs3.readFileSync(
|
|
1828
|
+
const manifest = JSON.parse(fs3.readFileSync(path4.join(current, "package.json"), "utf8"));
|
|
1553
1829
|
if (typeof manifest.name === "string") return { directory: current, name: manifest.name };
|
|
1554
1830
|
} catch {
|
|
1555
1831
|
}
|
|
1556
|
-
if (
|
|
1832
|
+
if (path4.dirname(current) === current) return null;
|
|
1557
1833
|
}
|
|
1558
1834
|
}
|
|
1559
1835
|
function ensureFarmInternalClientReference(root, clientFile) {
|
|
@@ -1562,8 +1838,8 @@ function ensureFarmInternalClientReference(root, clientFile) {
|
|
|
1562
1838
|
if (!owner || !names || names.length === 0) return null;
|
|
1563
1839
|
const directory = owner.name.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
|
|
1564
1840
|
const hash = createHash("sha256").update(owner.directory).digest("hex").slice(0, 8);
|
|
1565
|
-
const relative =
|
|
1566
|
-
const file =
|
|
1841
|
+
const relative = path4.relative(owner.directory, clientFile).split(path4.sep).join("+").replace(/[^A-Za-z0-9._+-]/g, "_");
|
|
1842
|
+
const file = path4.join(
|
|
1567
1843
|
root,
|
|
1568
1844
|
".farm",
|
|
1569
1845
|
"client-references",
|
|
@@ -1573,7 +1849,7 @@ function ensureFarmInternalClientReference(root, clientFile) {
|
|
|
1573
1849
|
);
|
|
1574
1850
|
const target = JSON.stringify(clientFile);
|
|
1575
1851
|
const lines = [
|
|
1576
|
-
`// Generated by Farm: ${owner.name}'s ${
|
|
1852
|
+
`// Generated by Farm: ${owner.name}'s ${path4.relative(owner.directory, clientFile).split(path4.sep).join("/")}, as a client reference for server components.`,
|
|
1577
1853
|
FARM_CLIENT_REFERENCE_PRAGMA,
|
|
1578
1854
|
'"use client";'
|
|
1579
1855
|
];
|
|
@@ -1636,7 +1912,7 @@ function rewriteFarmPackageClientImports(options) {
|
|
|
1636
1912
|
|
|
1637
1913
|
// src/islands-containers.ts
|
|
1638
1914
|
import fs4 from "fs";
|
|
1639
|
-
import
|
|
1915
|
+
import path5 from "path";
|
|
1640
1916
|
import { parseAst as parseAst3 } from "rolldown/parseAst";
|
|
1641
1917
|
var FARM_ISLAND_CONTAINER_EXPORT = "FarmIslandContainer";
|
|
1642
1918
|
var CONTAINER_LOCAL = "__FarmIslandContainer__";
|
|
@@ -1655,7 +1931,7 @@ var ISLAND_CONTAINER_TAGS = /* @__PURE__ */ new Set([
|
|
|
1655
1931
|
]);
|
|
1656
1932
|
var FLOW_CONTENT_TAGS = /* @__PURE__ */ new Set(["td", "th", "caption", "foreignObject", "li"]);
|
|
1657
1933
|
function farmIslandContainerReferencePath(root) {
|
|
1658
|
-
return
|
|
1934
|
+
return path5.join(root, ".farm", "client-references", "farm.js+core", "__island-container.tsx");
|
|
1659
1935
|
}
|
|
1660
1936
|
function ensureFarmIslandContainerReference(root) {
|
|
1661
1937
|
const file = farmIslandContainerReferencePath(root);
|
|
@@ -1674,13 +1950,13 @@ function ensureFarmIslandContainerReference(root) {
|
|
|
1674
1950
|
} catch {
|
|
1675
1951
|
}
|
|
1676
1952
|
if (current !== source) {
|
|
1677
|
-
fs4.mkdirSync(
|
|
1953
|
+
fs4.mkdirSync(path5.dirname(file), { recursive: true });
|
|
1678
1954
|
fs4.writeFileSync(file, source);
|
|
1679
1955
|
}
|
|
1680
1956
|
return file;
|
|
1681
1957
|
}
|
|
1682
1958
|
function parse2(code, file) {
|
|
1683
|
-
const extension =
|
|
1959
|
+
const extension = path5.extname(file).slice(1);
|
|
1684
1960
|
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : extension === "js" || extension === "mjs" || extension === "cjs" || extension === "jsx" ? "jsx" : "tsx";
|
|
1685
1961
|
return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => {
|
|
1686
1962
|
try {
|
|
@@ -1764,7 +2040,7 @@ function wrapFarmIslandContainers(options) {
|
|
|
1764
2040
|
for (const container of [...containers].reverse()) {
|
|
1765
2041
|
code = code.slice(0, container.start) + `<${CONTAINER_LOCAL}>` + code.slice(container.start, container.end) + `</${CONTAINER_LOCAL}>` + code.slice(container.end);
|
|
1766
2042
|
}
|
|
1767
|
-
const specifier = JSON.stringify(options.reference.split(
|
|
2043
|
+
const specifier = JSON.stringify(options.reference.split(path5.sep).join("/"));
|
|
1768
2044
|
const declaration = `import { ${FARM_ISLAND_CONTAINER_EXPORT} as ${CONTAINER_LOCAL} } from ${specifier};
|
|
1769
2045
|
`;
|
|
1770
2046
|
let prologueEnd = 0;
|
|
@@ -1780,9 +2056,9 @@ ${declaration}${code.slice(prologueEnd)}`;
|
|
|
1780
2056
|
// src/utils/package-client-boundary-cache.ts
|
|
1781
2057
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1782
2058
|
import fs5 from "fs";
|
|
1783
|
-
import
|
|
2059
|
+
import path6 from "path";
|
|
1784
2060
|
var SCHEMA_VERSION = 2;
|
|
1785
|
-
var NODE_MODULES_SEGMENT = `${
|
|
2061
|
+
var NODE_MODULES_SEGMENT = `${path6.sep}node_modules${path6.sep}`;
|
|
1786
2062
|
var PackageInspectionTrace = class {
|
|
1787
2063
|
constructor() {
|
|
1788
2064
|
this.files = /* @__PURE__ */ new Set();
|
|
@@ -1792,7 +2068,7 @@ var PackageInspectionTrace = class {
|
|
|
1792
2068
|
}
|
|
1793
2069
|
visit(file) {
|
|
1794
2070
|
this.files.add(file);
|
|
1795
|
-
const directory =
|
|
2071
|
+
const directory = path6.dirname(file);
|
|
1796
2072
|
if (!this.directoryStamps.has(directory)) {
|
|
1797
2073
|
this.directoryStamps.set(directory, stampPackagePath(directory, "directory"));
|
|
1798
2074
|
}
|
|
@@ -1819,7 +2095,7 @@ var PackageInspectionTrace = class {
|
|
|
1819
2095
|
}
|
|
1820
2096
|
};
|
|
1821
2097
|
function stampPackagePath(target, kind) {
|
|
1822
|
-
if (!`${target}${
|
|
2098
|
+
if (!`${target}${path6.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
|
|
1823
2099
|
try {
|
|
1824
2100
|
const stat = fs5.statSync(target, { throwIfNoEntry: false });
|
|
1825
2101
|
if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
|
|
@@ -1876,7 +2152,7 @@ var PackageClientBoundaryCache = class {
|
|
|
1876
2152
|
const { file, contents } = pending;
|
|
1877
2153
|
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
1878
2154
|
try {
|
|
1879
|
-
await fs5.promises.mkdir(
|
|
2155
|
+
await fs5.promises.mkdir(path6.dirname(file), { recursive: true });
|
|
1880
2156
|
await fs5.promises.writeFile(temporary, contents);
|
|
1881
2157
|
await fs5.promises.rename(temporary, file);
|
|
1882
2158
|
} catch {
|
|
@@ -1891,7 +2167,7 @@ var PackageClientBoundaryCache = class {
|
|
|
1891
2167
|
const { file, contents } = pending;
|
|
1892
2168
|
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
1893
2169
|
try {
|
|
1894
|
-
fs5.mkdirSync(
|
|
2170
|
+
fs5.mkdirSync(path6.dirname(file), { recursive: true });
|
|
1895
2171
|
fs5.writeFileSync(temporary, contents);
|
|
1896
2172
|
fs5.renameSync(temporary, file);
|
|
1897
2173
|
} catch {
|
|
@@ -1988,7 +2264,7 @@ function isRecord(value) {
|
|
|
1988
2264
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1989
2265
|
}
|
|
1990
2266
|
function isPathStamp(value) {
|
|
1991
|
-
return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" &&
|
|
2267
|
+
return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" && path6.isAbsolute(value[0]) && value.slice(1).every((part) => typeof part === "number" && Number.isFinite(part));
|
|
1992
2268
|
}
|
|
1993
2269
|
function isPathIndexList(value, pathCount) {
|
|
1994
2270
|
return Array.isArray(value) && value.length > 0 && value.every((index) => Number.isSafeInteger(index) && index >= 0 && index < pathCount);
|
|
@@ -1996,7 +2272,7 @@ function isPathIndexList(value, pathCount) {
|
|
|
1996
2272
|
function isStoredEntry(value, pathCount) {
|
|
1997
2273
|
if (!isRecord(value) || !isRecord(value.result)) return false;
|
|
1998
2274
|
const { isClientComponent, shouldHydrate, islandStrategy } = value.result;
|
|
1999
|
-
return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" &&
|
|
2275
|
+
return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" && path6.isAbsolute(file)) && typeof isClientComponent === "boolean" && typeof shouldHydrate === "boolean" && (islandStrategy === null || isFarmIslandStrategy(islandStrategy)) && Object.keys(value.result).length === 3;
|
|
2000
2276
|
}
|
|
2001
2277
|
var STORAGE_KEY = /* @__PURE__ */ Symbol.for("@farm.js/core/package-client-boundary-cache");
|
|
2002
2278
|
function getStorage() {
|
|
@@ -2024,7 +2300,7 @@ function usePackageClientBoundaryCacheFile(file) {
|
|
|
2024
2300
|
getPackageClientBoundaryCache()?.load(file);
|
|
2025
2301
|
}
|
|
2026
2302
|
function resolvePackageClientBoundaryCacheFile(root, distDir) {
|
|
2027
|
-
return
|
|
2303
|
+
return path6.resolve(root, distDir, "cache", "client-boundaries.json");
|
|
2028
2304
|
}
|
|
2029
2305
|
function runWithPackageClientBoundaryCacheFile(file, operation) {
|
|
2030
2306
|
if (getPackageClientBoundaryCache()) return operation();
|
|
@@ -2090,18 +2366,18 @@ function resolveModuleSourcePath(modulePath, root) {
|
|
|
2090
2366
|
}
|
|
2091
2367
|
if (modulePath.startsWith("/@fs/")) {
|
|
2092
2368
|
const fsPath = withoutQuery.slice("/@fs/".length);
|
|
2093
|
-
candidates.add(
|
|
2369
|
+
candidates.add(path7.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
|
|
2094
2370
|
}
|
|
2095
2371
|
}
|
|
2096
2372
|
if (root && modulePath) {
|
|
2097
2373
|
const normalized = withoutQuery.replace(/^\/+/, "");
|
|
2098
|
-
candidates.add(
|
|
2099
|
-
candidates.add(
|
|
2374
|
+
candidates.add(path7.join(root, normalized));
|
|
2375
|
+
candidates.add(path7.resolve(root, normalized));
|
|
2100
2376
|
}
|
|
2101
2377
|
if (withoutQuery?.startsWith("/src/")) {
|
|
2102
2378
|
const normalized = withoutQuery.replace(/^\/+/, "");
|
|
2103
|
-
candidates.add(
|
|
2104
|
-
candidates.add(
|
|
2379
|
+
candidates.add(path7.join(process.cwd(), normalized));
|
|
2380
|
+
candidates.add(path7.resolve(process.cwd(), normalized));
|
|
2105
2381
|
}
|
|
2106
2382
|
for (const candidate of candidates) {
|
|
2107
2383
|
if (fs6.existsSync(candidate)) {
|
|
@@ -2121,8 +2397,8 @@ var FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES = 4;
|
|
|
2121
2397
|
function isolatedHydrationBoundaryLimit() {
|
|
2122
2398
|
const benchmarkRoot = process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_ROOT;
|
|
2123
2399
|
const benchmarkLimit = Number(process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_LIMIT);
|
|
2124
|
-
const resolvedBenchmarkRoot = benchmarkRoot ?
|
|
2125
|
-
const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${
|
|
2400
|
+
const resolvedBenchmarkRoot = benchmarkRoot ? path7.resolve(benchmarkRoot) : null;
|
|
2401
|
+
const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path7.sep}`));
|
|
2126
2402
|
return isBenchmarkFixture && Number.isSafeInteger(benchmarkLimit) && benchmarkLimit > FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES ? benchmarkLimit : FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES;
|
|
2127
2403
|
}
|
|
2128
2404
|
var RESOLVABLE_SOURCE_EXTENSIONS = [
|
|
@@ -2153,7 +2429,7 @@ function hasUseClientDirective(content) {
|
|
|
2153
2429
|
if (!normalized.includes("use client")) {
|
|
2154
2430
|
return false;
|
|
2155
2431
|
}
|
|
2156
|
-
for (const token of
|
|
2432
|
+
for (const token of scanModuleSourceTokens(content, true)) {
|
|
2157
2433
|
if (token.kind === "string") {
|
|
2158
2434
|
if (token.value === "use client") {
|
|
2159
2435
|
return true;
|
|
@@ -2279,7 +2555,7 @@ function isIdentifierStartCode(code) {
|
|
|
2279
2555
|
function isIdentifierPartCode(code) {
|
|
2280
2556
|
return isIdentifierStartCode(code) || code >= 48 && code <= 57;
|
|
2281
2557
|
}
|
|
2282
|
-
function scanModuleSourceTokens(content) {
|
|
2558
|
+
function scanModuleSourceTokens(content, prologueOnly = false) {
|
|
2283
2559
|
const tokens = [];
|
|
2284
2560
|
let index = 0;
|
|
2285
2561
|
let line = 1;
|
|
@@ -2359,9 +2635,11 @@ function scanModuleSourceTokens(content) {
|
|
|
2359
2635
|
const start = index++;
|
|
2360
2636
|
while (index < content.length && isIdentifierPartCode(content.charCodeAt(index))) index++;
|
|
2361
2637
|
tokens.push({ kind: "identifier", value: content.slice(start, index), line });
|
|
2638
|
+
if (prologueOnly) return tokens;
|
|
2362
2639
|
continue;
|
|
2363
2640
|
}
|
|
2364
2641
|
tokens.push({ kind: "punctuation", value: character, line });
|
|
2642
|
+
if (prologueOnly && character !== ";") return tokens;
|
|
2365
2643
|
index++;
|
|
2366
2644
|
}
|
|
2367
2645
|
return tokens;
|
|
@@ -2474,7 +2752,7 @@ function getFarmClientRenderingBindings(code, file, root) {
|
|
|
2474
2752
|
for (const [specifier, locals] of getStaticImportBindings(code)) {
|
|
2475
2753
|
const imported = resolveImportedModule(file, specifier, root);
|
|
2476
2754
|
if (!imported.path) continue;
|
|
2477
|
-
const metadata = imported.local ? inspectClientModuleMetadata(imported.path, root, /* @__PURE__ */ new Set([
|
|
2755
|
+
const metadata = imported.local ? inspectClientModuleMetadata(imported.path, root, /* @__PURE__ */ new Set([path7.resolve(file)]), false) : inspectPackageClientBoundary(imported.path, root, /* @__PURE__ */ new Set());
|
|
2478
2756
|
if (metadata.isClientComponent || metadata.shouldHydrate) bindings.push(...locals);
|
|
2479
2757
|
}
|
|
2480
2758
|
return bindings;
|
|
@@ -2518,6 +2796,9 @@ function getClientModuleMetadata(modulePath, root) {
|
|
|
2518
2796
|
const resolvedPath = resolveModuleSourcePath(modulePath, root);
|
|
2519
2797
|
return inspectClientModuleMetadata(resolvedPath, root, /* @__PURE__ */ new Set(), true);
|
|
2520
2798
|
}
|
|
2799
|
+
function getClientModuleHydrationPlanKey(modulePath, root, mode, options = {}) {
|
|
2800
|
+
return `${path7.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${options.packageReferences === true}\0${path7.resolve(modulePath)}`;
|
|
2801
|
+
}
|
|
2521
2802
|
function getClientModuleHydrationPlan(modulePath, root, mode = "off", options = {}) {
|
|
2522
2803
|
const plan = planClientModuleHydration(modulePath, root, mode, options);
|
|
2523
2804
|
if (options.serverTreeLayouts !== true || options.asyncOwnerIslands !== true || !plan.shouldHydrate || plan.isClientComponent || plan.asyncOwnerIslands) {
|
|
@@ -3090,7 +3371,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
|
|
|
3090
3371
|
let fallbackReason;
|
|
3091
3372
|
let fallbackHint;
|
|
3092
3373
|
let costGuardExceeded = false;
|
|
3093
|
-
const projectRoot = root ?
|
|
3374
|
+
const projectRoot = root ? path7.resolve(root) : void 0;
|
|
3094
3375
|
const visit = (moduleSourcePath) => {
|
|
3095
3376
|
if (fallbackReason) return 0;
|
|
3096
3377
|
const cached = estimates.get(moduleSourcePath);
|
|
@@ -3277,7 +3558,7 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
|
|
|
3277
3558
|
}
|
|
3278
3559
|
function farmWorkspaceServerEntry(entry) {
|
|
3279
3560
|
const real = realpathOrSelf(entry);
|
|
3280
|
-
if (real.split(
|
|
3561
|
+
if (real.split(path7.sep).includes("node_modules")) return null;
|
|
3281
3562
|
if (parseClientModuleMetadata(readIfExists(real), false).isClientComponent) return null;
|
|
3282
3563
|
return real;
|
|
3283
3564
|
}
|
|
@@ -3441,7 +3722,7 @@ function isTypeOnlyNamedClause(tokens, startIndex, endIndex) {
|
|
|
3441
3722
|
function resolveImportedModule(importerPath, specifier, root) {
|
|
3442
3723
|
const resolved = memoizeInFarmSourceSnapshot(
|
|
3443
3724
|
"resolution",
|
|
3444
|
-
`${root
|
|
3725
|
+
`${root ? farmSourceSnapshotPathKey(root) : ""}\0${farmSourceSnapshotPathKey(importerPath)}\0${specifier}`,
|
|
3445
3726
|
() => resolveImportedModuleUncached(importerPath, specifier, root),
|
|
3446
3727
|
// A file added later may resolve an import that does not resolve now.
|
|
3447
3728
|
(result) => result.path !== null
|
|
@@ -3470,7 +3751,7 @@ var ALIAS_IMPORT = /^(?:@\/|~\/|#)/;
|
|
|
3470
3751
|
function warnUnresolvedAliasImport(importerPath, specifier, root) {
|
|
3471
3752
|
if (!ALIAS_IMPORT.test(specifier) || warnedUnresolvedAliasImports.has(specifier)) return;
|
|
3472
3753
|
warnedUnresolvedAliasImports.add(specifier);
|
|
3473
|
-
const importer = root ?
|
|
3754
|
+
const importer = root ? path7.relative(root, importerPath) : importerPath;
|
|
3474
3755
|
logger.warn(
|
|
3475
3756
|
`Could not resolve "${specifier}" (imported by ${importer}) while checking which pages need client JavaScript. If it holds client components, they will not hydrate. Map the alias in tsconfig.json "paths" or package.json "imports".`
|
|
3476
3757
|
);
|
|
@@ -3479,7 +3760,7 @@ var projectImportAliasCache = /* @__PURE__ */ new Map();
|
|
|
3479
3760
|
var PROJECT_ALIAS_FILES = ["tsconfig.json", "jsconfig.json", "package.json"];
|
|
3480
3761
|
function resolveProjectAliasSourcePath(specifier, root) {
|
|
3481
3762
|
if (!root) return void 0;
|
|
3482
|
-
const projectRoot =
|
|
3763
|
+
const projectRoot = path7.resolve(root);
|
|
3483
3764
|
let match;
|
|
3484
3765
|
for (const alias of getProjectImportAliases(projectRoot)) {
|
|
3485
3766
|
const captured = matchProjectImportAlias(alias, specifier);
|
|
@@ -3489,7 +3770,7 @@ function resolveProjectAliasSourcePath(specifier, root) {
|
|
|
3489
3770
|
if (!match) return void 0;
|
|
3490
3771
|
const resolved = resolveSourceCandidate(
|
|
3491
3772
|
match.alias.targets.map(
|
|
3492
|
-
(target) =>
|
|
3773
|
+
(target) => path7.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
|
|
3493
3774
|
)
|
|
3494
3775
|
);
|
|
3495
3776
|
return resolved && /\.d\.[cm]?ts$/.test(resolved) ? null : resolved;
|
|
@@ -3504,7 +3785,7 @@ function matchProjectImportAlias(alias, specifier) {
|
|
|
3504
3785
|
function getProjectImportAliases(projectRoot) {
|
|
3505
3786
|
const stamp = PROJECT_ALIAS_FILES.map((file) => {
|
|
3506
3787
|
try {
|
|
3507
|
-
return String(fs6.statSync(
|
|
3788
|
+
return String(fs6.statSync(path7.join(projectRoot, file)).mtimeMs);
|
|
3508
3789
|
} catch {
|
|
3509
3790
|
return "-";
|
|
3510
3791
|
}
|
|
@@ -3522,7 +3803,7 @@ function getProjectImportAliases(projectRoot) {
|
|
|
3522
3803
|
prefix: "@/",
|
|
3523
3804
|
suffix: "",
|
|
3524
3805
|
wildcard: true,
|
|
3525
|
-
targets: [
|
|
3806
|
+
targets: [path7.join(projectRoot, sourceDir, "*")]
|
|
3526
3807
|
});
|
|
3527
3808
|
}
|
|
3528
3809
|
projectImportAliasCache.set(projectRoot, { stamp: cacheStamp, aliases });
|
|
@@ -3530,11 +3811,11 @@ function getProjectImportAliases(projectRoot) {
|
|
|
3530
3811
|
}
|
|
3531
3812
|
function readTsconfigPathAliases(projectRoot) {
|
|
3532
3813
|
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
3533
|
-
const configPath =
|
|
3814
|
+
const configPath = path7.join(projectRoot, name);
|
|
3534
3815
|
if (!fs6.existsSync(configPath)) continue;
|
|
3535
3816
|
const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
|
|
3536
3817
|
if (!resolved?.paths) return [];
|
|
3537
|
-
const
|
|
3818
|
+
const base2 = resolved.baseUrl ?? resolved.pathsDirectory;
|
|
3538
3819
|
return Object.entries(resolved.paths).flatMap(([pattern, targets]) => {
|
|
3539
3820
|
if (!Array.isArray(targets)) return [];
|
|
3540
3821
|
const wildcardIndex = pattern.indexOf("*");
|
|
@@ -3543,7 +3824,7 @@ function readTsconfigPathAliases(projectRoot) {
|
|
|
3543
3824
|
prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
|
|
3544
3825
|
suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
|
|
3545
3826
|
wildcard: wildcardIndex !== -1,
|
|
3546
|
-
targets: targets.filter((target) => typeof target === "string").map((target) =>
|
|
3827
|
+
targets: targets.filter((target) => typeof target === "string").map((target) => path7.resolve(base2, target))
|
|
3547
3828
|
}
|
|
3548
3829
|
];
|
|
3549
3830
|
});
|
|
@@ -3555,27 +3836,27 @@ function readTsconfigPaths(configPath, visited) {
|
|
|
3555
3836
|
visited.add(configPath);
|
|
3556
3837
|
const config = readJsonWithComments(configPath);
|
|
3557
3838
|
if (!config) return null;
|
|
3558
|
-
const directory =
|
|
3839
|
+
const directory = path7.dirname(configPath);
|
|
3559
3840
|
const parents = (Array.isArray(config.extends) ? config.extends : [config.extends]).filter(
|
|
3560
3841
|
(parent) => typeof parent === "string" && parent.startsWith(".")
|
|
3561
3842
|
);
|
|
3562
3843
|
let inherited = null;
|
|
3563
3844
|
for (const parent of parents) {
|
|
3564
|
-
const parentPath =
|
|
3845
|
+
const parentPath = path7.resolve(
|
|
3565
3846
|
directory,
|
|
3566
3847
|
parent.endsWith(".json") ? parent : `${parent}.json`
|
|
3567
3848
|
);
|
|
3568
3849
|
inherited = readTsconfigPaths(parentPath, visited) ?? inherited;
|
|
3569
3850
|
}
|
|
3570
3851
|
const options = config.compilerOptions ?? {};
|
|
3571
|
-
const baseUrl = typeof options.baseUrl === "string" ?
|
|
3852
|
+
const baseUrl = typeof options.baseUrl === "string" ? path7.resolve(directory, options.baseUrl) : inherited?.baseUrl;
|
|
3572
3853
|
if (options.paths && typeof options.paths === "object") {
|
|
3573
3854
|
return { paths: options.paths, pathsDirectory: directory, baseUrl };
|
|
3574
3855
|
}
|
|
3575
3856
|
return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
|
|
3576
3857
|
}
|
|
3577
3858
|
function readPackageImportAliases(projectRoot) {
|
|
3578
|
-
const imports = readPackageJson(
|
|
3859
|
+
const imports = readPackageJson(path7.join(projectRoot, "package.json"))?.imports;
|
|
3579
3860
|
if (!imports || typeof imports !== "object") return [];
|
|
3580
3861
|
return Object.entries(imports).flatMap(([pattern, value]) => {
|
|
3581
3862
|
const target = resolveConditionalExportTarget(value);
|
|
@@ -3586,7 +3867,7 @@ function readPackageImportAliases(projectRoot) {
|
|
|
3586
3867
|
prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
|
|
3587
3868
|
suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
|
|
3588
3869
|
wildcard: wildcardIndex !== -1,
|
|
3589
|
-
targets: [
|
|
3870
|
+
targets: [path7.resolve(projectRoot, target)]
|
|
3590
3871
|
}
|
|
3591
3872
|
];
|
|
3592
3873
|
});
|
|
@@ -3632,7 +3913,7 @@ function resolveImportedModuleSourcePath(importerPath, specifier, root) {
|
|
|
3632
3913
|
return resolvePackageModuleSourcePath(importerPath, specifier, root);
|
|
3633
3914
|
}
|
|
3634
3915
|
const candidates = /* @__PURE__ */ new Set();
|
|
3635
|
-
const basePath = specifier.startsWith(".") ?
|
|
3916
|
+
const basePath = specifier.startsWith(".") ? path7.resolve(path7.dirname(importerPath), specifier) : root ? path7.resolve(root, specifier.replace(/^\/+/, "")) : path7.resolve(specifier);
|
|
3636
3917
|
candidates.add(basePath);
|
|
3637
3918
|
return resolveSourceCandidate(candidates);
|
|
3638
3919
|
}
|
|
@@ -3642,45 +3923,45 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
|
|
|
3642
3923
|
const packageSubpath = packageParts.slice(packageName.startsWith("@") ? 2 : 1).join("/");
|
|
3643
3924
|
const packageDirectory = findPackageDirectory2(importerPath, packageName, root);
|
|
3644
3925
|
if (!packageDirectory) return null;
|
|
3645
|
-
const packageJsonPath =
|
|
3926
|
+
const packageJsonPath = path7.join(packageDirectory, "package.json");
|
|
3646
3927
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3647
3928
|
const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
|
|
3648
3929
|
const exportTarget = resolvePackageExport(packageJson?.exports, exportKey);
|
|
3649
3930
|
const candidates = /* @__PURE__ */ new Set();
|
|
3650
3931
|
if (exportTarget?.startsWith("./")) {
|
|
3651
|
-
candidates.add(
|
|
3932
|
+
candidates.add(path7.resolve(packageDirectory, exportTarget));
|
|
3652
3933
|
}
|
|
3653
3934
|
if (packageSubpath) {
|
|
3654
|
-
candidates.add(
|
|
3935
|
+
candidates.add(path7.join(packageDirectory, packageSubpath));
|
|
3655
3936
|
} else {
|
|
3656
3937
|
for (const entry of [packageJson?.browser, packageJson?.module, packageJson?.main]) {
|
|
3657
|
-
if (typeof entry === "string") candidates.add(
|
|
3938
|
+
if (typeof entry === "string") candidates.add(path7.resolve(packageDirectory, entry));
|
|
3658
3939
|
}
|
|
3659
|
-
candidates.add(
|
|
3940
|
+
candidates.add(path7.join(packageDirectory, "index"));
|
|
3660
3941
|
}
|
|
3661
3942
|
return resolveSourceCandidate(candidates);
|
|
3662
3943
|
}
|
|
3663
3944
|
function findPackageDirectory2(importerPath, packageName, root) {
|
|
3664
3945
|
const searchRoots = /* @__PURE__ */ new Set();
|
|
3665
|
-
let current =
|
|
3946
|
+
let current = path7.dirname(importerPath);
|
|
3666
3947
|
while (true) {
|
|
3667
3948
|
searchRoots.add(current);
|
|
3668
|
-
const parent =
|
|
3949
|
+
const parent = path7.dirname(current);
|
|
3669
3950
|
if (parent === current) break;
|
|
3670
3951
|
current = parent;
|
|
3671
3952
|
}
|
|
3672
3953
|
if (root) {
|
|
3673
|
-
current =
|
|
3954
|
+
current = path7.resolve(root);
|
|
3674
3955
|
while (true) {
|
|
3675
3956
|
searchRoots.add(current);
|
|
3676
|
-
const parent =
|
|
3957
|
+
const parent = path7.dirname(current);
|
|
3677
3958
|
if (parent === current) break;
|
|
3678
3959
|
current = parent;
|
|
3679
3960
|
}
|
|
3680
3961
|
}
|
|
3681
3962
|
for (const searchRoot of searchRoots) {
|
|
3682
|
-
const packageDirectory =
|
|
3683
|
-
if (fs6.existsSync(
|
|
3963
|
+
const packageDirectory = path7.join(searchRoot, "node_modules", packageName);
|
|
3964
|
+
if (fs6.existsSync(path7.join(packageDirectory, "package.json"))) {
|
|
3684
3965
|
return packageDirectory;
|
|
3685
3966
|
}
|
|
3686
3967
|
}
|
|
@@ -3744,15 +4025,25 @@ function resolveConditionalExportTarget(value) {
|
|
|
3744
4025
|
}
|
|
3745
4026
|
function resolveSourceCandidate(candidates) {
|
|
3746
4027
|
for (const candidate of candidates) {
|
|
3747
|
-
const
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
4028
|
+
const resolved = memoizeInFarmSourceSnapshot(
|
|
4029
|
+
"source-candidate",
|
|
4030
|
+
farmSourceSnapshotPathKey(candidate),
|
|
4031
|
+
() => resolveSourceCandidatePath(candidate),
|
|
4032
|
+
(result) => result !== null
|
|
4033
|
+
);
|
|
4034
|
+
if (resolved) return resolved;
|
|
4035
|
+
}
|
|
4036
|
+
return null;
|
|
4037
|
+
}
|
|
4038
|
+
function resolveSourceCandidatePath(candidate) {
|
|
4039
|
+
const paths = [candidate];
|
|
4040
|
+
for (const extension of RESOLVABLE_SOURCE_EXTENSIONS) {
|
|
4041
|
+
paths.push(`${candidate}${extension}`, path7.join(candidate, `index${extension}`));
|
|
4042
|
+
}
|
|
4043
|
+
for (const sourcePath of paths) {
|
|
4044
|
+
try {
|
|
4045
|
+
if (fs6.statSync(sourcePath, { throwIfNoEntry: false })?.isFile()) return sourcePath;
|
|
4046
|
+
} catch {
|
|
3756
4047
|
}
|
|
3757
4048
|
}
|
|
3758
4049
|
return null;
|
|
@@ -3799,7 +4090,7 @@ function scanFarmPackageImports(directory, root) {
|
|
|
3799
4090
|
}
|
|
3800
4091
|
for (const entry of entries) {
|
|
3801
4092
|
if (entry.name.startsWith(".") && entry.isDirectory()) continue;
|
|
3802
|
-
const file =
|
|
4093
|
+
const file = path7.join(current, entry.name);
|
|
3803
4094
|
if (entry.isDirectory()) {
|
|
3804
4095
|
if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
|
|
3805
4096
|
continue;
|
|
@@ -3832,7 +4123,7 @@ function collectFarmServerBundledPackageInfo(directory) {
|
|
|
3832
4123
|
}
|
|
3833
4124
|
for (const entry of entries) {
|
|
3834
4125
|
if (entry.name.startsWith(".") && entry.isDirectory()) continue;
|
|
3835
|
-
const file =
|
|
4126
|
+
const file = path7.join(current, entry.name);
|
|
3836
4127
|
if (entry.isDirectory()) {
|
|
3837
4128
|
if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
|
|
3838
4129
|
continue;
|
|
@@ -3857,7 +4148,7 @@ function invalidateFarmClientReachableModules() {
|
|
|
3857
4148
|
clientReachableModules.clear();
|
|
3858
4149
|
}
|
|
3859
4150
|
function getFarmClientReachableModules(directory, root) {
|
|
3860
|
-
const key = `${
|
|
4151
|
+
const key = `${path7.resolve(root)}\0${path7.resolve(directory)}`;
|
|
3861
4152
|
const cached = clientReachableModules.get(key);
|
|
3862
4153
|
if (cached) return cached;
|
|
3863
4154
|
const reachable = /* @__PURE__ */ new Set();
|
|
@@ -3870,7 +4161,7 @@ function getFarmClientReachableModules(directory, root) {
|
|
|
3870
4161
|
return;
|
|
3871
4162
|
}
|
|
3872
4163
|
for (const entry of entries) {
|
|
3873
|
-
const file =
|
|
4164
|
+
const file = path7.join(current, entry.name);
|
|
3874
4165
|
if (entry.isDirectory()) {
|
|
3875
4166
|
if (!entry.name.startsWith(".") && !CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
|
|
3876
4167
|
} else if (isScannedSourceFile(entry.name)) {
|
|
@@ -3881,12 +4172,12 @@ function getFarmClientReachableModules(directory, root) {
|
|
|
3881
4172
|
};
|
|
3882
4173
|
walk2(directory);
|
|
3883
4174
|
while (queue.length > 0) {
|
|
3884
|
-
const file =
|
|
4175
|
+
const file = path7.resolve(queue.pop());
|
|
3885
4176
|
if (reachable.has(file)) continue;
|
|
3886
4177
|
reachable.add(file);
|
|
3887
4178
|
for (const specifier of getImportSpecifiers(readIfExists(file), { dynamic: true })) {
|
|
3888
4179
|
const imported = resolveImportedModule(file, specifier, root);
|
|
3889
|
-
if (imported.local && imported.path && !reachable.has(
|
|
4180
|
+
if (imported.local && imported.path && !reachable.has(path7.resolve(imported.path))) {
|
|
3890
4181
|
queue.push(imported.path);
|
|
3891
4182
|
}
|
|
3892
4183
|
}
|
|
@@ -3895,7 +4186,7 @@ function getFarmClientReachableModules(directory, root) {
|
|
|
3895
4186
|
return reachable;
|
|
3896
4187
|
}
|
|
3897
4188
|
function resolveFarmClientOptimizeDeps(directory, root) {
|
|
3898
|
-
const importer =
|
|
4189
|
+
const importer = path7.join(path7.resolve(root), "package.json");
|
|
3899
4190
|
const include = /* @__PURE__ */ new Set();
|
|
3900
4191
|
const exclude = /* @__PURE__ */ new Set();
|
|
3901
4192
|
const imports = scanFarmPackageImports(directory, root);
|
|
@@ -3981,7 +4272,15 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
3981
4272
|
}
|
|
3982
4273
|
return sources.files;
|
|
3983
4274
|
};
|
|
3984
|
-
const
|
|
4275
|
+
const relativeFile = (file) => path8.isAbsolute(file) ? path8.relative(projectRoot, file).replace(/\\/g, "/") || file : file;
|
|
4276
|
+
const routeSourceError = (file, importers = []) => formatFarmDiagnostic(
|
|
4277
|
+
createFarmDiagnostic(
|
|
4278
|
+
"CLIENT_ROUTES_FILE",
|
|
4279
|
+
file,
|
|
4280
|
+
"This module defines programmatic routes, but the browser bundle imports it" + (importers.length > 0 ? ` (from ${importers.map(relativeFile).join(", ")})` : "") + ". Routes files and the modules that define routes carry server-only guards, data hooks, and API handlers, so they never reach the browser."
|
|
4281
|
+
),
|
|
4282
|
+
projectRoot
|
|
4283
|
+
);
|
|
3985
4284
|
return {
|
|
3986
4285
|
name: "farm:environment-functions",
|
|
3987
4286
|
enforce: "post",
|
|
@@ -3993,7 +4292,7 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
3993
4292
|
routesFiles = new Set(
|
|
3994
4293
|
getFarmSourceRoots({ ...options, root: options.root ?? config.root }).flatMap(
|
|
3995
4294
|
(source) => PROGRAMMATIC_ROUTE_FILE_NAMES.map(
|
|
3996
|
-
(name) => resolvedFile(
|
|
4295
|
+
(name) => resolvedFile(path8.resolve(source.root, source.srcDir, name))
|
|
3997
4296
|
)
|
|
3998
4297
|
)
|
|
3999
4298
|
);
|
|
@@ -4011,12 +4310,25 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
4011
4310
|
if (environment === "server" && resolveFarmServerComponentsMode(options.experimental?.serverComponents) === "islands" && isApplicationScript(id)) {
|
|
4012
4311
|
const file = id.split("?", 1)[0];
|
|
4013
4312
|
const root = realpathSync(options.root ?? projectRoot);
|
|
4014
|
-
const clientCode = getFarmClientReachableModules(root, root).has(
|
|
4313
|
+
const clientCode = getFarmClientReachableModules(root, root).has(path8.resolve(file)) || existsSync(file) && hasUseClientDirective(readFileSync(file, "utf8"));
|
|
4015
4314
|
const reached = clientCode ? null : findFarmClientOnlyImport(code, file);
|
|
4016
4315
|
if (reached) {
|
|
4017
|
-
const chain = reached.chain.map((step) =>
|
|
4316
|
+
const chain = reached.chain.map((step) => path8.relative(root, step).replace(/\\/g, "/")).join(" -> ");
|
|
4317
|
+
const importMatch = new RegExp(
|
|
4318
|
+
String.raw`\b(?:from|import)\s*["']` + reached.specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + `["']`
|
|
4319
|
+
).exec(code);
|
|
4320
|
+
const importAt = importMatch ? importMatch.index + importMatch[0].search(/["']/) : void 0;
|
|
4321
|
+
const locate = createFarmSourceLocator(code, () => this.getCombinedSourcemap());
|
|
4018
4322
|
this.error(
|
|
4019
|
-
|
|
4323
|
+
formatFarmDiagnostic(
|
|
4324
|
+
createFarmDiagnostic(
|
|
4325
|
+
"SERVER_CLIENT_ONLY_IMPORT",
|
|
4326
|
+
file,
|
|
4327
|
+
`This module is server code, but its import of "${reached.specifier}" reaches "client-only" (${chain}), so that package can only run in the browser.`,
|
|
4328
|
+
importAt === void 0 ? void 0 : locate(importAt)
|
|
4329
|
+
),
|
|
4330
|
+
root
|
|
4331
|
+
)
|
|
4020
4332
|
);
|
|
4021
4333
|
}
|
|
4022
4334
|
}
|
|
@@ -4033,7 +4345,14 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
4033
4345
|
});
|
|
4034
4346
|
if (chain) {
|
|
4035
4347
|
this.error(
|
|
4036
|
-
|
|
4348
|
+
formatFarmDiagnostic(
|
|
4349
|
+
createFarmDiagnostic(
|
|
4350
|
+
"CLIENT_ROUTE_SERVER_IMPORT",
|
|
4351
|
+
moduleFile(id),
|
|
4352
|
+
`The browser bundle reaches the server-only module "${chain.at(-1)}" through this programmatic route module: ${chain.map((step) => relativeFile(moduleFile(step))).join(" -> ")}.`
|
|
4353
|
+
),
|
|
4354
|
+
projectRoot
|
|
4355
|
+
)
|
|
4037
4356
|
);
|
|
4038
4357
|
}
|
|
4039
4358
|
continue;
|
|
@@ -4326,13 +4645,19 @@ export {
|
|
|
4326
4645
|
createEvaluatedRouteGraph,
|
|
4327
4646
|
mergeProgrammaticClientRoutes,
|
|
4328
4647
|
generateProgrammaticClientRouteModule,
|
|
4648
|
+
getFarmSourceStamp,
|
|
4329
4649
|
FarmSourceSnapshotStore,
|
|
4330
4650
|
withFarmSourceSnapshot,
|
|
4651
|
+
withFarmSourceSnapshotOf,
|
|
4652
|
+
memoizeInFarmSourceSnapshot,
|
|
4653
|
+
noteFarmSourceRead,
|
|
4331
4654
|
traceFarmSourceReads,
|
|
4332
4655
|
rewriteFarmReactServerClientModuleImports,
|
|
4333
4656
|
rewriteFarmReactServerImports,
|
|
4334
4657
|
invalidateFarmClientOnlyScan,
|
|
4335
4658
|
farmRelativeImportFiles,
|
|
4659
|
+
usePackageScanCacheFile,
|
|
4660
|
+
persistPackageScanCache,
|
|
4336
4661
|
FARM_CLIENT_REFERENCE_PRAGMA,
|
|
4337
4662
|
FARM_CLIENT_REFERENCE_DIRECTORY,
|
|
4338
4663
|
FARM_RESOLVE_FROM_PREFIX,
|
|
@@ -4360,6 +4685,7 @@ export {
|
|
|
4360
4685
|
collectFarmRenderedClientModules,
|
|
4361
4686
|
collectFarmServerStylesheets,
|
|
4362
4687
|
getClientModuleMetadata,
|
|
4688
|
+
getClientModuleHydrationPlanKey,
|
|
4363
4689
|
getClientModuleHydrationPlan,
|
|
4364
4690
|
usesFarmServerTree,
|
|
4365
4691
|
createMarkdownPageHydrationPlanner,
|
|
@@ -4373,6 +4699,9 @@ export {
|
|
|
4373
4699
|
invalidateFarmClientReachableModules,
|
|
4374
4700
|
getFarmClientReachableModules,
|
|
4375
4701
|
resolveFarmClientOptimizeDeps,
|
|
4702
|
+
createFarmDiagnostic,
|
|
4703
|
+
formatFarmDiagnostic,
|
|
4704
|
+
createFarmSourceLocator,
|
|
4376
4705
|
transformEnvironmentFunctions,
|
|
4377
4706
|
farmEnvironmentFunctionsPlugin
|
|
4378
4707
|
};
|