@farm.js/core 0.1.73 → 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-RK7LDYEL.mjs → agent-mcp-handler-HX4F4VKN.mjs} +4 -4
- package/dist/{agent-mcp-handler-VBCA3WZ6.cjs → agent-mcp-handler-NRIL4JBC.cjs} +5 -5
- package/dist/{agent-mcp.d-PvEf-1mi.d.mts → agent-mcp.d-BEhDfdWc.d.mts} +1 -1
- package/dist/{agent-mcp.d-D_gHjCAE.d.ts → agent-mcp.d-CX8_oOT_.d.ts} +1 -1
- package/dist/agent-runtime.cjs +4 -4
- package/dist/agent-runtime.d.mts +4 -4
- package/dist/agent-runtime.d.ts +4 -4
- package/dist/agent-runtime.mjs +3 -3
- package/dist/{analyzer-MFYCJT75.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 +6 -6
- package/dist/api/node.d.ts +6 -6
- package/dist/api/node.mjs +8 -7
- package/dist/api/route-manager.cjs +11 -9
- package/dist/api/route-manager.d.mts +9 -7
- package/dist/api/route-manager.d.ts +9 -7
- package/dist/api/route-manager.mjs +10 -8
- package/dist/api/runtime.cjs +8 -7
- package/dist/api/runtime.d.mts +5 -5
- package/dist/api/runtime.d.ts +5 -5
- 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 +9 -9
- package/dist/api.d.ts +9 -9
- package/dist/api.mjs +12 -10
- package/dist/{app-manifest.d-CN7cEWHX.d.mts → app-manifest.d-BcXt2yCx.d.mts} +10 -1
- package/dist/{app-manifest.d-BpVTg43i.d.ts → app-manifest.d-CVEx1CFB.d.ts} +10 -1
- package/dist/app-markdown.cjs +8 -4
- package/dist/app-markdown.d.mts +6 -6
- package/dist/app-markdown.d.ts +6 -6
- package/dist/app-markdown.mjs +7 -3
- package/dist/{app.d-DO4PTCWm.d.ts → app.d-B6i8CSrx.d.ts} +30 -4
- package/dist/{app.d-BFWzAdTe.d.mts → app.d-DowzSmT5.d.mts} +30 -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-TDCP3Z4T.cjs → chunk-35GBGSQZ.cjs} +3 -3
- package/dist/{chunk-VPETSSWN.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-TAU3OF5B.cjs → chunk-56HHUSR5.cjs} +420 -337
- package/dist/chunk-5XD2ULJG.mjs +114 -0
- package/dist/{chunk-JX5VOLAV.cjs → chunk-65OS2TOT.cjs} +4 -4
- package/dist/{chunk-7GMBETHM.mjs → chunk-6JEXH7N6.mjs} +1 -1
- package/dist/{chunk-TY5KCYDE.mjs → chunk-72NTEYCX.mjs} +10 -3
- package/dist/{chunk-KDOZORJD.cjs → chunk-737MIVX3.cjs} +22 -22
- package/dist/{chunk-ROCF6UQD.cjs → chunk-77SVUQM5.cjs} +74 -17
- package/dist/{chunk-CKQAQFF6.mjs → chunk-7RKHXF4P.mjs} +2 -2
- package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
- package/dist/{chunk-CLEWORVY.cjs → chunk-ACAEFEOH.cjs} +38 -41
- package/dist/{chunk-OBYM5S5G.mjs → chunk-AL6E63FZ.mjs} +2 -2
- package/dist/{chunk-DQ2DI3Y7.mjs → chunk-AO5IRA2N.mjs} +2 -2
- package/dist/{chunk-CYRIIVD4.mjs → chunk-AU5UPNOD.mjs} +2 -2
- package/dist/{chunk-Z3IN6GEX.mjs → chunk-B3XY6FMC.mjs} +69 -12
- package/dist/{chunk-U7VH3Q5E.cjs → chunk-B5WZP3T3.cjs} +15 -2
- package/dist/{chunk-IBVN7SW5.mjs → chunk-BFOMCSZ2.mjs} +292 -120
- 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-B67CW2LM.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-ILQ5DKYF.cjs → chunk-D4TYE6MY.cjs} +2 -2
- package/dist/{chunk-4YHGQDTT.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-ODBM54RT.cjs → chunk-F244KE2D.cjs} +7 -7
- package/dist/{chunk-WW3LRNQV.mjs → chunk-FCBUNILW.mjs} +1 -1
- package/dist/{chunk-GZOKWJIW.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-XUSJVHHD.cjs → chunk-FYV6DTAG.cjs} +738 -485
- 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-JMOCMXTQ.mjs → chunk-IG4IQMIW.mjs} +1 -1
- package/dist/{chunk-GPO3LJDJ.cjs → chunk-IJFNXP3D.cjs} +2 -2
- package/dist/{chunk-FRO4BB2T.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-MJEKMT6B.mjs → chunk-JI6N4W2I.mjs} +125 -42
- 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-462MUII7.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-XI3OXOMK.mjs → chunk-KUMKBBYP.mjs} +1 -1
- package/dist/{chunk-VT25ERQK.mjs → chunk-KWUZJZ23.mjs} +21 -3
- package/dist/{chunk-SVQX5HYW.mjs → chunk-LHFGTR7F.mjs} +2 -2
- package/dist/{chunk-4P5634G6.cjs → chunk-LIQJYEQP.cjs} +14 -9
- package/dist/chunk-LXTYJ2HW.mjs +139 -0
- package/dist/{chunk-5PDMBWAF.cjs → chunk-MKQ27TGW.cjs} +5 -5
- package/dist/{chunk-SUQACHER.mjs → chunk-MQ5HA7H2.mjs} +2 -2
- package/dist/{chunk-HY6IVQ54.mjs → chunk-MUITBU5Z.mjs} +1 -1
- package/dist/{chunk-QKEZLYON.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-HTXKSREF.cjs → chunk-NXGQIXR7.cjs} +345 -173
- package/dist/{chunk-PXAHSCR6.cjs → chunk-O2A6HE76.cjs} +4 -4
- package/dist/{chunk-OAEDVXVE.mjs → chunk-O6K4G7YA.mjs} +5 -2
- package/dist/{chunk-73K53YPP.mjs → chunk-OSKIG4OP.mjs} +1 -1
- package/dist/{chunk-OXNZUCHN.cjs → chunk-P3EZKU6L.cjs} +18 -18
- package/dist/{chunk-HGB4PM2C.cjs → chunk-PG6ZIHKE.cjs} +102 -30
- package/dist/{chunk-YZK64PZT.cjs → chunk-Q3MVNRAO.cjs} +1071 -650
- package/dist/{chunk-AZ6IW6SF.mjs → chunk-Q4G52OSW.mjs} +1 -1
- package/dist/{chunk-TPYAYFMF.cjs → chunk-QL3YZTGZ.cjs} +2 -2
- package/dist/{chunk-UVZMSRHF.mjs → chunk-R4BWNP73.mjs} +2 -2
- package/dist/{chunk-OIP62QEL.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-UVQRMUAR.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-6O6PAZZR.mjs → chunk-UHAARKF3.mjs} +2 -2
- package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
- package/dist/{chunk-KTDG4THT.cjs → chunk-V6T3UJAH.cjs} +7 -7
- package/dist/{chunk-IXZSBO76.mjs → chunk-VFPFXMTF.mjs} +1 -1
- package/dist/{chunk-CPMME66W.mjs → chunk-VKLV7GF4.mjs} +72 -0
- package/dist/{chunk-TU6VAH4V.cjs → chunk-VKRMO3EZ.cjs} +8 -8
- package/dist/chunk-VWIW47FW.cjs +25 -0
- package/dist/{chunk-LGR7565L.cjs → chunk-VZKCGHWC.cjs} +39 -24
- package/dist/{chunk-JWLRBDDC.cjs → chunk-WH3PBJS7.cjs} +2 -2
- package/dist/{chunk-QGCSUC5O.mjs → chunk-WS4SLJW5.mjs} +403 -150
- 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-4CTCSKAF.mjs → chunk-YH33PZ3K.mjs} +1 -1
- package/dist/chunk-YQWRBBAA.mjs +284 -0
- package/dist/{chunk-REK6HZSU.mjs → chunk-YWDRWG4L.mjs} +962 -541
- package/dist/{chunk-E46NXBNJ.mjs → chunk-ZD7JUTBY.mjs} +11 -6
- package/dist/{chunk-JDO346NV.mjs → chunk-ZLRWO5GK.mjs} +1 -1
- package/dist/{chunk-HFUOLILA.cjs → chunk-ZRCGPSUM.cjs} +4 -4
- package/dist/{chunk-4Z3YLMSW.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-sF-Znk0j.d.ts → client-component.d-DYOwmq0c.d.ts} +80 -3
- package/dist/{client-component.d-C71rMuHF.d.mts → client-component.d-edV76QvU.d.mts} +80 -3
- package/dist/{client-plugins.d-MFibjgBg.d.ts → client-plugins.d-BmJYW2FY.d.ts} +19 -6
- package/dist/{client-plugins.d-B-Gd9mWR.d.mts → client-plugins.d-DwvqqGsU.d.mts} +19 -6
- package/dist/client-plugins.d.mts +4 -4
- package/dist/client-plugins.d.ts +4 -4
- package/dist/client.cjs +6 -5
- package/dist/client.d.mts +11 -11
- package/dist/client.d.ts +11 -11
- package/dist/client.mjs +5 -4
- package/dist/config.d.mts +4 -4
- package/dist/config.d.ts +4 -4
- 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 +5 -5
- package/dist/desktop.d.ts +5 -5
- package/dist/{devtools-TDIJ6HVC.mjs → devtools-WPX62NG2.mjs} +10 -9
- package/dist/{devtools-6K4QXFRL.cjs → devtools-YMDS7PUA.cjs} +12 -11
- package/dist/docs.cjs +13 -12
- package/dist/docs.d.mts +5 -5
- package/dist/docs.d.ts +5 -5
- package/dist/docs.mjs +12 -11
- 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-uQ6BR59u.d.ts → headers.d-BIbQyAxJ.d.ts} +1 -1
- package/dist/{headers.d-BUxGJTsj.d.mts → headers.d-BtNxFc2s.d.mts} +1 -1
- package/dist/headers.mjs +2 -2
- package/dist/index.cjs +70 -59
- package/dist/{index.d-BCGfxCXY.d.ts → index.d-CQ_wUzOV.d.ts} +1 -1
- package/dist/{index.d-CuWOJ-un.d.mts → index.d-CQdDRXd1.d.mts} +1 -1
- package/dist/index.d.mts +62 -28
- package/dist/index.d.ts +62 -28
- package/dist/index.mjs +66 -55
- package/dist/integrations/orm.d.mts +4 -4
- package/dist/integrations/orm.d.ts +4 -4
- package/dist/integrations.cjs +4 -4
- package/dist/integrations.d.mts +4 -4
- package/dist/integrations.d.ts +4 -4
- package/dist/integrations.mjs +3 -3
- package/dist/internal/app-markdown-runtime.cjs +7 -3
- 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 +6 -2
- package/dist/internal/build-runtime.cjs +41 -39
- package/dist/internal/build-runtime.d.mts +6 -6
- package/dist/internal/build-runtime.d.ts +6 -6
- package/dist/internal/build-runtime.mjs +40 -38
- package/dist/internal/cli-runtime.cjs +20 -19
- package/dist/internal/cli-runtime.mjs +19 -18
- 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 +21 -9
- package/dist/internal/client-runtime.d.ts +21 -9
- package/dist/internal/client-runtime.mjs +5 -1
- package/dist/internal/compression-runtime.d.mts +4 -4
- package/dist/internal/compression-runtime.d.ts +4 -4
- package/dist/internal/config-runtime.cjs +12 -11
- package/dist/internal/config-runtime.d.mts +6 -6
- package/dist/internal/config-runtime.d.ts +6 -6
- 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 +64 -13
- package/dist/internal/production-runtime.d.ts +64 -13
- 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 +4 -4
- package/dist/markdown.d.ts +4 -4
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.cjs +6 -6
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/middleware.mjs +5 -5
- package/dist/{mount.d-BIYmcGGg.d.mts → mount.d-6bhpBQQB.d.mts} +1 -1
- package/dist/{mount.d-q8k0cJV0.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-OYGKP2NZ.mjs → native-tree-3X23BT3N.mjs} +2 -2
- package/dist/{native-tree-R6CQMDTI.cjs → native-tree-TAPKR7QJ.cjs} +3 -3
- package/dist/{navigation-delegate.d-CYBUupsv.d.mts → navigation-delegate.d-nx6gtsY4.d.mts} +1 -1
- package/dist/{navigation-delegate.d-Btfs6Uoa.d.ts → navigation-delegate.d-xsG4T1x-.d.ts} +1 -1
- package/dist/navigation.cjs +4 -4
- package/dist/navigation.d.mts +7 -7
- package/dist/navigation.d.ts +7 -7
- 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/plugin.cjs +36 -33
- package/dist/plugin.d.mts +7 -7
- package/dist/plugin.d.ts +7 -7
- 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-BlyxqKMu.d.mts → render-plan.d-B5y3h97B.d.mts} +1 -1
- package/dist/{render-plan.d-0FHusf1D.d.ts → render-plan.d-gW0fwKz2.d.ts} +1 -1
- package/dist/renderer-client.cjs +4 -4
- package/dist/renderer-client.d.mts +7 -7
- package/dist/renderer-client.d.ts +7 -7
- package/dist/renderer-client.mjs +1 -1
- package/dist/request.cjs +2 -2
- package/dist/{request.d-CX-gks1l.d.mts → request.d-B0ugAadD.d.ts} +9 -2
- package/dist/{request.d-CPdVjssg.d.ts → request.d-DLq33nYo.d.mts} +9 -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-DSeIV7yV.d.mts} +1 -1
- package/dist/{route-rendering.d-DcOoSNoG.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-D2QnK8cM.d.ts → router.d-BaEAEGPg.d.ts} +1 -1
- package/dist/{router.d-C8RHma4A.d.mts → router.d-Chd5cpe3.d.mts} +1 -1
- package/dist/routes.cjs +5 -3
- package/dist/routes.d.mts +4 -4
- package/dist/routes.d.ts +4 -4
- package/dist/routes.mjs +4 -2
- package/dist/{rsc-pipeline-LC2FBZAR.mjs → rsc-pipeline-DPMYONEV.mjs} +12 -11
- package/dist/{rsc-pipeline-NTAM65NT.cjs → rsc-pipeline-XIUUMMG5.cjs} +13 -12
- package/dist/{runtime-U4PAMTVH.cjs → runtime-WD77S3C5.cjs} +25 -25
- package/dist/{runtime-MWAC7NWR.mjs → runtime-XIUJZTZ3.mjs} +16 -16
- package/dist/{runtime.d-BQUHHq8M.d.mts → runtime.d-DpCs0eAO.d.mts} +3 -3
- package/dist/{runtime.d-1l_1bLrL.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 +53 -9
- package/dist/server-plugins.d.ts +53 -9
- 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 +62 -67
- package/dist/server.d.mts +14 -14
- package/dist/server.d.ts +14 -14
- package/dist/server.mjs +41 -46
- package/dist/{spa-router.d-BzPdi48R.d.mts → spa-router.d-DCQVtEaE.d.mts} +11 -5
- package/dist/{spa-router.d-BJtXNeqo.d.ts → spa-router.d-DpdJHs1q.d.ts} +11 -5
- package/dist/testing.cjs +16 -14
- package/dist/testing.d.mts +4 -4
- package/dist/testing.d.ts +4 -4
- package/dist/testing.mjs +12 -10
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-B4ZW-6z6.d.mts → utils.d-DKDZtAY5.d.mts} +1 -1
- package/dist/{utils.d-DquC6qxy.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 +36 -33
- package/dist/vite.d.mts +13 -8
- package/dist/vite.d.ts +13 -8
- package/dist/vite.mjs +35 -32
- package/package.json +1 -1
- package/dist/analyzer-V5ZMRIIY.cjs +0 -16
- package/dist/chunk-6I4BFRE7.cjs +0 -51
- package/dist/chunk-EIVGPQN5.mjs +0 -51
- /package/dist/{chunk-QEJWNXRI.cjs → chunk-EMRYJG4U.cjs} +0 -0
- /package/dist/{chunk-TXE4SAMV.mjs → chunk-H2ZJ35NW.mjs} +0 -0
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
collectFarmNativeServerFns,
|
|
28
28
|
findFarmNativeScreenFiles
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6JEXH7N6.mjs";
|
|
30
30
|
import {
|
|
31
31
|
generateNativeMCPPluginSource
|
|
32
32
|
} from "./chunk-KQH2COEJ.mjs";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
hasFarmDocsRuntimeAdapter,
|
|
42
42
|
listFarmDocsAdapterPages,
|
|
43
43
|
listFarmDocsPagePaths
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-AU5UPNOD.mjs";
|
|
45
45
|
import {
|
|
46
46
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
47
47
|
createFarmDocsHandler,
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
loadFarmDocsPage,
|
|
55
55
|
resolveFarmDocsContentDir,
|
|
56
56
|
toFarmDocsMarkdownPage
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-OSKIG4OP.mjs";
|
|
58
58
|
import {
|
|
59
59
|
generateFarmDocsSearchClientRuntime,
|
|
60
60
|
isFarmDocsSearchEnabled,
|
|
@@ -62,10 +62,10 @@ import {
|
|
|
62
62
|
} from "./chunk-ALEUMLJN.mjs";
|
|
63
63
|
import {
|
|
64
64
|
CDN_CACHE_CONTROL_HEADERS
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-O6K4G7YA.mjs";
|
|
66
66
|
import {
|
|
67
67
|
FARM_PRERENDER_ENV
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-B3XY6FMC.mjs";
|
|
69
69
|
import {
|
|
70
70
|
loadFarmDocsEngine
|
|
71
71
|
} from "./chunk-LRPPXKCX.mjs";
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
getDeployTargetForPreset,
|
|
75
75
|
hasCustomFarmRouteContext,
|
|
76
76
|
resolveDeployOutputPath
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-JZ43UD6S.mjs";
|
|
78
78
|
import {
|
|
79
79
|
resolveFarmInstrumentationFile
|
|
80
80
|
} from "./chunk-57QAQU4F.mjs";
|
|
@@ -110,20 +110,21 @@ import {
|
|
|
110
110
|
resolveFarmImageServerRuntime,
|
|
111
111
|
resolveFarmNotFoundComponentPath,
|
|
112
112
|
resolveFarmRouteRootStrategy
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-JI6N4W2I.mjs";
|
|
114
114
|
import {
|
|
115
115
|
generateFarmClientPluginEntryCode,
|
|
116
116
|
hasFarmServerRuntimePlugins,
|
|
117
117
|
loadTailwindVitePlugin
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-BIX46FTI.mjs";
|
|
119
119
|
import {
|
|
120
120
|
PluginManager
|
|
121
121
|
} from "./chunk-Z5ZZAGIH.mjs";
|
|
122
122
|
import {
|
|
123
123
|
generateFarmTypeArtifacts,
|
|
124
124
|
readRouteRenderingDirectiveFromFile,
|
|
125
|
+
resolveRouteRenderingConfig,
|
|
125
126
|
resolveRouteRenderingConfigFromFile
|
|
126
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-CF77L6RL.mjs";
|
|
127
128
|
import {
|
|
128
129
|
HOISTED_HEAD_ELEMENT,
|
|
129
130
|
appMiddlewareMayHandlePath,
|
|
@@ -136,7 +137,7 @@ import {
|
|
|
136
137
|
layoutsCanCoverSamePage,
|
|
137
138
|
routeBoundaryCoversDirectory,
|
|
138
139
|
stripRouteGroups
|
|
139
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-LHFGTR7F.mjs";
|
|
140
141
|
import {
|
|
141
142
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
142
143
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -150,15 +151,15 @@ import {
|
|
|
150
151
|
listFarmBuiltInRoutePaths,
|
|
151
152
|
resolveFarmApiCatalogInput,
|
|
152
153
|
resolveFarmAppManifestInput
|
|
153
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-FEQ72ZHD.mjs";
|
|
154
155
|
import {
|
|
155
156
|
FARM_DEFAULT_MCP_PATH,
|
|
156
157
|
createFarmDefaultMCPServer,
|
|
157
158
|
farmConfigMountsMCP
|
|
158
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-R4BWNP73.mjs";
|
|
159
160
|
import {
|
|
160
161
|
isFarmPreviewDeploymentEnvironment
|
|
161
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-VFPFXMTF.mjs";
|
|
162
163
|
import {
|
|
163
164
|
FARM_NATIVE_SERVER_FN_PLUGIN
|
|
164
165
|
} from "./chunk-L4RTTTVE.mjs";
|
|
@@ -169,6 +170,7 @@ import {
|
|
|
169
170
|
enforceFarmIsolatedHydrationRouteBudget,
|
|
170
171
|
farmEnvironmentFunctionsPlugin,
|
|
171
172
|
getClientModuleHydrationPlan,
|
|
173
|
+
getClientModuleHydrationPlanKey,
|
|
172
174
|
getClientModuleMetadata,
|
|
173
175
|
getFarmClientHydrationPlanOptions,
|
|
174
176
|
resolveFarmIsolatedClientHydrationMode,
|
|
@@ -176,8 +178,9 @@ import {
|
|
|
176
178
|
usePackageClientBoundaryCacheFile,
|
|
177
179
|
usesFarmServerTree,
|
|
178
180
|
withFarmSourceSnapshot,
|
|
181
|
+
withFarmSourceSnapshotOf,
|
|
179
182
|
withPackageClientBoundaryCache
|
|
180
|
-
} from "./chunk-
|
|
183
|
+
} from "./chunk-BFOMCSZ2.mjs";
|
|
181
184
|
import {
|
|
182
185
|
generateFarmDocsAdapterClientRuntime,
|
|
183
186
|
getFarmDocsAdapterConfigModule
|
|
@@ -214,24 +217,28 @@ import {
|
|
|
214
217
|
applyFarmCronVercelCrons,
|
|
215
218
|
createFarmCronCloudflareConfig,
|
|
216
219
|
mergeScheduledTasks,
|
|
217
|
-
prepareFarmCronForNitro
|
|
218
|
-
|
|
220
|
+
prepareFarmCronForNitro,
|
|
221
|
+
toFarmCronCloudflareScheduledTasks
|
|
222
|
+
} from "./chunk-FGXSWRWA.mjs";
|
|
219
223
|
import {
|
|
220
224
|
resolveServerActionsConfig
|
|
221
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-ZD7JUTBY.mjs";
|
|
222
226
|
import {
|
|
223
227
|
createBundledEnv
|
|
224
228
|
} from "./chunk-N33DLJBC.mjs";
|
|
225
229
|
import {
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
FARM_MARKDOWN_PRECOMPILED_PAGES,
|
|
231
|
+
isFarmMarkdownPageFile,
|
|
232
|
+
parseMarkdownFrontmatter,
|
|
233
|
+
readFarmMarkdownRouteConfig
|
|
234
|
+
} from "./chunk-R6Q6VSGU.mjs";
|
|
228
235
|
import {
|
|
229
236
|
resolveFarmMdxComponentsModulePath,
|
|
230
237
|
resolveMdxConfig
|
|
231
238
|
} from "./chunk-UIJOLBUL.mjs";
|
|
232
239
|
import {
|
|
233
240
|
getFarmMarkdownAlternatePath
|
|
234
|
-
} from "./chunk-
|
|
241
|
+
} from "./chunk-VKLV7GF4.mjs";
|
|
235
242
|
import {
|
|
236
243
|
withPlainDiagnostics
|
|
237
244
|
} from "./chunk-MGKWYPE3.mjs";
|
|
@@ -242,7 +249,7 @@ import {
|
|
|
242
249
|
import {
|
|
243
250
|
getFarmIntegrationPluginServerRuntime,
|
|
244
251
|
getIntegrationProviders
|
|
245
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-FCBUNILW.mjs";
|
|
246
253
|
import {
|
|
247
254
|
FARM_INTEGRATION_API_BASE_PATH_KEY
|
|
248
255
|
} from "./chunk-M53MIIXY.mjs";
|
|
@@ -256,7 +263,7 @@ import {
|
|
|
256
263
|
} from "./chunk-MMK4MZUN.mjs";
|
|
257
264
|
import {
|
|
258
265
|
APIRouteManager
|
|
259
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-X2KNHD4B.mjs";
|
|
260
267
|
import {
|
|
261
268
|
readFarmI18nCatalogs
|
|
262
269
|
} from "./chunk-VO55MMBX.mjs";
|
|
@@ -284,7 +291,7 @@ import {
|
|
|
284
291
|
} from "./chunk-2I6PUKWJ.mjs";
|
|
285
292
|
import {
|
|
286
293
|
FARM_VERSION
|
|
287
|
-
} from "./chunk-
|
|
294
|
+
} from "./chunk-IG4IQMIW.mjs";
|
|
288
295
|
import {
|
|
289
296
|
getFarmPresetRuntime,
|
|
290
297
|
resolveCloudflareProcessEnvFlags
|
|
@@ -294,7 +301,7 @@ import {
|
|
|
294
301
|
} from "./chunk-4O26BPUY.mjs";
|
|
295
302
|
import {
|
|
296
303
|
_runWithFarmCspNonce
|
|
297
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-WTTJ2YS2.mjs";
|
|
298
305
|
import {
|
|
299
306
|
applyFarmBasePath,
|
|
300
307
|
normalizeFarmBasePath,
|
|
@@ -307,8 +314,8 @@ import {
|
|
|
307
314
|
} from "./chunk-AYP2YFVN.mjs";
|
|
308
315
|
|
|
309
316
|
// src/build/index.ts
|
|
310
|
-
import
|
|
311
|
-
import { existsSync as
|
|
317
|
+
import path16 from "path";
|
|
318
|
+
import { existsSync as existsSync4 } from "fs";
|
|
312
319
|
|
|
313
320
|
// src/nitro/universal-build.ts
|
|
314
321
|
import { randomBytes } from "crypto";
|
|
@@ -319,15 +326,15 @@ var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
|
319
326
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
320
327
|
var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
|
|
321
328
|
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
322
|
-
const
|
|
329
|
+
const fs5 = await import("fs/promises");
|
|
323
330
|
try {
|
|
324
|
-
const bytes = await
|
|
331
|
+
const bytes = await fs5.readFile(sourcePath);
|
|
325
332
|
if (bytes.length === 0) return null;
|
|
326
333
|
const { createHash } = await import("crypto");
|
|
327
334
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
328
335
|
const name = hashedName(hash);
|
|
329
|
-
await
|
|
330
|
-
await
|
|
336
|
+
await fs5.mkdir(destinationDir, { recursive: true });
|
|
337
|
+
await fs5.writeFile(path.join(destinationDir, name), bytes);
|
|
331
338
|
return name;
|
|
332
339
|
} catch {
|
|
333
340
|
return null;
|
|
@@ -342,18 +349,18 @@ async function resolveHashedClientCssHref(clientOutputDir) {
|
|
|
342
349
|
return name ? `/assets/${name}` : "/farm-client.css";
|
|
343
350
|
}
|
|
344
351
|
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
345
|
-
const
|
|
352
|
+
const fs5 = await import("fs/promises");
|
|
346
353
|
try {
|
|
347
|
-
const entries = await
|
|
354
|
+
const entries = await fs5.readdir(clientOutputDir);
|
|
348
355
|
return entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)) ?? null;
|
|
349
356
|
} catch {
|
|
350
357
|
return null;
|
|
351
358
|
}
|
|
352
359
|
}
|
|
353
360
|
async function resolveClientBootSrc(clientOutputDir) {
|
|
354
|
-
const
|
|
361
|
+
const fs5 = await import("fs/promises");
|
|
355
362
|
try {
|
|
356
|
-
const entries = await
|
|
363
|
+
const entries = await fs5.readdir(clientOutputDir);
|
|
357
364
|
const name = entries.find((entry) => /^farm-client-boot-h[0-9a-f]+\.js$/.test(entry));
|
|
358
365
|
return name ? `/${name}` : null;
|
|
359
366
|
} catch {
|
|
@@ -363,17 +370,18 @@ async function resolveClientBootSrc(clientOutputDir) {
|
|
|
363
370
|
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
364
371
|
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
365
372
|
if (!entryName) return "/farm-client.js";
|
|
366
|
-
const
|
|
373
|
+
const fs5 = await import("fs/promises");
|
|
367
374
|
const shim = `export * from "./${entryName}";
|
|
368
375
|
`;
|
|
369
|
-
await
|
|
376
|
+
await fs5.writeFile(path.join(clientOutputDir, "farm-client.js"), shim);
|
|
370
377
|
return `/${entryName}`;
|
|
371
378
|
}
|
|
372
379
|
|
|
373
380
|
// src/nitro/universal-build.ts
|
|
374
381
|
import os from "os";
|
|
375
|
-
import
|
|
376
|
-
import { constants as fsConstants, existsSync as
|
|
382
|
+
import path15 from "path";
|
|
383
|
+
import { constants as fsConstants, existsSync as existsSync3, readFileSync, realpathSync as realpathSync2, statSync } from "fs";
|
|
384
|
+
import { initSync as initModuleLexer, parse as lexModule } from "es-module-lexer";
|
|
377
385
|
import { fileURLToPath } from "url";
|
|
378
386
|
import { builtinModules, createRequire as createRequire2 } from "module";
|
|
379
387
|
import { isDeepStrictEqual } from "util";
|
|
@@ -636,12 +644,51 @@ async function readFarmClientModulePreloads(buildDir) {
|
|
|
636
644
|
}
|
|
637
645
|
}
|
|
638
646
|
function encodeFarmClientModulePreloads(manifest) {
|
|
639
|
-
return
|
|
647
|
+
return encodeFarmBuildJSONPlaceholder(manifest);
|
|
648
|
+
}
|
|
649
|
+
function encodeFarmBuildJSONPlaceholder(value) {
|
|
650
|
+
return JSON.stringify(JSON.stringify(value)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
640
651
|
}
|
|
641
652
|
|
|
642
|
-
// src/
|
|
653
|
+
// src/nitro/client-route-table.ts
|
|
643
654
|
import fs2 from "fs/promises";
|
|
644
655
|
import path4 from "path";
|
|
656
|
+
var FARM_CLIENT_ROUTE_TABLE_MODULE = "farm-client-routes";
|
|
657
|
+
var FARM_CLIENT_ROUTE_TABLE_FILE = "client-route-table.json";
|
|
658
|
+
var FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER = "__farm_client_route_table__";
|
|
659
|
+
function createFarmClientRouteTable(clientPages) {
|
|
660
|
+
let loaders = 0;
|
|
661
|
+
return clientPages.map((page) => ({
|
|
662
|
+
pattern: page.pattern,
|
|
663
|
+
...page.directory ? { directory: page.directory } : {},
|
|
664
|
+
pageShouldHydrate: page.pageShouldHydrate,
|
|
665
|
+
...page.docs ? { docs: true } : {},
|
|
666
|
+
...page.hasIsolatedClientBoundaries ? { hasIsolatedClientBoundaries: true } : {},
|
|
667
|
+
islandStrategy: page.islandStrategy,
|
|
668
|
+
...page.pageShouldHydrate ? { loader: loaders++ } : {}
|
|
669
|
+
}));
|
|
670
|
+
}
|
|
671
|
+
function generateFarmClientRouteTableModule(table) {
|
|
672
|
+
return `export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
|
|
673
|
+
`;
|
|
674
|
+
}
|
|
675
|
+
async function writeFarmClientRouteTable(buildDir, table) {
|
|
676
|
+
await fs2.mkdir(buildDir, { recursive: true });
|
|
677
|
+
await fs2.writeFile(path4.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), JSON.stringify(table));
|
|
678
|
+
}
|
|
679
|
+
async function readFarmClientRouteTable(buildDir) {
|
|
680
|
+
try {
|
|
681
|
+
return JSON.parse(
|
|
682
|
+
await fs2.readFile(path4.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), "utf8")
|
|
683
|
+
);
|
|
684
|
+
} catch {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// src/docs/module-preloads.ts
|
|
690
|
+
import fs3 from "fs/promises";
|
|
691
|
+
import path5 from "path";
|
|
645
692
|
var FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER = "__farm_docs_module_preloads__";
|
|
646
693
|
var FARM_DOCS_MODULE_PRELOADS_FILE = "docs-module-preloads.json";
|
|
647
694
|
function normalizeModuleId(id) {
|
|
@@ -677,7 +724,7 @@ function collectFarmDocsModulePreloads(bundle, options) {
|
|
|
677
724
|
return value;
|
|
678
725
|
};
|
|
679
726
|
const pages = {};
|
|
680
|
-
const root = normalizeModuleId(
|
|
727
|
+
const root = normalizeModuleId(path5.resolve(options.root));
|
|
681
728
|
for (const [moduleId, chunk] of byModule) {
|
|
682
729
|
if (!/\.mdx?$/.test(moduleId) || !moduleId.startsWith(`${root}/`)) continue;
|
|
683
730
|
const own = [...withStaticImports(chunk.fileName, /* @__PURE__ */ new Set())].filter(
|
|
@@ -705,9 +752,9 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
705
752
|
entryName: options.entryName,
|
|
706
753
|
runtimeModuleIds
|
|
707
754
|
});
|
|
708
|
-
await
|
|
709
|
-
await
|
|
710
|
-
|
|
755
|
+
await fs3.mkdir(options.buildDir, { recursive: true });
|
|
756
|
+
await fs3.writeFile(
|
|
757
|
+
path5.join(options.buildDir, FARM_DOCS_MODULE_PRELOADS_FILE),
|
|
711
758
|
JSON.stringify(manifest)
|
|
712
759
|
);
|
|
713
760
|
}
|
|
@@ -716,7 +763,7 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
716
763
|
async function readFarmDocsModulePreloads(buildDir) {
|
|
717
764
|
try {
|
|
718
765
|
return JSON.parse(
|
|
719
|
-
await
|
|
766
|
+
await fs3.readFile(path5.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
|
|
720
767
|
);
|
|
721
768
|
} catch {
|
|
722
769
|
return null;
|
|
@@ -727,10 +774,10 @@ function encodeFarmDocsModulePreloads(manifest) {
|
|
|
727
774
|
}
|
|
728
775
|
|
|
729
776
|
// src/route-runtime-manifest.ts
|
|
730
|
-
import
|
|
777
|
+
import path6 from "path";
|
|
731
778
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
732
779
|
async function createFarmRouteRuntimeManifest(options) {
|
|
733
|
-
const root =
|
|
780
|
+
const root = path6.resolve(options.root || options.config.root || process.cwd());
|
|
734
781
|
const routes = [];
|
|
735
782
|
for (const [pattern, entry] of options.routeManager.getRoutes()) {
|
|
736
783
|
const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
|
|
@@ -799,10 +846,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
799
846
|
};
|
|
800
847
|
}
|
|
801
848
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
802
|
-
const
|
|
803
|
-
const manifestPath =
|
|
804
|
-
await
|
|
805
|
-
await
|
|
849
|
+
const fs5 = await import("fs/promises");
|
|
850
|
+
const manifestPath = path6.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
851
|
+
await fs5.mkdir(directory, { recursive: true });
|
|
852
|
+
await fs5.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
806
853
|
`);
|
|
807
854
|
return manifestPath;
|
|
808
855
|
}
|
|
@@ -838,13 +885,13 @@ function normalizeManifestSource(root, modulePath) {
|
|
|
838
885
|
const queryIndex = modulePath.indexOf("?");
|
|
839
886
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
840
887
|
const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
|
|
841
|
-
const relativePath =
|
|
888
|
+
const relativePath = path6.isAbsolute(filePath) ? path6.relative(root, filePath) : filePath;
|
|
842
889
|
return `${relativePath.replace(/\\/g, "/")}${query}`;
|
|
843
890
|
}
|
|
844
891
|
|
|
845
892
|
// src/nitro/vercel-route-runtime.ts
|
|
846
|
-
import
|
|
847
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
893
|
+
import path7 from "path";
|
|
894
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, basePath = "/") {
|
|
848
895
|
const dynamicRoutes = manifest.routes.filter(
|
|
849
896
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
850
897
|
);
|
|
@@ -863,8 +910,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
|
|
|
863
910
|
group.routes.push(route);
|
|
864
911
|
groups.set(key, group);
|
|
865
912
|
}
|
|
866
|
-
const functionsDir =
|
|
867
|
-
const baseFunctionDir =
|
|
913
|
+
const functionsDir = path7.join(outputDir, "functions");
|
|
914
|
+
const baseFunctionDir = path7.join(functionsDir, "__nitro.func");
|
|
868
915
|
const destinations = /* @__PURE__ */ new Map();
|
|
869
916
|
let groupIndex = 0;
|
|
870
917
|
for (const [key, group] of groups) {
|
|
@@ -874,9 +921,9 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
|
|
|
874
921
|
}
|
|
875
922
|
groupIndex += 1;
|
|
876
923
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
877
|
-
const functionDir =
|
|
878
|
-
await
|
|
879
|
-
await configureVercelFunction(functionDir, group.config,
|
|
924
|
+
const functionDir = path7.join(functionsDir, `${functionName}.func`);
|
|
925
|
+
await fs5.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
926
|
+
await configureVercelFunction(functionDir, group.config, fs5);
|
|
880
927
|
destinations.set(key, `/${functionName}`);
|
|
881
928
|
}
|
|
882
929
|
const routes = [];
|
|
@@ -913,15 +960,15 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
913
960
|
if (!normalizedBasePath) return source || "/";
|
|
914
961
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
915
962
|
}
|
|
916
|
-
async function configureVercelFunction(functionDir, config,
|
|
917
|
-
const configPath =
|
|
918
|
-
const current = JSON.parse(await
|
|
963
|
+
async function configureVercelFunction(functionDir, config, fs5) {
|
|
964
|
+
const configPath = path7.join(functionDir, ".vc-config.json");
|
|
965
|
+
const current = JSON.parse(await fs5.readFile(configPath, "utf8"));
|
|
919
966
|
const next = {
|
|
920
967
|
...current,
|
|
921
968
|
...config.regions?.length ? { regions: config.regions } : {},
|
|
922
969
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
923
970
|
};
|
|
924
|
-
await
|
|
971
|
+
await fs5.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
925
972
|
`);
|
|
926
973
|
}
|
|
927
974
|
function hasVercelFunctionControls(route) {
|
|
@@ -958,7 +1005,7 @@ function escapeRegExp(value) {
|
|
|
958
1005
|
}
|
|
959
1006
|
|
|
960
1007
|
// src/nitro/immutable-assets.ts
|
|
961
|
-
import
|
|
1008
|
+
import path8 from "path";
|
|
962
1009
|
var FARM_IMMUTABLE_ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
963
1010
|
var FARM_IMMUTABLE_ASSET_MAX_AGE = 31536e3;
|
|
964
1011
|
var FARM_IMMUTABLE_ASSET_PATH_SOURCE = "^/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-(?:mobile-)?client(?:-boot)?)-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$";
|
|
@@ -993,7 +1040,7 @@ function planFarmImmutableAssets(options) {
|
|
|
993
1040
|
for (const [dir, files] of dirFiles) {
|
|
994
1041
|
if (!routeDirs.has(dir) && files.every(isImmutable)) {
|
|
995
1042
|
plan.publicAssets.push({
|
|
996
|
-
dir:
|
|
1043
|
+
dir: path8.join(options.clientOutputDir, dir),
|
|
997
1044
|
baseURL: `/${dir}`,
|
|
998
1045
|
maxAge: FARM_IMMUTABLE_ASSET_MAX_AGE
|
|
999
1046
|
});
|
|
@@ -1004,11 +1051,11 @@ function planFarmImmutableAssets(options) {
|
|
|
1004
1051
|
return plan;
|
|
1005
1052
|
}
|
|
1006
1053
|
async function listFarmClientOutputFiles(dir) {
|
|
1007
|
-
const
|
|
1008
|
-
const entries = await
|
|
1054
|
+
const fs5 = await import("fs/promises");
|
|
1055
|
+
const entries = await fs5.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
|
|
1009
1056
|
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
1010
|
-
const relative =
|
|
1011
|
-
return `/${relative.split(
|
|
1057
|
+
const relative = path8.relative(dir, path8.join(entry.parentPath, entry.name));
|
|
1058
|
+
return `/${relative.split(path8.sep).join("/")}`;
|
|
1012
1059
|
});
|
|
1013
1060
|
}
|
|
1014
1061
|
|
|
@@ -1081,7 +1128,7 @@ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
|
|
|
1081
1128
|
}
|
|
1082
1129
|
|
|
1083
1130
|
// src/nitro/ssr-public-assets.ts
|
|
1084
|
-
import
|
|
1131
|
+
import path9 from "path";
|
|
1085
1132
|
var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
1086
1133
|
function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
1087
1134
|
if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
|
|
@@ -1090,8 +1137,8 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
|
1090
1137
|
relativePath = decodeURI(relativePath);
|
|
1091
1138
|
} catch {
|
|
1092
1139
|
}
|
|
1093
|
-
const fileName =
|
|
1094
|
-
|
|
1140
|
+
const fileName = path9.posix.normalize(
|
|
1141
|
+
path9.posix.join(path9.posix.dirname(chunkFileName), relativePath)
|
|
1095
1142
|
);
|
|
1096
1143
|
return fileName.startsWith("../") ? null : fileName;
|
|
1097
1144
|
}
|
|
@@ -1135,7 +1182,7 @@ function collectServerOnlySSRAssets(bundle) {
|
|
|
1135
1182
|
}
|
|
1136
1183
|
}
|
|
1137
1184
|
for (const fileName of serverOnly) {
|
|
1138
|
-
const name =
|
|
1185
|
+
const name = path9.posix.basename(fileName);
|
|
1139
1186
|
if (publicReferenceSources.some((source) => source.includes(name))) {
|
|
1140
1187
|
serverOnly.delete(fileName);
|
|
1141
1188
|
}
|
|
@@ -1153,7 +1200,7 @@ function assertServerReadSSRAssetsSupported(bundle, preset, root) {
|
|
|
1153
1200
|
const output = bundle[fileName];
|
|
1154
1201
|
const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
|
|
1155
1202
|
if (!original) return fileName;
|
|
1156
|
-
return
|
|
1203
|
+
return path9.relative(root, path9.resolve(root, original)).split(path9.sep).join("/");
|
|
1157
1204
|
});
|
|
1158
1205
|
throw new Error(
|
|
1159
1206
|
`The "${preset}" preset cannot run server code that imports ${sources.join(", ")}. Server code reads such a file from beside the server bundle, and this edge runtime deploys no such file (Cloudflare Workers and Vercel Edge also refuse to compile WebAssembly from bytes). Load it in the browser instead, from client code with the @farm.js/wasm plugin or a "?url" import, or deploy to a Node target such as node-server, bun, vercel or netlify.`
|
|
@@ -1169,7 +1216,7 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1169
1216
|
},
|
|
1170
1217
|
transform(code, id) {
|
|
1171
1218
|
if (!code.includes("import.meta.url")) return null;
|
|
1172
|
-
const chunkFileName =
|
|
1219
|
+
const chunkFileName = path9.relative(ssrOutputDir, id.split("?", 1)[0]).split(path9.sep).join("/");
|
|
1173
1220
|
if (bundle[chunkFileName]?.type !== "chunk") return null;
|
|
1174
1221
|
let changed = false;
|
|
1175
1222
|
const transformed = replaceServerFileReferences(
|
|
@@ -1197,10 +1244,10 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1197
1244
|
|
|
1198
1245
|
// src/nitro/netlify-entry.ts
|
|
1199
1246
|
import { existsSync } from "fs";
|
|
1200
|
-
import
|
|
1247
|
+
import path10 from "path";
|
|
1201
1248
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
1202
|
-
const entry =
|
|
1203
|
-
|
|
1249
|
+
const entry = path10.join(
|
|
1250
|
+
path10.dirname(nitroRuntimeEntry),
|
|
1204
1251
|
"..",
|
|
1205
1252
|
"presets",
|
|
1206
1253
|
"netlify",
|
|
@@ -1212,7 +1259,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
1212
1259
|
`[Farm.js] Could not find Nitro's Netlify function entry at ${entry}. Farm wraps it so private responses are never cached by Netlify's CDN; reinstall dependencies or report the installed Nitro version.`
|
|
1213
1260
|
);
|
|
1214
1261
|
}
|
|
1215
|
-
return entry.split(
|
|
1262
|
+
return entry.split(path10.sep).join("/");
|
|
1216
1263
|
}
|
|
1217
1264
|
function createFarmNetlifyEntry(options) {
|
|
1218
1265
|
return `
|
|
@@ -1262,7 +1309,7 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
1262
1309
|
|
|
1263
1310
|
// src/build/strip-platform-config.ts
|
|
1264
1311
|
import { realpathSync } from "fs";
|
|
1265
|
-
import
|
|
1312
|
+
import path11 from "path";
|
|
1266
1313
|
var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
|
|
1267
1314
|
var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
|
|
1268
1315
|
function isConfigObject(node) {
|
|
@@ -1336,11 +1383,11 @@ function realPath(file) {
|
|
|
1336
1383
|
try {
|
|
1337
1384
|
return realpathSync(file);
|
|
1338
1385
|
} catch {
|
|
1339
|
-
return
|
|
1386
|
+
return path11.resolve(file);
|
|
1340
1387
|
}
|
|
1341
1388
|
}
|
|
1342
1389
|
function farmStripPlatformConfigPlugin(configFiles) {
|
|
1343
|
-
const files = new Set(configFiles.flatMap((file) => [
|
|
1390
|
+
const files = new Set(configFiles.flatMap((file) => [path11.resolve(file), realPath(file)]));
|
|
1344
1391
|
return {
|
|
1345
1392
|
name: "farm:strip-platform-config",
|
|
1346
1393
|
// Before the TypeScript transform, so its import elision also drops imports only the
|
|
@@ -1350,9 +1397,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1350
1397
|
filter: { id: fileNamePattern(configFiles) },
|
|
1351
1398
|
async handler(code, id) {
|
|
1352
1399
|
const file = id.split("?", 1)[0];
|
|
1353
|
-
if (!files.has(
|
|
1400
|
+
if (!files.has(path11.resolve(file)) && !files.has(realPath(file))) return null;
|
|
1354
1401
|
const { parseAst } = await import("rolldown/parseAst");
|
|
1355
|
-
const extension =
|
|
1402
|
+
const extension = path11.extname(file).slice(1);
|
|
1356
1403
|
const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
|
|
1357
1404
|
const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
|
|
1358
1405
|
return stripped === null ? null : { code: stripped, map: null };
|
|
@@ -1361,9 +1408,62 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1361
1408
|
};
|
|
1362
1409
|
}
|
|
1363
1410
|
|
|
1411
|
+
// src/build/markdown-precompile.ts
|
|
1412
|
+
import { existsSync as existsSync2 } from "fs";
|
|
1413
|
+
import path12 from "path";
|
|
1414
|
+
import { pathToFileURL } from "url";
|
|
1415
|
+
import { Worker } from "worker_threads";
|
|
1416
|
+
var WORKER_SOURCE = `
|
|
1417
|
+
const { parentPort, workerData } = require("node:worker_threads");
|
|
1418
|
+
import(workerData.runtime).then(async ({ compileFarmMarkdownPage }) => {
|
|
1419
|
+
const pages = [];
|
|
1420
|
+
for (const body of workerData.bodies) {
|
|
1421
|
+
try {
|
|
1422
|
+
pages.push([body, await compileFarmMarkdownPage(body)]);
|
|
1423
|
+
} catch {}
|
|
1424
|
+
}
|
|
1425
|
+
parentPort.postMessage(pages);
|
|
1426
|
+
});
|
|
1427
|
+
`;
|
|
1428
|
+
function precompileFarmMarkdownPages(bodies, coreRoot) {
|
|
1429
|
+
const runtime = coreRoot ? path12.join(coreRoot, "dist", "internal", "app-markdown-runtime.mjs") : null;
|
|
1430
|
+
if (bodies.length === 0 || !runtime || !existsSync2(runtime)) {
|
|
1431
|
+
return { pages: Promise.resolve(/* @__PURE__ */ new Map()), dispose() {
|
|
1432
|
+
} };
|
|
1433
|
+
}
|
|
1434
|
+
let worker;
|
|
1435
|
+
const pages = new Promise((resolve) => {
|
|
1436
|
+
const done = (entries = []) => {
|
|
1437
|
+
worker = void 0;
|
|
1438
|
+
resolve(new Map(entries));
|
|
1439
|
+
};
|
|
1440
|
+
try {
|
|
1441
|
+
worker = new Worker(WORKER_SOURCE, {
|
|
1442
|
+
eval: true,
|
|
1443
|
+
workerData: { runtime: pathToFileURL(runtime).href, bodies: [...new Set(bodies)] }
|
|
1444
|
+
});
|
|
1445
|
+
} catch {
|
|
1446
|
+
done();
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
worker.once("message", (entries) => {
|
|
1450
|
+
void worker?.terminate();
|
|
1451
|
+
done(entries);
|
|
1452
|
+
});
|
|
1453
|
+
worker.once("error", () => done());
|
|
1454
|
+
worker.once("exit", () => done());
|
|
1455
|
+
});
|
|
1456
|
+
return {
|
|
1457
|
+
pages,
|
|
1458
|
+
dispose() {
|
|
1459
|
+
void worker?.terminate();
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1364
1464
|
// src/nitro/client-sourcemaps.ts
|
|
1365
|
-
import
|
|
1366
|
-
import
|
|
1465
|
+
import fs4 from "fs/promises";
|
|
1466
|
+
import path13 from "path";
|
|
1367
1467
|
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
1368
1468
|
function resolveFarmClientSourcemap(sourcemap) {
|
|
1369
1469
|
return sourcemap ? "hidden" : false;
|
|
@@ -1382,11 +1482,11 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
|
1382
1482
|
}
|
|
1383
1483
|
},
|
|
1384
1484
|
async writeBundle() {
|
|
1385
|
-
await
|
|
1485
|
+
await fs4.rm(options.outDir, { recursive: true, force: true });
|
|
1386
1486
|
for (const [fileName, source] of maps) {
|
|
1387
|
-
const target =
|
|
1388
|
-
await
|
|
1389
|
-
await
|
|
1487
|
+
const target = path13.join(options.outDir, fileName);
|
|
1488
|
+
await fs4.mkdir(path13.dirname(target), { recursive: true });
|
|
1489
|
+
await fs4.writeFile(target, source);
|
|
1390
1490
|
}
|
|
1391
1491
|
}
|
|
1392
1492
|
};
|
|
@@ -1468,7 +1568,7 @@ async function readMiddlewareFileConfig(filePath) {
|
|
|
1468
1568
|
|
|
1469
1569
|
// src/nitro/vercel-edge-middleware.ts
|
|
1470
1570
|
import { createRequire, isBuiltin } from "module";
|
|
1471
|
-
import
|
|
1571
|
+
import path14 from "path";
|
|
1472
1572
|
import { gzipSync } from "zlib";
|
|
1473
1573
|
var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
|
|
1474
1574
|
var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
|
|
@@ -1522,22 +1622,22 @@ ${modules.join("\n")}
|
|
|
1522
1622
|
});
|
|
1523
1623
|
`;
|
|
1524
1624
|
}
|
|
1525
|
-
async function resolveFarmCoreDir(root,
|
|
1526
|
-
const runtimeEntry = createRequire(
|
|
1625
|
+
async function resolveFarmCoreDir(root, fs5) {
|
|
1626
|
+
const runtimeEntry = createRequire(path14.join(root, "package.json")).resolve(
|
|
1527
1627
|
"@farm.js/core/internal/vercel-edge-middleware"
|
|
1528
1628
|
);
|
|
1529
|
-
return
|
|
1629
|
+
return fs5.realpath(path14.resolve(path14.dirname(runtimeEntry), "..", ".."));
|
|
1530
1630
|
}
|
|
1531
1631
|
function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
1532
1632
|
const streamStub = "\0farm-edge-node-stream";
|
|
1533
|
-
const corePrefix = coreDir +
|
|
1633
|
+
const corePrefix = coreDir + path14.sep;
|
|
1534
1634
|
return {
|
|
1535
1635
|
name: "farm-vercel-edge-node-modules",
|
|
1536
1636
|
resolveId(source, importer) {
|
|
1537
1637
|
if (!isBuiltin(source)) return null;
|
|
1538
1638
|
const name = source.replace(/^node:/, "").split("/")[0];
|
|
1539
1639
|
if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
|
|
1540
|
-
if (name === "stream" && importer &&
|
|
1640
|
+
if (name === "stream" && importer && path14.resolve(importer).startsWith(corePrefix)) {
|
|
1541
1641
|
return streamStub;
|
|
1542
1642
|
}
|
|
1543
1643
|
unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
|
|
@@ -1550,20 +1650,20 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
|
1550
1650
|
};
|
|
1551
1651
|
}
|
|
1552
1652
|
async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
1553
|
-
const { root, outputDir, buildDir, config, routes, guardedPages, fs:
|
|
1554
|
-
const functionDir =
|
|
1653
|
+
const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs5 } = options;
|
|
1654
|
+
const functionDir = path14.join(
|
|
1555
1655
|
outputDir,
|
|
1556
1656
|
"functions",
|
|
1557
1657
|
`${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
|
|
1558
1658
|
);
|
|
1559
|
-
const entryPath =
|
|
1560
|
-
await
|
|
1561
|
-
await
|
|
1659
|
+
const entryPath = path14.join(buildDir, "vercel-edge-middleware-entry.mjs");
|
|
1660
|
+
await fs5.mkdir(path14.dirname(entryPath), { recursive: true });
|
|
1661
|
+
await fs5.writeFile(
|
|
1562
1662
|
entryPath,
|
|
1563
1663
|
generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
|
|
1564
1664
|
);
|
|
1565
1665
|
const unsupported = /* @__PURE__ */ new Set();
|
|
1566
|
-
const coreDir = await resolveFarmCoreDir(root,
|
|
1666
|
+
const coreDir = await resolveFarmCoreDir(root, fs5);
|
|
1567
1667
|
const { rolldown } = await import("rolldown");
|
|
1568
1668
|
let code;
|
|
1569
1669
|
try {
|
|
@@ -1595,7 +1695,7 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
|
1595
1695
|
} catch (error) {
|
|
1596
1696
|
throw withPlainDiagnostics(error);
|
|
1597
1697
|
} finally {
|
|
1598
|
-
await
|
|
1698
|
+
await fs5.rm(entryPath, { force: true });
|
|
1599
1699
|
}
|
|
1600
1700
|
if (unsupported.size > 0) {
|
|
1601
1701
|
throw new Error(
|
|
@@ -1604,11 +1704,11 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
|
1604
1704
|
Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(", ")}), or remove runtime: "edge" so the middleware runs in the server and its pages render on request.`
|
|
1605
1705
|
);
|
|
1606
1706
|
}
|
|
1607
|
-
await
|
|
1608
|
-
await
|
|
1609
|
-
await
|
|
1610
|
-
await
|
|
1611
|
-
|
|
1707
|
+
await fs5.rm(functionDir, { recursive: true, force: true });
|
|
1708
|
+
await fs5.mkdir(functionDir, { recursive: true });
|
|
1709
|
+
await fs5.writeFile(path14.join(functionDir, "index.js"), code);
|
|
1710
|
+
await fs5.writeFile(
|
|
1711
|
+
path14.join(functionDir, ".vc-config.json"),
|
|
1612
1712
|
`${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
|
|
1613
1713
|
`
|
|
1614
1714
|
);
|
|
@@ -1626,11 +1726,11 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
|
|
|
1626
1726
|
// src/nitro/universal-build.ts
|
|
1627
1727
|
var FARM_NATIVE_STYLESHEETS_PLACEHOLDER = "__FARM_NATIVE_STYLESHEETS__";
|
|
1628
1728
|
async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
|
|
1629
|
-
const
|
|
1729
|
+
const fs5 = await import("fs/promises");
|
|
1630
1730
|
try {
|
|
1631
1731
|
return {
|
|
1632
|
-
[clientCssHref]: await
|
|
1633
|
-
|
|
1732
|
+
[clientCssHref]: await fs5.readFile(
|
|
1733
|
+
path15.join(clientOutputDir, clientCssHref.slice(1)),
|
|
1634
1734
|
"utf8"
|
|
1635
1735
|
)
|
|
1636
1736
|
};
|
|
@@ -1645,18 +1745,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1645
1745
|
);
|
|
1646
1746
|
}
|
|
1647
1747
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1648
|
-
var _dirname =
|
|
1748
|
+
var _dirname = path15.dirname(_filename);
|
|
1649
1749
|
function findFarmCoreRoot(from) {
|
|
1650
|
-
let dir =
|
|
1651
|
-
while (dir !==
|
|
1652
|
-
const manifest =
|
|
1653
|
-
if (
|
|
1750
|
+
let dir = path15.dirname(from);
|
|
1751
|
+
while (dir !== path15.dirname(dir)) {
|
|
1752
|
+
const manifest = path15.join(dir, "package.json");
|
|
1753
|
+
if (existsSync3(manifest)) {
|
|
1654
1754
|
try {
|
|
1655
1755
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1656
1756
|
} catch {
|
|
1657
1757
|
}
|
|
1658
1758
|
}
|
|
1659
|
-
dir =
|
|
1759
|
+
dir = path15.dirname(dir);
|
|
1660
1760
|
}
|
|
1661
1761
|
return null;
|
|
1662
1762
|
}
|
|
@@ -1666,16 +1766,16 @@ function toModulePath(file) {
|
|
|
1666
1766
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1667
1767
|
}
|
|
1668
1768
|
function findInstalledPackageDir(name, from) {
|
|
1669
|
-
for (let dir = from; ; dir =
|
|
1670
|
-
const candidate =
|
|
1671
|
-
if (
|
|
1769
|
+
for (let dir = from; ; dir = path15.dirname(dir)) {
|
|
1770
|
+
const candidate = path15.join(dir, "node_modules", name);
|
|
1771
|
+
if (existsSync3(path15.join(candidate, "package.json"))) {
|
|
1672
1772
|
try {
|
|
1673
1773
|
return realpathSync2(candidate);
|
|
1674
1774
|
} catch {
|
|
1675
1775
|
return null;
|
|
1676
1776
|
}
|
|
1677
1777
|
}
|
|
1678
|
-
if (dir ===
|
|
1778
|
+
if (dir === path15.dirname(dir)) return null;
|
|
1679
1779
|
}
|
|
1680
1780
|
}
|
|
1681
1781
|
function collectFarmDependencyDirs(root) {
|
|
@@ -1686,7 +1786,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1686
1786
|
seen.add(dir);
|
|
1687
1787
|
let manifest;
|
|
1688
1788
|
try {
|
|
1689
|
-
manifest = JSON.parse(readFileSync(
|
|
1789
|
+
manifest = JSON.parse(readFileSync(path15.join(dir, "package.json"), "utf8"));
|
|
1690
1790
|
} catch {
|
|
1691
1791
|
return;
|
|
1692
1792
|
}
|
|
@@ -1697,7 +1797,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1697
1797
|
if (farmCoreRoot) visit(realpathSync2(farmCoreRoot));
|
|
1698
1798
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1699
1799
|
try {
|
|
1700
|
-
const manifest = JSON.parse(readFileSync(
|
|
1800
|
+
const manifest = JSON.parse(readFileSync(path15.join(root, "package.json"), "utf8"));
|
|
1701
1801
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1702
1802
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1703
1803
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1764,17 +1864,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1764
1864
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1765
1865
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1766
1866
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1767
|
-
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1867
|
+
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path15.sep).join("/");
|
|
1768
1868
|
}
|
|
1769
1869
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1770
1870
|
const nitroEntry = resolveNitroPackageEntry(root);
|
|
1771
|
-
const runtimeDir =
|
|
1871
|
+
const runtimeDir = path15.dirname(nitroEntry);
|
|
1772
1872
|
const nitroRequire = createRequire2(nitroEntry);
|
|
1773
1873
|
return {
|
|
1774
1874
|
...Object.fromEntries(
|
|
1775
1875
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1776
1876
|
`#nitro/runtime/${moduleName}`,
|
|
1777
|
-
|
|
1877
|
+
path15.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path15.sep).join("/")
|
|
1778
1878
|
])
|
|
1779
1879
|
),
|
|
1780
1880
|
// Farm's generated workflow and cron wrappers live under `.farm/` and
|
|
@@ -1783,18 +1883,31 @@ function resolveNitroInternalRuntimeAliases(root) {
|
|
|
1783
1883
|
...Object.fromEntries(
|
|
1784
1884
|
["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
|
|
1785
1885
|
specifier,
|
|
1786
|
-
nitroRequire.resolve(specifier).split(
|
|
1886
|
+
nitroRequire.resolve(specifier).split(path15.sep).join("/")
|
|
1787
1887
|
])
|
|
1788
1888
|
)
|
|
1789
1889
|
};
|
|
1790
1890
|
}
|
|
1891
|
+
function createPrerenderMarkdownPagesPlugin(pages) {
|
|
1892
|
+
return {
|
|
1893
|
+
name: "farm-prerender-markdown-pages",
|
|
1894
|
+
async banner(chunk) {
|
|
1895
|
+
if (!chunk.isEntry) return "";
|
|
1896
|
+
const compiled = await pages;
|
|
1897
|
+
if (compiled.size === 0) return "";
|
|
1898
|
+
return `globalThis[Symbol.for(${JSON.stringify(
|
|
1899
|
+
FARM_MARKDOWN_PRECOMPILED_PAGES.description
|
|
1900
|
+
)})] = new Map(${JSON.stringify([...compiled])});`;
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1791
1904
|
function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveNitroPackageEntry) {
|
|
1792
1905
|
let nitroEntry;
|
|
1793
1906
|
return {
|
|
1794
1907
|
name: "farm-prerender-runtime-resolver",
|
|
1795
1908
|
async resolveId(id, _importer, options) {
|
|
1796
1909
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1797
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1910
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path15.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1798
1911
|
return null;
|
|
1799
1912
|
}
|
|
1800
1913
|
if (nitroEntry === void 0) {
|
|
@@ -1817,7 +1930,7 @@ function createFarmStorageModuleRegistration(config) {
|
|
|
1817
1930
|
const modules = _collectFarmStorageModules(config.storage);
|
|
1818
1931
|
if (modules.length === 0) return "";
|
|
1819
1932
|
const root = config.root || process.cwd();
|
|
1820
|
-
const projectRequire = createRequire2(
|
|
1933
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
1821
1934
|
let runtimeRequire = projectRequire;
|
|
1822
1935
|
try {
|
|
1823
1936
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1844,7 +1957,7 @@ ${loaders.join("\n")}
|
|
|
1844
1957
|
});` : "";
|
|
1845
1958
|
}
|
|
1846
1959
|
function resolveNitroPackageEntry(root) {
|
|
1847
|
-
const projectRequire = createRequire2(
|
|
1960
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
1848
1961
|
let runtimeRequire = projectRequire;
|
|
1849
1962
|
try {
|
|
1850
1963
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1914,7 +2027,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1914
2027
|
}
|
|
1915
2028
|
function hasReactDomEdgeServerBuild(root) {
|
|
1916
2029
|
try {
|
|
1917
|
-
createRequire2(
|
|
2030
|
+
createRequire2(path15.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1918
2031
|
return true;
|
|
1919
2032
|
} catch {
|
|
1920
2033
|
return false;
|
|
@@ -1945,17 +2058,17 @@ function isNitroRollupExternal(id) {
|
|
|
1945
2058
|
var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
|
|
1946
2059
|
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
1947
2060
|
function isFarmCoreModule(file) {
|
|
1948
|
-
let dir =
|
|
1949
|
-
while (dir !==
|
|
1950
|
-
const manifest =
|
|
1951
|
-
if (
|
|
2061
|
+
let dir = path15.dirname(file.split("?", 1)[0]);
|
|
2062
|
+
while (dir !== path15.dirname(dir)) {
|
|
2063
|
+
const manifest = path15.join(dir, "package.json");
|
|
2064
|
+
if (existsSync3(manifest)) {
|
|
1952
2065
|
try {
|
|
1953
2066
|
return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
|
|
1954
2067
|
} catch {
|
|
1955
2068
|
return false;
|
|
1956
2069
|
}
|
|
1957
2070
|
}
|
|
1958
|
-
dir =
|
|
2071
|
+
dir = path15.dirname(dir);
|
|
1959
2072
|
}
|
|
1960
2073
|
return false;
|
|
1961
2074
|
}
|
|
@@ -1966,7 +2079,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
|
1966
2079
|
filter: { id: exactIdPattern(["@vercel/og"]) },
|
|
1967
2080
|
handler(source, importer) {
|
|
1968
2081
|
if (source !== "@vercel/og") return null;
|
|
1969
|
-
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(
|
|
2082
|
+
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path15.basename(importer.split("?", 1)[0]));
|
|
1970
2083
|
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
1971
2084
|
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
1972
2085
|
}
|
|
@@ -1987,14 +2100,14 @@ export class ImageResponse {
|
|
|
1987
2100
|
};
|
|
1988
2101
|
}
|
|
1989
2102
|
function readVercelOgManifest(file) {
|
|
1990
|
-
let dir =
|
|
1991
|
-
while (dir !==
|
|
1992
|
-
const manifestPath =
|
|
1993
|
-
if (
|
|
2103
|
+
let dir = path15.dirname(file.split("?", 1)[0]);
|
|
2104
|
+
while (dir !== path15.dirname(dir)) {
|
|
2105
|
+
const manifestPath = path15.join(dir, "package.json");
|
|
2106
|
+
if (existsSync3(manifestPath)) {
|
|
1994
2107
|
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
1995
2108
|
return manifest.name === "@vercel/og" ? { dir, manifest } : null;
|
|
1996
2109
|
}
|
|
1997
|
-
dir =
|
|
2110
|
+
dir = path15.dirname(dir);
|
|
1998
2111
|
}
|
|
1999
2112
|
return null;
|
|
2000
2113
|
}
|
|
@@ -2002,7 +2115,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
|
|
|
2002
2115
|
const vercelOg = readVercelOgManifest(resolvedId);
|
|
2003
2116
|
const entry = vercelOg?.manifest.exports?.["."]?.[condition];
|
|
2004
2117
|
const file = typeof entry === "string" ? entry : entry?.default;
|
|
2005
|
-
return vercelOg && typeof file === "string" ?
|
|
2118
|
+
return vercelOg && typeof file === "string" ? path15.join(vercelOg.dir, file) : null;
|
|
2006
2119
|
}
|
|
2007
2120
|
function createEdgeMetadataImageRuntimePlugin({
|
|
2008
2121
|
condition,
|
|
@@ -2020,7 +2133,7 @@ function createEdgeMetadataImageRuntimePlugin({
|
|
|
2020
2133
|
if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
2021
2134
|
return null;
|
|
2022
2135
|
}
|
|
2023
|
-
const resolvedPath =
|
|
2136
|
+
const resolvedPath = path15.resolve(path15.dirname(importer.split("?", 1)[0]), source);
|
|
2024
2137
|
return { id: toPosixPath(resolvedPath), external: "absolute" };
|
|
2025
2138
|
}
|
|
2026
2139
|
};
|
|
@@ -2035,7 +2148,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
|
|
|
2035
2148
|
return null;
|
|
2036
2149
|
}
|
|
2037
2150
|
const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
|
|
2038
|
-
const encoded = readFileSync(
|
|
2151
|
+
const encoded = readFileSync(path15.resolve(path15.dirname(file), request)).toString("base64");
|
|
2039
2152
|
return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
|
|
2040
2153
|
});
|
|
2041
2154
|
if (inlined !== code) return { code: inlined, map: null };
|
|
@@ -2054,7 +2167,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
2054
2167
|
return null;
|
|
2055
2168
|
}
|
|
2056
2169
|
const requestPath = source.slice(0, -"?module".length);
|
|
2057
|
-
const resolvedPath =
|
|
2170
|
+
const resolvedPath = path15.isAbsolute(requestPath) ? requestPath : path15.resolve(path15.dirname(importer.split("?", 1)[0]), requestPath);
|
|
2058
2171
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
2059
2172
|
},
|
|
2060
2173
|
load(id) {
|
|
@@ -2079,11 +2192,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2079
2192
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
2080
2193
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
2081
2194
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
2082
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
2195
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path15.posix.normalize(path15.posix.join(path15.posix.dirname(fileName), normalizedImportId)) : null;
|
|
2083
2196
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
2084
2197
|
continue;
|
|
2085
2198
|
}
|
|
2086
|
-
if (
|
|
2199
|
+
if (path15.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
2087
2200
|
externalPackages.add(importId);
|
|
2088
2201
|
continue;
|
|
2089
2202
|
}
|
|
@@ -2095,15 +2208,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2095
2208
|
return externalPackages;
|
|
2096
2209
|
}
|
|
2097
2210
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
2098
|
-
const resolvedNitroEntry =
|
|
2099
|
-
const resolvedSSREntry =
|
|
2211
|
+
const resolvedNitroEntry = path15.resolve(nitroEntryPath);
|
|
2212
|
+
const resolvedSSREntry = path15.resolve(ssrOutputDir, ssrEntryFile);
|
|
2100
2213
|
return {
|
|
2101
2214
|
name: "farm-externalize-prebuilt-ssr",
|
|
2102
2215
|
resolveId(source, importer) {
|
|
2103
|
-
if (!importer ||
|
|
2216
|
+
if (!importer || path15.resolve(importer) !== resolvedNitroEntry) {
|
|
2104
2217
|
return null;
|
|
2105
2218
|
}
|
|
2106
|
-
const resolvedImport =
|
|
2219
|
+
const resolvedImport = path15.resolve(path15.dirname(importer), source);
|
|
2107
2220
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
2108
2221
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
2109
2222
|
}
|
|
@@ -2152,37 +2265,42 @@ async function minifyFarmServerChunk(code, fileName, options) {
|
|
|
2152
2265
|
}
|
|
2153
2266
|
return restoreLiteralModuleSpecifiers(result.code, fileName, rolldownUtils);
|
|
2154
2267
|
}
|
|
2268
|
+
var moduleLexerReady = false;
|
|
2269
|
+
function lexDynamicImportArguments(code) {
|
|
2270
|
+
if (!moduleLexerReady) {
|
|
2271
|
+
initModuleLexer();
|
|
2272
|
+
moduleLexerReady = true;
|
|
2273
|
+
}
|
|
2274
|
+
try {
|
|
2275
|
+
return lexModule(code)[0].filter((entry) => entry.d > -1).map((entry) => ({ start: entry.s, end: entry.e }));
|
|
2276
|
+
} catch {
|
|
2277
|
+
return null;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2155
2280
|
function restoreLiteralModuleSpecifiers(code, fileName, { parseSync, Visitor }) {
|
|
2156
2281
|
const hasImportTemplate = code.includes("import(`");
|
|
2157
2282
|
const hasRequireTemplate = code.includes("require(`");
|
|
2158
2283
|
if (!hasImportTemplate && !hasRequireTemplate) return code;
|
|
2159
|
-
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
2160
|
-
if (parsed.errors.length > 0) {
|
|
2161
|
-
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
2162
|
-
}
|
|
2163
2284
|
const replacements = [];
|
|
2164
2285
|
let needsAst = hasRequireTemplate && /(?<![\w$])require\(`/.test(code);
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
}
|
|
2177
|
-
replacements.push({
|
|
2178
|
-
start: moduleRequest.start,
|
|
2179
|
-
end: moduleRequest.end,
|
|
2180
|
-
text: toAsciiStringLiteral(value)
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2286
|
+
const dynamicImports = needsAst ? null : lexDynamicImportArguments(code);
|
|
2287
|
+
if (!dynamicImports) needsAst = true;
|
|
2288
|
+
for (const { start, end } of dynamicImports ?? []) {
|
|
2289
|
+
const source = code.slice(start, end);
|
|
2290
|
+
if (!source.startsWith("`")) continue;
|
|
2291
|
+
const value = source.slice(1, -1);
|
|
2292
|
+
if (source.length < 2 || !source.endsWith("`") || /[\\\r\n`]|\$\{/.test(value)) {
|
|
2293
|
+
needsAst = true;
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2296
|
+
replacements.push({ start, end, text: toAsciiStringLiteral(value) });
|
|
2183
2297
|
}
|
|
2184
2298
|
if (needsAst) {
|
|
2185
2299
|
replacements.length = 0;
|
|
2300
|
+
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
2301
|
+
if (parsed.errors.length > 0) {
|
|
2302
|
+
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
2303
|
+
}
|
|
2186
2304
|
const restore = (node) => {
|
|
2187
2305
|
if (node?.type !== "TemplateLiteral") return;
|
|
2188
2306
|
const template = node;
|
|
@@ -2236,14 +2354,14 @@ function trimSlashes(value) {
|
|
|
2236
2354
|
function resolveBuildDocsContentDir(docs, root, srcDir) {
|
|
2237
2355
|
const configuredContentDir = docs.contentDir || docs.config.contentDir;
|
|
2238
2356
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
2239
|
-
const contentDir =
|
|
2240
|
-
return
|
|
2357
|
+
const contentDir = path15.isAbsolute(configuredContentDir) ? configuredContentDir : path15.join(root, configuredContentDir);
|
|
2358
|
+
return existsSync3(contentDir) ? contentDir : null;
|
|
2241
2359
|
}
|
|
2242
2360
|
const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
|
|
2243
|
-
const appDocsDir =
|
|
2244
|
-
if (
|
|
2245
|
-
const rootDocsDir =
|
|
2246
|
-
return
|
|
2361
|
+
const appDocsDir = path15.join(root, srcDir || "src", "app", entryDir);
|
|
2362
|
+
if (existsSync3(appDocsDir)) return appDocsDir;
|
|
2363
|
+
const rootDocsDir = path15.join(root, entryDir);
|
|
2364
|
+
return existsSync3(rootDocsDir) ? rootDocsDir : null;
|
|
2247
2365
|
}
|
|
2248
2366
|
function hasProjectPostcssConfig(root) {
|
|
2249
2367
|
const candidates = [
|
|
@@ -2259,7 +2377,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2259
2377
|
".postcssrc.mjs",
|
|
2260
2378
|
".postcssrc.ts"
|
|
2261
2379
|
];
|
|
2262
|
-
const projectRequire = createRequire2(
|
|
2380
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
2263
2381
|
return candidates.some((file) => {
|
|
2264
2382
|
try {
|
|
2265
2383
|
projectRequire.resolve(`./${file}`);
|
|
@@ -2270,7 +2388,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2270
2388
|
});
|
|
2271
2389
|
}
|
|
2272
2390
|
async function findFarmConfigPath(root) {
|
|
2273
|
-
const
|
|
2391
|
+
const fs5 = await import("fs/promises");
|
|
2274
2392
|
const candidates = [
|
|
2275
2393
|
"farm.config.ts",
|
|
2276
2394
|
"farm.config.mts",
|
|
@@ -2282,9 +2400,9 @@ async function findFarmConfigPath(root) {
|
|
|
2282
2400
|
"config.mjs"
|
|
2283
2401
|
];
|
|
2284
2402
|
for (const candidate of candidates) {
|
|
2285
|
-
const resolvedPath =
|
|
2403
|
+
const resolvedPath = path15.join(root, candidate);
|
|
2286
2404
|
try {
|
|
2287
|
-
await
|
|
2405
|
+
await fs5.access(resolvedPath);
|
|
2288
2406
|
return resolvedPath;
|
|
2289
2407
|
} catch {
|
|
2290
2408
|
}
|
|
@@ -2302,13 +2420,13 @@ function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
|
2302
2420
|
);
|
|
2303
2421
|
}
|
|
2304
2422
|
async function discoverMiddlewareRoutes(appDir) {
|
|
2305
|
-
const
|
|
2423
|
+
const fs5 = await import("fs/promises");
|
|
2306
2424
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
2307
2425
|
const routes = /* @__PURE__ */ new Map();
|
|
2308
2426
|
async function walk(dir, routePath, directory, discovered) {
|
|
2309
2427
|
let entries;
|
|
2310
2428
|
try {
|
|
2311
|
-
entries = await
|
|
2429
|
+
entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2312
2430
|
} catch {
|
|
2313
2431
|
return;
|
|
2314
2432
|
}
|
|
@@ -2319,7 +2437,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2319
2437
|
discovered.push({
|
|
2320
2438
|
path: routePath,
|
|
2321
2439
|
directory,
|
|
2322
|
-
filePath:
|
|
2440
|
+
filePath: path15.join(dir, middlewareFile.name)
|
|
2323
2441
|
});
|
|
2324
2442
|
}
|
|
2325
2443
|
for (const entry of entries) {
|
|
@@ -2327,7 +2445,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2327
2445
|
continue;
|
|
2328
2446
|
}
|
|
2329
2447
|
await walk(
|
|
2330
|
-
|
|
2448
|
+
path15.join(dir, entry.name),
|
|
2331
2449
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
2332
2450
|
appendMiddlewareDirectory(directory, entry.name),
|
|
2333
2451
|
discovered
|
|
@@ -2365,6 +2483,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2365
2483
|
logger.info(`\u{1F69C} Building Farm.js application (universal) with preset: ${preset}...`);
|
|
2366
2484
|
const rendererBuild = options.rendererBuildLifetime ? void 0 : new AbortController();
|
|
2367
2485
|
const rendererBuildLifetime = options.rendererBuildLifetime ?? rendererBuild.signal;
|
|
2486
|
+
let markdownPrecompile;
|
|
2368
2487
|
try {
|
|
2369
2488
|
const routeRuntimeManifestPromise = options.routeRuntimeManifest ? Promise.resolve(options.routeRuntimeManifest) : createFarmRouteRuntimeManifest({
|
|
2370
2489
|
config,
|
|
@@ -2386,6 +2505,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2386
2505
|
} : {}
|
|
2387
2506
|
});
|
|
2388
2507
|
}
|
|
2508
|
+
markdownPrecompile = precompileFarmMarkdownPages(
|
|
2509
|
+
collectFarmPrerenderedMarkdownBodies(pageRoutes),
|
|
2510
|
+
farmCoreRoot
|
|
2511
|
+
);
|
|
2389
2512
|
const routeSlots = Array.from(
|
|
2390
2513
|
routeManager.getRouteSlots().values(),
|
|
2391
2514
|
(entry) => ({
|
|
@@ -2400,21 +2523,21 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2400
2523
|
})
|
|
2401
2524
|
);
|
|
2402
2525
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
2403
|
-
const
|
|
2526
|
+
const fs5 = await import("fs/promises");
|
|
2404
2527
|
const layoutRoutes = [];
|
|
2405
|
-
const appDir =
|
|
2528
|
+
const appDir = path15.join(root, srcDir, "app");
|
|
2406
2529
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
2407
2530
|
try {
|
|
2408
|
-
const entries = await
|
|
2531
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2409
2532
|
for (const entry of entries) {
|
|
2410
2533
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
2411
2534
|
layoutRoutes.push({
|
|
2412
2535
|
pattern: routePrefix,
|
|
2413
|
-
modulePath:
|
|
2536
|
+
modulePath: path15.join(dir, entry.name)
|
|
2414
2537
|
});
|
|
2415
2538
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
2416
2539
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
2417
|
-
await findLayoutsForClient(
|
|
2540
|
+
await findLayoutsForClient(path15.join(dir, entry.name), childPrefix);
|
|
2418
2541
|
}
|
|
2419
2542
|
}
|
|
2420
2543
|
} catch {
|
|
@@ -2437,8 +2560,9 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2437
2560
|
${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
2438
2561
|
);
|
|
2439
2562
|
}
|
|
2440
|
-
const hydrationPlanCache =
|
|
2441
|
-
const
|
|
2563
|
+
const hydrationPlanCache = routeManager.getRouteModuleHydrationPlans();
|
|
2564
|
+
const sourceSnapshot = routeManager.takeBuildSourceSnapshot();
|
|
2565
|
+
const clientOutputDir = path15.join(root, distDir, "client");
|
|
2442
2566
|
const [productionViteResult] = await productionViteResultPromise;
|
|
2443
2567
|
if (productionViteResult.status === "rejected") {
|
|
2444
2568
|
await routeRuntimeManifestResultPromise;
|
|
@@ -2450,8 +2574,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2450
2574
|
const rendererDisabled = isFarmRendererDisabled(config.renderer);
|
|
2451
2575
|
const buildClientBundle = async () => {
|
|
2452
2576
|
if (rendererDisabled) {
|
|
2453
|
-
await
|
|
2454
|
-
await
|
|
2577
|
+
await fs5.rm(clientOutputDir, { recursive: true, force: true });
|
|
2578
|
+
await fs5.mkdir(clientOutputDir, { recursive: true });
|
|
2455
2579
|
return;
|
|
2456
2580
|
}
|
|
2457
2581
|
return buildClient(
|
|
@@ -2467,7 +2591,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2467
2591
|
hydrationPlanCache,
|
|
2468
2592
|
rendererBuildLifetime,
|
|
2469
2593
|
routeManager.getProgrammaticClientRoutes(),
|
|
2470
|
-
mobileClient
|
|
2594
|
+
mobileClient,
|
|
2595
|
+
sourceSnapshot
|
|
2471
2596
|
);
|
|
2472
2597
|
};
|
|
2473
2598
|
const buildSSRBundle = () => buildSSRInMemory(
|
|
@@ -2483,7 +2608,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2483
2608
|
routeSlots,
|
|
2484
2609
|
isolatedClientBoundaryModules,
|
|
2485
2610
|
hydrationPlanCache,
|
|
2486
|
-
rendererBuildLifetime
|
|
2611
|
+
rendererBuildLifetime,
|
|
2612
|
+
sourceSnapshot
|
|
2487
2613
|
);
|
|
2488
2614
|
let clientBuildResult;
|
|
2489
2615
|
let ssrBuildResult;
|
|
@@ -2524,7 +2650,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2524
2650
|
hydrationPlanCache,
|
|
2525
2651
|
rendererBuildLifetime,
|
|
2526
2652
|
routeManager.getProgrammaticClientRoutes(),
|
|
2527
|
-
mobileClient
|
|
2653
|
+
mobileClient,
|
|
2654
|
+
sourceSnapshot
|
|
2528
2655
|
);
|
|
2529
2656
|
} catch (retryError) {
|
|
2530
2657
|
if (!(retryError instanceof IncompleteClientBuildOutputError)) throw retryError;
|
|
@@ -2533,6 +2660,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2533
2660
|
);
|
|
2534
2661
|
}
|
|
2535
2662
|
}
|
|
2663
|
+
sourceSnapshot?.clear();
|
|
2536
2664
|
const ssrResult = ssrBuildResult.value;
|
|
2537
2665
|
const routeRuntimeManifest = routeRuntimeManifestResult.value;
|
|
2538
2666
|
const runtimeValidation = validateFarmRouteRuntimeDeployment(routeRuntimeManifest, preset);
|
|
@@ -2560,13 +2688,14 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2560
2688
|
routeRuntimeManifest,
|
|
2561
2689
|
configuredHeaderRoutes,
|
|
2562
2690
|
nitroBuilderResultPromise,
|
|
2563
|
-
lifecyclePluginManager
|
|
2691
|
+
lifecyclePluginManager,
|
|
2692
|
+
markdownPrecompile?.pages
|
|
2564
2693
|
);
|
|
2565
2694
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
2566
|
-
|
|
2695
|
+
path15.join(root, distDir),
|
|
2567
2696
|
routeRuntimeManifest
|
|
2568
2697
|
);
|
|
2569
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
2698
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path15.relative(root, runtimeManifestPath)}`);
|
|
2570
2699
|
} catch (error) {
|
|
2571
2700
|
if (lifecyclePluginManager) {
|
|
2572
2701
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -2582,8 +2711,22 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2582
2711
|
throw error;
|
|
2583
2712
|
} finally {
|
|
2584
2713
|
rendererBuild?.abort();
|
|
2714
|
+
markdownPrecompile?.dispose();
|
|
2585
2715
|
}
|
|
2586
2716
|
}
|
|
2717
|
+
function collectFarmPrerenderedMarkdownBodies(pageRoutes) {
|
|
2718
|
+
const bodies = [];
|
|
2719
|
+
for (const route of pageRoutes) {
|
|
2720
|
+
if (route.source === void 0 || !isFarmMarkdownPageFile(route.modulePath)) continue;
|
|
2721
|
+
const { body } = parseMarkdownFrontmatter(route.source);
|
|
2722
|
+
const rendering = resolveRouteRenderingConfig(
|
|
2723
|
+
readFarmMarkdownRouteConfig(body),
|
|
2724
|
+
route.source
|
|
2725
|
+
);
|
|
2726
|
+
if (rendering.ssg && rendering.revalidate === void 0) bodies.push(body);
|
|
2727
|
+
}
|
|
2728
|
+
return bodies;
|
|
2729
|
+
}
|
|
2587
2730
|
function shouldBuildFarmMobileClient(config) {
|
|
2588
2731
|
return Boolean(config.mobileClient) && !config.desktop;
|
|
2589
2732
|
}
|
|
@@ -2602,7 +2745,7 @@ function varyFarmNitroCacheRules(rules, headerNames) {
|
|
|
2602
2745
|
);
|
|
2603
2746
|
}
|
|
2604
2747
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
2605
|
-
const
|
|
2748
|
+
const fs5 = await import("fs/promises");
|
|
2606
2749
|
const serverOnlyAssets = collectServerOnlySSRAssets(bundle);
|
|
2607
2750
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
2608
2751
|
if (output.type !== "asset" || serverOnlyAssets.has(fileName)) continue;
|
|
@@ -2610,41 +2753,41 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
2610
2753
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
2611
2754
|
continue;
|
|
2612
2755
|
}
|
|
2613
|
-
const filePath =
|
|
2614
|
-
await
|
|
2615
|
-
await
|
|
2756
|
+
const filePath = path15.join(outputDir, fileName);
|
|
2757
|
+
await fs5.mkdir(path15.dirname(filePath), { recursive: true });
|
|
2758
|
+
await fs5.writeFile(filePath, output.source);
|
|
2616
2759
|
}
|
|
2617
2760
|
}
|
|
2618
2761
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
2619
|
-
const
|
|
2762
|
+
const fs5 = await import("fs/promises");
|
|
2620
2763
|
await Promise.all(
|
|
2621
2764
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
2622
|
-
const targetPath =
|
|
2623
|
-
await
|
|
2624
|
-
await
|
|
2765
|
+
const targetPath = path15.join(outputDir, url.replace(/^\/+/, ""));
|
|
2766
|
+
await fs5.mkdir(path15.dirname(targetPath), { recursive: true });
|
|
2767
|
+
await fs5.copyFile(sourcePath, targetPath);
|
|
2625
2768
|
})
|
|
2626
2769
|
);
|
|
2627
2770
|
}
|
|
2628
2771
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
2629
|
-
const
|
|
2630
|
-
const fontCssPath =
|
|
2772
|
+
const fs5 = await import("fs/promises");
|
|
2773
|
+
const fontCssPath = path15.join(outputDir, "farm-fonts.css");
|
|
2631
2774
|
let fontCss = fontCssSource;
|
|
2632
2775
|
if (fontCss === void 0) {
|
|
2633
2776
|
try {
|
|
2634
|
-
fontCss = await
|
|
2777
|
+
fontCss = await fs5.readFile(fontCssPath);
|
|
2635
2778
|
} catch {
|
|
2636
2779
|
return;
|
|
2637
2780
|
}
|
|
2638
2781
|
}
|
|
2639
|
-
const clientCssPath =
|
|
2782
|
+
const clientCssPath = path15.join(outputDir, "farm-client.css");
|
|
2640
2783
|
let clientCss = "";
|
|
2641
2784
|
try {
|
|
2642
|
-
clientCss = await
|
|
2785
|
+
clientCss = await fs5.readFile(clientCssPath, "utf8");
|
|
2643
2786
|
} catch {
|
|
2644
2787
|
}
|
|
2645
2788
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
2646
|
-
await
|
|
2647
|
-
await
|
|
2789
|
+
await fs5.writeFile(fontCssPath, normalizedFontCss);
|
|
2790
|
+
await fs5.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
|
|
2648
2791
|
}
|
|
2649
2792
|
function importsFarmClientBlockedPackage(id, packageName) {
|
|
2650
2793
|
return id === packageName || id.startsWith(`${packageName}/`);
|
|
@@ -2660,28 +2803,28 @@ var IncompleteClientBuildOutputError = class extends Error {
|
|
|
2660
2803
|
}
|
|
2661
2804
|
};
|
|
2662
2805
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
2663
|
-
const
|
|
2806
|
+
const fs5 = await import("fs/promises");
|
|
2664
2807
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
2665
|
-
const clientEntryPath =
|
|
2808
|
+
const clientEntryPath = path15.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
2666
2809
|
let clientEntrySize = 0;
|
|
2667
2810
|
try {
|
|
2668
|
-
const clientEntry = await
|
|
2811
|
+
const clientEntry = await fs5.stat(clientEntryPath);
|
|
2669
2812
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
2670
2813
|
} catch {
|
|
2671
2814
|
}
|
|
2672
2815
|
if (clientEntrySize === 0) {
|
|
2673
2816
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
2674
2817
|
}
|
|
2675
|
-
const clientCssPath =
|
|
2676
|
-
const globalsCssPath =
|
|
2818
|
+
const clientCssPath = path15.join(outputDir, "farm-client.css");
|
|
2819
|
+
const globalsCssPath = path15.join(root, srcDir, "app", "globals.css");
|
|
2677
2820
|
let expectsCss = false;
|
|
2678
2821
|
try {
|
|
2679
|
-
const globalsCss = await
|
|
2822
|
+
const globalsCss = await fs5.readFile(globalsCssPath, "utf8");
|
|
2680
2823
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
2681
2824
|
} catch {
|
|
2682
2825
|
}
|
|
2683
2826
|
try {
|
|
2684
|
-
const clientCss = await
|
|
2827
|
+
const clientCss = await fs5.stat(clientCssPath);
|
|
2685
2828
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
2686
2829
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
2687
2830
|
}
|
|
@@ -2690,11 +2833,11 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2690
2833
|
if (expectsCss) {
|
|
2691
2834
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
2692
2835
|
}
|
|
2693
|
-
await
|
|
2836
|
+
await fs5.writeFile(clientCssPath, "");
|
|
2694
2837
|
}
|
|
2695
2838
|
}
|
|
2696
2839
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
2697
|
-
const key =
|
|
2840
|
+
const key = getClientModuleHydrationPlanKey(modulePath, root, mode, options);
|
|
2698
2841
|
let plan = cache.get(key);
|
|
2699
2842
|
if (!plan) {
|
|
2700
2843
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2702,12 +2845,12 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
2702
2845
|
}
|
|
2703
2846
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
2704
2847
|
}
|
|
2705
|
-
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
|
|
2706
|
-
if (!mobile) await removeFarmMobileClientManifest(
|
|
2848
|
+
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false, sourceSnapshot) {
|
|
2849
|
+
if (!mobile) await removeFarmMobileClientManifest(path15.dirname(outputDir));
|
|
2707
2850
|
const viteBuild = productionVite.build;
|
|
2708
2851
|
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2709
2852
|
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
2710
|
-
const
|
|
2853
|
+
const fs5 = await import("fs/promises");
|
|
2711
2854
|
const pluginManager = new PluginManager2({
|
|
2712
2855
|
config,
|
|
2713
2856
|
isDev: false,
|
|
@@ -2760,7 +2903,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2760
2903
|
);
|
|
2761
2904
|
const syntheticDocsEntry = config.docs?.enabled && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
|
|
2762
2905
|
const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
|
|
2763
|
-
const
|
|
2906
|
+
const plan = (operation) => sourceSnapshot ? withFarmSourceSnapshotOf(sourceSnapshot, operation) : withFarmSourceSnapshot(operation);
|
|
2907
|
+
const { clientLayouts, clientRouteSlots } = plan(() => {
|
|
2764
2908
|
const clientLayouts2 = layoutRoutes.map((layout) => {
|
|
2765
2909
|
try {
|
|
2766
2910
|
const metadata = getCachedClientModuleHydrationPlan(
|
|
@@ -2874,14 +3018,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2874
3018
|
}
|
|
2875
3019
|
}
|
|
2876
3020
|
const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
|
|
2877
|
-
const
|
|
3021
|
+
const plan2 = getCachedClientModuleHydrationPlan(
|
|
2878
3022
|
slot.modulePath,
|
|
2879
3023
|
root,
|
|
2880
3024
|
isolatedMode,
|
|
2881
3025
|
hydrationPlanCache,
|
|
2882
3026
|
{ ...pagePlanOptions, serverOwners: true }
|
|
2883
3027
|
);
|
|
2884
|
-
return
|
|
3028
|
+
return plan2.isClientComponent ? [] : [{ slot, plan: plan2 }];
|
|
2885
3029
|
}) : [];
|
|
2886
3030
|
for (const { route, metadata } of routePlans) {
|
|
2887
3031
|
if (isAdapterDocsRoute(route.pattern)) continue;
|
|
@@ -2896,7 +3040,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2896
3040
|
}
|
|
2897
3041
|
const slotBoundaries = serverSlotPlans.filter(
|
|
2898
3042
|
({ slot }) => layoutAppliesToRoute(slot.ownerDirectory ?? slot.ownerPattern, routeDirectory(route))
|
|
2899
|
-
).flatMap(({ plan }) =>
|
|
3043
|
+
).flatMap(({ plan: plan2 }) => plan2.isolatedBoundaries);
|
|
2900
3044
|
if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
|
|
2901
3045
|
const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
|
|
2902
3046
|
const islandStrategy = resolveFarmRouteRootStrategy(
|
|
@@ -2967,11 +3111,13 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2967
3111
|
logger.info(
|
|
2968
3112
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2969
3113
|
);
|
|
3114
|
+
const clientRouteTable = createFarmClientRouteTable(clientPages);
|
|
3115
|
+
await writeFarmClientRouteTable(path15.dirname(outputDir), clientRouteTable);
|
|
2970
3116
|
const buildTarget = async (platform) => {
|
|
2971
|
-
const clientEntryRoot =
|
|
2972
|
-
await
|
|
2973
|
-
const clientEntryDir = await
|
|
2974
|
-
const clientEntryPath =
|
|
3117
|
+
const clientEntryRoot = path15.join(root, ".farm", "tmp");
|
|
3118
|
+
await fs5.mkdir(clientEntryRoot, { recursive: true });
|
|
3119
|
+
const clientEntryDir = await fs5.mkdtemp(path15.join(clientEntryRoot, "client-entry-"));
|
|
3120
|
+
const clientEntryPath = path15.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2975
3121
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2976
3122
|
clientPages,
|
|
2977
3123
|
clientLayouts,
|
|
@@ -3003,14 +3149,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3003
3149
|
);
|
|
3004
3150
|
const entryName = platform === "mobile" ? FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
|
|
3005
3151
|
const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
|
|
3006
|
-
await
|
|
3152
|
+
await fs5.writeFile(clientEntryPath, clientEntry.entry);
|
|
3153
|
+
await fs5.writeFile(
|
|
3154
|
+
path15.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
|
|
3155
|
+
generateFarmClientRouteTableModule(clientRouteTable)
|
|
3156
|
+
);
|
|
3007
3157
|
if (clientEntry.router !== void 0) {
|
|
3008
|
-
await
|
|
3158
|
+
await fs5.writeFile(path15.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
|
|
3009
3159
|
}
|
|
3010
3160
|
const clientInput = { [entryName]: clientEntryPath };
|
|
3011
3161
|
if (platform === "web" && canBootFarmIslandsClient(config)) {
|
|
3012
|
-
const clientBootPath =
|
|
3013
|
-
await
|
|
3162
|
+
const clientBootPath = path15.join(clientEntryDir, "farm-client-boot.tsx");
|
|
3163
|
+
await fs5.writeFile(
|
|
3014
3164
|
clientBootPath,
|
|
3015
3165
|
'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
|
|
3016
3166
|
);
|
|
@@ -3026,8 +3176,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3026
3176
|
if (hasScopedPostcssConfig) {
|
|
3027
3177
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
3028
3178
|
} else {
|
|
3029
|
-
const postcssConfigPath =
|
|
3030
|
-
await
|
|
3179
|
+
const postcssConfigPath = path15.join(clientEntryDir, "postcss.config.cjs");
|
|
3180
|
+
await fs5.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
3031
3181
|
postcssSearchPath = clientEntryDir;
|
|
3032
3182
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
3033
3183
|
builder: productionVite.builder,
|
|
@@ -3082,24 +3232,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3082
3232
|
plugins: [
|
|
3083
3233
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
3084
3234
|
createFarmPrivateClientSourcemapsPlugin({
|
|
3085
|
-
outDir:
|
|
3086
|
-
|
|
3235
|
+
outDir: path15.join(
|
|
3236
|
+
path15.dirname(outputDir),
|
|
3087
3237
|
platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
|
|
3088
3238
|
)
|
|
3089
3239
|
}),
|
|
3090
3240
|
// The web client's preload manifests; the mobile client records its files instead.
|
|
3091
3241
|
platform === "mobile" ? createFarmMobileClientManifestPlugin({
|
|
3092
|
-
buildDir:
|
|
3242
|
+
buildDir: path15.dirname(outputDir),
|
|
3093
3243
|
entryName
|
|
3094
3244
|
}) : createFarmClientModulePreloadPlugin({
|
|
3095
3245
|
root,
|
|
3096
|
-
buildDir:
|
|
3246
|
+
buildDir: path15.dirname(outputDir),
|
|
3097
3247
|
entryName: "farm-client"
|
|
3098
3248
|
}),
|
|
3099
3249
|
...adapterOwnsDocsRuntime && platform === "web" ? [
|
|
3100
3250
|
createFarmDocsModulePreloadPlugin({
|
|
3101
3251
|
root,
|
|
3102
|
-
buildDir:
|
|
3252
|
+
buildDir: path15.dirname(outputDir),
|
|
3103
3253
|
importer: clientEntryPath,
|
|
3104
3254
|
entryName: "farm-client",
|
|
3105
3255
|
modules: [
|
|
@@ -3180,7 +3330,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3180
3330
|
},
|
|
3181
3331
|
farmIslandContainersPlugin(config),
|
|
3182
3332
|
farmPlugin(
|
|
3183
|
-
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes },
|
|
3333
|
+
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes, sourceSnapshot },
|
|
3184
3334
|
pluginManager
|
|
3185
3335
|
),
|
|
3186
3336
|
farmEnvironmentFunctionsPlugin(config)
|
|
@@ -3208,8 +3358,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3208
3358
|
mergeFarmProductionViteConfig(clientViteConfig, config.vite, { clientOutput: true })
|
|
3209
3359
|
);
|
|
3210
3360
|
if (platform === "mobile") {
|
|
3211
|
-
await
|
|
3212
|
-
if (!await hasFarmMobileClientEntry(
|
|
3361
|
+
await fs5.rm(path15.join(outputDir, `${entryName}.css`), { force: true });
|
|
3362
|
+
if (!await hasFarmMobileClientEntry(path15.dirname(outputDir), outputDir)) {
|
|
3213
3363
|
throw new IncompleteClientBuildOutputError(
|
|
3214
3364
|
`${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
|
|
3215
3365
|
);
|
|
@@ -3220,7 +3370,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3220
3370
|
}
|
|
3221
3371
|
} finally {
|
|
3222
3372
|
try {
|
|
3223
|
-
await
|
|
3373
|
+
await fs5.rm(clientEntryDir, { recursive: true, force: true });
|
|
3224
3374
|
} catch {
|
|
3225
3375
|
}
|
|
3226
3376
|
}
|
|
@@ -3230,17 +3380,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3230
3380
|
}
|
|
3231
3381
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
3232
3382
|
if (!filePath) return "";
|
|
3233
|
-
if (!
|
|
3234
|
-
const relative =
|
|
3235
|
-
if (!relative || relative.startsWith("..") ||
|
|
3236
|
-
return
|
|
3383
|
+
if (!path15.isAbsolute(filePath)) return filePath.split(path15.sep).join("/");
|
|
3384
|
+
const relative = path15.relative(root, filePath);
|
|
3385
|
+
if (!relative || relative.startsWith("..") || path15.isAbsolute(relative)) {
|
|
3386
|
+
return path15.basename(filePath);
|
|
3237
3387
|
}
|
|
3238
|
-
return relative.split(
|
|
3388
|
+
return relative.split(path15.sep).join("/");
|
|
3239
3389
|
}
|
|
3240
3390
|
function generateUniversalRouterStateRuntime(streamNavigations = false) {
|
|
3241
3391
|
return `
|
|
3242
3392
|
const FARM_PAGE_STATE_KEY = "__farmPageState";
|
|
3243
3393
|
const FARM_HISTORY_INDEX_KEY = "__farmHistoryIndex";
|
|
3394
|
+
const FARM_HISTORY_KEY = "__farmHistoryKey";
|
|
3244
3395
|
const IDLE_NAVIGATION_STATE = {
|
|
3245
3396
|
state: "idle",
|
|
3246
3397
|
pending: false,
|
|
@@ -3260,8 +3411,8 @@ function createNavigationLocation(url) {
|
|
|
3260
3411
|
};
|
|
3261
3412
|
}
|
|
3262
3413
|
|
|
3263
|
-
function scrollElementStorageKey(
|
|
3264
|
-
return "farm-scroll-" +
|
|
3414
|
+
function scrollElementStorageKey(scrollKey, key) {
|
|
3415
|
+
return "farm-scroll-" + scrollKey + ":" + key;
|
|
3265
3416
|
}
|
|
3266
3417
|
|
|
3267
3418
|
function createHistoryState(path, pageState, currentState) {
|
|
@@ -3320,12 +3471,140 @@ function readHistoryIndex(state) {
|
|
|
3320
3471
|
return Number.isSafeInteger(value) ? value : null;
|
|
3321
3472
|
}
|
|
3322
3473
|
|
|
3474
|
+
function readHistoryKey(state) {
|
|
3475
|
+
if (!state || typeof state !== "object") return null;
|
|
3476
|
+
const value = state[FARM_HISTORY_KEY];
|
|
3477
|
+
return typeof value === "string" && value.length > 0 && value.length <= 64 ? value : null;
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3480
|
+
// The time keeps keys unique across the reloads and documents that share a tab's sessionStorage.
|
|
3481
|
+
function createHistoryKey() {
|
|
3482
|
+
return Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 10);
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
// Scroll positions are saved per history entry, so the same URL twice in history keeps two
|
|
3486
|
+
// positions. An entry Farm did not write has no key and falls back to its path.
|
|
3487
|
+
function historyScrollKey(state, path) {
|
|
3488
|
+
return readHistoryKey(state) || path;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3323
3491
|
/*farm-router-end*/
|
|
3324
3492
|
function hasAbsoluteNavigationHref(href) {
|
|
3325
3493
|
return /^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(href) || href.startsWith("//");
|
|
3326
3494
|
}
|
|
3327
3495
|
`.trim();
|
|
3328
3496
|
}
|
|
3497
|
+
function generateFarmClientRouteTableRuntime(options) {
|
|
3498
|
+
const prefetch = `const farmPrefetchWhileRouteTableLoads = ${!options.streamNavigations};`;
|
|
3499
|
+
if (!options.table) {
|
|
3500
|
+
return `${prefetch}
|
|
3501
|
+
const clientRoutes = [];
|
|
3502
|
+
const clientRouteMatcher = createFarmRouter([]);
|
|
3503
|
+
const clientPageRouteMatcher = clientRouteMatcher;
|
|
3504
|
+
function loadFarmClientRouteTable() { return null; }
|
|
3505
|
+
function prefetchFarmClientRouteTable() {}
|
|
3506
|
+
const farmClientRoutesBoot = null;`;
|
|
3507
|
+
}
|
|
3508
|
+
return `${prefetch}
|
|
3509
|
+
let clientRoutes = [];
|
|
3510
|
+
let clientRouteMatcher = createFarmRouter([]);
|
|
3511
|
+
let clientPageRouteMatcher = clientRouteMatcher;
|
|
3512
|
+
let farmClientRouteTableLoad = null;
|
|
3513
|
+
let farmClientRouteTableLoaded = false;
|
|
3514
|
+
|
|
3515
|
+
function setFarmClientRoutes(routes) {
|
|
3516
|
+
clientRoutes = routes.map(function(route) {
|
|
3517
|
+
const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
|
|
3518
|
+
return { ...route, navigation: "html-fragment", load: load || null };
|
|
3519
|
+
});
|
|
3520
|
+
clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
|
|
3521
|
+
return { path: route.pattern, meta: route };
|
|
3522
|
+
}));
|
|
3523
|
+
clientPageRouteMatcher = ${options.docs ? `createFarmRouter(clientRoutes.filter(function(route) {
|
|
3524
|
+
return !route.docs;
|
|
3525
|
+
}).map(function(route) {
|
|
3526
|
+
return { path: route.pattern, meta: route };
|
|
3527
|
+
}))` : "clientRouteMatcher"};
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
// Null once the whole table is in place, else a promise that settles when it is.
|
|
3531
|
+
function loadFarmClientRouteTable() {
|
|
3532
|
+
if (farmClientRouteTableLoaded) return null;
|
|
3533
|
+
return farmClientRouteTableLoad || (farmClientRouteTableLoad = import("./${FARM_CLIENT_ROUTE_TABLE_MODULE}").then(function(module) {
|
|
3534
|
+
setFarmClientRoutes(module.default);
|
|
3535
|
+
farmClientRouteTableLoaded = true;
|
|
3536
|
+
}, function(error) {
|
|
3537
|
+
farmClientRouteTableLoad = null;
|
|
3538
|
+
throw error;
|
|
3539
|
+
}));
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
// A navigation to come (a prefetch, the lazy router) warms the table; that navigation handles a failure.
|
|
3543
|
+
function prefetchFarmClientRouteTable() {
|
|
3544
|
+
const table = loadFarmClientRouteTable();
|
|
3545
|
+
if (table) table.catch(function() {});
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
const farmClientRoutesBoot = (function() {
|
|
3549
|
+
const boot = window.__FARM_CLIENT_ROUTES__;
|
|
3550
|
+
if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)) {
|
|
3551
|
+
setFarmClientRoutes(boot.routes);
|
|
3552
|
+
return null;
|
|
3553
|
+
}
|
|
3554
|
+
return loadFarmClientRouteTable().catch(function(error) {
|
|
3555
|
+
console.warn("[Farm.js] Could not load the client route table; the page was left as the server rendered it.", error);
|
|
3556
|
+
});
|
|
3557
|
+
})();
|
|
3558
|
+
|
|
3559
|
+
// A plain <a> has no prefetch, unlike Link: a pointer or focus reaching one warms the table its
|
|
3560
|
+
// navigation will read.
|
|
3561
|
+
const FARM_ROUTE_TABLE_INTENT_EVENTS = ["pointerover", "pointerdown", "focusin", "touchstart"];
|
|
3562
|
+
function warmFarmClientRouteTable(event) {
|
|
3563
|
+
const target = event.target;
|
|
3564
|
+
if (!target || !target.closest || !target.closest("a[href]")) return;
|
|
3565
|
+
for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
|
|
3566
|
+
document.removeEventListener(type, warmFarmClientRouteTable, true);
|
|
3567
|
+
}
|
|
3568
|
+
prefetchFarmClientRouteTable();
|
|
3569
|
+
}
|
|
3570
|
+
for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
|
|
3571
|
+
document.addEventListener(type, warmFarmClientRouteTable, { capture: true, passive: true });
|
|
3572
|
+
}`;
|
|
3573
|
+
}
|
|
3574
|
+
function generateFarmClientBootRoutesServerSource(tableSource) {
|
|
3575
|
+
return `// The client route table (client-route-table.ts), filled in from the client build. The client
|
|
3576
|
+
// loads it on its first navigation; a document names the entries its page boots with, found
|
|
3577
|
+
// with the client's own matcher, so its page hydrates without the table.
|
|
3578
|
+
const farmClientRouteTable = (() => {
|
|
3579
|
+
try {
|
|
3580
|
+
const table = JSON.parse(${tableSource});
|
|
3581
|
+
if (!Array.isArray(table) || table.length === 0) return null;
|
|
3582
|
+
const toRoute = function(route) { return { path: route.pattern, meta: route }; };
|
|
3583
|
+
const routes = createFarmRouter(table.map(toRoute));
|
|
3584
|
+
return {
|
|
3585
|
+
routes: routes,
|
|
3586
|
+
pages: table.some(function(route) { return route.docs; })
|
|
3587
|
+
? createFarmRouter(table.filter(function(route) { return !route.docs; }).map(toRoute))
|
|
3588
|
+
: routes,
|
|
3589
|
+
};
|
|
3590
|
+
} catch {
|
|
3591
|
+
return null;
|
|
3592
|
+
}
|
|
3593
|
+
})();
|
|
3594
|
+
|
|
3595
|
+
// The entries the client's matchRoute and getFarmPageDirectory read for this route path.
|
|
3596
|
+
function getFarmClientBootRoutes(routePathname) {
|
|
3597
|
+
if (!farmClientRouteTable || typeof routePathname !== "string") return undefined;
|
|
3598
|
+
const routes = [];
|
|
3599
|
+
const matched = farmClientRouteTable.routes.match(routePathname);
|
|
3600
|
+
if (matched) {
|
|
3601
|
+
routes.push(matched.route.meta);
|
|
3602
|
+
const page = matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
|
|
3603
|
+
if (page) routes.push(page.route.meta);
|
|
3604
|
+
}
|
|
3605
|
+
return { path: routePathname, routes: routes };
|
|
3606
|
+
}`;
|
|
3607
|
+
}
|
|
3329
3608
|
function generateClientPageDirectorySource() {
|
|
3330
3609
|
return `function getFarmPageDirectory(pathname) {
|
|
3331
3610
|
const path = getFarmRoutePathname(pathname);
|
|
@@ -3652,7 +3931,8 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3652
3931
|
|
|
3653
3932
|
initializeHistory: function() {
|
|
3654
3933
|
const existingIndex = readHistoryIndex(window.history.state);
|
|
3655
|
-
|
|
3934
|
+
const existingKey = readHistoryKey(window.history.state);
|
|
3935
|
+
if (existingIndex != null && existingKey != null) {
|
|
3656
3936
|
this.currentHistoryIndex = existingIndex;
|
|
3657
3937
|
this.currentHistoryState = window.history.state;
|
|
3658
3938
|
return;
|
|
@@ -3662,14 +3942,15 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3662
3942
|
...(window.history.state && typeof window.history.state === "object"
|
|
3663
3943
|
? window.history.state
|
|
3664
3944
|
: {}),
|
|
3665
|
-
[FARM_HISTORY_INDEX_KEY]: 0,
|
|
3945
|
+
[FARM_HISTORY_INDEX_KEY]: existingIndex != null ? existingIndex : 0,
|
|
3946
|
+
[FARM_HISTORY_KEY]: existingKey || createHistoryKey(),
|
|
3666
3947
|
};
|
|
3667
3948
|
window.history.replaceState(initialState, "", window.location.href);
|
|
3668
|
-
this.currentHistoryIndex =
|
|
3949
|
+
this.currentHistoryIndex = initialState[FARM_HISTORY_INDEX_KEY];
|
|
3669
3950
|
this.currentHistoryState = initialState;
|
|
3670
3951
|
} catch {
|
|
3671
|
-
this.currentHistoryIndex =
|
|
3672
|
-
this.currentHistoryState = null;
|
|
3952
|
+
this.currentHistoryIndex = existingIndex;
|
|
3953
|
+
this.currentHistoryState = existingIndex != null ? window.history.state : null;
|
|
3673
3954
|
}
|
|
3674
3955
|
},
|
|
3675
3956
|
|
|
@@ -3962,6 +4243,9 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3962
4243
|
? this.currentHistoryIndex
|
|
3963
4244
|
: this.currentHistoryIndex + 1;
|
|
3964
4245
|
if (nextIndex != null) nextState[FARM_HISTORY_INDEX_KEY] = nextIndex;
|
|
4246
|
+
// A push is a new entry; createHistoryState copied the current entry's key into it.
|
|
4247
|
+
nextState[FARM_HISTORY_KEY] =
|
|
4248
|
+
(action === "replace" && readHistoryKey(nextState)) || createHistoryKey();
|
|
3965
4249
|
if (action === "replace") window.history.replaceState(nextState, "", url);
|
|
3966
4250
|
else window.history.pushState(nextState, "", url);
|
|
3967
4251
|
this.currentHistoryIndex = nextIndex;
|
|
@@ -3977,43 +4261,54 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3977
4261
|
|
|
3978
4262
|
registerScrollElement: function(key, element) {
|
|
3979
4263
|
this.scrollElements.set(key, element);
|
|
3980
|
-
this.restoreScrollElement(
|
|
4264
|
+
this.restoreScrollElement(
|
|
4265
|
+
historyScrollKey(this.currentHistoryState, window.location.pathname + window.location.search),
|
|
4266
|
+
key,
|
|
4267
|
+
element,
|
|
4268
|
+
);
|
|
3981
4269
|
return () => {
|
|
3982
4270
|
if (this.scrollElements.get(key) === element) this.scrollElements.delete(key);
|
|
3983
4271
|
};
|
|
3984
4272
|
},
|
|
3985
4273
|
|
|
3986
|
-
|
|
4274
|
+
// Without a key, saves the entry on screen (the unload handler, which may run on a stand-in).
|
|
4275
|
+
saveScrollPosition: function(scrollKey) {
|
|
4276
|
+
if (scrollKey === undefined) {
|
|
4277
|
+
scrollKey = historyScrollKey(
|
|
4278
|
+
this.currentHistoryState,
|
|
4279
|
+
window.location.pathname + window.location.search,
|
|
4280
|
+
);
|
|
4281
|
+
}
|
|
3987
4282
|
try {
|
|
3988
4283
|
sessionStorage.setItem(
|
|
3989
|
-
"farm-scroll-" +
|
|
4284
|
+
"farm-scroll-" + scrollKey,
|
|
3990
4285
|
JSON.stringify({ x: window.scrollX, y: window.scrollY }),
|
|
3991
4286
|
);
|
|
3992
4287
|
for (const [key, element] of this.scrollElements) {
|
|
3993
4288
|
sessionStorage.setItem(
|
|
3994
|
-
scrollElementStorageKey(
|
|
4289
|
+
scrollElementStorageKey(scrollKey, key),
|
|
3995
4290
|
JSON.stringify({ x: element.scrollLeft, y: element.scrollTop }),
|
|
3996
4291
|
);
|
|
3997
4292
|
}
|
|
3998
4293
|
} catch {}
|
|
3999
4294
|
},
|
|
4000
4295
|
|
|
4001
|
-
restoreScrollPosition: function(
|
|
4296
|
+
restoreScrollPosition: function(scrollKey) {
|
|
4002
4297
|
try {
|
|
4003
|
-
const saved = sessionStorage.getItem("farm-scroll-" +
|
|
4298
|
+
const saved = sessionStorage.getItem("farm-scroll-" + scrollKey);
|
|
4004
4299
|
if (saved) {
|
|
4005
4300
|
const position = JSON.parse(saved);
|
|
4006
4301
|
setTimeout(() => window.scrollTo(position.x, position.y), 0);
|
|
4007
4302
|
}
|
|
4008
4303
|
for (const [key, element] of this.scrollElements) {
|
|
4009
|
-
this.restoreScrollElement(
|
|
4304
|
+
this.restoreScrollElement(scrollKey, key, element);
|
|
4010
4305
|
}
|
|
4011
4306
|
} catch {}
|
|
4012
4307
|
},
|
|
4013
4308
|
|
|
4014
|
-
restoreScrollElement: function(
|
|
4309
|
+
restoreScrollElement: function(scrollKey, key, element) {
|
|
4015
4310
|
try {
|
|
4016
|
-
const saved = sessionStorage.getItem(scrollElementStorageKey(
|
|
4311
|
+
const saved = sessionStorage.getItem(scrollElementStorageKey(scrollKey, key));
|
|
4017
4312
|
if (!saved) return;
|
|
4018
4313
|
const position = JSON.parse(saved);
|
|
4019
4314
|
setTimeout(() => {
|
|
@@ -4040,6 +4335,8 @@ const farmRouterReady = [];
|
|
|
4040
4335
|
const farmRouterObserved = new Set();
|
|
4041
4336
|
|
|
4042
4337
|
function loadFarmRouter() {
|
|
4338
|
+
// The router's first navigation needs the route table: fetch both at once.
|
|
4339
|
+
if (!farmRouterLoading) prefetchFarmClientRouteTable();
|
|
4043
4340
|
return farmRouterLoading || (farmRouterLoading = import("./farm-client-router").then(function(module) {
|
|
4044
4341
|
farmLoadedRouter = module.spaRouter;
|
|
4045
4342
|
// The router module installs itself as the global; this object stays it, so a reference taken
|
|
@@ -4280,10 +4577,10 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
4280
4577
|
root,
|
|
4281
4578
|
renderer.componentExtensions ?? []
|
|
4282
4579
|
);
|
|
4283
|
-
const globalsCssPath =
|
|
4580
|
+
const globalsCssPath = path15.join(root, srcDir, "app", "globals.css");
|
|
4284
4581
|
const serverStyleModules = [];
|
|
4285
4582
|
const cssImport = [
|
|
4286
|
-
...
|
|
4583
|
+
...existsSync3(globalsCssPath) ? [globalsCssPath] : [],
|
|
4287
4584
|
...serverStylesheets.filter((stylesheet) => stylesheet !== globalsCssPath)
|
|
4288
4585
|
].map((stylesheet) => {
|
|
4289
4586
|
if (!/\.module\.[a-z]+$/.test(stylesheet)) {
|
|
@@ -4379,7 +4676,7 @@ function isFarmDocsPath() {
|
|
|
4379
4676
|
// Farm.js Client Runtime (no client components)
|
|
4380
4677
|
${cssImport}
|
|
4381
4678
|
${layoutImports}
|
|
4382
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4679
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4383
4680
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4384
4681
|
${clientPluginEntry.imports}
|
|
4385
4682
|
${clientCachePersistence.imports}
|
|
@@ -4455,13 +4752,14 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4455
4752
|
this.cancelActiveNavigation();
|
|
4456
4753
|
return;
|
|
4457
4754
|
}
|
|
4755
|
+
// The entry still on screen: on Back/Forward the URL and history.state already name the destination.
|
|
4756
|
+
const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
|
|
4458
4757
|
if (action === "pop") {
|
|
4459
4758
|
this.currentHistoryIndex = readHistoryIndex(options.popState);
|
|
4460
4759
|
this.currentHistoryState = options.popState;
|
|
4461
4760
|
}
|
|
4462
4761
|
|
|
4463
|
-
|
|
4464
|
-
this.saveScrollPosition(from);
|
|
4762
|
+
this.saveScrollPosition(fromScrollKey);
|
|
4465
4763
|
const navigation = this.startNavigation(from, url, action);
|
|
4466
4764
|
let clientNavigation;
|
|
4467
4765
|
try {
|
|
@@ -4492,7 +4790,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4492
4790
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
4493
4791
|
else window.scrollTo(0, 0);
|
|
4494
4792
|
} else {
|
|
4495
|
-
this.restoreScrollPosition(to);
|
|
4793
|
+
this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
|
|
4496
4794
|
}
|
|
4497
4795
|
});
|
|
4498
4796
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
@@ -4631,7 +4929,7 @@ window.addEventListener("beforeunload", function(event) {
|
|
|
4631
4929
|
event.preventDefault();
|
|
4632
4930
|
event.returnValue = "";
|
|
4633
4931
|
}
|
|
4634
|
-
spaRouter.saveScrollPosition(
|
|
4932
|
+
spaRouter.saveScrollPosition();
|
|
4635
4933
|
});
|
|
4636
4934
|
|
|
4637
4935
|
// Handle popstate (back/forward)
|
|
@@ -4659,10 +4957,13 @@ document.addEventListener("click", function(e) {
|
|
|
4659
4957
|
e.preventDefault();
|
|
4660
4958
|
spaRouter.navigate(href);
|
|
4661
4959
|
});
|
|
4960
|
+
|
|
4961
|
+
// Link anchors on a page that does not hydrate prefetch through the router as Link would.
|
|
4962
|
+
installFarmLinkPrefetch();
|
|
4662
4963
|
`.trim();
|
|
4663
4964
|
}
|
|
4664
4965
|
const imports = [];
|
|
4665
|
-
const
|
|
4966
|
+
const routeLoaders = [];
|
|
4666
4967
|
const routeSlotEntries = [];
|
|
4667
4968
|
const isolatedBoundaryModules = /* @__PURE__ */ new Map();
|
|
4668
4969
|
clientPages.forEach((page) => {
|
|
@@ -4672,16 +4973,11 @@ document.addEventListener("click", function(e) {
|
|
|
4672
4973
|
toImportPath(boundary.modulePath)
|
|
4673
4974
|
);
|
|
4674
4975
|
}
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
${page.hasIsolatedClientBoundaries ? "hasIsolatedClientBoundaries: true," : ""}
|
|
4681
|
-
islandStrategy: ${JSON.stringify(page.islandStrategy)},
|
|
4682
|
-
navigation: "html-fragment",
|
|
4683
|
-
load: ${load},
|
|
4684
|
-
}`);
|
|
4976
|
+
if (page.pageShouldHydrate) {
|
|
4977
|
+
routeLoaders.push(
|
|
4978
|
+
` () => import(${JSON.stringify(toImportPath(page.modulePath))}).then((module) => module.default),`
|
|
4979
|
+
);
|
|
4980
|
+
}
|
|
4685
4981
|
});
|
|
4686
4982
|
const isolatedHydrationEnabled = isolatedBoundaryModules.size > 0;
|
|
4687
4983
|
const serverTreeEnabled = isolatedHydrationEnabled && clientPages.some((page) => page.serverTree);
|
|
@@ -4752,7 +5048,7 @@ ${layoutImports}
|
|
|
4752
5048
|
${rendererClientImports}
|
|
4753
5049
|
${isolatedHydrationImport}
|
|
4754
5050
|
${providerClientCode.imports}
|
|
4755
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
5051
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4756
5052
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4757
5053
|
import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
|
|
4758
5054
|
${clientPluginEntry.imports}
|
|
@@ -4771,18 +5067,15 @@ setFarmTrailingSlashPreference(${JSON.stringify(trailingSlash)});
|
|
|
4771
5067
|
installChunkErrorRecovery();
|
|
4772
5068
|
${clientCachePersistence.init}
|
|
4773
5069
|
|
|
4774
|
-
//
|
|
4775
|
-
const
|
|
4776
|
-
${
|
|
5070
|
+
// The page modules that hydrate, by their route's \`loader\` index
|
|
5071
|
+
const farmClientRouteLoaders = [
|
|
5072
|
+
${routeLoaders.join("\n")}
|
|
4777
5073
|
];
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
}).map(function(route) {
|
|
4784
|
-
return { path: route.pattern, meta: route };
|
|
4785
|
-
}));` : "const clientPageRouteMatcher = clientRouteMatcher;"}
|
|
5074
|
+
${generateFarmClientRouteTableRuntime({
|
|
5075
|
+
table: clientPages.length > 0,
|
|
5076
|
+
docs: clientPages.some((page) => page.docs),
|
|
5077
|
+
streamNavigations: islandValues
|
|
5078
|
+
})}
|
|
4786
5079
|
${generateClientPageDirectorySource()}
|
|
4787
5080
|
|
|
4788
5081
|
${isolatedHydrationRuntime}
|
|
@@ -5271,6 +5564,8 @@ async function hydrate() {
|
|
|
5271
5564
|
window.__FARM_PPR_HYDRATING__ = true;
|
|
5272
5565
|
await farmClientRuntime.start();
|
|
5273
5566
|
|
|
5567
|
+
// The route table, when the document named no entries for this URL.
|
|
5568
|
+
await farmClientRoutesBoot;
|
|
5274
5569
|
const pathname = window.location.pathname;
|
|
5275
5570
|
const matched = matchRoute(pathname);
|
|
5276
5571
|
${islandValues ? `if (
|
|
@@ -5647,6 +5942,21 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5647
5942
|
return;
|
|
5648
5943
|
}
|
|
5649
5944
|
|
|
5945
|
+
// The first navigation that matches a route waits for the client route table; a prefetch
|
|
5946
|
+
// usually loaded it already (generateFarmClientRouteTableRuntime). Without it (a deployment
|
|
5947
|
+
// that removed it, a network error), a document navigation is the safe fallback.
|
|
5948
|
+
const routeTable = loadFarmClientRouteTable();
|
|
5949
|
+
if (routeTable) {
|
|
5950
|
+
if (farmPrefetchWhileRouteTableLoads && !options.refresh) this.prefetch(url.href);
|
|
5951
|
+
try {
|
|
5952
|
+
await routeTable;
|
|
5953
|
+
} catch (error) {
|
|
5954
|
+
console.warn("[Farm.js] Could not load the client route table; navigating to " + href + " in full.", error);
|
|
5955
|
+
if (action === "push") window.location.assign(url.href);
|
|
5956
|
+
else window.location.replace(url.href);
|
|
5957
|
+
return;
|
|
5958
|
+
}
|
|
5959
|
+
}
|
|
5650
5960
|
const pathname = url.pathname;
|
|
5651
5961
|
const matched = matchRoute(pathname);
|
|
5652
5962
|
const from = this.currentPath;
|
|
@@ -5663,6 +5973,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5663
5973
|
this.cancelActiveNavigation();
|
|
5664
5974
|
return;
|
|
5665
5975
|
}
|
|
5976
|
+
// The entry still on screen: on Back/Forward the URL and history.state already name the destination.
|
|
5977
|
+
const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
|
|
5666
5978
|
if (action === "pop") {
|
|
5667
5979
|
this.currentHistoryIndex = readHistoryIndex(options.popState);
|
|
5668
5980
|
this.currentHistoryState = options.popState;
|
|
@@ -5671,8 +5983,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5671
5983
|
// A route transition invalidates any trigger waiting on the previous DOM boundary.
|
|
5672
5984
|
cancelPendingPageHydration();
|
|
5673
5985
|
this.stopNavigationStream();
|
|
5674
|
-
|
|
5675
|
-
this.saveScrollPosition(from);
|
|
5986
|
+
this.saveScrollPosition(fromScrollKey);
|
|
5676
5987
|
const navigation = this.startNavigation(from, url, action);
|
|
5677
5988
|
// A refresh keeps the islands still on the page (islands mode).
|
|
5678
5989
|
navigation.refresh = options.refresh === true;
|
|
@@ -5841,7 +6152,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5841
6152
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
5842
6153
|
else window.scrollTo(0, 0);
|
|
5843
6154
|
} else {
|
|
5844
|
-
this.restoreScrollPosition(to);
|
|
6155
|
+
this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
|
|
5845
6156
|
}
|
|
5846
6157
|
await farmClientRuntime.resolveNavigation(clientNavigation);
|
|
5847
6158
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
@@ -6022,6 +6333,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6022
6333
|
const url = new URL(href, window.location.href);
|
|
6023
6334
|
if (isFarmExternalNavigationURL(url, window.location.origin)) return;
|
|
6024
6335
|
if (isFarmDocsPath(url.pathname)) return;
|
|
6336
|
+
prefetchFarmClientRouteTable();
|
|
6025
6337
|
|
|
6026
6338
|
// A prefetch warms an ordinary future navigation, which reads the bare
|
|
6027
6339
|
// URL key. Carrying the intercept identity here both missed every real
|
|
@@ -6073,6 +6385,9 @@ void farmClientRuntime.start();
|
|
|
6073
6385
|
/*farm-router-start*/
|
|
6074
6386
|
spaRouter.initializeHistory();
|
|
6075
6387
|
window.__FARM_SPA_ROUTER__ = spaRouter;
|
|
6388
|
+
// Link anchors on a page that does not hydrate prefetch through the router as Link would. In
|
|
6389
|
+
// islands mode this runs once the router loads, so a page still loads it only when it needs it.
|
|
6390
|
+
installFarmLinkPrefetch();
|
|
6076
6391
|
/*farm-router-end*/
|
|
6077
6392
|
|
|
6078
6393
|
window.addEventListener("beforeunload", function(event) {
|
|
@@ -6080,7 +6395,7 @@ window.addEventListener("beforeunload", function(event) {
|
|
|
6080
6395
|
event.preventDefault();
|
|
6081
6396
|
event.returnValue = "";
|
|
6082
6397
|
}
|
|
6083
|
-
spaRouter.saveScrollPosition(
|
|
6398
|
+
spaRouter.saveScrollPosition();
|
|
6084
6399
|
});
|
|
6085
6400
|
|
|
6086
6401
|
// Handle popstate (back/forward)
|
|
@@ -6116,11 +6431,11 @@ if (isFarmDocsSearchPage()) {
|
|
|
6116
6431
|
void hydrate();
|
|
6117
6432
|
`.trim();
|
|
6118
6433
|
}
|
|
6119
|
-
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
|
|
6434
|
+
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime, sourceSnapshot) {
|
|
6120
6435
|
const viteBuild = productionVite.build;
|
|
6121
6436
|
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
6122
6437
|
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
6123
|
-
const
|
|
6438
|
+
const fs5 = await import("fs/promises");
|
|
6124
6439
|
const pluginManager = new PluginManager2({
|
|
6125
6440
|
config,
|
|
6126
6441
|
isDev: false,
|
|
@@ -6135,9 +6450,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6135
6450
|
buildLifetime: rendererBuildLifetime
|
|
6136
6451
|
});
|
|
6137
6452
|
if (!hasScopedPostcssConfig) {
|
|
6138
|
-
postcssConfigDir = await
|
|
6139
|
-
await
|
|
6140
|
-
|
|
6453
|
+
postcssConfigDir = await fs5.mkdtemp(path15.join(os.tmpdir(), "farm-postcss-"));
|
|
6454
|
+
await fs5.writeFile(
|
|
6455
|
+
path15.join(postcssConfigDir, "postcss.config.cjs"),
|
|
6141
6456
|
"module.exports = { plugins: [] };\n"
|
|
6142
6457
|
);
|
|
6143
6458
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -6162,7 +6477,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6162
6477
|
fileName: entry.fileName,
|
|
6163
6478
|
sourceType: "static",
|
|
6164
6479
|
staticInfo: entry.staticInfo,
|
|
6165
|
-
data: (await
|
|
6480
|
+
data: (await fs5.readFile(entry.modulePath)).toString("base64")
|
|
6166
6481
|
});
|
|
6167
6482
|
continue;
|
|
6168
6483
|
}
|
|
@@ -6222,10 +6537,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6222
6537
|
const appDirs = getFarmAppDirectories(config);
|
|
6223
6538
|
let openAPIReference = null;
|
|
6224
6539
|
if (config.openapi.enabled && config.openapi.route) {
|
|
6225
|
-
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-
|
|
6540
|
+
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-RHB2P35B.mjs");
|
|
6226
6541
|
const openAPIManager = new OpenAPIManager(appDirs, config.openapi, {
|
|
6227
6542
|
mode: "production",
|
|
6228
6543
|
apiBaseURL: config.api.baseURL,
|
|
6544
|
+
routes: () => apiRouteManager.getRoutes().values(),
|
|
6229
6545
|
loadModule: (filePath) => apiRouteManager.loadModule(filePath)
|
|
6230
6546
|
});
|
|
6231
6547
|
const spec = await openAPIManager.generateSpec();
|
|
@@ -6481,7 +6797,14 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6481
6797
|
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
6482
6798
|
farmServerOnlyEntriesPlugin(),
|
|
6483
6799
|
farmIslandContainersPlugin(config),
|
|
6484
|
-
farmPlugin(
|
|
6800
|
+
farmPlugin(
|
|
6801
|
+
{
|
|
6802
|
+
...config,
|
|
6803
|
+
isolatedClientBoundaryModules,
|
|
6804
|
+
sourceSnapshot
|
|
6805
|
+
},
|
|
6806
|
+
pluginManager
|
|
6807
|
+
),
|
|
6485
6808
|
farmEnvironmentFunctionsPlugin(config),
|
|
6486
6809
|
...hasRuntimeConfigModule ? [
|
|
6487
6810
|
farmStripPlatformConfigPlugin(
|
|
@@ -6547,7 +6870,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6547
6870
|
} finally {
|
|
6548
6871
|
if (postcssConfigDir) {
|
|
6549
6872
|
try {
|
|
6550
|
-
await
|
|
6873
|
+
await fs5.rm(postcssConfigDir, { recursive: true, force: true });
|
|
6551
6874
|
} catch {
|
|
6552
6875
|
}
|
|
6553
6876
|
}
|
|
@@ -6560,7 +6883,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6560
6883
|
}
|
|
6561
6884
|
function readFarmAppPackageIdentity(root) {
|
|
6562
6885
|
try {
|
|
6563
|
-
return JSON.parse(readFileSync(
|
|
6886
|
+
return JSON.parse(readFileSync(path15.join(root, "package.json"), "utf8"));
|
|
6564
6887
|
} catch {
|
|
6565
6888
|
return {};
|
|
6566
6889
|
}
|
|
@@ -7410,6 +7733,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7410
7733
|
listFarmMCPLlmsTxtLinks,
|
|
7411
7734
|
readFarmLlmsMarkdownFrom,
|
|
7412
7735
|
registerFarmMCPServer,
|
|
7736
|
+
_listFarmRegisteredMCPServerTools,
|
|
7737
|
+
_observeFarmRegisteredMCPResponse,
|
|
7738
|
+
_readFarmRegisteredMCPCalls,
|
|
7413
7739
|
renderFarmLlmsFullTxt,
|
|
7414
7740
|
resolveFarmAgentOrigin,
|
|
7415
7741
|
createFarmLlmsFullRenderer,
|
|
@@ -7451,6 +7777,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7451
7777
|
resolveFarmInstrumentationRuntime,
|
|
7452
7778
|
resolveFarmPreviewDeployment,
|
|
7453
7779
|
resolveFarmWebRequestOrigin,
|
|
7780
|
+
_withFarmTrustedProxyOrigin,
|
|
7454
7781
|
fetchFarmExternalRewrite,
|
|
7455
7782
|
runWithFarmRequestSpan,
|
|
7456
7783
|
createFarmSearchParams,
|
|
@@ -7554,7 +7881,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
7554
7881
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
7555
7882
|
const appMarkdownImport = hasMarkdownPages ? `import { FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS, createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
|
|
7556
7883
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
7557
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
7884
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path15.isAbsolute(config.mdx.components) ? config.mdx.components : path15.join(config.root, config.mdx.components) : null;
|
|
7558
7885
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
7559
7886
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
7560
7887
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -7725,7 +8052,7 @@ ${instrumentationImport}
|
|
|
7725
8052
|
${imageRuntimeImport}
|
|
7726
8053
|
${imageNodeRuntimeImport}
|
|
7727
8054
|
import { farmFontPreloadHeader } from "virtual:farm-font-runtime";
|
|
7728
|
-
import { isFarmRouteActive } from "@farm.js/core/router";
|
|
8055
|
+
import { createFarmRouter, isFarmRouteActive } from "@farm.js/core/router";
|
|
7729
8056
|
${rendererServerImports}
|
|
7730
8057
|
|
|
7731
8058
|
${routeClientGraphServerRuntime}
|
|
@@ -7776,7 +8103,7 @@ const farmUserConfig = ${configModulePath ? "(FarmUserConfigModule.default || Fa
|
|
|
7776
8103
|
const farmRuntimeConfigs = [${[...layerConfigValues, "farmUserConfig"].join(", ")}].filter(Boolean);
|
|
7777
8104
|
const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
|
|
7778
8105
|
|
|
7779
|
-
function
|
|
8106
|
+
function renderFarmDefault404Page() {
|
|
7780
8107
|
return React.createElement(React.Fragment, null,
|
|
7781
8108
|
React.createElement("style", null, ${JSON.stringify(DEFAULT_NOT_FOUND_STYLES)}),
|
|
7782
8109
|
React.createElement("main", {
|
|
@@ -7802,6 +8129,12 @@ function FarmDefault404Page() {
|
|
|
7802
8129
|
);
|
|
7803
8130
|
}
|
|
7804
8131
|
|
|
8132
|
+
// Renderers that compile their own components (Vue, Svelte) render a plain function as a
|
|
8133
|
+
// component only once it is marked; unmarked, Vue printed this page as "[object Object]".
|
|
8134
|
+
const FarmDefault404Page = typeof React.markFunctionComponent === "function"
|
|
8135
|
+
? React.markFunctionComponent(renderFarmDefault404Page)
|
|
8136
|
+
: renderFarmDefault404Page;
|
|
8137
|
+
|
|
7805
8138
|
/** The app's not-found page, or Farm's, without layouts. */
|
|
7806
8139
|
function createFarmNotFoundElement(pathname) {
|
|
7807
8140
|
const NotFoundPage = hasCustomNotFound && CustomNotFoundComponent ? CustomNotFoundComponent : FarmDefault404Page;
|
|
@@ -8093,7 +8426,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
8093
8426
|
|
|
8094
8427
|
// API routes bundled at build time
|
|
8095
8428
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
8096
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
8429
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path17, methods }) => ({ path: path17, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
8097
8430
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
8098
8431
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
8099
8432
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -8139,7 +8472,17 @@ farmAppManifestInput.guardCoversPath = (path) =>
|
|
|
8139
8472
|
path,
|
|
8140
8473
|
farmLocalAPIBasePath,
|
|
8141
8474
|
);
|
|
8142
|
-
|
|
8475
|
+
${config.docs?.enabled ? `// A docs runtime's MCP server lists its tools when asked over MCP, in process. A build
|
|
8476
|
+
// can't change them, so they are read once.
|
|
8477
|
+
if (farmDocsHandler) {
|
|
8478
|
+
farmAppManifestInput.registeredMCP = (request) =>
|
|
8479
|
+
_listFarmRegisteredMCPServerTools(farmDocsHandler, request, {
|
|
8480
|
+
basePath: ${JSON.stringify(config.basePath)},
|
|
8481
|
+
guardCoversPath: farmAppManifestInput.guardCoversPath,
|
|
8482
|
+
cache: true,
|
|
8483
|
+
});
|
|
8484
|
+
}
|
|
8485
|
+
` : ""}` : ""}
|
|
8143
8486
|
function isFarmLocalAPIPathname(pathname) {
|
|
8144
8487
|
return farmLocalAPIBasePath !== "/" &&
|
|
8145
8488
|
(pathname === farmLocalAPIBasePath ||
|
|
@@ -8223,7 +8566,7 @@ function serializeFarmInlineValue(value) {
|
|
|
8223
8566
|
.replace(/\\u2029/g, "\\\\u2029");
|
|
8224
8567
|
}
|
|
8225
8568
|
|
|
8226
|
-
function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps) {
|
|
8569
|
+
function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps, routePathname) {
|
|
8227
8570
|
const integrationManifest = ${hasRuntimeIntegrationConfig ? "getRegisteredIntegrationAPIManifest()" : "{}"};
|
|
8228
8571
|
const serializedRouteSlots = serializeFarmInlineValue(selectedRouteSlots || []);
|
|
8229
8572
|
const serializedPageProps = serializeFarmInlineValue(pageProps || {});
|
|
@@ -8232,6 +8575,13 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
8232
8575
|
serializeFarmInlineValue(integrationManifest) +
|
|
8233
8576
|
';window.__FARM_ROUTE_SLOTS__=' + serializedRouteSlots +
|
|
8234
8577
|
';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';';
|
|
8578
|
+
// The client boots at the canonical path when the script below moves it there.
|
|
8579
|
+
const bootRoutes = getFarmClientBootRoutes(
|
|
8580
|
+
typeof canonicalPath === "string" && canonicalPath.startsWith("/")
|
|
8581
|
+
? getFarmRoutePathname(canonicalPath.split(/[?#]/)[0])
|
|
8582
|
+
: routePathname
|
|
8583
|
+
);
|
|
8584
|
+
if (bootRoutes) source += 'window.__FARM_CLIENT_ROUTES__=' + serializeFarmInlineValue(bootRoutes) + ';';
|
|
8235
8585
|
if (typeof canonicalPath === "string" && canonicalPath.startsWith("/")) {
|
|
8236
8586
|
const serializedPath = serializeFarmInlineValue(canonicalPath);
|
|
8237
8587
|
source += 'if(location.pathname+location.search!==' + serializedPath + '){' +
|
|
@@ -8322,9 +8672,12 @@ async function farmKeptLayoutsRender(ReactDOMServer, layouts, keptCount, params)
|
|
|
8322
8672
|
if (Layout) element = React.createElement(Layout, { children: element, params });
|
|
8323
8673
|
}
|
|
8324
8674
|
try {
|
|
8675
|
+
// The markup is thrown away, so client components render as plain components, as in a root
|
|
8676
|
+
// that hydrates whole: their props are not encoded for a browser that never receives them.
|
|
8677
|
+
// Server components, guards included, run as usual.
|
|
8325
8678
|
const rendered = await renderFarmElement(
|
|
8326
8679
|
ReactDOMServer,
|
|
8327
|
-
wrapWithFarmIntegrationProviders(element),
|
|
8680
|
+
wrapWithFarmIntegrationProviders(wrapFarmRouteClientGraph(element)),
|
|
8328
8681
|
);
|
|
8329
8682
|
if (rendered.stream) {
|
|
8330
8683
|
const reader = rendered.stream.getReader();
|
|
@@ -9044,6 +9397,9 @@ function createFarmErrorDocument(html, title) {
|
|
|
9044
9397
|
' ' + renderFarmClientEntryScript() + '\\n</body>';
|
|
9045
9398
|
},
|
|
9046
9399
|
);
|
|
9400
|
+
// The charset and viewport a layout's own document leaves out, as on a page and the
|
|
9401
|
+
// not-found page: without the viewport the error page lays out at desktop width on phones.
|
|
9402
|
+
fullHtml = ensureFarmDocumentMeta(fullHtml, renderViewportHead(undefined));
|
|
9047
9403
|
return fullHtml.trim().startsWith("<!DOCTYPE")
|
|
9048
9404
|
? fullHtml
|
|
9049
9405
|
: "<!DOCTYPE html>\\n" + fullHtml;
|
|
@@ -9058,6 +9414,8 @@ const farmClientModulePreloads = (() => {
|
|
|
9058
9414
|
return null;
|
|
9059
9415
|
}
|
|
9060
9416
|
})();
|
|
9417
|
+
${generateFarmClientBootRoutesServerSource(`"${FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER}"`)}
|
|
9418
|
+
|
|
9061
9419
|
const farmClientEntryPreloadTags = farmClientModulePreloads
|
|
9062
9420
|
? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
|
|
9063
9421
|
: "";
|
|
@@ -10090,7 +10448,7 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10090
10448
|
: html.replace(/<[/]head>/i, clientStylesheet + "</head>");
|
|
10091
10449
|
}
|
|
10092
10450
|
if (!html.includes('id="__farm_route_slots_data__"')) {
|
|
10093
|
-
html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript() + "\\n</body>"; });
|
|
10451
|
+
html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript(undefined, undefined, undefined, pathname) + "\\n</body>"; });
|
|
10094
10452
|
}
|
|
10095
10453
|
if (!html.includes('src="/__farm_client_js_src__"')) {
|
|
10096
10454
|
html = html.replace(
|
|
@@ -10509,7 +10867,13 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10509
10867
|
const owned = getFarmAppOwnedDocsEnginePaths(config.agent, applicationMetadataRoutes);
|
|
10510
10868
|
return owned.length ? ` && !${JSON.stringify(owned)}.includes(normalizeRuntimePath(routePathname))` : "";
|
|
10511
10869
|
})()}) {
|
|
10512
|
-
const
|
|
10870
|
+
const farmDocsRequest = cloneFarmRequestWithContext(request);
|
|
10871
|
+
// Tool calls to a docs runtime's MCP server emit mcp.tool.complete, as @farm.js/mcp's do.
|
|
10872
|
+
const farmRegisteredMCPCalls = await _readFarmRegisteredMCPCalls(
|
|
10873
|
+
farmDocsRequest,
|
|
10874
|
+
${JSON.stringify(config.basePath)},
|
|
10875
|
+
);
|
|
10876
|
+
const docsResponse = await farmDocsHandler(farmDocsRequest);
|
|
10513
10877
|
if (docsResponse) {${hasInfraAnalyticsRuntime ? `
|
|
10514
10878
|
const farmAnalyticsRoute = adapterContext?.[farmRouteLabelSlot];
|
|
10515
10879
|
if (farmAnalyticsRoute) {
|
|
@@ -10520,7 +10884,19 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10520
10884
|
}` : ""}
|
|
10521
10885
|
if (!docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html")) {
|
|
10522
10886
|
return applyProductionMiddlewareHeaders(
|
|
10523
|
-
withFarmDocsRequestCache(
|
|
10887
|
+
withFarmDocsRequestCache(
|
|
10888
|
+
_observeFarmRegisteredMCPResponse(
|
|
10889
|
+
docsResponse,
|
|
10890
|
+
farmRegisteredMCPCalls,
|
|
10891
|
+
typeof adapterContext?.waitUntil === "function"
|
|
10892
|
+
? adapterContext.waitUntil.bind(adapterContext)
|
|
10893
|
+
: undefined,
|
|
10894
|
+
),
|
|
10895
|
+
request,
|
|
10896
|
+
farmLocaleResolution,
|
|
10897
|
+
middlewareData,
|
|
10898
|
+
middlewareContext,
|
|
10899
|
+
),
|
|
10524
10900
|
middlewareHeaders,
|
|
10525
10901
|
);
|
|
10526
10902
|
}
|
|
@@ -10816,7 +11192,9 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10816
11192
|
if (matchedRoute && request.method === "POST") {
|
|
10817
11193
|
const actionResponse = await _runWithMiddlewareData(middlewareData || {}, () =>
|
|
10818
11194
|
_runWithMiddlewareContext(middlewareContext || {}, () =>
|
|
10819
|
-
handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl
|
|
11195
|
+
handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl, {
|
|
11196
|
+
trustProxy: farmServerConfig.trustProxy === true,
|
|
11197
|
+
})
|
|
10820
11198
|
)
|
|
10821
11199
|
);
|
|
10822
11200
|
if (actionResponse) return applyProductionMiddlewareHeaders(actionResponse, middlewareHeaders);
|
|
@@ -11550,7 +11928,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11550
11928
|
return ' ' + renderFarmClientBootstrapScript(
|
|
11551
11929
|
pageProps.__farmCanonicalPath,
|
|
11552
11930
|
farmDeferredData.data.slots,
|
|
11553
|
-
farmDeferredData.data.page
|
|
11931
|
+
farmDeferredData.data.page,
|
|
11932
|
+
routePathname
|
|
11554
11933
|
) + '\\n' +
|
|
11555
11934
|
' ' + renderFarmClientEntryScript(early) + '\\n';
|
|
11556
11935
|
};
|
|
@@ -11707,7 +12086,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11707
12086
|
() => ' ' + renderFarmClientBootstrapScript(
|
|
11708
12087
|
pageProps.__farmCanonicalPath,
|
|
11709
12088
|
farmDeferredData.data.slots,
|
|
11710
|
-
farmDeferredData.data.page
|
|
12089
|
+
farmDeferredData.data.page,
|
|
12090
|
+
routePathname
|
|
11711
12091
|
) + renderFarmDeferredDataScript(farmDeferredData.records) + '\\n' +
|
|
11712
12092
|
' ' + farmEntryScript + '\\n</body>',
|
|
11713
12093
|
);
|
|
@@ -11725,7 +12105,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11725
12105
|
</head>
|
|
11726
12106
|
<body>
|
|
11727
12107
|
<div id="root">\${html}</div>
|
|
11728
|
-
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
12108
|
+
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page, routePathname)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
11729
12109
|
\${farmEntryScript}
|
|
11730
12110
|
</body>
|
|
11731
12111
|
</html>\`;
|
|
@@ -12062,7 +12442,7 @@ ${farmRendererDisabled ? `
|
|
|
12062
12442
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
12063
12443
|
.replace(
|
|
12064
12444
|
/<\\/body>/i,
|
|
12065
|
-
() => ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
12445
|
+
() => ' ' + renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname) + '\\n' +
|
|
12066
12446
|
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
12067
12447
|
);
|
|
12068
12448
|
fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
|
|
@@ -12082,7 +12462,7 @@ ${farmRendererDisabled ? `
|
|
|
12082
12462
|
</head>
|
|
12083
12463
|
<body>
|
|
12084
12464
|
<div id="root">\${html}</div>
|
|
12085
|
-
\${renderFarmClientBootstrapScript()}
|
|
12465
|
+
\${renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname)}
|
|
12086
12466
|
\${renderFarmClientEntryScript()}
|
|
12087
12467
|
</body>
|
|
12088
12468
|
</html>\`;
|
|
@@ -12219,7 +12599,10 @@ export async function fetch(request, context) {${imageRuntime === "none" ? "" :
|
|
|
12219
12599
|
return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
|
|
12220
12600
|
}
|
|
12221
12601
|
|
|
12222
|
-
async function handleFarmFetch(request, context) {
|
|
12602
|
+
async function handleFarmFetch(request, context) {${config.server.trustProxy ? `
|
|
12603
|
+
// server.trustProxy: middleware, pages, and API routes read the URL the visitor requested,
|
|
12604
|
+
// at the origin the trusted proxy forwards, as in development.
|
|
12605
|
+
request = _withFarmTrustedProxyOrigin(request);` : ""}
|
|
12223
12606
|
const healthResponse = await farmProductionLifecycle.handleHealthRequest(request);
|
|
12224
12607
|
if (healthResponse) return healthResponse;
|
|
12225
12608
|
|
|
@@ -12536,8 +12919,8 @@ function hasFarmNitroCacheRouteRule(routeRules) {
|
|
|
12536
12919
|
return swr !== void 0 && swr !== false || cache !== void 0 && cache !== false || !!headers && typeof headers === "object" && Object.keys(headers).length > 0;
|
|
12537
12920
|
});
|
|
12538
12921
|
}
|
|
12539
|
-
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
|
|
12540
|
-
const [
|
|
12922
|
+
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager, markdownPrecompiledPages) {
|
|
12923
|
+
const [fs5, nitroBuilderResult] = await Promise.all([
|
|
12541
12924
|
import("fs/promises"),
|
|
12542
12925
|
nitroBuilderResultPromise
|
|
12543
12926
|
]);
|
|
@@ -12546,8 +12929,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12546
12929
|
const isVercel = preset === "vercel";
|
|
12547
12930
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
12548
12931
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
12549
|
-
const runtimeServerOutputDir = isVercel ?
|
|
12550
|
-
const ssrOutputDir =
|
|
12932
|
+
const runtimeServerOutputDir = isVercel ? path15.join(outputDir, "functions", "__nitro.func") : path15.join(outputDir, "server");
|
|
12933
|
+
const ssrOutputDir = path15.join(root, distDir, "ssr");
|
|
12551
12934
|
const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
|
|
12552
12935
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
12553
12936
|
(image) => image.sourceType === "module"
|
|
@@ -12663,21 +13046,34 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12663
13046
|
"Cloudflare Pages does not install Cron Triggers. Use the cloudflare-module preset or an external scheduler with .farm/cron-manifest.json."
|
|
12664
13047
|
);
|
|
12665
13048
|
}
|
|
12666
|
-
const
|
|
13049
|
+
const portableScheduledTasks = mergeScheduledTasks(
|
|
13050
|
+
farmWorkflows.scheduledTasks,
|
|
13051
|
+
farmCron.scheduledTasks
|
|
13052
|
+
);
|
|
13053
|
+
const scheduledTasks = preset.startsWith("cloudflare") ? toFarmCronCloudflareScheduledTasks(portableScheduledTasks) : portableScheduledTasks;
|
|
12667
13054
|
const cloudflareCronConfig = farmCron.provider === "host" ? createFarmCronCloudflareConfig(farmCron.jobs) : void 0;
|
|
12668
|
-
const [
|
|
13055
|
+
const [
|
|
13056
|
+
clientCssHref,
|
|
13057
|
+
clientJsSrc,
|
|
13058
|
+
clientBootSrc,
|
|
13059
|
+
docsModulePreloads,
|
|
13060
|
+
clientModulePreloads,
|
|
13061
|
+
clientRouteTable
|
|
13062
|
+
] = await Promise.all([
|
|
12669
13063
|
resolveHashedClientCssHref(clientOutputDir),
|
|
12670
13064
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
12671
13065
|
resolveClientBootSrc(clientOutputDir),
|
|
12672
|
-
readFarmDocsModulePreloads(
|
|
12673
|
-
readFarmClientModulePreloads(
|
|
13066
|
+
readFarmDocsModulePreloads(path15.join(root, distDir)),
|
|
13067
|
+
readFarmClientModulePreloads(path15.join(root, distDir)),
|
|
13068
|
+
readFarmClientRouteTable(path15.join(root, distDir))
|
|
12674
13069
|
]);
|
|
12675
13070
|
let nativeStylesheets;
|
|
12676
13071
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
12677
13072
|
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
13073
|
+
const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
|
|
12678
13074
|
const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
|
|
12679
13075
|
await finalizeFarmMobileClient({
|
|
12680
|
-
buildDir:
|
|
13076
|
+
buildDir: path15.join(root, distDir),
|
|
12681
13077
|
clientOutputDir,
|
|
12682
13078
|
webEntry: clientJsSrc,
|
|
12683
13079
|
webBoot: clientBootSrc,
|
|
@@ -12696,6 +13092,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12696
13092
|
if (output.code.includes(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
12697
13093
|
output.code = output.code.split(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER).join(encodedClientModulePreloads);
|
|
12698
13094
|
}
|
|
13095
|
+
if (output.code.includes(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER)) {
|
|
13096
|
+
output.code = output.code.split(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER).join(encodedClientRouteTable);
|
|
13097
|
+
}
|
|
12699
13098
|
if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
|
|
12700
13099
|
output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
|
|
12701
13100
|
}
|
|
@@ -12713,15 +13112,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12713
13112
|
output.code = output.code.split(JSON.stringify(FARM_NATIVE_STYLESHEETS_PLACEHOLDER)).join(JSON.stringify(JSON.stringify(nativeStylesheets)));
|
|
12714
13113
|
}
|
|
12715
13114
|
}
|
|
12716
|
-
await
|
|
13115
|
+
await fs5.mkdir(ssrOutputDir, { recursive: true });
|
|
12717
13116
|
await Promise.all(
|
|
12718
13117
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
12719
|
-
const filePath =
|
|
12720
|
-
await
|
|
12721
|
-
await
|
|
13118
|
+
const filePath = path15.join(ssrOutputDir, fileName);
|
|
13119
|
+
await fs5.mkdir(path15.dirname(filePath), { recursive: true });
|
|
13120
|
+
await fs5.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
12722
13121
|
})
|
|
12723
13122
|
);
|
|
12724
|
-
const nitroEntryPath =
|
|
13123
|
+
const nitroEntryPath = path15.join(ssrOutputDir, "nitro-entry.mjs");
|
|
12725
13124
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
12726
13125
|
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
12727
13126
|
const nitroEntryCode = `
|
|
@@ -12927,7 +13326,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12927
13326
|
})
|
|
12928
13327
|
}` : ""}
|
|
12929
13328
|
`.trim();
|
|
12930
|
-
await
|
|
13329
|
+
await fs5.writeFile(nitroEntryPath, nitroEntryCode);
|
|
12931
13330
|
const desktopServerEntry = config.desktop ? {
|
|
12932
13331
|
basePath: config.basePath === "/" ? "" : config.basePath || "",
|
|
12933
13332
|
guardModule: "@farm.js/core/internal/desktop-guard"
|
|
@@ -12938,21 +13337,21 @@ function toFarmNodeResponse(request, response) {
|
|
|
12938
13337
|
`[Farm] A desktop build runs its server in the shell, so it needs the "bun" or "node-server" preset, not "${preset}".`
|
|
12939
13338
|
);
|
|
12940
13339
|
}
|
|
12941
|
-
await
|
|
12942
|
-
|
|
13340
|
+
await fs5.writeFile(
|
|
13341
|
+
path15.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
|
|
12943
13342
|
FARM_DESKTOP_ENV_MODULE_SOURCE
|
|
12944
13343
|
);
|
|
12945
13344
|
}
|
|
12946
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
13345
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path15.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
12947
13346
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
12948
|
-
await
|
|
12949
|
-
|
|
13347
|
+
await fs5.writeFile(
|
|
13348
|
+
path15.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
12950
13349
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
12951
13350
|
);
|
|
12952
|
-
await
|
|
13351
|
+
await fs5.writeFile(
|
|
12953
13352
|
farmNodeServerEntryPath,
|
|
12954
13353
|
createFarmNodeServerEntry({
|
|
12955
|
-
nitroEntryFile:
|
|
13354
|
+
nitroEntryFile: path15.basename(nitroEntryPath),
|
|
12956
13355
|
nodeAdapterModule,
|
|
12957
13356
|
server: config.server,
|
|
12958
13357
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
|
|
@@ -12960,12 +13359,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
12960
13359
|
})
|
|
12961
13360
|
);
|
|
12962
13361
|
}
|
|
12963
|
-
const farmBunServerEntryPath = preset === "bun" ?
|
|
13362
|
+
const farmBunServerEntryPath = preset === "bun" ? path15.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
12964
13363
|
if (farmBunServerEntryPath) {
|
|
12965
|
-
await
|
|
13364
|
+
await fs5.writeFile(
|
|
12966
13365
|
farmBunServerEntryPath,
|
|
12967
13366
|
createFarmBunServerEntry({
|
|
12968
|
-
nitroEntryFile:
|
|
13367
|
+
nitroEntryFile: path15.basename(nitroEntryPath),
|
|
12969
13368
|
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
12970
13369
|
server: config.server,
|
|
12971
13370
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
|
|
@@ -12973,18 +13372,18 @@ function toFarmNodeResponse(request, response) {
|
|
|
12973
13372
|
})
|
|
12974
13373
|
);
|
|
12975
13374
|
}
|
|
12976
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
13375
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path15.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
12977
13376
|
if (farmNetlifyEntryPath) {
|
|
12978
|
-
await
|
|
13377
|
+
await fs5.writeFile(
|
|
12979
13378
|
farmNetlifyEntryPath,
|
|
12980
13379
|
createFarmNetlifyEntry({
|
|
12981
13380
|
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
12982
13381
|
})
|
|
12983
13382
|
);
|
|
12984
13383
|
}
|
|
12985
|
-
const farmCloudflareEnvPath = preset === "cloudflare-pages" ?
|
|
13384
|
+
const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path15.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
|
|
12986
13385
|
if (farmCloudflareEnvPath) {
|
|
12987
|
-
await
|
|
13386
|
+
await fs5.writeFile(
|
|
12988
13387
|
farmCloudflareEnvPath,
|
|
12989
13388
|
`export default function farmCloudflareEnv(event) {
|
|
12990
13389
|
const env = event.req.runtime?.cloudflare?.env
|
|
@@ -13056,7 +13455,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13056
13455
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
13057
13456
|
serverDir: false,
|
|
13058
13457
|
serverEntry: false,
|
|
13059
|
-
buildDir:
|
|
13458
|
+
buildDir: path15.join(root, distDir, ".nitro"),
|
|
13060
13459
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
13061
13460
|
compatibilityDate: "2024-12-01",
|
|
13062
13461
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -13080,7 +13479,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
13080
13479
|
// answered independently, as by the production server, so keeping several
|
|
13081
13480
|
// in flight overlaps the worker's rendering with this thread's per-route work.
|
|
13082
13481
|
concurrency: Math.min(os.availableParallelism(), 8),
|
|
13083
|
-
routes: prerenderRoutes.map(toPrerenderPublicPath)
|
|
13482
|
+
routes: prerenderRoutes.map(toPrerenderPublicPath),
|
|
13483
|
+
// Cloudflare's asset server answers a directory index (about/index.html) at the
|
|
13484
|
+
// trailing-slash URL and redirects the other spelling to it, so a page is written as
|
|
13485
|
+
// about.html unless trailingSlash asks for the slash, as Nitro's Netlify and Vercel
|
|
13486
|
+
// presets already write it.
|
|
13487
|
+
...preset.startsWith("cloudflare") ? { autoSubfolderIndex: config.trailingSlash === true } : {}
|
|
13084
13488
|
}
|
|
13085
13489
|
} : {},
|
|
13086
13490
|
experimental: {
|
|
@@ -13145,7 +13549,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13145
13549
|
if (pluginManager) {
|
|
13146
13550
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
13147
13551
|
}
|
|
13148
|
-
const expectedServerDir =
|
|
13552
|
+
const expectedServerDir = path15.join(outputDir, "server");
|
|
13149
13553
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
13150
13554
|
(key) => key !== "external" && key !== "plugins"
|
|
13151
13555
|
);
|
|
@@ -13160,10 +13564,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
13160
13564
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
13161
13565
|
const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && Boolean(
|
|
13162
13566
|
nitroConfig.handlers?.some(
|
|
13163
|
-
(handler) =>
|
|
13567
|
+
(handler) => path15.resolve(handler?.handler || "") === nitroEntryPath
|
|
13164
13568
|
)
|
|
13165
13569
|
);
|
|
13166
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms &&
|
|
13570
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path15.resolve(nitroConfig.output?.serverDir || "") === path15.resolve(expectedServerDir);
|
|
13167
13571
|
const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
|
|
13168
13572
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
13169
13573
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
@@ -13201,6 +13605,21 @@ function toFarmNodeResponse(request, response) {
|
|
|
13201
13605
|
const orderOf = (route) => prerenderOrder.get(route) ?? Number.MAX_SAFE_INTEGER;
|
|
13202
13606
|
prerenderedRoutes.sort((a, b) => orderOf(a.route) - orderOf(b.route));
|
|
13203
13607
|
});
|
|
13608
|
+
const prerenderPagePaths = new Set(prerenderRoutes.map(toPrerenderPublicPath));
|
|
13609
|
+
let skippedNonHtmlPrerenderRoute = false;
|
|
13610
|
+
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
13611
|
+
if (route.error || !prerenderPagePaths.has(route.route)) return;
|
|
13612
|
+
if (route.contentType?.toLowerCase().includes("html")) return;
|
|
13613
|
+
route.skip = true;
|
|
13614
|
+
skippedNonHtmlPrerenderRoute = true;
|
|
13615
|
+
const configuredRule = configuredNitroRouteRules[route.route];
|
|
13616
|
+
if (configuredRule) nitroInstance.options.routeRules[route.route] = configuredRule;
|
|
13617
|
+
else delete nitroInstance.options.routeRules[route.route];
|
|
13618
|
+
logger.info(`\u21AA Keeping SSG route ${route.route} server-handled (it does not render HTML)`);
|
|
13619
|
+
});
|
|
13620
|
+
nitroInstance.hooks.hook("prerender:done", () => {
|
|
13621
|
+
if (skippedNonHtmlPrerenderRoute) nitroInstance.routing.sync();
|
|
13622
|
+
});
|
|
13204
13623
|
if (config.md?.enabled) {
|
|
13205
13624
|
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
13206
13625
|
if (!route.contents || !route.contentType?.toLowerCase().includes("html")) return;
|
|
@@ -13253,7 +13672,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13253
13672
|
const configuredPlugins = rollupConfig.plugins;
|
|
13254
13673
|
rollupConfig.plugins = [
|
|
13255
13674
|
...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [],
|
|
13256
|
-
createPrerenderRuntimeResolverPlugin(config.root)
|
|
13675
|
+
createPrerenderRuntimeResolverPlugin(config.root),
|
|
13676
|
+
...markdownPrecompiledPages ? [createPrerenderMarkdownPagesPlugin(markdownPrecompiledPages)] : []
|
|
13257
13677
|
];
|
|
13258
13678
|
});
|
|
13259
13679
|
});
|
|
@@ -13269,8 +13689,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13269
13689
|
};
|
|
13270
13690
|
prerendererConfig.output = {
|
|
13271
13691
|
...prerendererConfig.output,
|
|
13272
|
-
serverDir:
|
|
13273
|
-
prerendererConfig.buildDir ??
|
|
13692
|
+
serverDir: path15.join(
|
|
13693
|
+
prerendererConfig.buildDir ?? path15.join(root, distDir, ".nitro"),
|
|
13274
13694
|
"prerender"
|
|
13275
13695
|
)
|
|
13276
13696
|
};
|
|
@@ -13289,11 +13709,11 @@ function toFarmNodeResponse(request, response) {
|
|
|
13289
13709
|
const prerenderServerDir = prerenderer.options.output.serverDir;
|
|
13290
13710
|
await copyPrebuiltSSRBundle(
|
|
13291
13711
|
ssrBundle,
|
|
13292
|
-
|
|
13712
|
+
path15.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
13293
13713
|
null,
|
|
13294
|
-
|
|
13714
|
+
fs5
|
|
13295
13715
|
);
|
|
13296
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
13716
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs5);
|
|
13297
13717
|
});
|
|
13298
13718
|
});
|
|
13299
13719
|
}
|
|
@@ -13327,7 +13747,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13327
13747
|
else process.env[FARM_PRERENDER_ENV] = previousPrerender;
|
|
13328
13748
|
}
|
|
13329
13749
|
}
|
|
13330
|
-
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir,
|
|
13750
|
+
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs5, preset) : Promise.resolve(null);
|
|
13331
13751
|
const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
|
|
13332
13752
|
ssrBundle,
|
|
13333
13753
|
shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
|
|
@@ -13340,7 +13760,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13340
13760
|
await nitroInstance.close();
|
|
13341
13761
|
if (nitroBuildResult.status === "rejected") {
|
|
13342
13762
|
if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
|
|
13343
|
-
await
|
|
13763
|
+
await fs5.rm(sharpRuntimeStageResult.value.stageDir, {
|
|
13344
13764
|
recursive: true,
|
|
13345
13765
|
force: true
|
|
13346
13766
|
});
|
|
@@ -13353,20 +13773,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
13353
13773
|
if (prebuiltSSRFilesResult.status === "rejected") {
|
|
13354
13774
|
throw prebuiltSSRFilesResult.reason;
|
|
13355
13775
|
}
|
|
13356
|
-
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir,
|
|
13776
|
+
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs5, preset) : null);
|
|
13357
13777
|
const runtimeCopyPromise = (async () => {
|
|
13358
13778
|
if (stagedSharpRuntime) {
|
|
13359
|
-
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir,
|
|
13779
|
+
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs5);
|
|
13360
13780
|
}
|
|
13361
13781
|
if (useExternalMetadataImageRuntime) {
|
|
13362
|
-
await copyMetadataImageRuntime(root, runtimeServerOutputDir,
|
|
13782
|
+
await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs5);
|
|
13363
13783
|
}
|
|
13364
13784
|
})();
|
|
13365
13785
|
const copyResults = await Promise.allSettled([
|
|
13366
13786
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
13367
13787
|
prebuiltSSRFilesResult.value,
|
|
13368
|
-
|
|
13369
|
-
|
|
13788
|
+
path15.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
13789
|
+
fs5
|
|
13370
13790
|
) : Promise.resolve(),
|
|
13371
13791
|
runtimeCopyPromise
|
|
13372
13792
|
]);
|
|
@@ -13375,17 +13795,17 @@ function toFarmNodeResponse(request, response) {
|
|
|
13375
13795
|
);
|
|
13376
13796
|
if (failedCopy) throw failedCopy.reason;
|
|
13377
13797
|
if (canReusePrebuiltSSR) {
|
|
13378
|
-
await registerPrebuiltSSRPackageImport(
|
|
13798
|
+
await registerPrebuiltSSRPackageImport(path15.join(outputDir, "server"), ssrEntryFile, fs5);
|
|
13379
13799
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
13380
13800
|
}
|
|
13381
13801
|
if (useRolldownBuilder) {
|
|
13382
13802
|
logger.info("\u26A1 Built the Node adapter with Rolldown");
|
|
13383
13803
|
}
|
|
13384
13804
|
if (preset === "node-server" && !desktopServerEntry) {
|
|
13385
|
-
await installFarmCompileCacheLauncher(
|
|
13805
|
+
await installFarmCompileCacheLauncher(path15.join(outputDir, "server"), fs5);
|
|
13386
13806
|
}
|
|
13387
13807
|
if (preset.startsWith("cloudflare")) {
|
|
13388
|
-
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir,
|
|
13808
|
+
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs5);
|
|
13389
13809
|
}
|
|
13390
13810
|
if (pluginManager) {
|
|
13391
13811
|
await pluginManager.runHookParallel("afterNitroBuild", {
|
|
@@ -13399,13 +13819,13 @@ function toFarmNodeResponse(request, response) {
|
|
|
13399
13819
|
await postProcessVercelOutput(
|
|
13400
13820
|
root,
|
|
13401
13821
|
outputDir,
|
|
13402
|
-
|
|
13822
|
+
fs5,
|
|
13403
13823
|
config,
|
|
13404
13824
|
farmWorkflows,
|
|
13405
13825
|
routeRuntimeManifest,
|
|
13406
13826
|
farmCron.provider === "host" ? farmCron.jobs : [],
|
|
13407
13827
|
{
|
|
13408
|
-
buildDir:
|
|
13828
|
+
buildDir: path15.join(root, distDir),
|
|
13409
13829
|
middlewareRoutes: edgeMiddlewareRoutes,
|
|
13410
13830
|
guardedPages: edgeGuardedPrerenderRoutes
|
|
13411
13831
|
},
|
|
@@ -13419,19 +13839,19 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
13419
13839
|
return {
|
|
13420
13840
|
dir: outputDir,
|
|
13421
13841
|
...preset === "node-server" ? {
|
|
13422
|
-
serverDir:
|
|
13423
|
-
publicDir:
|
|
13842
|
+
serverDir: path15.join(outputDir, "server"),
|
|
13843
|
+
publicDir: path15.join(outputDir, "public")
|
|
13424
13844
|
} : isVercel ? {
|
|
13425
|
-
serverDir:
|
|
13426
|
-
publicDir:
|
|
13845
|
+
serverDir: path15.join(outputDir, "functions", "__nitro.func"),
|
|
13846
|
+
publicDir: path15.join(outputDir, "static")
|
|
13427
13847
|
} : {}
|
|
13428
13848
|
};
|
|
13429
13849
|
}
|
|
13430
|
-
async function populateCloudflareProcessEnv(serverDir,
|
|
13431
|
-
const wranglerPath =
|
|
13850
|
+
async function populateCloudflareProcessEnv(serverDir, fs5) {
|
|
13851
|
+
const wranglerPath = path15.join(serverDir, "wrangler.json");
|
|
13432
13852
|
let source;
|
|
13433
13853
|
try {
|
|
13434
|
-
source = await
|
|
13854
|
+
source = await fs5.readFile(wranglerPath, "utf8");
|
|
13435
13855
|
} catch (error) {
|
|
13436
13856
|
if (error.code === "ENOENT") return;
|
|
13437
13857
|
throw error;
|
|
@@ -13439,7 +13859,7 @@ async function populateCloudflareProcessEnv(serverDir, fs4) {
|
|
|
13439
13859
|
const wrangler = JSON.parse(source);
|
|
13440
13860
|
const flags = resolveCloudflareProcessEnvFlags(wrangler);
|
|
13441
13861
|
if (!flags) return;
|
|
13442
|
-
await
|
|
13862
|
+
await fs5.writeFile(
|
|
13443
13863
|
wranglerPath,
|
|
13444
13864
|
JSON.stringify({ ...wrangler, compatibility_flags: flags }, null, 2)
|
|
13445
13865
|
);
|
|
@@ -13452,36 +13872,36 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
|
13452
13872
|
}))
|
|
13453
13873
|
);
|
|
13454
13874
|
}
|
|
13455
|
-
async function writeSSRBundleFiles(files, targetDir,
|
|
13456
|
-
await
|
|
13875
|
+
async function writeSSRBundleFiles(files, targetDir, fs5) {
|
|
13876
|
+
await fs5.rm(targetDir, { recursive: true, force: true });
|
|
13457
13877
|
await Promise.all(
|
|
13458
13878
|
files.map(async ({ fileName, contents }) => {
|
|
13459
|
-
const targetPath =
|
|
13460
|
-
await
|
|
13461
|
-
await
|
|
13879
|
+
const targetPath = path15.join(targetDir, fileName);
|
|
13880
|
+
await fs5.mkdir(path15.dirname(targetPath), { recursive: true });
|
|
13881
|
+
await fs5.writeFile(targetPath, contents);
|
|
13462
13882
|
})
|
|
13463
13883
|
);
|
|
13464
13884
|
}
|
|
13465
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions,
|
|
13466
|
-
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir,
|
|
13885
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs5) {
|
|
13886
|
+
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs5);
|
|
13467
13887
|
}
|
|
13468
|
-
async function installFarmCompileCacheLauncher(serverDir,
|
|
13469
|
-
const entryPath =
|
|
13470
|
-
const serverPath =
|
|
13471
|
-
const entry = await
|
|
13888
|
+
async function installFarmCompileCacheLauncher(serverDir, fs5) {
|
|
13889
|
+
const entryPath = path15.join(serverDir, "index.mjs");
|
|
13890
|
+
const serverPath = path15.join(serverDir, FARM_SERVER_MODULE_FILE);
|
|
13891
|
+
const entry = await fs5.readFile(entryPath, "utf8").catch((error) => {
|
|
13472
13892
|
if (error.code === "ENOENT") return null;
|
|
13473
13893
|
throw error;
|
|
13474
13894
|
});
|
|
13475
13895
|
if (entry === null) return false;
|
|
13476
13896
|
if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
|
|
13477
|
-
await
|
|
13478
|
-
await
|
|
13479
|
-
await
|
|
13897
|
+
await fs5.rename(entryPath, serverPath);
|
|
13898
|
+
await fs5.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
|
|
13899
|
+
await fs5.rm(path15.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
|
|
13480
13900
|
return true;
|
|
13481
13901
|
}
|
|
13482
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
13483
|
-
const packagePath =
|
|
13484
|
-
const packageJSON = await
|
|
13902
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs5) {
|
|
13903
|
+
const packagePath = path15.join(serverDir, "package.json");
|
|
13904
|
+
const packageJSON = await fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13485
13905
|
if (error.code === "ENOENT") return { type: "module" };
|
|
13486
13906
|
throw error;
|
|
13487
13907
|
});
|
|
@@ -13491,13 +13911,13 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
|
|
|
13491
13911
|
...existingImports,
|
|
13492
13912
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
13493
13913
|
};
|
|
13494
|
-
await
|
|
13495
|
-
await
|
|
13914
|
+
await fs5.mkdir(serverDir, { recursive: true });
|
|
13915
|
+
await fs5.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
13496
13916
|
`);
|
|
13497
13917
|
}
|
|
13498
|
-
async function moveVercelOutputPath(src, dest,
|
|
13918
|
+
async function moveVercelOutputPath(src, dest, fs5) {
|
|
13499
13919
|
try {
|
|
13500
|
-
await
|
|
13920
|
+
await fs5.rename(src, dest);
|
|
13501
13921
|
return;
|
|
13502
13922
|
} catch (error) {
|
|
13503
13923
|
const code = error?.code;
|
|
@@ -13505,38 +13925,38 @@ async function moveVercelOutputPath(src, dest, fs4) {
|
|
|
13505
13925
|
throw error;
|
|
13506
13926
|
}
|
|
13507
13927
|
}
|
|
13508
|
-
await
|
|
13509
|
-
await
|
|
13928
|
+
await fs5.cp(src, dest, { recursive: true, force: true });
|
|
13929
|
+
await fs5.rm(src, { recursive: true, force: true });
|
|
13510
13930
|
}
|
|
13511
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
13512
|
-
const serverDir =
|
|
13513
|
-
const functionsDir =
|
|
13514
|
-
const nitroFuncDir =
|
|
13515
|
-
const staticDir =
|
|
13516
|
-
const publicDir =
|
|
13517
|
-
await
|
|
13518
|
-
const serverContents = await
|
|
13931
|
+
async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
|
|
13932
|
+
const serverDir = path15.join(outputDir, "server");
|
|
13933
|
+
const functionsDir = path15.join(outputDir, "functions");
|
|
13934
|
+
const nitroFuncDir = path15.join(functionsDir, "__nitro.func");
|
|
13935
|
+
const staticDir = path15.join(outputDir, "static");
|
|
13936
|
+
const publicDir = path15.join(outputDir, "public");
|
|
13937
|
+
await fs5.mkdir(nitroFuncDir, { recursive: true });
|
|
13938
|
+
const serverContents = await fs5.readdir(serverDir).catch((error) => {
|
|
13519
13939
|
if (error.code === "ENOENT") return [];
|
|
13520
13940
|
throw error;
|
|
13521
13941
|
});
|
|
13522
13942
|
for (const file of serverContents) {
|
|
13523
|
-
await moveVercelOutputPath(
|
|
13943
|
+
await moveVercelOutputPath(path15.join(serverDir, file), path15.join(nitroFuncDir, file), fs5);
|
|
13524
13944
|
}
|
|
13525
|
-
if (serverContents.length > 0) await
|
|
13945
|
+
if (serverContents.length > 0) await fs5.rm(serverDir, { recursive: true, force: true });
|
|
13526
13946
|
try {
|
|
13527
|
-
await moveVercelOutputPath(publicDir, staticDir,
|
|
13947
|
+
await moveVercelOutputPath(publicDir, staticDir, fs5);
|
|
13528
13948
|
} catch (error) {
|
|
13529
13949
|
if (error?.code !== "ENOENT") throw error;
|
|
13530
13950
|
}
|
|
13531
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
13532
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
13533
|
-
const configPath =
|
|
13534
|
-
const configContent = await
|
|
13951
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5);
|
|
13952
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs5);
|
|
13953
|
+
const configPath = path15.join(outputDir, "config.json");
|
|
13954
|
+
const configContent = await fs5.readFile(configPath, "utf-8");
|
|
13535
13955
|
const vercelConfig = JSON.parse(configContent);
|
|
13536
13956
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
13537
13957
|
outputDir,
|
|
13538
13958
|
routeRuntimeManifest,
|
|
13539
|
-
|
|
13959
|
+
fs5,
|
|
13540
13960
|
config.basePath
|
|
13541
13961
|
);
|
|
13542
13962
|
const edgeMiddlewareRoutes = edgeMiddleware.middlewareRoutes.filter(
|
|
@@ -13550,7 +13970,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13550
13970
|
config,
|
|
13551
13971
|
routes: edgeMiddlewareRoutes,
|
|
13552
13972
|
guardedPages: edgeMiddleware.guardedPages,
|
|
13553
|
-
fs:
|
|
13973
|
+
fs: fs5
|
|
13554
13974
|
});
|
|
13555
13975
|
}
|
|
13556
13976
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
@@ -13564,30 +13984,30 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13564
13984
|
farmWorkflows.workflows
|
|
13565
13985
|
);
|
|
13566
13986
|
const vercelConfigWithCrons = applyFarmCronVercelCrons(vercelConfigWithWorkflowCrons, cronJobs);
|
|
13567
|
-
await
|
|
13987
|
+
await fs5.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
13568
13988
|
logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
13569
13989
|
}
|
|
13570
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
13990
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
|
|
13571
13991
|
if (!config.docs?.enabled) return;
|
|
13572
13992
|
const [mainRoot, ...extraRoots] = getFarmDocsRoots(config.docs);
|
|
13573
13993
|
await copyFarmDocsRootContent(
|
|
13574
13994
|
mainRoot,
|
|
13575
13995
|
root,
|
|
13576
13996
|
config.srcDir,
|
|
13577
|
-
|
|
13578
|
-
|
|
13997
|
+
path15.join(nitroFuncDir, "farm-docs-content"),
|
|
13998
|
+
fs5
|
|
13579
13999
|
);
|
|
13580
14000
|
for (const [index, docsRoot] of extraRoots.entries()) {
|
|
13581
14001
|
await copyFarmDocsRootContent(
|
|
13582
14002
|
docsRoot,
|
|
13583
14003
|
root,
|
|
13584
14004
|
config.srcDir,
|
|
13585
|
-
|
|
13586
|
-
|
|
14005
|
+
path15.join(nitroFuncDir, "farm-docs-roots", String(index)),
|
|
14006
|
+
fs5
|
|
13587
14007
|
);
|
|
13588
14008
|
}
|
|
13589
14009
|
}
|
|
13590
|
-
async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir,
|
|
14010
|
+
async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs5) {
|
|
13591
14011
|
const docsContentDir = resolveBuildDocsContentDir(docs, root, srcDir);
|
|
13592
14012
|
if (!docsContentDir) return;
|
|
13593
14013
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
@@ -13599,19 +14019,19 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
|
|
|
13599
14019
|
`${undatedPages} docs page(s) were last changed before this shallow clone's Git history, so they show no "Last updated" date. Build from a full clone (git fetch --unshallow) or set lastModified in the page's frontmatter.`
|
|
13600
14020
|
);
|
|
13601
14021
|
}
|
|
13602
|
-
await
|
|
13603
|
-
await
|
|
13604
|
-
await
|
|
14022
|
+
await fs5.rm(bundledContentDir, { recursive: true, force: true });
|
|
14023
|
+
await fs5.mkdir(path15.dirname(bundledContentDir), { recursive: true });
|
|
14024
|
+
await fs5.cp(docsContentDir, bundledContentDir, {
|
|
13605
14025
|
recursive: true,
|
|
13606
14026
|
force: true,
|
|
13607
14027
|
dereference: true
|
|
13608
14028
|
});
|
|
13609
|
-
await
|
|
13610
|
-
|
|
14029
|
+
await fs5.writeFile(
|
|
14030
|
+
path15.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
13611
14031
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
13612
14032
|
`
|
|
13613
14033
|
);
|
|
13614
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
14034
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path15.relative(root, docsContentDir)}`);
|
|
13615
14035
|
}
|
|
13616
14036
|
function resolveServerFunctionPlatform(preset) {
|
|
13617
14037
|
return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
|
|
@@ -13626,9 +14046,9 @@ function platformFieldAllows(field, value) {
|
|
|
13626
14046
|
const allowed = entries.filter((entry) => !entry.startsWith("!"));
|
|
13627
14047
|
return allowed.length === 0 || allowed.includes(value);
|
|
13628
14048
|
}
|
|
13629
|
-
async function stageSharpRuntime(config, root, distDir,
|
|
14049
|
+
async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
13630
14050
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
13631
|
-
const projectRequire = createRequire2(
|
|
14051
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
13632
14052
|
let sharpRequire = projectRequire;
|
|
13633
14053
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
13634
14054
|
try {
|
|
@@ -13638,10 +14058,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13638
14058
|
}
|
|
13639
14059
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
13640
14060
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
13641
|
-
const stageRoot =
|
|
13642
|
-
await
|
|
13643
|
-
const stageDir = await
|
|
13644
|
-
const targetNodeModules =
|
|
14061
|
+
const stageRoot = path15.join(root, distDir, "tmp");
|
|
14062
|
+
await fs5.mkdir(stageRoot, { recursive: true });
|
|
14063
|
+
const stageDir = await fs5.mkdtemp(path15.join(stageRoot, "sharp-runtime-"));
|
|
14064
|
+
const targetNodeModules = path15.join(stageDir, "node_modules");
|
|
13645
14065
|
function copyPackage(packageName, parentRequire) {
|
|
13646
14066
|
const activeCopy = packageCopies.get(packageName);
|
|
13647
14067
|
if (activeCopy) return activeCopy;
|
|
@@ -13652,19 +14072,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13652
14072
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
13653
14073
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
13654
14074
|
if (!packageJsonPath) return;
|
|
13655
|
-
const packageJson = JSON.parse(await
|
|
14075
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
13656
14076
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
13657
|
-
const packageDir =
|
|
13658
|
-
const targetDir =
|
|
14077
|
+
const packageDir = path15.dirname(packageJsonPath);
|
|
14078
|
+
const targetDir = path15.join(targetNodeModules, ...packageName.split("/"));
|
|
13659
14079
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
13660
|
-
await
|
|
14080
|
+
await fs5.mkdir(path15.dirname(targetDir), { recursive: true });
|
|
13661
14081
|
const packageRequire = createRequire2(packageJsonPath);
|
|
13662
14082
|
const dependencies = {
|
|
13663
14083
|
...packageJson.dependencies,
|
|
13664
14084
|
...packageJson.optionalDependencies
|
|
13665
14085
|
};
|
|
13666
14086
|
await settleAllOrThrow([
|
|
13667
|
-
|
|
14087
|
+
fs5.cp(packageDir, targetDir, {
|
|
13668
14088
|
recursive: true,
|
|
13669
14089
|
force: true,
|
|
13670
14090
|
dereference: true,
|
|
@@ -13681,7 +14101,7 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13681
14101
|
throw new Error(`Farm image optimization requires sharp. ${SHARP_INSTALL_HINT}`);
|
|
13682
14102
|
}
|
|
13683
14103
|
} catch (error) {
|
|
13684
|
-
await
|
|
14104
|
+
await fs5.rm(stageDir, { recursive: true, force: true });
|
|
13685
14105
|
throw error;
|
|
13686
14106
|
}
|
|
13687
14107
|
return {
|
|
@@ -13691,19 +14111,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13691
14111
|
)
|
|
13692
14112
|
};
|
|
13693
14113
|
}
|
|
13694
|
-
async function installStagedSharpRuntime(staged, nitroFuncDir,
|
|
13695
|
-
const stagedNodeModules =
|
|
13696
|
-
const targetNodeModules =
|
|
14114
|
+
async function installStagedSharpRuntime(staged, nitroFuncDir, fs5) {
|
|
14115
|
+
const stagedNodeModules = path15.join(staged.stageDir, "node_modules");
|
|
14116
|
+
const targetNodeModules = path15.join(nitroFuncDir, "node_modules");
|
|
13697
14117
|
try {
|
|
13698
|
-
await mergeStagedDirectory(stagedNodeModules, targetNodeModules,
|
|
13699
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
14118
|
+
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs5);
|
|
14119
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
13700
14120
|
functionPackage.dependencies = {
|
|
13701
14121
|
...functionPackage.dependencies,
|
|
13702
14122
|
...staged.dependencies
|
|
13703
14123
|
};
|
|
13704
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14124
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13705
14125
|
} finally {
|
|
13706
|
-
await
|
|
14126
|
+
await fs5.rm(staged.stageDir, { recursive: true, force: true });
|
|
13707
14127
|
}
|
|
13708
14128
|
logger.info(
|
|
13709
14129
|
`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
|
|
@@ -13716,15 +14136,15 @@ async function settleAllOrThrow(operations) {
|
|
|
13716
14136
|
);
|
|
13717
14137
|
if (failure) throw failure.reason;
|
|
13718
14138
|
}
|
|
13719
|
-
async function mergeStagedDirectory(sourceDir, targetDir,
|
|
13720
|
-
await
|
|
13721
|
-
const entries = await
|
|
14139
|
+
async function mergeStagedDirectory(sourceDir, targetDir, fs5) {
|
|
14140
|
+
await fs5.mkdir(targetDir, { recursive: true });
|
|
14141
|
+
const entries = await fs5.readdir(sourceDir, { withFileTypes: true });
|
|
13722
14142
|
await settleAllOrThrow(
|
|
13723
14143
|
entries.map(async (entry) => {
|
|
13724
|
-
const sourcePath =
|
|
13725
|
-
const targetPath =
|
|
14144
|
+
const sourcePath = path15.join(sourceDir, entry.name);
|
|
14145
|
+
const targetPath = path15.join(targetDir, entry.name);
|
|
13726
14146
|
try {
|
|
13727
|
-
await
|
|
14147
|
+
await fs5.rename(sourcePath, targetPath);
|
|
13728
14148
|
return;
|
|
13729
14149
|
} catch (error) {
|
|
13730
14150
|
const code = error.code;
|
|
@@ -13733,29 +14153,29 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
13733
14153
|
}
|
|
13734
14154
|
}
|
|
13735
14155
|
if (entry.isDirectory()) {
|
|
13736
|
-
await mergeStagedDirectory(sourcePath, targetPath,
|
|
13737
|
-
await
|
|
14156
|
+
await mergeStagedDirectory(sourcePath, targetPath, fs5);
|
|
14157
|
+
await fs5.rm(sourcePath, { recursive: true, force: true });
|
|
13738
14158
|
return;
|
|
13739
14159
|
}
|
|
13740
|
-
await
|
|
14160
|
+
await fs5.cp(sourcePath, targetPath, {
|
|
13741
14161
|
force: true,
|
|
13742
14162
|
dereference: true,
|
|
13743
14163
|
mode: fsConstants.COPYFILE_FICLONE
|
|
13744
14164
|
});
|
|
13745
|
-
await
|
|
14165
|
+
await fs5.rm(sourcePath, { force: true });
|
|
13746
14166
|
})
|
|
13747
14167
|
);
|
|
13748
14168
|
}
|
|
13749
14169
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
13750
14170
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
13751
14171
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
13752
|
-
const file = generated.modulePath ? toPosixPath(
|
|
14172
|
+
const file = generated.modulePath ? toPosixPath(path15.relative(root, generated.modulePath)) : "";
|
|
13753
14173
|
throw new Error(
|
|
13754
14174
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
13755
14175
|
);
|
|
13756
14176
|
}
|
|
13757
14177
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
13758
|
-
const projectRequire = createRequire2(
|
|
14178
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
13759
14179
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
13760
14180
|
if (packageJsonPath) return packageJsonPath;
|
|
13761
14181
|
try {
|
|
@@ -13764,38 +14184,38 @@ function resolveMetadataImageRuntimePackageJson(root) {
|
|
|
13764
14184
|
return null;
|
|
13765
14185
|
}
|
|
13766
14186
|
}
|
|
13767
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
14187
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs5) {
|
|
13768
14188
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
13769
14189
|
if (!packageJsonPath) return;
|
|
13770
|
-
const packageJson = JSON.parse(await
|
|
13771
|
-
const packageDir =
|
|
13772
|
-
const targetDir =
|
|
13773
|
-
await
|
|
13774
|
-
await
|
|
14190
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
14191
|
+
const packageDir = path15.dirname(packageJsonPath);
|
|
14192
|
+
const targetDir = path15.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
14193
|
+
await fs5.mkdir(path15.dirname(targetDir), { recursive: true });
|
|
14194
|
+
await fs5.cp(packageDir, targetDir, {
|
|
13775
14195
|
recursive: true,
|
|
13776
14196
|
force: true,
|
|
13777
14197
|
dereference: true,
|
|
13778
14198
|
mode: fsConstants.COPYFILE_FICLONE
|
|
13779
14199
|
});
|
|
13780
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
14200
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
13781
14201
|
functionPackage.dependencies = {
|
|
13782
14202
|
...functionPackage.dependencies,
|
|
13783
14203
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
13784
14204
|
};
|
|
13785
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14205
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13786
14206
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
13787
14207
|
}
|
|
13788
|
-
async function readNitroOutputPackage(outputDir,
|
|
13789
|
-
const packagePath =
|
|
13790
|
-
return
|
|
14208
|
+
async function readNitroOutputPackage(outputDir, fs5) {
|
|
14209
|
+
const packagePath = path15.join(outputDir, "package.json");
|
|
14210
|
+
return fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13791
14211
|
if (error.code === "ENOENT") return {};
|
|
13792
14212
|
throw error;
|
|
13793
14213
|
});
|
|
13794
14214
|
}
|
|
13795
|
-
async function writeNitroOutputPackage(outputDir, packageJson,
|
|
13796
|
-
await
|
|
13797
|
-
await
|
|
13798
|
-
|
|
14215
|
+
async function writeNitroOutputPackage(outputDir, packageJson, fs5) {
|
|
14216
|
+
await fs5.mkdir(outputDir, { recursive: true });
|
|
14217
|
+
await fs5.writeFile(
|
|
14218
|
+
path15.join(outputDir, "package.json"),
|
|
13799
14219
|
`${JSON.stringify(packageJson, null, 2)}
|
|
13800
14220
|
`
|
|
13801
14221
|
);
|
|
@@ -13811,70 +14231,70 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
13811
14231
|
}
|
|
13812
14232
|
}
|
|
13813
14233
|
try {
|
|
13814
|
-
let directory =
|
|
13815
|
-
while (directory !==
|
|
13816
|
-
const candidate =
|
|
13817
|
-
if (
|
|
14234
|
+
let directory = path15.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
14235
|
+
while (directory !== path15.dirname(directory)) {
|
|
14236
|
+
const candidate = path15.join(directory, "package.json");
|
|
14237
|
+
if (existsSync3(candidate)) {
|
|
13818
14238
|
try {
|
|
13819
14239
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
13820
14240
|
if (manifest.name === packageName) return candidate;
|
|
13821
14241
|
} catch {
|
|
13822
14242
|
}
|
|
13823
14243
|
}
|
|
13824
|
-
if (
|
|
13825
|
-
directory =
|
|
14244
|
+
if (path15.basename(directory) === "node_modules") break;
|
|
14245
|
+
directory = path15.dirname(directory);
|
|
13826
14246
|
}
|
|
13827
14247
|
} catch {
|
|
13828
14248
|
}
|
|
13829
14249
|
return null;
|
|
13830
14250
|
}
|
|
13831
|
-
async function resolveProjectInstalledPackageDir(root, packageName,
|
|
13832
|
-
let directory =
|
|
14251
|
+
async function resolveProjectInstalledPackageDir(root, packageName, fs5) {
|
|
14252
|
+
let directory = path15.resolve(root);
|
|
13833
14253
|
while (true) {
|
|
13834
|
-
const candidate =
|
|
14254
|
+
const candidate = path15.join(directory, "node_modules", ...packageName.split("/"));
|
|
13835
14255
|
try {
|
|
13836
|
-
const packageDir = await
|
|
13837
|
-
if ((await
|
|
14256
|
+
const packageDir = await fs5.realpath(candidate);
|
|
14257
|
+
if ((await fs5.stat(path15.join(packageDir, "package.json"))).isFile()) return packageDir;
|
|
13838
14258
|
} catch {
|
|
13839
14259
|
}
|
|
13840
|
-
const parent =
|
|
14260
|
+
const parent = path15.dirname(directory);
|
|
13841
14261
|
if (parent === directory) return null;
|
|
13842
14262
|
directory = parent;
|
|
13843
14263
|
}
|
|
13844
14264
|
}
|
|
13845
|
-
async function copyPrismaClientForVercel(root, nitroFuncDir,
|
|
13846
|
-
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client",
|
|
14265
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs5) {
|
|
14266
|
+
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs5);
|
|
13847
14267
|
if (!prismaClientDir) return;
|
|
13848
|
-
const generatedClientDir =
|
|
14268
|
+
const generatedClientDir = path15.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
13849
14269
|
try {
|
|
13850
|
-
await
|
|
14270
|
+
await fs5.access(generatedClientDir);
|
|
13851
14271
|
} catch {
|
|
13852
14272
|
return;
|
|
13853
14273
|
}
|
|
13854
|
-
const targetNodeModules =
|
|
13855
|
-
const targetPrismaScopeDir =
|
|
13856
|
-
const targetGeneratedDir =
|
|
13857
|
-
const targetClientDir =
|
|
13858
|
-
await
|
|
13859
|
-
await
|
|
14274
|
+
const targetNodeModules = path15.join(nitroFuncDir, "node_modules");
|
|
14275
|
+
const targetPrismaScopeDir = path15.join(targetNodeModules, "@prisma");
|
|
14276
|
+
const targetGeneratedDir = path15.join(targetNodeModules, ".prisma", "client");
|
|
14277
|
+
const targetClientDir = path15.join(targetPrismaScopeDir, "client");
|
|
14278
|
+
await fs5.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
14279
|
+
await fs5.cp(prismaClientDir, targetClientDir, {
|
|
13860
14280
|
recursive: true,
|
|
13861
14281
|
force: true
|
|
13862
14282
|
});
|
|
13863
|
-
await
|
|
14283
|
+
await fs5.cp(generatedClientDir, targetGeneratedDir, {
|
|
13864
14284
|
recursive: true,
|
|
13865
14285
|
force: true
|
|
13866
14286
|
});
|
|
13867
|
-
const clientPackagePath =
|
|
14287
|
+
const clientPackagePath = path15.join(prismaClientDir, "package.json");
|
|
13868
14288
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
13869
|
-
readNitroOutputPackage(nitroFuncDir,
|
|
13870
|
-
|
|
14289
|
+
readNitroOutputPackage(nitroFuncDir, fs5),
|
|
14290
|
+
fs5.readFile(clientPackagePath, "utf-8")
|
|
13871
14291
|
]);
|
|
13872
14292
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
13873
14293
|
functionPackage.dependencies = {
|
|
13874
14294
|
...functionPackage.dependencies,
|
|
13875
14295
|
"@prisma/client": clientPackage.version
|
|
13876
14296
|
};
|
|
13877
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14297
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13878
14298
|
}
|
|
13879
14299
|
function islandsActionKeyCode() {
|
|
13880
14300
|
const key = randomBytes(32).toString("base64url");
|
|
@@ -14004,6 +14424,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
14004
14424
|
rendererBuild.signal
|
|
14005
14425
|
);
|
|
14006
14426
|
const farmApp = createFarmApp(config, projectModuleServer);
|
|
14427
|
+
if (options.universal !== false) farmApp.getRouteManager().keepBuildSourceSnapshot();
|
|
14007
14428
|
await farmApp.initialize();
|
|
14008
14429
|
const routeManager = farmApp.getRouteManager();
|
|
14009
14430
|
const serverRenderer = farmApp.getServerRenderer();
|
|
@@ -14050,9 +14471,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
14050
14471
|
} else {
|
|
14051
14472
|
const { build: legacyViteBuild } = await import("vite");
|
|
14052
14473
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
14053
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
14474
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path16.join(root, distDir, "client"));
|
|
14054
14475
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
14055
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
14476
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path16.join(root, distDir, "server"));
|
|
14056
14477
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
14057
14478
|
await buildNitro(
|
|
14058
14479
|
config,
|
|
@@ -14154,8 +14575,8 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14154
14575
|
root,
|
|
14155
14576
|
// Vite keys its pre-bundled dependencies on the config, mode included, so this server and
|
|
14156
14577
|
// `farm dev` sharing one cache would each rebuild it after the other ran.
|
|
14157
|
-
cacheDir:
|
|
14158
|
-
|
|
14578
|
+
cacheDir: path16.join(
|
|
14579
|
+
path16.resolve(root, viteConfig.cacheDir ?? path16.join("node_modules", ".vite")),
|
|
14159
14580
|
"farm-build"
|
|
14160
14581
|
),
|
|
14161
14582
|
configFile: false,
|
|
@@ -14255,16 +14676,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14255
14676
|
});
|
|
14256
14677
|
}
|
|
14257
14678
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
14258
|
-
const appDir =
|
|
14679
|
+
const appDir = path16.join(root, srcDir, "app");
|
|
14259
14680
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
14260
|
-
const candidate =
|
|
14261
|
-
if (
|
|
14681
|
+
const candidate = path16.join(appDir, `page${extension}`);
|
|
14682
|
+
if (existsSync4(candidate)) return candidate;
|
|
14262
14683
|
}
|
|
14263
|
-
return
|
|
14684
|
+
return path16.join(appDir, "page.tsx");
|
|
14264
14685
|
}
|
|
14265
14686
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
14266
14687
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
14267
|
-
import("./nitro-
|
|
14688
|
+
import("./nitro-XTQ2HKDL.mjs"),
|
|
14268
14689
|
import("nitro/builder")
|
|
14269
14690
|
]);
|
|
14270
14691
|
let nitroConfig = await createNitroConfig(
|
|
@@ -14278,23 +14699,23 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14278
14699
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
14279
14700
|
}
|
|
14280
14701
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
14281
|
-
const serverOutputDir =
|
|
14282
|
-
const publicOutputDir =
|
|
14702
|
+
const serverOutputDir = path16.join(outputDir, "server");
|
|
14703
|
+
const publicOutputDir = path16.join(outputDir, "public");
|
|
14283
14704
|
const { mkdir, cp } = await import("fs/promises");
|
|
14284
14705
|
await mkdir(serverOutputDir, { recursive: true });
|
|
14285
14706
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14286
|
-
const clientDir =
|
|
14707
|
+
const clientDir = path16.join(root, distDir, "client");
|
|
14287
14708
|
try {
|
|
14288
14709
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14289
14710
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
14290
14711
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
14291
|
-
const manifestPath =
|
|
14292
|
-
const assetsDir =
|
|
14712
|
+
const manifestPath = path16.join(publicOutputDir, "farm-client-manifest.json");
|
|
14713
|
+
const assetsDir = path16.join(publicOutputDir, "assets");
|
|
14293
14714
|
const manifestExists = await import("fs/promises").then(
|
|
14294
|
-
(
|
|
14715
|
+
(fs5) => fs5.access(manifestPath).then(() => true).catch(() => false)
|
|
14295
14716
|
);
|
|
14296
14717
|
const assetsExist = await import("fs/promises").then(
|
|
14297
|
-
(
|
|
14718
|
+
(fs5) => fs5.access(assetsDir).then(() => true).catch(() => false)
|
|
14298
14719
|
);
|
|
14299
14720
|
if (manifestExists && assetsExist) {
|
|
14300
14721
|
logger.info("\u2705 Verified client assets are present");
|
|
@@ -14305,8 +14726,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14305
14726
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
14306
14727
|
throw error;
|
|
14307
14728
|
}
|
|
14308
|
-
const serverDir =
|
|
14309
|
-
const nitroServerDir =
|
|
14729
|
+
const serverDir = path16.join(root, distDir, "server");
|
|
14730
|
+
const nitroServerDir = path16.join(root, distDir, ".nitro", "server", "farm");
|
|
14310
14731
|
try {
|
|
14311
14732
|
await mkdir(nitroServerDir, { recursive: true });
|
|
14312
14733
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -14315,7 +14736,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14315
14736
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
14316
14737
|
}
|
|
14317
14738
|
const nitro = await createNitro(nitroConfig);
|
|
14318
|
-
const registryPath =
|
|
14739
|
+
const registryPath = path16.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
14319
14740
|
try {
|
|
14320
14741
|
const { farmRegistry } = await import(
|
|
14321
14742
|
/* @vite-ignore */
|
|
@@ -14332,7 +14753,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14332
14753
|
}
|
|
14333
14754
|
farmRegistry.routePaths = routePaths;
|
|
14334
14755
|
try {
|
|
14335
|
-
const clientManifestPath =
|
|
14756
|
+
const clientManifestPath = path16.join(root, distDir, "client", "farm-client-manifest.json");
|
|
14336
14757
|
const { readFile } = await import("fs/promises");
|
|
14337
14758
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
14338
14759
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|