@farm.js/core 0.1.72 → 0.1.74
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-VIT4GOSR.mjs → agent-mcp-handler-HX4F4VKN.mjs} +4 -4
- package/dist/{agent-mcp-handler-KE4J3W7S.cjs → agent-mcp-handler-NRIL4JBC.cjs} +5 -5
- package/dist/{agent-mcp.d-Cwff7lcA.d.mts → agent-mcp.d-BEhDfdWc.d.mts} +1 -1
- package/dist/{agent-mcp.d-BO3rZXEM.d.ts → agent-mcp.d-CX8_oOT_.d.ts} +1 -1
- package/dist/agent-runtime.cjs +4 -4
- package/dist/agent-runtime.d.mts +5 -5
- package/dist/agent-runtime.d.ts +5 -5
- package/dist/agent-runtime.mjs +3 -3
- package/dist/{analyzer-5Q75LTIL.mjs → analyzer-2K35LIQZ.mjs} +2 -2
- package/dist/analyzer-6EOYURMV.cjs +16 -0
- package/dist/api/client.d.mts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.native.d.mts +4 -4
- package/dist/api/client.native.d.ts +4 -4
- package/dist/api/node.cjs +9 -8
- package/dist/api/node.d.mts +7 -7
- package/dist/api/node.d.ts +7 -7
- package/dist/api/node.mjs +8 -7
- package/dist/api/route-manager.cjs +11 -9
- package/dist/api/route-manager.d.mts +10 -8
- package/dist/api/route-manager.d.ts +10 -8
- package/dist/api/route-manager.mjs +10 -8
- package/dist/api/runtime.cjs +8 -7
- package/dist/api/runtime.d.mts +6 -6
- package/dist/api/runtime.d.ts +6 -6
- package/dist/api/runtime.mjs +7 -6
- 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 +13 -11
- package/dist/api.d.mts +10 -10
- package/dist/api.d.ts +10 -10
- package/dist/api.mjs +12 -10
- package/dist/{app-manifest.d-USD_IbFd.d.mts → app-manifest.d-BcXt2yCx.d.mts} +10 -1
- package/dist/{app-manifest.d-DwjGkYlP.d.ts → app-manifest.d-CVEx1CFB.d.ts} +10 -1
- package/dist/app-markdown.cjs +8 -4
- package/dist/app-markdown.d.mts +7 -7
- package/dist/app-markdown.d.ts +7 -7
- package/dist/app-markdown.mjs +7 -3
- package/dist/{app.d-DAmF2MAk.d.ts → app.d-B6i8CSrx.d.ts} +36 -4
- package/dist/{app.d-fW06_h8h.d.mts → app.d-DowzSmT5.d.mts} +36 -4
- package/dist/cache.cjs +2 -2
- package/dist/cache.d.mts +8 -0
- package/dist/cache.d.ts +8 -0
- package/dist/cache.mjs +1 -1
- package/dist/chunk-2DOI6HLJ.cjs +284 -0
- package/dist/chunk-2GQBBOFH.mjs +76 -0
- package/dist/{chunk-5LOARKDP.cjs → chunk-2TZ3F6TN.cjs} +29 -17
- package/dist/{chunk-IWCYRDRQ.cjs → chunk-35GBGSQZ.cjs} +3 -3
- package/dist/{chunk-GF22VGMS.cjs → chunk-3BUJIPKE.cjs} +2 -2
- package/dist/{chunk-Y5LEPEVH.mjs → chunk-3ODLJRA6.mjs} +1 -1
- package/dist/{chunk-DMAP4RND.cjs → chunk-3OMLZLDE.cjs} +54 -16
- package/dist/{chunk-VNBDN5W2.cjs → chunk-47ZDUDN5.cjs} +64 -27
- package/dist/{chunk-2W4GNXGX.cjs → chunk-4AB62NMW.cjs} +2 -2
- package/dist/{chunk-HDPT6OYE.cjs → chunk-4M5ESTJ2.cjs} +10 -2
- package/dist/{chunk-CBLRSZQL.cjs → chunk-56HHUSR5.cjs} +502 -430
- package/dist/chunk-5XD2ULJG.mjs +114 -0
- package/dist/{chunk-JX5VOLAV.cjs → chunk-65OS2TOT.cjs} +4 -4
- package/dist/{chunk-WIJF3PBM.mjs → chunk-6JEXH7N6.mjs} +1 -1
- package/dist/{chunk-TY5KCYDE.mjs → chunk-72NTEYCX.mjs} +10 -3
- package/dist/{chunk-5R4Q5FN7.cjs → chunk-737MIVX3.cjs} +52 -41
- package/dist/{chunk-5X6OHJEE.cjs → chunk-77SVUQM5.cjs} +74 -20
- package/dist/{chunk-CKQAQFF6.mjs → chunk-7RKHXF4P.mjs} +2 -2
- package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
- package/dist/{chunk-E3LE6EZH.cjs → chunk-ACAEFEOH.cjs} +38 -41
- package/dist/{chunk-REP6HWJN.mjs → chunk-AL6E63FZ.mjs} +2 -2
- package/dist/{chunk-DQ2DI3Y7.mjs → chunk-AO5IRA2N.mjs} +2 -2
- package/dist/{chunk-VAWDGGW3.mjs → chunk-AU5UPNOD.mjs} +26 -15
- package/dist/{chunk-DS7JGFW5.mjs → chunk-B3XY6FMC.mjs} +71 -17
- package/dist/{chunk-U7VH3Q5E.cjs → chunk-B5WZP3T3.cjs} +15 -2
- package/dist/{chunk-3JN5M3T5.mjs → chunk-BFOMCSZ2.mjs} +476 -138
- package/dist/{chunk-I4KPA2C6.mjs → chunk-BIX46FTI.mjs} +1 -1
- package/dist/{chunk-YZLEOMMA.mjs → chunk-BNXV3PRM.mjs} +4 -4
- package/dist/{chunk-3GNVIYPO.cjs → chunk-BSJMWCWM.cjs} +7 -7
- package/dist/{chunk-WVQNXXNE.cjs → chunk-BWFBTTJ5.cjs} +2 -2
- package/dist/{chunk-FEFCISOX.cjs → chunk-CEVXKJKF.cjs} +2 -2
- package/dist/{chunk-DGNMXL2O.mjs → chunk-CF77L6RL.mjs} +33 -36
- package/dist/{chunk-OB45EAQL.mjs → chunk-CXQZQK6R.mjs} +3 -2
- package/dist/{chunk-255J7K4X.mjs → chunk-D2IAYGYA.mjs} +1 -1
- package/dist/{chunk-OSEQL34Q.cjs → chunk-D4TYE6MY.cjs} +2 -2
- package/dist/{chunk-FSSONJRV.cjs → chunk-DM2YGTRH.cjs} +24 -17
- package/dist/{chunk-ICFPTHXM.mjs → chunk-DRBXYJZ6.mjs} +7 -3
- package/dist/{chunk-E3HDJCWF.mjs → chunk-DRHHTHA3.mjs} +1 -1
- package/dist/{chunk-YXIQYWOK.cjs → chunk-DTBRSRTR.cjs} +23 -5
- package/dist/{chunk-JZQS3ZOI.mjs → chunk-E4T7WJJN.mjs} +10 -2
- package/dist/{chunk-YAEN3L2F.cjs → chunk-EF5AP4CV.cjs} +21 -2
- package/dist/{chunk-SPP3EZTJ.cjs → chunk-EHJOSIXM.cjs} +137 -67
- package/dist/{chunk-JZBU7V4D.mjs → chunk-ELJQWUAR.mjs} +125 -55
- package/dist/{chunk-DMXMIE2C.cjs → chunk-ENYBDM4U.cjs} +2 -2
- package/dist/{chunk-ZFEJ2SF2.cjs → chunk-EWIEJQP6.cjs} +28 -28
- package/dist/{chunk-ZUVAGMQ5.cjs → chunk-F244KE2D.cjs} +7 -7
- package/dist/{chunk-WW3LRNQV.mjs → chunk-FCBUNILW.mjs} +1 -1
- package/dist/{chunk-645ENY7W.mjs → chunk-FEQ72ZHD.mjs} +16 -9
- package/dist/{chunk-ME7RVELR.mjs → chunk-FGXSWRWA.mjs} +20 -1
- package/dist/{chunk-2AFW7673.cjs → chunk-FNWL5DMG.cjs} +4 -3
- package/dist/{chunk-HLMUWKAP.cjs → chunk-FYV6DTAG.cjs} +826 -531
- package/dist/{chunk-7PPLTD3P.cjs → chunk-G7S6XG6X.cjs} +6 -6
- package/dist/{chunk-AQIO3RNL.mjs → chunk-GK2GBIXD.mjs} +3 -3
- package/dist/{chunk-IHTDLCDJ.cjs → chunk-GRHSQYD4.cjs} +17 -4
- package/dist/{chunk-W44X6IC2.cjs → chunk-HBLYSWIJ.cjs} +13 -9
- package/dist/chunk-HK4VJI27.cjs +76 -0
- package/dist/{chunk-EGIY4A7V.cjs → chunk-HKZVC5GP.cjs} +2 -2
- package/dist/{chunk-EYPSKXO4.mjs → chunk-HRQV5Q3J.mjs} +1 -1
- package/dist/{chunk-S7MWSFFP.cjs → chunk-IBEHVSU4.cjs} +2 -2
- package/dist/{chunk-77VNYVVX.mjs → chunk-IG4IQMIW.mjs} +1 -1
- package/dist/{chunk-N3XO5AL5.cjs → chunk-IJFNXP3D.cjs} +2 -2
- package/dist/{chunk-RFWWXEIF.mjs → chunk-IP2R2TAE.mjs} +1 -1
- package/dist/{chunk-FETMUBIA.mjs → chunk-IZ5WOTQP.mjs} +1 -1
- package/dist/{chunk-CSLHNBPS.cjs → chunk-J42QN7OC.cjs} +6 -6
- package/dist/{chunk-NDDRTFN4.mjs → chunk-J7EUGGTY.mjs} +2 -2
- package/dist/{chunk-5XFKWHZD.mjs → chunk-JI6N4W2I.mjs} +208 -136
- package/dist/{chunk-GJ7QVFAG.mjs → chunk-JOECBGY7.mjs} +1 -1
- package/dist/{chunk-CL52PD6D.cjs → chunk-JSUVQ5HG.cjs} +8 -8
- package/dist/{chunk-DZHTNSQ5.cjs → chunk-JWHRVBCZ.cjs} +14 -14
- package/dist/{chunk-OSMUE5ST.mjs → chunk-JZ43UD6S.mjs} +7 -7
- package/dist/{chunk-RLEALQEN.mjs → chunk-KIRIFO6T.mjs} +43 -5
- package/dist/{chunk-XGTFLG73.cjs → chunk-KMYOKQPP.cjs} +18 -11
- package/dist/{chunk-WX63N6C5.mjs → chunk-KNEYWPZV.mjs} +64 -27
- package/dist/{chunk-AYVGD3PK.mjs → chunk-KUMKBBYP.mjs} +1 -1
- package/dist/{chunk-VT25ERQK.mjs → chunk-KWUZJZ23.mjs} +21 -3
- package/dist/{chunk-NV26EGMC.mjs → chunk-LHFGTR7F.mjs} +2 -2
- package/dist/{chunk-4P5634G6.cjs → chunk-LIQJYEQP.cjs} +14 -9
- package/dist/chunk-LRPPXKCX.mjs +58 -0
- package/dist/chunk-LXTYJ2HW.mjs +139 -0
- package/dist/{chunk-O32QPFVV.cjs → chunk-MKQ27TGW.cjs} +5 -5
- package/dist/{chunk-KQAB5LML.mjs → chunk-MQ5HA7H2.mjs} +2 -2
- package/dist/{chunk-Z3GPAFIA.mjs → chunk-MUITBU5Z.mjs} +1 -1
- package/dist/chunk-NDOE76QC.cjs +58 -0
- package/dist/{chunk-EXN4DTVF.cjs → chunk-NET6PBUH.cjs} +2 -2
- package/dist/{chunk-YBY34UHB.mjs → chunk-NKETXVKP.mjs} +15 -2
- package/dist/chunk-NRWEY2CM.mjs +25 -0
- package/dist/chunk-NU5XLYRN.cjs +139 -0
- package/dist/{chunk-BE7AQXJB.cjs → chunk-NXGQIXR7.cjs} +507 -169
- package/dist/{chunk-C5AM2XDN.cjs → chunk-O2A6HE76.cjs} +4 -4
- package/dist/{chunk-OAEDVXVE.mjs → chunk-O6K4G7YA.mjs} +5 -2
- package/dist/{chunk-LXEJNWF5.mjs → chunk-OSKIG4OP.mjs} +2 -2
- package/dist/{chunk-3WG7GJQL.cjs → chunk-P3EZKU6L.cjs} +18 -18
- package/dist/{chunk-C2JOS77Z.cjs → chunk-PG6ZIHKE.cjs} +250 -51
- package/dist/{chunk-ET6WW3FY.cjs → chunk-Q3MVNRAO.cjs} +1305 -848
- package/dist/{chunk-AZ6IW6SF.mjs → chunk-Q4G52OSW.mjs} +1 -1
- package/dist/{chunk-TPYAYFMF.cjs → chunk-QL3YZTGZ.cjs} +2 -2
- package/dist/{chunk-JMFTKNBA.mjs → chunk-R4BWNP73.mjs} +2 -2
- package/dist/{chunk-J5ASGNKF.mjs → chunk-R6Q6VSGU.mjs} +24 -9
- package/dist/{chunk-B6RBJJ5G.mjs → chunk-RBRIKT6B.mjs} +15 -2
- package/dist/{chunk-C6CUUBY5.cjs → chunk-RHI67C2V.cjs} +5 -5
- package/dist/chunk-RK3YYUX6.cjs +114 -0
- package/dist/{chunk-Y2LU4LE5.mjs → chunk-ROPMQNCG.mjs} +2 -2
- package/dist/{chunk-QIXEU2WV.cjs → chunk-RQ4UZJPR.cjs} +3 -3
- package/dist/{chunk-ZDZUFD67.cjs → chunk-RSL3YFJG.cjs} +1 -1
- package/dist/{chunk-JWY66PID.cjs → chunk-S3D6SL2V.cjs} +9 -6
- package/dist/{chunk-4HGLJOXZ.cjs → chunk-TPDKFRQX.cjs} +11 -11
- package/dist/{chunk-E2V7RRFL.mjs → chunk-UHAARKF3.mjs} +2 -2
- package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
- package/dist/{chunk-7QCJDYZQ.cjs → chunk-V6T3UJAH.cjs} +7 -7
- package/dist/{chunk-AUAMXI6N.mjs → chunk-VFPFXMTF.mjs} +1 -1
- package/dist/{chunk-KPJYBSHL.mjs → chunk-VKLV7GF4.mjs} +221 -22
- package/dist/{chunk-TP4RAV7Y.cjs → chunk-VKRMO3EZ.cjs} +8 -8
- package/dist/chunk-VWIW47FW.cjs +25 -0
- package/dist/{chunk-L6E4SHUB.cjs → chunk-VZKCGHWC.cjs} +39 -24
- package/dist/{chunk-JWLRBDDC.cjs → chunk-WH3PBJS7.cjs} +2 -2
- package/dist/{chunk-BSXKZPFE.mjs → chunk-WS4SLJW5.mjs} +501 -206
- package/dist/{chunk-5OFNUETM.mjs → chunk-WTTJ2YS2.mjs} +9 -1
- package/dist/{chunk-RLFGKJQ6.mjs → chunk-X2KNHD4B.mjs} +14 -2
- package/dist/{chunk-5CFHQ7HM.mjs → chunk-XXKMAHYE.mjs} +1 -1
- package/dist/{chunk-MBCRWU3P.cjs → chunk-XZPI44Q7.cjs} +4 -4
- package/dist/{chunk-ACGBXN3U.cjs → chunk-Y4FEQBKY.cjs} +17 -9
- package/dist/{chunk-MWUDEYBI.mjs → chunk-YH33PZ3K.mjs} +1 -1
- package/dist/chunk-YQWRBBAA.mjs +284 -0
- package/dist/{chunk-QUYAGU65.mjs → chunk-YWDRWG4L.mjs} +1210 -753
- package/dist/{chunk-E46NXBNJ.mjs → chunk-ZD7JUTBY.mjs} +11 -6
- package/dist/{chunk-JDO346NV.mjs → chunk-ZLRWO5GK.mjs} +1 -1
- package/dist/{chunk-NAXKOTPP.cjs → chunk-ZRCGPSUM.cjs} +21 -21
- package/dist/{chunk-YCNHUIPR.cjs → chunk-ZZGANFQH.cjs} +10 -10
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/{client-component.d-9J7CkTWW.d.ts → client-component.d-DYOwmq0c.d.ts} +80 -3
- package/dist/{client-component.d-ciHeCxr-.d.mts → client-component.d-edV76QvU.d.mts} +80 -3
- package/dist/{client-plugins.d-CUOhfapO.d.ts → client-plugins.d-BmJYW2FY.d.ts} +20 -7
- package/dist/{client-plugins.d-JnRz5a1o.d.mts → client-plugins.d-DwvqqGsU.d.mts} +20 -7
- package/dist/client-plugins.d.mts +5 -5
- package/dist/client-plugins.d.ts +5 -5
- package/dist/client.cjs +6 -5
- package/dist/client.d.mts +12 -12
- package/dist/client.d.ts +12 -12
- package/dist/client.mjs +5 -4
- package/dist/config.d.mts +5 -5
- package/dist/config.d.ts +5 -5
- package/dist/cron.cjs +6 -2
- package/dist/cron.d.mts +11 -2
- package/dist/cron.d.ts +11 -2
- package/dist/cron.mjs +7 -3
- package/dist/desktop.d.mts +6 -6
- package/dist/desktop.d.ts +6 -6
- package/dist/{devtools-7JPQMSTQ.mjs → devtools-WPX62NG2.mjs} +10 -9
- package/dist/{devtools-IZFUYWPG.cjs → devtools-YMDS7PUA.cjs} +12 -11
- package/dist/docs.cjs +14 -13
- package/dist/docs.d.mts +6 -6
- package/dist/docs.d.ts +6 -6
- package/dist/docs.mjs +13 -12
- 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 +3 -3
- package/dist/environment/vite.mjs +2 -2
- package/dist/headers.cjs +3 -3
- package/dist/{headers.d-CqpTL_fZ.d.ts → headers.d-BIbQyAxJ.d.ts} +1 -1
- package/dist/{headers.d-rbbTKGaN.d.mts → headers.d-BtNxFc2s.d.mts} +1 -1
- package/dist/headers.mjs +2 -2
- package/dist/index.cjs +73 -60
- package/dist/{index.d-CMKvzHLW.d.ts → index.d-CQ_wUzOV.d.ts} +1 -1
- package/dist/{index.d-D_B2D9Il.d.mts → index.d-CQdDRXd1.d.mts} +1 -1
- package/dist/index.d.mts +63 -29
- package/dist/index.d.ts +63 -29
- package/dist/index.mjs +69 -56
- package/dist/integrations/orm.d.mts +5 -5
- package/dist/integrations/orm.d.ts +5 -5
- package/dist/integrations.cjs +4 -4
- package/dist/integrations.d.mts +5 -5
- package/dist/integrations.d.ts +5 -5
- package/dist/integrations.mjs +3 -3
- package/dist/internal/app-markdown-runtime.cjs +7 -3
- package/dist/internal/app-markdown-runtime.d.mts +18 -7
- package/dist/internal/app-markdown-runtime.d.ts +18 -7
- package/dist/internal/app-markdown-runtime.mjs +6 -2
- package/dist/internal/build-runtime.cjs +42 -40
- package/dist/internal/build-runtime.d.mts +7 -7
- package/dist/internal/build-runtime.d.ts +7 -7
- package/dist/internal/build-runtime.mjs +41 -39
- package/dist/internal/cli-runtime.cjs +21 -20
- package/dist/internal/cli-runtime.mjs +20 -19
- package/dist/internal/client-error-overlay.cjs +6 -6
- package/dist/internal/client-error-overlay.mjs +2 -2
- package/dist/internal/client-runtime.cjs +6 -2
- package/dist/internal/client-runtime.d.mts +22 -10
- package/dist/internal/client-runtime.d.ts +22 -10
- package/dist/internal/client-runtime.mjs +5 -1
- package/dist/internal/compression-runtime.d.mts +5 -5
- package/dist/internal/compression-runtime.d.ts +5 -5
- package/dist/internal/config-runtime.cjs +12 -11
- package/dist/internal/config-runtime.d.mts +7 -7
- package/dist/internal/config-runtime.d.ts +7 -7
- package/dist/internal/config-runtime.mjs +11 -10
- package/dist/internal/form-actions.cjs +5 -4
- package/dist/internal/form-actions.d.mts +2 -2
- package/dist/internal/form-actions.d.ts +2 -2
- package/dist/internal/form-actions.mjs +4 -3
- package/dist/internal/infra-analytics-runtime.cjs +10 -10
- package/dist/internal/infra-analytics-runtime.mjs +8 -8
- package/dist/internal/native-server-fns.cjs +4 -4
- package/dist/internal/native-server-fns.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +32 -22
- package/dist/internal/production-runtime.d.mts +65 -14
- package/dist/internal/production-runtime.d.ts +65 -14
- package/dist/internal/production-runtime.mjs +31 -21
- package/dist/internal/react-cache.cjs +3 -3
- package/dist/internal/react-cache.mjs +1 -1
- package/dist/internal/vercel-edge-middleware.cjs +4 -4
- package/dist/internal/vercel-edge-middleware.mjs +3 -3
- 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-JIA66YJ2.mjs → manager-RHB2P35B.mjs} +4 -1
- package/dist/{manager-JOHU6BQI.cjs → manager-S77ZARTC.cjs} +5 -2
- package/dist/markdown.cjs +2 -2
- package/dist/markdown.d.mts +5 -5
- package/dist/markdown.d.ts +5 -5
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.cjs +6 -6
- package/dist/middleware.d.mts +5 -5
- package/dist/middleware.d.ts +5 -5
- package/dist/middleware.mjs +5 -5
- package/dist/{mount.d-ImEO7q8a.d.mts → mount.d-6bhpBQQB.d.mts} +1 -1
- package/dist/{mount.d-B0XMxDRh.d.ts → mount.d-C-u7rFkM.d.ts} +1 -1
- package/dist/{native-server-fn-handler-EP5AFJYE.mjs → native-server-fn-handler-I66X4E5S.mjs} +6 -5
- package/dist/{native-server-fn-handler-QRTXGZA4.cjs → native-server-fn-handler-W4FSD76W.cjs} +7 -6
- package/dist/{native-tree-L2IIEBXH.mjs → native-tree-3X23BT3N.mjs} +2 -2
- package/dist/{native-tree-GF4BH33L.cjs → native-tree-TAPKR7QJ.cjs} +3 -3
- package/dist/{navigation-delegate.d-83Q7ksf7.d.mts → navigation-delegate.d-nx6gtsY4.d.mts} +1 -1
- package/dist/{navigation-delegate.d-RRx1CSlb.d.ts → navigation-delegate.d-xsG4T1x-.d.ts} +1 -1
- package/dist/navigation.cjs +4 -4
- package/dist/navigation.d.mts +8 -8
- package/dist/navigation.d.ts +8 -8
- package/dist/navigation.mjs +3 -3
- package/dist/{nitro-2LMOMIST.cjs → nitro-SSFTPZMW.cjs} +4 -4
- package/dist/{nitro-72TFIGGO.mjs → nitro-XTQ2HKDL.mjs} +1 -1
- package/dist/{observability.d-B2363jB6.d.ts → observability.d-DdJRiaIX.d.mts} +27 -3
- package/dist/{observability.d-B2363jB6.d.mts → observability.d-DdJRiaIX.d.ts} +27 -3
- package/dist/observability.d.mts +1 -1
- package/dist/observability.d.ts +1 -1
- package/dist/plugin.cjs +36 -33
- package/dist/plugin.d.mts +8 -8
- package/dist/plugin.d.ts +8 -8
- package/dist/plugin.mjs +35 -32
- package/dist/query/client.cjs +5 -5
- package/dist/query/client.mjs +1 -1
- package/dist/{render-plan.d-wP8nTeRV.d.mts → render-plan.d-B5y3h97B.d.mts} +1 -1
- package/dist/{render-plan.d-Ds2sXJ5m.d.ts → render-plan.d-gW0fwKz2.d.ts} +1 -1
- package/dist/renderer-client.cjs +4 -4
- package/dist/renderer-client.d.mts +8 -8
- package/dist/renderer-client.d.ts +8 -8
- package/dist/renderer-client.mjs +1 -1
- package/dist/request.cjs +2 -2
- package/dist/{request.d-zpSn6pu_.d.ts → request.d-B0ugAadD.d.ts} +9 -2
- package/dist/{request.d-F3h7K37m.d.mts → request.d-DLq33nYo.d.mts} +9 -2
- package/dist/request.d.mts +6 -6
- package/dist/request.d.ts +6 -6
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering.d-Mw0ZKG2e.d.mts → route-rendering.d-DSeIV7yV.d.mts} +1 -1
- package/dist/{route-rendering.d-BL0_AdKj.d.ts → route-rendering.d-ytaqDQD6.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.d-BwXigemZ.d.ts → router.d-BaEAEGPg.d.ts} +1 -1
- package/dist/{router.d-NGVsU11T.d.mts → router.d-Chd5cpe3.d.mts} +1 -1
- package/dist/routes.cjs +5 -3
- package/dist/routes.d.mts +5 -5
- package/dist/routes.d.ts +5 -5
- package/dist/routes.mjs +4 -2
- package/dist/{rsc-pipeline-DHYZLWSF.mjs → rsc-pipeline-DPMYONEV.mjs} +12 -11
- package/dist/{rsc-pipeline-BNXYMG4G.cjs → rsc-pipeline-XIUUMMG5.cjs} +13 -12
- package/dist/{runtime-IWOT6ZVC.cjs → runtime-WD77S3C5.cjs} +25 -25
- package/dist/{runtime-XPYKUNL3.mjs → runtime-XIUJZTZ3.mjs} +16 -16
- package/dist/{runtime.d-BA3MzhXz.d.mts → runtime.d-DpCs0eAO.d.mts} +3 -3
- package/dist/{runtime.d-OBIZWpx1.d.ts → runtime.d-h2USyQsz.d.ts} +3 -3
- package/dist/server-action-security.cjs +5 -3
- package/dist/server-action-security.d.mts +11 -3
- package/dist/server-action-security.d.ts +11 -3
- package/dist/server-action-security.mjs +4 -2
- package/dist/server-fn-client.d.mts +3 -3
- package/dist/server-fn-client.d.ts +3 -3
- package/dist/server-fn.cjs +6 -5
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-fn.mjs +5 -4
- package/dist/server-plugins.cjs +4 -4
- package/dist/server-plugins.d.mts +54 -10
- package/dist/server-plugins.d.ts +54 -10
- package/dist/server-plugins.mjs +3 -3
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.cjs +7 -6
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server-query.mjs +6 -5
- package/dist/server.cjs +65 -68
- package/dist/server.d.mts +15 -15
- package/dist/server.d.ts +15 -15
- package/dist/server.mjs +44 -47
- package/dist/{spa-router.d-BG2XzE5p.d.mts → spa-router.d-DCQVtEaE.d.mts} +11 -5
- package/dist/{spa-router.d-DrYT944-.d.ts → spa-router.d-DpdJHs1q.d.ts} +11 -5
- package/dist/testing.cjs +16 -14
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.mjs +12 -10
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-C1k9BJeD.d.mts → utils.d-DKDZtAY5.d.mts} +1 -1
- package/dist/{utils.d-DcF4wxey.d.ts → utils.d-DmicwMvS.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +38 -33
- package/dist/vite.d.mts +24 -10
- package/dist/vite.d.ts +24 -10
- package/dist/vite.mjs +37 -32
- package/package.json +1 -1
- package/dist/analyzer-UJG4MIZW.cjs +0 -16
- package/dist/chunk-6I4BFRE7.cjs +0 -51
- package/dist/chunk-EIVGPQN5.mjs +0 -51
- package/dist/chunk-V3UOEWCB.cjs +0 -46
- package/dist/chunk-VE3FWJBO.mjs +0 -46
- /package/dist/{chunk-QEJWNXRI.cjs → chunk-EMRYJG4U.cjs} +0 -0
- /package/dist/{chunk-TXE4SAMV.mjs → chunk-H2ZJ35NW.mjs} +0 -0
|
@@ -21,23 +21,139 @@ import {
|
|
|
21
21
|
} from "./chunk-JSDV2NUN.mjs";
|
|
22
22
|
import {
|
|
23
23
|
FARM_VERSION
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-IG4IQMIW.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";
|
|
34
145
|
|
|
35
146
|
// src/utils/source-snapshot.ts
|
|
36
147
|
import fs from "fs";
|
|
148
|
+
import path2 from "path";
|
|
37
149
|
var snapshot;
|
|
150
|
+
var base;
|
|
38
151
|
var volatile;
|
|
39
152
|
var trace;
|
|
40
|
-
function
|
|
153
|
+
function farmSourceSnapshotPathKey(file, paths = path2) {
|
|
154
|
+
return paths.resolve(file);
|
|
155
|
+
}
|
|
156
|
+
function getFarmSourceStamp(file) {
|
|
41
157
|
try {
|
|
42
158
|
const stat = fs.statSync(file);
|
|
43
159
|
return `${stat.mtimeMs}:${stat.size}`;
|
|
@@ -46,7 +162,12 @@ function stampOf(file) {
|
|
|
46
162
|
}
|
|
47
163
|
}
|
|
48
164
|
var FarmSourceSnapshotStore = class {
|
|
49
|
-
|
|
165
|
+
/**
|
|
166
|
+
* `tracked: false` keeps entries for a process that edits no sources while it runs, a production
|
|
167
|
+
* build: nothing is stamped, so each plan does not stat every file the snapshot holds.
|
|
168
|
+
*/
|
|
169
|
+
constructor(tracked = true) {
|
|
170
|
+
this.tracked = tracked;
|
|
50
171
|
this.entries = /* @__PURE__ */ new Map();
|
|
51
172
|
this.stamps = /* @__PURE__ */ new Map();
|
|
52
173
|
}
|
|
@@ -59,7 +180,7 @@ var FarmSourceSnapshotStore = class {
|
|
|
59
180
|
const changed = /* @__PURE__ */ new Map();
|
|
60
181
|
for (const file of edited) changed.set(file, void 0);
|
|
61
182
|
for (const [file, stamp] of this.stamps) {
|
|
62
|
-
if (
|
|
183
|
+
if (getFarmSourceStamp(file) !== stamp) changed.set(file, void 0);
|
|
63
184
|
}
|
|
64
185
|
if (changed.size === 0) return changed;
|
|
65
186
|
const replaced = /* @__PURE__ */ new Set();
|
|
@@ -85,10 +206,11 @@ var FarmSourceSnapshotStore = class {
|
|
|
85
206
|
}
|
|
86
207
|
/** Records the stamp of every file an entry read that has none yet. */
|
|
87
208
|
stamp() {
|
|
209
|
+
if (!this.tracked) return;
|
|
88
210
|
for (const entries of this.entries.values()) {
|
|
89
211
|
for (const entry of entries.values()) {
|
|
90
212
|
for (const file of entry.files) {
|
|
91
|
-
if (!this.stamps.has(file)) this.stamps.set(file,
|
|
213
|
+
if (!this.stamps.has(file)) this.stamps.set(file, getFarmSourceStamp(file));
|
|
92
214
|
}
|
|
93
215
|
}
|
|
94
216
|
}
|
|
@@ -112,11 +234,20 @@ function withFarmSourceSnapshot(operation, store) {
|
|
|
112
234
|
store?.stamp();
|
|
113
235
|
}
|
|
114
236
|
}
|
|
237
|
+
function withFarmSourceSnapshotOf(store, operation) {
|
|
238
|
+
if (snapshot) return operation();
|
|
239
|
+
base = store.entries;
|
|
240
|
+
try {
|
|
241
|
+
return withFarmSourceSnapshot(operation);
|
|
242
|
+
} finally {
|
|
243
|
+
base = void 0;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
115
246
|
function memoizeInFarmSourceSnapshot(scope, key, compute, lasting) {
|
|
116
247
|
if (!snapshot) return compute();
|
|
117
248
|
let entries = snapshot.get(scope);
|
|
118
249
|
if (!entries) snapshot.set(scope, entries = /* @__PURE__ */ new Map());
|
|
119
|
-
const memoized = entries.get(key);
|
|
250
|
+
const memoized = entries.get(key) ?? base?.get(scope)?.get(key);
|
|
120
251
|
if (memoized) {
|
|
121
252
|
if (trace) for (const file of memoized.files) trace.add(file);
|
|
122
253
|
return memoized.value;
|
|
@@ -165,10 +296,10 @@ function packageNameOf(specifier) {
|
|
|
165
296
|
return { name, subpath: parts.slice(name.startsWith("@") ? 2 : 1).join("/") };
|
|
166
297
|
}
|
|
167
298
|
function findPackageDirectory(importer, name) {
|
|
168
|
-
for (let current =
|
|
169
|
-
const directory =
|
|
170
|
-
if (fs2.existsSync(
|
|
171
|
-
if (
|
|
299
|
+
for (let current = path3.dirname(importer); ; current = path3.dirname(current)) {
|
|
300
|
+
const directory = path3.join(current, "node_modules", name);
|
|
301
|
+
if (fs2.existsSync(path3.join(directory, "package.json"))) return fs2.realpathSync(directory);
|
|
302
|
+
if (path3.dirname(current) === current) return null;
|
|
172
303
|
}
|
|
173
304
|
}
|
|
174
305
|
function pickTarget(value, conditions) {
|
|
@@ -225,12 +356,12 @@ function resolveFarmReactServerExport(importer, specifier) {
|
|
|
225
356
|
if (cache.has(key)) return cache.get(key);
|
|
226
357
|
let resolved = null;
|
|
227
358
|
try {
|
|
228
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
359
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
229
360
|
const entry = exportEntry(manifest.exports, parsed.subpath);
|
|
230
361
|
const server = pickTarget(entry, SERVER_CONDITIONS);
|
|
231
362
|
const fallback = pickTarget(entry, DEFAULT_CONDITIONS);
|
|
232
363
|
if (server && server !== fallback && server.startsWith("./")) {
|
|
233
|
-
const file =
|
|
364
|
+
const file = path3.resolve(directory, server);
|
|
234
365
|
if (fs2.existsSync(file)) resolved = file;
|
|
235
366
|
}
|
|
236
367
|
} catch {
|
|
@@ -253,7 +384,7 @@ function readModule(file) {
|
|
|
253
384
|
let program = null;
|
|
254
385
|
try {
|
|
255
386
|
const code = fs2.readFileSync(file, "utf8");
|
|
256
|
-
const extension =
|
|
387
|
+
const extension = path3.extname(file).slice(1);
|
|
257
388
|
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
|
|
258
389
|
program = parseAst(code, { lang });
|
|
259
390
|
} catch {
|
|
@@ -270,13 +401,13 @@ function isClientModule(program) {
|
|
|
270
401
|
return false;
|
|
271
402
|
}
|
|
272
403
|
function resolveRelative(from, specifier) {
|
|
273
|
-
const
|
|
404
|
+
const base2 = path3.resolve(path3.dirname(from), specifier);
|
|
274
405
|
for (const extension of SCRIPT_EXTENSIONS) {
|
|
275
|
-
const file = `${
|
|
406
|
+
const file = `${base2}${extension}`;
|
|
276
407
|
if (fs2.existsSync(file) && fs2.statSync(file).isFile()) return file;
|
|
277
408
|
}
|
|
278
409
|
for (const index of INDEX_FILES) {
|
|
279
|
-
const file =
|
|
410
|
+
const file = path3.join(base2, index);
|
|
280
411
|
if (fs2.existsSync(file)) return file;
|
|
281
412
|
}
|
|
282
413
|
return null;
|
|
@@ -290,10 +421,10 @@ function resolveFarmPackageDefaultEntry(importer, specifier, conditions = ["brow
|
|
|
290
421
|
const directory = findPackageDirectory(importer, parsed.name);
|
|
291
422
|
if (!directory) return null;
|
|
292
423
|
try {
|
|
293
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
424
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
294
425
|
const target = pickTarget(exportEntry(manifest.exports, parsed.subpath), conditions) ?? (!parsed.subpath ? manifest.module ?? manifest.main ?? "index.js" : parsed.subpath);
|
|
295
426
|
return resolveRelative(
|
|
296
|
-
|
|
427
|
+
path3.join(directory, "package.json"),
|
|
297
428
|
`./${String(target).replace(/^\.\//, "")}`
|
|
298
429
|
);
|
|
299
430
|
} catch {
|
|
@@ -372,7 +503,7 @@ function isFarmClientExport(file, name) {
|
|
|
372
503
|
function isFarmPackageClientExport(importer, specifier, name) {
|
|
373
504
|
return memoizeInFarmSourceSnapshot(
|
|
374
505
|
"package-client-export",
|
|
375
|
-
`${
|
|
506
|
+
`${farmSourceSnapshotPathKey(path3.dirname(importer))}\0${specifier}\0${name}`,
|
|
376
507
|
() => {
|
|
377
508
|
const entry = resolveFarmPackageDefaultEntry(importer, specifier);
|
|
378
509
|
return !entry || traceFarmExport(entry, name) !== "server";
|
|
@@ -380,13 +511,15 @@ function isFarmPackageClientExport(importer, specifier, name) {
|
|
|
380
511
|
);
|
|
381
512
|
}
|
|
382
513
|
function parseCode(code, file) {
|
|
383
|
-
const extension =
|
|
514
|
+
const extension = path3.extname(file).slice(1);
|
|
384
515
|
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
516
|
+
return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => {
|
|
517
|
+
try {
|
|
518
|
+
return parseAst(code, { lang });
|
|
519
|
+
} catch {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
390
523
|
}
|
|
391
524
|
function namespaceMembers(program, local) {
|
|
392
525
|
const members = /* @__PURE__ */ new Set();
|
|
@@ -672,7 +805,7 @@ function scanPackage(directory) {
|
|
|
672
805
|
}
|
|
673
806
|
for (const entry of entries) {
|
|
674
807
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
675
|
-
const file =
|
|
808
|
+
const file = path3.join(current, entry.name);
|
|
676
809
|
if (entry.isDirectory()) pending.push(file);
|
|
677
810
|
else if (/\.(?:[cm]?js|jsx)$/.test(entry.name) && scanned++ < MAX_SCANNED_FILES) {
|
|
678
811
|
let code;
|
|
@@ -697,8 +830,8 @@ function findFarmServerBundledPackage(importer, specifier) {
|
|
|
697
830
|
const directory = findPackageDirectory(importer, parsed.name);
|
|
698
831
|
if (!directory) return null;
|
|
699
832
|
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" &&
|
|
833
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
834
|
+
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
835
|
return { name: parsed.name, prebundle: isSelfContainedPackage(manifest, importer) };
|
|
703
836
|
}
|
|
704
837
|
} catch {
|
|
@@ -719,7 +852,7 @@ function findFarmPackageManifest(importer, specifier) {
|
|
|
719
852
|
if (!directory) return null;
|
|
720
853
|
let names;
|
|
721
854
|
try {
|
|
722
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
855
|
+
const manifest = JSON.parse(fs2.readFileSync(path3.join(directory, "package.json"), "utf8"));
|
|
723
856
|
names = new Set(Object.keys(manifest.dependencies ?? {}));
|
|
724
857
|
} catch {
|
|
725
858
|
return null;
|
|
@@ -1325,14 +1458,14 @@ function toModuleFile(file) {
|
|
|
1325
1458
|
}
|
|
1326
1459
|
|
|
1327
1460
|
// src/utils/client-component.ts
|
|
1328
|
-
import
|
|
1329
|
-
import
|
|
1461
|
+
import fs6 from "fs";
|
|
1462
|
+
import path7 from "path";
|
|
1330
1463
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1331
1464
|
|
|
1332
1465
|
// src/islands-package-references.ts
|
|
1333
1466
|
import { createHash } from "crypto";
|
|
1334
1467
|
import fs3 from "fs";
|
|
1335
|
-
import
|
|
1468
|
+
import path4 from "path";
|
|
1336
1469
|
import { parseAst as parseAst2 } from "rolldown/parseAst";
|
|
1337
1470
|
var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
1338
1471
|
var moduleName = (node) => {
|
|
@@ -1340,7 +1473,7 @@ var moduleName = (node) => {
|
|
|
1340
1473
|
return typeof name === "string" ? name : null;
|
|
1341
1474
|
};
|
|
1342
1475
|
function parse(code, file) {
|
|
1343
|
-
const extension =
|
|
1476
|
+
const extension = path4.extname(file).slice(1);
|
|
1344
1477
|
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
|
|
1345
1478
|
return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => parseAs(code, lang));
|
|
1346
1479
|
}
|
|
@@ -1457,18 +1590,18 @@ function parseFarmResolveFrom(id, importer) {
|
|
|
1457
1590
|
const rest = id.slice(FARM_RESOLVE_FROM_PREFIX.length);
|
|
1458
1591
|
const separator = rest.indexOf(":");
|
|
1459
1592
|
if (separator <= 0) return null;
|
|
1460
|
-
const directory =
|
|
1461
|
-
|
|
1593
|
+
const directory = path4.resolve(
|
|
1594
|
+
path4.dirname(importer),
|
|
1462
1595
|
decodeURIComponent(rest.slice(0, separator))
|
|
1463
1596
|
);
|
|
1464
1597
|
return {
|
|
1465
1598
|
specifier: rest.slice(separator + 1),
|
|
1466
|
-
importer:
|
|
1599
|
+
importer: path4.join(directory, "__farm_client_reference__.js")
|
|
1467
1600
|
};
|
|
1468
1601
|
}
|
|
1469
1602
|
function farmPackageClientReferencePath(root, specifier, exportName, scope) {
|
|
1470
1603
|
const directory = specifier.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
|
|
1471
|
-
return
|
|
1604
|
+
return path4.join(
|
|
1472
1605
|
root,
|
|
1473
1606
|
".farm",
|
|
1474
1607
|
"client-references",
|
|
@@ -1482,22 +1615,22 @@ function specifierPackage(specifier) {
|
|
|
1482
1615
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
1483
1616
|
}
|
|
1484
1617
|
function packageLookup(directory, packageName) {
|
|
1485
|
-
for (let current = directory; ; current =
|
|
1486
|
-
if (
|
|
1487
|
-
const candidate =
|
|
1618
|
+
for (let current = directory; ; current = path4.dirname(current)) {
|
|
1619
|
+
if (path4.basename(current) !== "node_modules") {
|
|
1620
|
+
const candidate = path4.join(current, "node_modules", packageName);
|
|
1488
1621
|
try {
|
|
1489
1622
|
return { from: current, real: fs3.realpathSync(candidate) };
|
|
1490
1623
|
} catch {
|
|
1491
1624
|
}
|
|
1492
1625
|
}
|
|
1493
|
-
if (
|
|
1626
|
+
if (path4.dirname(current) === current) return null;
|
|
1494
1627
|
}
|
|
1495
1628
|
}
|
|
1496
1629
|
function referenceResolveFrom(root, specifier, importer) {
|
|
1497
1630
|
const packageName = specifierPackage(specifier);
|
|
1498
|
-
const own = packageLookup(
|
|
1631
|
+
const own = packageLookup(path4.dirname(importer), packageName);
|
|
1499
1632
|
if (!own) return null;
|
|
1500
|
-
const app = packageLookup(
|
|
1633
|
+
const app = packageLookup(path4.join(root, ".farm", "client-references"), packageName);
|
|
1501
1634
|
if (app?.real === own.real) return null;
|
|
1502
1635
|
try {
|
|
1503
1636
|
return fs3.realpathSync(own.from);
|
|
@@ -1507,11 +1640,11 @@ function referenceResolveFrom(root, specifier, importer) {
|
|
|
1507
1640
|
}
|
|
1508
1641
|
function ensureFarmPackageClientReference(root, specifier, exportName, importer) {
|
|
1509
1642
|
const resolveFrom = importer ? referenceResolveFrom(root, specifier, importer) : null;
|
|
1510
|
-
const scope = resolveFrom ? `__from__${createHash("sha256").update(
|
|
1643
|
+
const scope = resolveFrom ? `__from__${createHash("sha256").update(path4.relative(root, resolveFrom).split(path4.sep).join("/")).digest("hex").slice(0, 8)}` : void 0;
|
|
1511
1644
|
const file = farmPackageClientReferencePath(root, specifier, exportName, scope);
|
|
1512
1645
|
const target = JSON.stringify(
|
|
1513
1646
|
resolveFrom ? `${FARM_RESOLVE_FROM_PREFIX}${encodeURIComponent(
|
|
1514
|
-
|
|
1647
|
+
path4.relative(path4.dirname(file), resolveFrom).split(path4.sep).join("/")
|
|
1515
1648
|
)}:${specifier}` : specifier
|
|
1516
1649
|
);
|
|
1517
1650
|
const source = [
|
|
@@ -1530,7 +1663,7 @@ function ensureFarmPackageClientReference(root, specifier, exportName, importer)
|
|
|
1530
1663
|
} catch {
|
|
1531
1664
|
}
|
|
1532
1665
|
if (current !== source) {
|
|
1533
|
-
fs3.mkdirSync(
|
|
1666
|
+
fs3.mkdirSync(path4.dirname(file), { recursive: true });
|
|
1534
1667
|
fs3.writeFileSync(file, source);
|
|
1535
1668
|
}
|
|
1536
1669
|
return file;
|
|
@@ -1542,18 +1675,18 @@ function writeIfChanged(file, source) {
|
|
|
1542
1675
|
} catch {
|
|
1543
1676
|
}
|
|
1544
1677
|
if (current !== source) {
|
|
1545
|
-
fs3.mkdirSync(
|
|
1678
|
+
fs3.mkdirSync(path4.dirname(file), { recursive: true });
|
|
1546
1679
|
fs3.writeFileSync(file, source);
|
|
1547
1680
|
}
|
|
1548
1681
|
}
|
|
1549
1682
|
function owningPackage(file) {
|
|
1550
|
-
for (let current =
|
|
1683
|
+
for (let current = path4.dirname(file); ; current = path4.dirname(current)) {
|
|
1551
1684
|
try {
|
|
1552
|
-
const manifest = JSON.parse(fs3.readFileSync(
|
|
1685
|
+
const manifest = JSON.parse(fs3.readFileSync(path4.join(current, "package.json"), "utf8"));
|
|
1553
1686
|
if (typeof manifest.name === "string") return { directory: current, name: manifest.name };
|
|
1554
1687
|
} catch {
|
|
1555
1688
|
}
|
|
1556
|
-
if (
|
|
1689
|
+
if (path4.dirname(current) === current) return null;
|
|
1557
1690
|
}
|
|
1558
1691
|
}
|
|
1559
1692
|
function ensureFarmInternalClientReference(root, clientFile) {
|
|
@@ -1562,8 +1695,8 @@ function ensureFarmInternalClientReference(root, clientFile) {
|
|
|
1562
1695
|
if (!owner || !names || names.length === 0) return null;
|
|
1563
1696
|
const directory = owner.name.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
|
|
1564
1697
|
const hash = createHash("sha256").update(owner.directory).digest("hex").slice(0, 8);
|
|
1565
|
-
const relative =
|
|
1566
|
-
const file =
|
|
1698
|
+
const relative = path4.relative(owner.directory, clientFile).split(path4.sep).join("+").replace(/[^A-Za-z0-9._+-]/g, "_");
|
|
1699
|
+
const file = path4.join(
|
|
1567
1700
|
root,
|
|
1568
1701
|
".farm",
|
|
1569
1702
|
"client-references",
|
|
@@ -1573,7 +1706,7 @@ function ensureFarmInternalClientReference(root, clientFile) {
|
|
|
1573
1706
|
);
|
|
1574
1707
|
const target = JSON.stringify(clientFile);
|
|
1575
1708
|
const lines = [
|
|
1576
|
-
`// Generated by Farm: ${owner.name}'s ${
|
|
1709
|
+
`// Generated by Farm: ${owner.name}'s ${path4.relative(owner.directory, clientFile).split(path4.sep).join("/")}, as a client reference for server components.`,
|
|
1577
1710
|
FARM_CLIENT_REFERENCE_PRAGMA,
|
|
1578
1711
|
'"use client";'
|
|
1579
1712
|
];
|
|
@@ -1634,12 +1767,155 @@ function rewriteFarmPackageClientImports(options) {
|
|
|
1634
1767
|
return changed ? output : null;
|
|
1635
1768
|
}
|
|
1636
1769
|
|
|
1770
|
+
// src/islands-containers.ts
|
|
1771
|
+
import fs4 from "fs";
|
|
1772
|
+
import path5 from "path";
|
|
1773
|
+
import { parseAst as parseAst3 } from "rolldown/parseAst";
|
|
1774
|
+
var FARM_ISLAND_CONTAINER_EXPORT = "FarmIslandContainer";
|
|
1775
|
+
var CONTAINER_LOCAL = "__FarmIslandContainer__";
|
|
1776
|
+
var ISLAND_CONTAINER_TAGS = /* @__PURE__ */ new Set([
|
|
1777
|
+
"table",
|
|
1778
|
+
"thead",
|
|
1779
|
+
"tbody",
|
|
1780
|
+
"tfoot",
|
|
1781
|
+
"tr",
|
|
1782
|
+
"select",
|
|
1783
|
+
"optgroup",
|
|
1784
|
+
"datalist",
|
|
1785
|
+
"svg",
|
|
1786
|
+
"ul",
|
|
1787
|
+
"ol"
|
|
1788
|
+
]);
|
|
1789
|
+
var FLOW_CONTENT_TAGS = /* @__PURE__ */ new Set(["td", "th", "caption", "foreignObject", "li"]);
|
|
1790
|
+
function farmIslandContainerReferencePath(root) {
|
|
1791
|
+
return path5.join(root, ".farm", "client-references", "farm.js+core", "__island-container.tsx");
|
|
1792
|
+
}
|
|
1793
|
+
function ensureFarmIslandContainerReference(root) {
|
|
1794
|
+
const file = farmIslandContainerReferencePath(root);
|
|
1795
|
+
const source = [
|
|
1796
|
+
"// Generated by Farm: the island around an element whose children are client components (RFC 0006).",
|
|
1797
|
+
FARM_CLIENT_REFERENCE_PRAGMA,
|
|
1798
|
+
'"use client";',
|
|
1799
|
+
`export function ${FARM_ISLAND_CONTAINER_EXPORT}({ children }: { children?: unknown }) {`,
|
|
1800
|
+
" return children as never;",
|
|
1801
|
+
"}",
|
|
1802
|
+
""
|
|
1803
|
+
].join("\n");
|
|
1804
|
+
let current = null;
|
|
1805
|
+
try {
|
|
1806
|
+
current = fs4.readFileSync(file, "utf8");
|
|
1807
|
+
} catch {
|
|
1808
|
+
}
|
|
1809
|
+
if (current !== source) {
|
|
1810
|
+
fs4.mkdirSync(path5.dirname(file), { recursive: true });
|
|
1811
|
+
fs4.writeFileSync(file, source);
|
|
1812
|
+
}
|
|
1813
|
+
return file;
|
|
1814
|
+
}
|
|
1815
|
+
function parse2(code, file) {
|
|
1816
|
+
const extension = path5.extname(file).slice(1);
|
|
1817
|
+
const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : extension === "js" || extension === "mjs" || extension === "cjs" || extension === "jsx" ? "jsx" : "tsx";
|
|
1818
|
+
return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => {
|
|
1819
|
+
try {
|
|
1820
|
+
return parseAst3(code, { lang });
|
|
1821
|
+
} catch {
|
|
1822
|
+
return null;
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
function jsxName(node) {
|
|
1827
|
+
if (!node) return null;
|
|
1828
|
+
if (node.type === "JSXIdentifier") return node.name;
|
|
1829
|
+
if (node.type === "JSXMemberExpression") {
|
|
1830
|
+
let object = node.object;
|
|
1831
|
+
while (object.type === "JSXMemberExpression") object = object.object;
|
|
1832
|
+
return object.type === "JSXIdentifier" ? object.name : null;
|
|
1833
|
+
}
|
|
1834
|
+
return null;
|
|
1835
|
+
}
|
|
1836
|
+
function findFarmIslandContainers(code, file, bindings) {
|
|
1837
|
+
if (bindings.length === 0) return [];
|
|
1838
|
+
if (!/<(?:table|thead|tbody|tfoot|tr|select|optgroup|datalist|svg|ul|ol)[\s>/]/.test(code)) {
|
|
1839
|
+
return [];
|
|
1840
|
+
}
|
|
1841
|
+
const program = parse2(code, file);
|
|
1842
|
+
if (!program) return null;
|
|
1843
|
+
const names = new Set(bindings);
|
|
1844
|
+
const found = /* @__PURE__ */ new Map();
|
|
1845
|
+
const open = [];
|
|
1846
|
+
const visit = (node) => {
|
|
1847
|
+
if (!node || typeof node !== "object") return;
|
|
1848
|
+
if (Array.isArray(node)) {
|
|
1849
|
+
for (const child of node) visit(child);
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
const current = node;
|
|
1853
|
+
if (typeof current.type !== "string") return;
|
|
1854
|
+
if (current.type === "JSXElement") {
|
|
1855
|
+
const name = jsxName(current.openingElement?.name);
|
|
1856
|
+
if (name && names.has(name)) {
|
|
1857
|
+
let container;
|
|
1858
|
+
for (let depth = open.length - 1; depth >= 0; depth--) {
|
|
1859
|
+
const tag = jsxName(open[depth].openingElement.name);
|
|
1860
|
+
if (FLOW_CONTENT_TAGS.has(tag)) break;
|
|
1861
|
+
if (ISLAND_CONTAINER_TAGS.has(tag)) container = open[depth];
|
|
1862
|
+
}
|
|
1863
|
+
if (container && !found.has(container.start)) {
|
|
1864
|
+
found.set(container.start, {
|
|
1865
|
+
tag: jsxName(container.openingElement.name),
|
|
1866
|
+
start: container.start,
|
|
1867
|
+
end: container.end
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
const host = current.openingElement?.name?.type === "JSXIdentifier" && (ISLAND_CONTAINER_TAGS.has(name) || FLOW_CONTENT_TAGS.has(name));
|
|
1872
|
+
if (host) open.push(current);
|
|
1873
|
+
visit(current.openingElement?.attributes);
|
|
1874
|
+
visit(current.children);
|
|
1875
|
+
if (host) open.pop();
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
for (const [key, value] of Object.entries(current)) {
|
|
1879
|
+
if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
|
|
1880
|
+
if (value && typeof value === "object") visit(value);
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
visit(program);
|
|
1884
|
+
const sorted = [...found.values()].sort((a, b) => a.start - b.start);
|
|
1885
|
+
const outermost = [];
|
|
1886
|
+
for (const container of sorted) {
|
|
1887
|
+
const last = outermost[outermost.length - 1];
|
|
1888
|
+
if (last && container.start >= last.start && container.end <= last.end) continue;
|
|
1889
|
+
outermost.push(container);
|
|
1890
|
+
}
|
|
1891
|
+
return outermost;
|
|
1892
|
+
}
|
|
1893
|
+
function wrapFarmIslandContainers(options) {
|
|
1894
|
+
const containers = findFarmIslandContainers(options.code, options.file, options.bindings);
|
|
1895
|
+
if (!containers || containers.length === 0) return null;
|
|
1896
|
+
let code = options.code;
|
|
1897
|
+
for (const container of [...containers].reverse()) {
|
|
1898
|
+
code = code.slice(0, container.start) + `<${CONTAINER_LOCAL}>` + code.slice(container.start, container.end) + `</${CONTAINER_LOCAL}>` + code.slice(container.end);
|
|
1899
|
+
}
|
|
1900
|
+
const specifier = JSON.stringify(options.reference.split(path5.sep).join("/"));
|
|
1901
|
+
const declaration = `import { ${FARM_ISLAND_CONTAINER_EXPORT} as ${CONTAINER_LOCAL} } from ${specifier};
|
|
1902
|
+
`;
|
|
1903
|
+
let prologueEnd = 0;
|
|
1904
|
+
for (const statement of parse2(options.code, options.file)?.body ?? []) {
|
|
1905
|
+
if (statement.type !== "ExpressionStatement" || typeof statement.directive !== "string") break;
|
|
1906
|
+
prologueEnd = statement.end;
|
|
1907
|
+
}
|
|
1908
|
+
if (prologueEnd === 0) return declaration + code;
|
|
1909
|
+
return `${code.slice(0, prologueEnd)}
|
|
1910
|
+
${declaration}${code.slice(prologueEnd)}`;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1637
1913
|
// src/utils/package-client-boundary-cache.ts
|
|
1638
1914
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1639
|
-
import
|
|
1640
|
-
import
|
|
1915
|
+
import fs5 from "fs";
|
|
1916
|
+
import path6 from "path";
|
|
1641
1917
|
var SCHEMA_VERSION = 2;
|
|
1642
|
-
var NODE_MODULES_SEGMENT = `${
|
|
1918
|
+
var NODE_MODULES_SEGMENT = `${path6.sep}node_modules${path6.sep}`;
|
|
1643
1919
|
var PackageInspectionTrace = class {
|
|
1644
1920
|
constructor() {
|
|
1645
1921
|
this.files = /* @__PURE__ */ new Set();
|
|
@@ -1649,7 +1925,7 @@ var PackageInspectionTrace = class {
|
|
|
1649
1925
|
}
|
|
1650
1926
|
visit(file) {
|
|
1651
1927
|
this.files.add(file);
|
|
1652
|
-
const directory =
|
|
1928
|
+
const directory = path6.dirname(file);
|
|
1653
1929
|
if (!this.directoryStamps.has(directory)) {
|
|
1654
1930
|
this.directoryStamps.set(directory, stampPackagePath(directory, "directory"));
|
|
1655
1931
|
}
|
|
@@ -1676,9 +1952,9 @@ var PackageInspectionTrace = class {
|
|
|
1676
1952
|
}
|
|
1677
1953
|
};
|
|
1678
1954
|
function stampPackagePath(target, kind) {
|
|
1679
|
-
if (!`${target}${
|
|
1955
|
+
if (!`${target}${path6.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
|
|
1680
1956
|
try {
|
|
1681
|
-
const stat =
|
|
1957
|
+
const stat = fs5.statSync(target, { throwIfNoEntry: false });
|
|
1682
1958
|
if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
|
|
1683
1959
|
return [target, stat.size, stat.mtimeMs, stat.ctimeMs];
|
|
1684
1960
|
} catch {
|
|
@@ -1733,11 +2009,11 @@ var PackageClientBoundaryCache = class {
|
|
|
1733
2009
|
const { file, contents } = pending;
|
|
1734
2010
|
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
1735
2011
|
try {
|
|
1736
|
-
await
|
|
1737
|
-
await
|
|
1738
|
-
await
|
|
2012
|
+
await fs5.promises.mkdir(path6.dirname(file), { recursive: true });
|
|
2013
|
+
await fs5.promises.writeFile(temporary, contents);
|
|
2014
|
+
await fs5.promises.rename(temporary, file);
|
|
1739
2015
|
} catch {
|
|
1740
|
-
await
|
|
2016
|
+
await fs5.promises.rm(temporary, { force: true }).catch(() => {
|
|
1741
2017
|
});
|
|
1742
2018
|
}
|
|
1743
2019
|
}
|
|
@@ -1748,12 +2024,12 @@ var PackageClientBoundaryCache = class {
|
|
|
1748
2024
|
const { file, contents } = pending;
|
|
1749
2025
|
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
1750
2026
|
try {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
2027
|
+
fs5.mkdirSync(path6.dirname(file), { recursive: true });
|
|
2028
|
+
fs5.writeFileSync(temporary, contents);
|
|
2029
|
+
fs5.renameSync(temporary, file);
|
|
1754
2030
|
} catch {
|
|
1755
2031
|
try {
|
|
1756
|
-
|
|
2032
|
+
fs5.rmSync(temporary, { force: true });
|
|
1757
2033
|
} catch {
|
|
1758
2034
|
}
|
|
1759
2035
|
}
|
|
@@ -1824,7 +2100,7 @@ var PackageClientBoundaryCache = class {
|
|
|
1824
2100
|
function readStoredCache(file) {
|
|
1825
2101
|
let value;
|
|
1826
2102
|
try {
|
|
1827
|
-
value = JSON.parse(
|
|
2103
|
+
value = JSON.parse(fs5.readFileSync(file, "utf8"));
|
|
1828
2104
|
} catch {
|
|
1829
2105
|
return null;
|
|
1830
2106
|
}
|
|
@@ -1845,7 +2121,7 @@ function isRecord(value) {
|
|
|
1845
2121
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1846
2122
|
}
|
|
1847
2123
|
function isPathStamp(value) {
|
|
1848
|
-
return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" &&
|
|
2124
|
+
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));
|
|
1849
2125
|
}
|
|
1850
2126
|
function isPathIndexList(value, pathCount) {
|
|
1851
2127
|
return Array.isArray(value) && value.length > 0 && value.every((index) => Number.isSafeInteger(index) && index >= 0 && index < pathCount);
|
|
@@ -1853,7 +2129,7 @@ function isPathIndexList(value, pathCount) {
|
|
|
1853
2129
|
function isStoredEntry(value, pathCount) {
|
|
1854
2130
|
if (!isRecord(value) || !isRecord(value.result)) return false;
|
|
1855
2131
|
const { isClientComponent, shouldHydrate, islandStrategy } = value.result;
|
|
1856
|
-
return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" &&
|
|
2132
|
+
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;
|
|
1857
2133
|
}
|
|
1858
2134
|
var STORAGE_KEY = /* @__PURE__ */ Symbol.for("@farm.js/core/package-client-boundary-cache");
|
|
1859
2135
|
function getStorage() {
|
|
@@ -1881,7 +2157,7 @@ function usePackageClientBoundaryCacheFile(file) {
|
|
|
1881
2157
|
getPackageClientBoundaryCache()?.load(file);
|
|
1882
2158
|
}
|
|
1883
2159
|
function resolvePackageClientBoundaryCacheFile(root, distDir) {
|
|
1884
|
-
return
|
|
2160
|
+
return path6.resolve(root, distDir, "cache", "client-boundaries.json");
|
|
1885
2161
|
}
|
|
1886
2162
|
function runWithPackageClientBoundaryCacheFile(file, operation) {
|
|
1887
2163
|
if (getPackageClientBoundaryCache()) return operation();
|
|
@@ -1925,10 +2201,10 @@ function readSourceFile(filePath) {
|
|
|
1925
2201
|
}
|
|
1926
2202
|
function readSourceFileContents(filePath) {
|
|
1927
2203
|
try {
|
|
1928
|
-
if (!filePath || !
|
|
2204
|
+
if (!filePath || !fs6.existsSync(filePath)) {
|
|
1929
2205
|
return null;
|
|
1930
2206
|
}
|
|
1931
|
-
return
|
|
2207
|
+
return fs6.readFileSync(filePath, "utf-8");
|
|
1932
2208
|
} catch {
|
|
1933
2209
|
return null;
|
|
1934
2210
|
}
|
|
@@ -1947,21 +2223,21 @@ function resolveModuleSourcePath(modulePath, root) {
|
|
|
1947
2223
|
}
|
|
1948
2224
|
if (modulePath.startsWith("/@fs/")) {
|
|
1949
2225
|
const fsPath = withoutQuery.slice("/@fs/".length);
|
|
1950
|
-
candidates.add(
|
|
2226
|
+
candidates.add(path7.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
|
|
1951
2227
|
}
|
|
1952
2228
|
}
|
|
1953
2229
|
if (root && modulePath) {
|
|
1954
2230
|
const normalized = withoutQuery.replace(/^\/+/, "");
|
|
1955
|
-
candidates.add(
|
|
1956
|
-
candidates.add(
|
|
2231
|
+
candidates.add(path7.join(root, normalized));
|
|
2232
|
+
candidates.add(path7.resolve(root, normalized));
|
|
1957
2233
|
}
|
|
1958
2234
|
if (withoutQuery?.startsWith("/src/")) {
|
|
1959
2235
|
const normalized = withoutQuery.replace(/^\/+/, "");
|
|
1960
|
-
candidates.add(
|
|
1961
|
-
candidates.add(
|
|
2236
|
+
candidates.add(path7.join(process.cwd(), normalized));
|
|
2237
|
+
candidates.add(path7.resolve(process.cwd(), normalized));
|
|
1962
2238
|
}
|
|
1963
2239
|
for (const candidate of candidates) {
|
|
1964
|
-
if (
|
|
2240
|
+
if (fs6.existsSync(candidate)) {
|
|
1965
2241
|
return candidate;
|
|
1966
2242
|
}
|
|
1967
2243
|
}
|
|
@@ -1978,8 +2254,8 @@ var FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES = 4;
|
|
|
1978
2254
|
function isolatedHydrationBoundaryLimit() {
|
|
1979
2255
|
const benchmarkRoot = process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_ROOT;
|
|
1980
2256
|
const benchmarkLimit = Number(process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_LIMIT);
|
|
1981
|
-
const resolvedBenchmarkRoot = benchmarkRoot ?
|
|
1982
|
-
const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${
|
|
2257
|
+
const resolvedBenchmarkRoot = benchmarkRoot ? path7.resolve(benchmarkRoot) : null;
|
|
2258
|
+
const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path7.sep}`));
|
|
1983
2259
|
return isBenchmarkFixture && Number.isSafeInteger(benchmarkLimit) && benchmarkLimit > FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES ? benchmarkLimit : FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES;
|
|
1984
2260
|
}
|
|
1985
2261
|
var RESOLVABLE_SOURCE_EXTENSIONS = [
|
|
@@ -2010,7 +2286,7 @@ function hasUseClientDirective(content) {
|
|
|
2010
2286
|
if (!normalized.includes("use client")) {
|
|
2011
2287
|
return false;
|
|
2012
2288
|
}
|
|
2013
|
-
for (const token of
|
|
2289
|
+
for (const token of scanModuleSourceTokens(content, true)) {
|
|
2014
2290
|
if (token.kind === "string") {
|
|
2015
2291
|
if (token.value === "use client") {
|
|
2016
2292
|
return true;
|
|
@@ -2136,7 +2412,7 @@ function isIdentifierStartCode(code) {
|
|
|
2136
2412
|
function isIdentifierPartCode(code) {
|
|
2137
2413
|
return isIdentifierStartCode(code) || code >= 48 && code <= 57;
|
|
2138
2414
|
}
|
|
2139
|
-
function scanModuleSourceTokens(content) {
|
|
2415
|
+
function scanModuleSourceTokens(content, prologueOnly = false) {
|
|
2140
2416
|
const tokens = [];
|
|
2141
2417
|
let index = 0;
|
|
2142
2418
|
let line = 1;
|
|
@@ -2216,9 +2492,11 @@ function scanModuleSourceTokens(content) {
|
|
|
2216
2492
|
const start = index++;
|
|
2217
2493
|
while (index < content.length && isIdentifierPartCode(content.charCodeAt(index))) index++;
|
|
2218
2494
|
tokens.push({ kind: "identifier", value: content.slice(start, index), line });
|
|
2495
|
+
if (prologueOnly) return tokens;
|
|
2219
2496
|
continue;
|
|
2220
2497
|
}
|
|
2221
2498
|
tokens.push({ kind: "punctuation", value: character, line });
|
|
2499
|
+
if (prologueOnly && character !== ";") return tokens;
|
|
2222
2500
|
index++;
|
|
2223
2501
|
}
|
|
2224
2502
|
return tokens;
|
|
@@ -2326,6 +2604,16 @@ function resolveOwnerSourcePath(resolvedPath, root) {
|
|
|
2326
2604
|
}
|
|
2327
2605
|
return current;
|
|
2328
2606
|
}
|
|
2607
|
+
function getFarmClientRenderingBindings(code, file, root) {
|
|
2608
|
+
const bindings = [];
|
|
2609
|
+
for (const [specifier, locals] of getStaticImportBindings(code)) {
|
|
2610
|
+
const imported = resolveImportedModule(file, specifier, root);
|
|
2611
|
+
if (!imported.path) continue;
|
|
2612
|
+
const metadata = imported.local ? inspectClientModuleMetadata(imported.path, root, /* @__PURE__ */ new Set([path7.resolve(file)]), false) : inspectPackageClientBoundary(imported.path, root, /* @__PURE__ */ new Set());
|
|
2613
|
+
if (metadata.isClientComponent || metadata.shouldHydrate) bindings.push(...locals);
|
|
2614
|
+
}
|
|
2615
|
+
return bindings;
|
|
2616
|
+
}
|
|
2329
2617
|
function collectFarmRenderedClientModules(modulePath, root) {
|
|
2330
2618
|
const resolvedPath = resolveOwnerSourcePath(resolveModuleSourcePath(modulePath, root), root);
|
|
2331
2619
|
if (!resolvedPath) return null;
|
|
@@ -2365,6 +2653,9 @@ function getClientModuleMetadata(modulePath, root) {
|
|
|
2365
2653
|
const resolvedPath = resolveModuleSourcePath(modulePath, root);
|
|
2366
2654
|
return inspectClientModuleMetadata(resolvedPath, root, /* @__PURE__ */ new Set(), true);
|
|
2367
2655
|
}
|
|
2656
|
+
function getClientModuleHydrationPlanKey(modulePath, root, mode, options = {}) {
|
|
2657
|
+
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)}`;
|
|
2658
|
+
}
|
|
2368
2659
|
function getClientModuleHydrationPlan(modulePath, root, mode = "off", options = {}) {
|
|
2369
2660
|
const plan = planClientModuleHydration(modulePath, root, mode, options);
|
|
2370
2661
|
if (options.serverTreeLayouts !== true || options.asyncOwnerIslands !== true || !plan.shouldHydrate || plan.isClientComponent || plan.asyncOwnerIslands) {
|
|
@@ -2591,6 +2882,13 @@ function enforceFarmIsolatedHydrationRouteBudget(layouts, routes, layoutAppliesT
|
|
|
2591
2882
|
(ancestor) => ancestor !== layout && ancestor.depth < layout.depth && ancestor.metadata.shouldHydrate && layoutAppliesToRoute(ancestor.pattern, layout.pattern)
|
|
2592
2883
|
);
|
|
2593
2884
|
if (hasRouteWideAncestor && layout.metadata.hasIsolatedClientBoundaries) {
|
|
2885
|
+
if (options.serverOwners && !layout.metadata.asyncOwnerIslands) {
|
|
2886
|
+
layout.metadata.shouldHydrate = layout.metadata.legacyShouldHydrate;
|
|
2887
|
+
layout.metadata.islandStrategy = layout.metadata.legacyIslandStrategy;
|
|
2888
|
+
layout.metadata.hasIsolatedClientBoundaries = false;
|
|
2889
|
+
layout.metadata.serverTreeLayout = true;
|
|
2890
|
+
continue;
|
|
2891
|
+
}
|
|
2594
2892
|
restoreRouteWideHydration(layout.metadata);
|
|
2595
2893
|
}
|
|
2596
2894
|
}
|
|
@@ -2930,7 +3228,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
|
|
|
2930
3228
|
let fallbackReason;
|
|
2931
3229
|
let fallbackHint;
|
|
2932
3230
|
let costGuardExceeded = false;
|
|
2933
|
-
const projectRoot = root ?
|
|
3231
|
+
const projectRoot = root ? path7.resolve(root) : void 0;
|
|
2934
3232
|
const visit = (moduleSourcePath) => {
|
|
2935
3233
|
if (fallbackReason) return 0;
|
|
2936
3234
|
const cached = estimates.get(moduleSourcePath);
|
|
@@ -3028,7 +3326,9 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
|
|
|
3028
3326
|
const localBindings = importedBindings.get(specifier) ?? [];
|
|
3029
3327
|
const staticUses = countStaticJsxUses(content, localBindings);
|
|
3030
3328
|
if (staticUses > 0) {
|
|
3031
|
-
const
|
|
3329
|
+
const grows = options.packageReferences === true && projectRoot !== void 0 && (findFarmIslandContainers(content ?? "", moduleSourcePath, localBindings)?.length ?? 0) > 0;
|
|
3330
|
+
if (grows) visit(ensureFarmIslandContainerReference(projectRoot));
|
|
3331
|
+
const container = grows ? void 0 : findParserSensitiveJsxContainer(content, localBindings);
|
|
3032
3332
|
if (container) {
|
|
3033
3333
|
fallbackReason = `the client boundary imported from ${specifier} renders inside <${container}>, where the HTML parser relocates its hydration marker`;
|
|
3034
3334
|
fallbackHint = `Move "use client" up to a component that renders the whole <${container}>${PARSER_SENSITIVE_FLOW_HINTS[container] ?? ""}`;
|
|
@@ -3115,13 +3415,13 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
|
|
|
3115
3415
|
}
|
|
3116
3416
|
function farmWorkspaceServerEntry(entry) {
|
|
3117
3417
|
const real = realpathOrSelf(entry);
|
|
3118
|
-
if (real.split(
|
|
3418
|
+
if (real.split(path7.sep).includes("node_modules")) return null;
|
|
3119
3419
|
if (parseClientModuleMetadata(readIfExists(real), false).isClientComponent) return null;
|
|
3120
3420
|
return real;
|
|
3121
3421
|
}
|
|
3122
3422
|
function realpathOrSelf(file) {
|
|
3123
3423
|
try {
|
|
3124
|
-
return
|
|
3424
|
+
return fs6.realpathSync(file);
|
|
3125
3425
|
} catch {
|
|
3126
3426
|
return file;
|
|
3127
3427
|
}
|
|
@@ -3279,7 +3579,7 @@ function isTypeOnlyNamedClause(tokens, startIndex, endIndex) {
|
|
|
3279
3579
|
function resolveImportedModule(importerPath, specifier, root) {
|
|
3280
3580
|
const resolved = memoizeInFarmSourceSnapshot(
|
|
3281
3581
|
"resolution",
|
|
3282
|
-
`${root
|
|
3582
|
+
`${root ? farmSourceSnapshotPathKey(root) : ""}\0${farmSourceSnapshotPathKey(importerPath)}\0${specifier}`,
|
|
3283
3583
|
() => resolveImportedModuleUncached(importerPath, specifier, root),
|
|
3284
3584
|
// A file added later may resolve an import that does not resolve now.
|
|
3285
3585
|
(result) => result.path !== null
|
|
@@ -3308,7 +3608,7 @@ var ALIAS_IMPORT = /^(?:@\/|~\/|#)/;
|
|
|
3308
3608
|
function warnUnresolvedAliasImport(importerPath, specifier, root) {
|
|
3309
3609
|
if (!ALIAS_IMPORT.test(specifier) || warnedUnresolvedAliasImports.has(specifier)) return;
|
|
3310
3610
|
warnedUnresolvedAliasImports.add(specifier);
|
|
3311
|
-
const importer = root ?
|
|
3611
|
+
const importer = root ? path7.relative(root, importerPath) : importerPath;
|
|
3312
3612
|
logger.warn(
|
|
3313
3613
|
`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".`
|
|
3314
3614
|
);
|
|
@@ -3317,7 +3617,7 @@ var projectImportAliasCache = /* @__PURE__ */ new Map();
|
|
|
3317
3617
|
var PROJECT_ALIAS_FILES = ["tsconfig.json", "jsconfig.json", "package.json"];
|
|
3318
3618
|
function resolveProjectAliasSourcePath(specifier, root) {
|
|
3319
3619
|
if (!root) return void 0;
|
|
3320
|
-
const projectRoot =
|
|
3620
|
+
const projectRoot = path7.resolve(root);
|
|
3321
3621
|
let match;
|
|
3322
3622
|
for (const alias of getProjectImportAliases(projectRoot)) {
|
|
3323
3623
|
const captured = matchProjectImportAlias(alias, specifier);
|
|
@@ -3327,7 +3627,7 @@ function resolveProjectAliasSourcePath(specifier, root) {
|
|
|
3327
3627
|
if (!match) return void 0;
|
|
3328
3628
|
const resolved = resolveSourceCandidate(
|
|
3329
3629
|
match.alias.targets.map(
|
|
3330
|
-
(target) =>
|
|
3630
|
+
(target) => path7.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
|
|
3331
3631
|
)
|
|
3332
3632
|
);
|
|
3333
3633
|
return resolved && /\.d\.[cm]?ts$/.test(resolved) ? null : resolved;
|
|
@@ -3342,7 +3642,7 @@ function matchProjectImportAlias(alias, specifier) {
|
|
|
3342
3642
|
function getProjectImportAliases(projectRoot) {
|
|
3343
3643
|
const stamp = PROJECT_ALIAS_FILES.map((file) => {
|
|
3344
3644
|
try {
|
|
3345
|
-
return String(
|
|
3645
|
+
return String(fs6.statSync(path7.join(projectRoot, file)).mtimeMs);
|
|
3346
3646
|
} catch {
|
|
3347
3647
|
return "-";
|
|
3348
3648
|
}
|
|
@@ -3360,7 +3660,7 @@ function getProjectImportAliases(projectRoot) {
|
|
|
3360
3660
|
prefix: "@/",
|
|
3361
3661
|
suffix: "",
|
|
3362
3662
|
wildcard: true,
|
|
3363
|
-
targets: [
|
|
3663
|
+
targets: [path7.join(projectRoot, sourceDir, "*")]
|
|
3364
3664
|
});
|
|
3365
3665
|
}
|
|
3366
3666
|
projectImportAliasCache.set(projectRoot, { stamp: cacheStamp, aliases });
|
|
@@ -3368,11 +3668,11 @@ function getProjectImportAliases(projectRoot) {
|
|
|
3368
3668
|
}
|
|
3369
3669
|
function readTsconfigPathAliases(projectRoot) {
|
|
3370
3670
|
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
3371
|
-
const configPath =
|
|
3372
|
-
if (!
|
|
3671
|
+
const configPath = path7.join(projectRoot, name);
|
|
3672
|
+
if (!fs6.existsSync(configPath)) continue;
|
|
3373
3673
|
const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
|
|
3374
3674
|
if (!resolved?.paths) return [];
|
|
3375
|
-
const
|
|
3675
|
+
const base2 = resolved.baseUrl ?? resolved.pathsDirectory;
|
|
3376
3676
|
return Object.entries(resolved.paths).flatMap(([pattern, targets]) => {
|
|
3377
3677
|
if (!Array.isArray(targets)) return [];
|
|
3378
3678
|
const wildcardIndex = pattern.indexOf("*");
|
|
@@ -3381,7 +3681,7 @@ function readTsconfigPathAliases(projectRoot) {
|
|
|
3381
3681
|
prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
|
|
3382
3682
|
suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
|
|
3383
3683
|
wildcard: wildcardIndex !== -1,
|
|
3384
|
-
targets: targets.filter((target) => typeof target === "string").map((target) =>
|
|
3684
|
+
targets: targets.filter((target) => typeof target === "string").map((target) => path7.resolve(base2, target))
|
|
3385
3685
|
}
|
|
3386
3686
|
];
|
|
3387
3687
|
});
|
|
@@ -3393,27 +3693,27 @@ function readTsconfigPaths(configPath, visited) {
|
|
|
3393
3693
|
visited.add(configPath);
|
|
3394
3694
|
const config = readJsonWithComments(configPath);
|
|
3395
3695
|
if (!config) return null;
|
|
3396
|
-
const directory =
|
|
3696
|
+
const directory = path7.dirname(configPath);
|
|
3397
3697
|
const parents = (Array.isArray(config.extends) ? config.extends : [config.extends]).filter(
|
|
3398
3698
|
(parent) => typeof parent === "string" && parent.startsWith(".")
|
|
3399
3699
|
);
|
|
3400
3700
|
let inherited = null;
|
|
3401
3701
|
for (const parent of parents) {
|
|
3402
|
-
const parentPath =
|
|
3702
|
+
const parentPath = path7.resolve(
|
|
3403
3703
|
directory,
|
|
3404
3704
|
parent.endsWith(".json") ? parent : `${parent}.json`
|
|
3405
3705
|
);
|
|
3406
3706
|
inherited = readTsconfigPaths(parentPath, visited) ?? inherited;
|
|
3407
3707
|
}
|
|
3408
3708
|
const options = config.compilerOptions ?? {};
|
|
3409
|
-
const baseUrl = typeof options.baseUrl === "string" ?
|
|
3709
|
+
const baseUrl = typeof options.baseUrl === "string" ? path7.resolve(directory, options.baseUrl) : inherited?.baseUrl;
|
|
3410
3710
|
if (options.paths && typeof options.paths === "object") {
|
|
3411
3711
|
return { paths: options.paths, pathsDirectory: directory, baseUrl };
|
|
3412
3712
|
}
|
|
3413
3713
|
return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
|
|
3414
3714
|
}
|
|
3415
3715
|
function readPackageImportAliases(projectRoot) {
|
|
3416
|
-
const imports = readPackageJson(
|
|
3716
|
+
const imports = readPackageJson(path7.join(projectRoot, "package.json"))?.imports;
|
|
3417
3717
|
if (!imports || typeof imports !== "object") return [];
|
|
3418
3718
|
return Object.entries(imports).flatMap(([pattern, value]) => {
|
|
3419
3719
|
const target = resolveConditionalExportTarget(value);
|
|
@@ -3424,7 +3724,7 @@ function readPackageImportAliases(projectRoot) {
|
|
|
3424
3724
|
prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
|
|
3425
3725
|
suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
|
|
3426
3726
|
wildcard: wildcardIndex !== -1,
|
|
3427
|
-
targets: [
|
|
3727
|
+
targets: [path7.resolve(projectRoot, target)]
|
|
3428
3728
|
}
|
|
3429
3729
|
];
|
|
3430
3730
|
});
|
|
@@ -3432,7 +3732,7 @@ function readPackageImportAliases(projectRoot) {
|
|
|
3432
3732
|
function readJsonWithComments(filePath) {
|
|
3433
3733
|
let source;
|
|
3434
3734
|
try {
|
|
3435
|
-
source =
|
|
3735
|
+
source = fs6.readFileSync(filePath, "utf8");
|
|
3436
3736
|
} catch {
|
|
3437
3737
|
return null;
|
|
3438
3738
|
}
|
|
@@ -3470,7 +3770,7 @@ function resolveImportedModuleSourcePath(importerPath, specifier, root) {
|
|
|
3470
3770
|
return resolvePackageModuleSourcePath(importerPath, specifier, root);
|
|
3471
3771
|
}
|
|
3472
3772
|
const candidates = /* @__PURE__ */ new Set();
|
|
3473
|
-
const basePath = specifier.startsWith(".") ?
|
|
3773
|
+
const basePath = specifier.startsWith(".") ? path7.resolve(path7.dirname(importerPath), specifier) : root ? path7.resolve(root, specifier.replace(/^\/+/, "")) : path7.resolve(specifier);
|
|
3474
3774
|
candidates.add(basePath);
|
|
3475
3775
|
return resolveSourceCandidate(candidates);
|
|
3476
3776
|
}
|
|
@@ -3480,45 +3780,45 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
|
|
|
3480
3780
|
const packageSubpath = packageParts.slice(packageName.startsWith("@") ? 2 : 1).join("/");
|
|
3481
3781
|
const packageDirectory = findPackageDirectory2(importerPath, packageName, root);
|
|
3482
3782
|
if (!packageDirectory) return null;
|
|
3483
|
-
const packageJsonPath =
|
|
3783
|
+
const packageJsonPath = path7.join(packageDirectory, "package.json");
|
|
3484
3784
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3485
3785
|
const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
|
|
3486
3786
|
const exportTarget = resolvePackageExport(packageJson?.exports, exportKey);
|
|
3487
3787
|
const candidates = /* @__PURE__ */ new Set();
|
|
3488
3788
|
if (exportTarget?.startsWith("./")) {
|
|
3489
|
-
candidates.add(
|
|
3789
|
+
candidates.add(path7.resolve(packageDirectory, exportTarget));
|
|
3490
3790
|
}
|
|
3491
3791
|
if (packageSubpath) {
|
|
3492
|
-
candidates.add(
|
|
3792
|
+
candidates.add(path7.join(packageDirectory, packageSubpath));
|
|
3493
3793
|
} else {
|
|
3494
3794
|
for (const entry of [packageJson?.browser, packageJson?.module, packageJson?.main]) {
|
|
3495
|
-
if (typeof entry === "string") candidates.add(
|
|
3795
|
+
if (typeof entry === "string") candidates.add(path7.resolve(packageDirectory, entry));
|
|
3496
3796
|
}
|
|
3497
|
-
candidates.add(
|
|
3797
|
+
candidates.add(path7.join(packageDirectory, "index"));
|
|
3498
3798
|
}
|
|
3499
3799
|
return resolveSourceCandidate(candidates);
|
|
3500
3800
|
}
|
|
3501
3801
|
function findPackageDirectory2(importerPath, packageName, root) {
|
|
3502
3802
|
const searchRoots = /* @__PURE__ */ new Set();
|
|
3503
|
-
let current =
|
|
3803
|
+
let current = path7.dirname(importerPath);
|
|
3504
3804
|
while (true) {
|
|
3505
3805
|
searchRoots.add(current);
|
|
3506
|
-
const parent =
|
|
3806
|
+
const parent = path7.dirname(current);
|
|
3507
3807
|
if (parent === current) break;
|
|
3508
3808
|
current = parent;
|
|
3509
3809
|
}
|
|
3510
3810
|
if (root) {
|
|
3511
|
-
current =
|
|
3811
|
+
current = path7.resolve(root);
|
|
3512
3812
|
while (true) {
|
|
3513
3813
|
searchRoots.add(current);
|
|
3514
|
-
const parent =
|
|
3814
|
+
const parent = path7.dirname(current);
|
|
3515
3815
|
if (parent === current) break;
|
|
3516
3816
|
current = parent;
|
|
3517
3817
|
}
|
|
3518
3818
|
}
|
|
3519
3819
|
for (const searchRoot of searchRoots) {
|
|
3520
|
-
const packageDirectory =
|
|
3521
|
-
if (
|
|
3820
|
+
const packageDirectory = path7.join(searchRoot, "node_modules", packageName);
|
|
3821
|
+
if (fs6.existsSync(path7.join(packageDirectory, "package.json"))) {
|
|
3522
3822
|
return packageDirectory;
|
|
3523
3823
|
}
|
|
3524
3824
|
}
|
|
@@ -3526,7 +3826,7 @@ function findPackageDirectory2(importerPath, packageName, root) {
|
|
|
3526
3826
|
}
|
|
3527
3827
|
function readPackageJson(packageJsonPath) {
|
|
3528
3828
|
try {
|
|
3529
|
-
return JSON.parse(
|
|
3829
|
+
return JSON.parse(fs6.readFileSync(packageJsonPath, "utf8"));
|
|
3530
3830
|
} catch {
|
|
3531
3831
|
return null;
|
|
3532
3832
|
}
|
|
@@ -3584,11 +3884,11 @@ function resolveSourceCandidate(candidates) {
|
|
|
3584
3884
|
for (const candidate of candidates) {
|
|
3585
3885
|
const paths = [candidate];
|
|
3586
3886
|
for (const extension of RESOLVABLE_SOURCE_EXTENSIONS) {
|
|
3587
|
-
paths.push(`${candidate}${extension}`,
|
|
3887
|
+
paths.push(`${candidate}${extension}`, path7.join(candidate, `index${extension}`));
|
|
3588
3888
|
}
|
|
3589
3889
|
for (const sourcePath of paths) {
|
|
3590
3890
|
try {
|
|
3591
|
-
if (
|
|
3891
|
+
if (fs6.statSync(sourcePath).isFile()) return sourcePath;
|
|
3592
3892
|
} catch {
|
|
3593
3893
|
}
|
|
3594
3894
|
}
|
|
@@ -3631,13 +3931,13 @@ function scanFarmPackageImports(directory, root) {
|
|
|
3631
3931
|
const walk2 = (current) => {
|
|
3632
3932
|
let entries;
|
|
3633
3933
|
try {
|
|
3634
|
-
entries =
|
|
3934
|
+
entries = fs6.readdirSync(current, { withFileTypes: true });
|
|
3635
3935
|
} catch {
|
|
3636
3936
|
return;
|
|
3637
3937
|
}
|
|
3638
3938
|
for (const entry of entries) {
|
|
3639
3939
|
if (entry.name.startsWith(".") && entry.isDirectory()) continue;
|
|
3640
|
-
const file =
|
|
3940
|
+
const file = path7.join(current, entry.name);
|
|
3641
3941
|
if (entry.isDirectory()) {
|
|
3642
3942
|
if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
|
|
3643
3943
|
continue;
|
|
@@ -3664,13 +3964,13 @@ function collectFarmServerBundledPackageInfo(directory) {
|
|
|
3664
3964
|
const walk2 = (current) => {
|
|
3665
3965
|
let entries;
|
|
3666
3966
|
try {
|
|
3667
|
-
entries =
|
|
3967
|
+
entries = fs6.readdirSync(current, { withFileTypes: true });
|
|
3668
3968
|
} catch {
|
|
3669
3969
|
return;
|
|
3670
3970
|
}
|
|
3671
3971
|
for (const entry of entries) {
|
|
3672
3972
|
if (entry.name.startsWith(".") && entry.isDirectory()) continue;
|
|
3673
|
-
const file =
|
|
3973
|
+
const file = path7.join(current, entry.name);
|
|
3674
3974
|
if (entry.isDirectory()) {
|
|
3675
3975
|
if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
|
|
3676
3976
|
continue;
|
|
@@ -3695,7 +3995,7 @@ function invalidateFarmClientReachableModules() {
|
|
|
3695
3995
|
clientReachableModules.clear();
|
|
3696
3996
|
}
|
|
3697
3997
|
function getFarmClientReachableModules(directory, root) {
|
|
3698
|
-
const key = `${
|
|
3998
|
+
const key = `${path7.resolve(root)}\0${path7.resolve(directory)}`;
|
|
3699
3999
|
const cached = clientReachableModules.get(key);
|
|
3700
4000
|
if (cached) return cached;
|
|
3701
4001
|
const reachable = /* @__PURE__ */ new Set();
|
|
@@ -3703,12 +4003,12 @@ function getFarmClientReachableModules(directory, root) {
|
|
|
3703
4003
|
const walk2 = (current) => {
|
|
3704
4004
|
let entries;
|
|
3705
4005
|
try {
|
|
3706
|
-
entries =
|
|
4006
|
+
entries = fs6.readdirSync(current, { withFileTypes: true });
|
|
3707
4007
|
} catch {
|
|
3708
4008
|
return;
|
|
3709
4009
|
}
|
|
3710
4010
|
for (const entry of entries) {
|
|
3711
|
-
const file =
|
|
4011
|
+
const file = path7.join(current, entry.name);
|
|
3712
4012
|
if (entry.isDirectory()) {
|
|
3713
4013
|
if (!entry.name.startsWith(".") && !CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
|
|
3714
4014
|
} else if (isScannedSourceFile(entry.name)) {
|
|
@@ -3719,12 +4019,12 @@ function getFarmClientReachableModules(directory, root) {
|
|
|
3719
4019
|
};
|
|
3720
4020
|
walk2(directory);
|
|
3721
4021
|
while (queue.length > 0) {
|
|
3722
|
-
const file =
|
|
4022
|
+
const file = path7.resolve(queue.pop());
|
|
3723
4023
|
if (reachable.has(file)) continue;
|
|
3724
4024
|
reachable.add(file);
|
|
3725
4025
|
for (const specifier of getImportSpecifiers(readIfExists(file), { dynamic: true })) {
|
|
3726
4026
|
const imported = resolveImportedModule(file, specifier, root);
|
|
3727
|
-
if (imported.local && imported.path && !reachable.has(
|
|
4027
|
+
if (imported.local && imported.path && !reachable.has(path7.resolve(imported.path))) {
|
|
3728
4028
|
queue.push(imported.path);
|
|
3729
4029
|
}
|
|
3730
4030
|
}
|
|
@@ -3733,7 +4033,7 @@ function getFarmClientReachableModules(directory, root) {
|
|
|
3733
4033
|
return reachable;
|
|
3734
4034
|
}
|
|
3735
4035
|
function resolveFarmClientOptimizeDeps(directory, root) {
|
|
3736
|
-
const importer =
|
|
4036
|
+
const importer = path7.join(path7.resolve(root), "package.json");
|
|
3737
4037
|
const include = /* @__PURE__ */ new Set();
|
|
3738
4038
|
const exclude = /* @__PURE__ */ new Set();
|
|
3739
4039
|
const imports = scanFarmPackageImports(directory, root);
|
|
@@ -3819,7 +4119,15 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
3819
4119
|
}
|
|
3820
4120
|
return sources.files;
|
|
3821
4121
|
};
|
|
3822
|
-
const
|
|
4122
|
+
const relativeFile = (file) => path8.isAbsolute(file) ? path8.relative(projectRoot, file).replace(/\\/g, "/") || file : file;
|
|
4123
|
+
const routeSourceError = (file, importers = []) => formatFarmDiagnostic(
|
|
4124
|
+
createFarmDiagnostic(
|
|
4125
|
+
"CLIENT_ROUTES_FILE",
|
|
4126
|
+
file,
|
|
4127
|
+
"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."
|
|
4128
|
+
),
|
|
4129
|
+
projectRoot
|
|
4130
|
+
);
|
|
3823
4131
|
return {
|
|
3824
4132
|
name: "farm:environment-functions",
|
|
3825
4133
|
enforce: "post",
|
|
@@ -3831,7 +4139,7 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
3831
4139
|
routesFiles = new Set(
|
|
3832
4140
|
getFarmSourceRoots({ ...options, root: options.root ?? config.root }).flatMap(
|
|
3833
4141
|
(source) => PROGRAMMATIC_ROUTE_FILE_NAMES.map(
|
|
3834
|
-
(name) => resolvedFile(
|
|
4142
|
+
(name) => resolvedFile(path8.resolve(source.root, source.srcDir, name))
|
|
3835
4143
|
)
|
|
3836
4144
|
)
|
|
3837
4145
|
);
|
|
@@ -3841,20 +4149,33 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
3841
4149
|
this,
|
|
3842
4150
|
transformOptions?.ssr
|
|
3843
4151
|
);
|
|
3844
|
-
const
|
|
3845
|
-
const result = transformEnvironmentFunctions({ code, id, environment, parse:
|
|
4152
|
+
const parse3 = (source) => this.parse(source);
|
|
4153
|
+
const result = transformEnvironmentFunctions({ code, id, environment, parse: parse3 });
|
|
3846
4154
|
if (environment === "client" && !isBuild && !parseProgrammaticRouteModuleId(id) && routeSourceFiles().has(moduleFile(id)) && !isProgrammaticRouteActionProxy(code)) {
|
|
3847
4155
|
this.error(routeSourceError(moduleFile(id)));
|
|
3848
4156
|
}
|
|
3849
4157
|
if (environment === "server" && resolveFarmServerComponentsMode(options.experimental?.serverComponents) === "islands" && isApplicationScript(id)) {
|
|
3850
4158
|
const file = id.split("?", 1)[0];
|
|
3851
4159
|
const root = realpathSync(options.root ?? projectRoot);
|
|
3852
|
-
const clientCode = getFarmClientReachableModules(root, root).has(
|
|
4160
|
+
const clientCode = getFarmClientReachableModules(root, root).has(path8.resolve(file)) || existsSync(file) && hasUseClientDirective(readFileSync(file, "utf8"));
|
|
3853
4161
|
const reached = clientCode ? null : findFarmClientOnlyImport(code, file);
|
|
3854
4162
|
if (reached) {
|
|
3855
|
-
const chain = reached.chain.map((step) =>
|
|
4163
|
+
const chain = reached.chain.map((step) => path8.relative(root, step).replace(/\\/g, "/")).join(" -> ");
|
|
4164
|
+
const importMatch = new RegExp(
|
|
4165
|
+
String.raw`\b(?:from|import)\s*["']` + reached.specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + `["']`
|
|
4166
|
+
).exec(code);
|
|
4167
|
+
const importAt = importMatch ? importMatch.index + importMatch[0].search(/["']/) : void 0;
|
|
4168
|
+
const locate = createFarmSourceLocator(code, () => this.getCombinedSourcemap());
|
|
3856
4169
|
this.error(
|
|
3857
|
-
|
|
4170
|
+
formatFarmDiagnostic(
|
|
4171
|
+
createFarmDiagnostic(
|
|
4172
|
+
"SERVER_CLIENT_ONLY_IMPORT",
|
|
4173
|
+
file,
|
|
4174
|
+
`This module is server code, but its import of "${reached.specifier}" reaches "client-only" (${chain}), so that package can only run in the browser.`,
|
|
4175
|
+
importAt === void 0 ? void 0 : locate(importAt)
|
|
4176
|
+
),
|
|
4177
|
+
root
|
|
4178
|
+
)
|
|
3858
4179
|
);
|
|
3859
4180
|
}
|
|
3860
4181
|
}
|
|
@@ -3871,7 +4192,14 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
|
|
|
3871
4192
|
});
|
|
3872
4193
|
if (chain) {
|
|
3873
4194
|
this.error(
|
|
3874
|
-
|
|
4195
|
+
formatFarmDiagnostic(
|
|
4196
|
+
createFarmDiagnostic(
|
|
4197
|
+
"CLIENT_ROUTE_SERVER_IMPORT",
|
|
4198
|
+
moduleFile(id),
|
|
4199
|
+
`The browser bundle reaches the server-only module "${chain.at(-1)}" through this programmatic route module: ${chain.map((step) => relativeFile(moduleFile(step))).join(" -> ")}.`
|
|
4200
|
+
),
|
|
4201
|
+
projectRoot
|
|
4202
|
+
)
|
|
3875
4203
|
);
|
|
3876
4204
|
}
|
|
3877
4205
|
continue;
|
|
@@ -4164,8 +4492,10 @@ export {
|
|
|
4164
4492
|
createEvaluatedRouteGraph,
|
|
4165
4493
|
mergeProgrammaticClientRoutes,
|
|
4166
4494
|
generateProgrammaticClientRouteModule,
|
|
4495
|
+
getFarmSourceStamp,
|
|
4167
4496
|
FarmSourceSnapshotStore,
|
|
4168
4497
|
withFarmSourceSnapshot,
|
|
4498
|
+
withFarmSourceSnapshotOf,
|
|
4169
4499
|
traceFarmSourceReads,
|
|
4170
4500
|
rewriteFarmReactServerClientModuleImports,
|
|
4171
4501
|
rewriteFarmReactServerImports,
|
|
@@ -4178,6 +4508,9 @@ export {
|
|
|
4178
4508
|
ensureFarmPackageClientReference,
|
|
4179
4509
|
ensureFarmInternalClientReference,
|
|
4180
4510
|
rewriteFarmPackageClientImports,
|
|
4511
|
+
farmIslandContainerReferencePath,
|
|
4512
|
+
ensureFarmIslandContainerReference,
|
|
4513
|
+
wrapFarmIslandContainers,
|
|
4181
4514
|
withPackageClientBoundaryCache,
|
|
4182
4515
|
usePackageClientBoundaryCacheFile,
|
|
4183
4516
|
resolvePackageClientBoundaryCacheFile,
|
|
@@ -4191,9 +4524,11 @@ export {
|
|
|
4191
4524
|
hasUseClientDirective,
|
|
4192
4525
|
getIslandStrategyExport,
|
|
4193
4526
|
stripUseClientDirective,
|
|
4527
|
+
getFarmClientRenderingBindings,
|
|
4194
4528
|
collectFarmRenderedClientModules,
|
|
4195
4529
|
collectFarmServerStylesheets,
|
|
4196
4530
|
getClientModuleMetadata,
|
|
4531
|
+
getClientModuleHydrationPlanKey,
|
|
4197
4532
|
getClientModuleHydrationPlan,
|
|
4198
4533
|
usesFarmServerTree,
|
|
4199
4534
|
createMarkdownPageHydrationPlanner,
|
|
@@ -4207,6 +4542,9 @@ export {
|
|
|
4207
4542
|
invalidateFarmClientReachableModules,
|
|
4208
4543
|
getFarmClientReachableModules,
|
|
4209
4544
|
resolveFarmClientOptimizeDeps,
|
|
4545
|
+
createFarmDiagnostic,
|
|
4546
|
+
formatFarmDiagnostic,
|
|
4547
|
+
createFarmSourceLocator,
|
|
4210
4548
|
transformEnvironmentFunctions,
|
|
4211
4549
|
farmEnvironmentFunctionsPlugin
|
|
4212
4550
|
};
|