@farm.js/core 0.1.37 → 0.1.39
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-BC0bAGVF.d.mts → agent-mcp-BhneNPb4.d.mts} +1 -1
- package/dist/{agent-mcp-jyDHbQKe.d.ts → agent-mcp-HcTYQmNX.d.ts} +1 -1
- package/dist/{agent-mcp-handler-SJAHFSPI.cjs → agent-mcp-handler-MRGP3WJ3.cjs} +5 -5
- package/dist/{agent-mcp-handler-LPJ2CADR.mjs → agent-mcp-handler-OLRMZONF.mjs} +4 -4
- package/dist/agent-runtime.cjs +3 -3
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +2 -2
- package/dist/api/client.cjs +3 -3
- package/dist/api/client.mjs +2 -2
- package/dist/api/route-manager.cjs +5 -5
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/route-manager.mjs +4 -4
- package/dist/api/runtime.cjs +4 -4
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api/runtime.mjs +3 -3
- package/dist/api.cjs +7 -7
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +6 -6
- package/dist/{app-CKO3iN1c.d.ts → app-CMkoghtp.d.ts} +21 -3
- package/dist/{app-Cbkj9ufe.d.mts → app-DVzmmbNO.d.mts} +21 -3
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +3 -3
- package/dist/chunk-2ZYGC6SS.cjs +576 -0
- package/dist/{chunk-75X755YZ.cjs → chunk-34UCJRQO.cjs} +2 -2
- package/dist/{chunk-CVH2BXPY.cjs → chunk-3LOLJTFV.cjs} +6 -6
- package/dist/{chunk-4GPOC4LN.cjs → chunk-472NCAZ7.cjs} +3 -3
- package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
- package/dist/{chunk-6LGFV2CQ.cjs → chunk-5OKBARDN.cjs} +2 -2
- package/dist/{chunk-3IP27TCG.cjs → chunk-5PWXMJOH.cjs} +19 -19
- package/dist/{chunk-WT4TGLXT.cjs → chunk-5ULKUBIA.cjs} +6 -6
- package/dist/{chunk-WRPHYQVY.mjs → chunk-677THUVP.mjs} +1 -1
- package/dist/chunk-6BK3K2GB.mjs +318 -0
- package/dist/{chunk-HEVMCTSR.mjs → chunk-6HB6V3R7.mjs} +1 -1
- package/dist/{chunk-NICDYKBS.cjs → chunk-6XWDE2P2.cjs} +22 -4
- package/dist/{chunk-CXEN47J3.mjs → chunk-73WX6PRY.mjs} +25 -0
- package/dist/{chunk-EXG5LD6B.mjs → chunk-75HN5IZ3.mjs} +21 -9
- package/dist/{chunk-7O5M4UKW.cjs → chunk-A657YSP4.cjs} +2 -2
- package/dist/{chunk-LBDP3YT3.mjs → chunk-ARC7I3O2.mjs} +1 -1
- package/dist/{chunk-Q5FYSK45.cjs → chunk-AS2VPMEE.cjs} +640 -521
- package/dist/{chunk-Z5BEWYVO.mjs → chunk-ATSDUUFK.mjs} +27 -1
- package/dist/{chunk-EMMQ64QW.cjs → chunk-B5J2YVG7.cjs} +16 -16
- package/dist/{chunk-FWE7LEQC.cjs → chunk-BD3D7EZV.cjs} +4 -4
- package/dist/{chunk-Z7LA7MHQ.mjs → chunk-BFJTHYTN.mjs} +1 -1
- package/dist/{chunk-UJZLSXUB.cjs → chunk-BWIQR4DH.cjs} +30 -4
- package/dist/{chunk-W2YDNK66.cjs → chunk-BXDJXFQG.cjs} +4 -4
- package/dist/{chunk-MCIZVNOQ.mjs → chunk-BZHXGVMA.mjs} +1 -1
- package/dist/{chunk-7DWNJI73.cjs → chunk-CIOT4HGT.cjs} +37 -19
- package/dist/{chunk-KDTBF3UU.mjs → chunk-CNNOLE4O.mjs} +1 -1
- package/dist/{chunk-TDNWPAVR.mjs → chunk-CUM5NYL5.mjs} +1 -1
- package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
- package/dist/{chunk-KPFKMDM7.mjs → chunk-EGCTIS5F.mjs} +2 -2
- package/dist/{chunk-VR4GD5I3.cjs → chunk-EIPC3FDA.cjs} +12 -4
- package/dist/{chunk-B5PFZLKV.cjs → chunk-EKN7NSZO.cjs} +25 -8
- package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
- package/dist/{chunk-LBGILORX.mjs → chunk-GKBWWRBG.mjs} +101 -10
- package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
- package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
- package/dist/{chunk-3A4KGQYI.cjs → chunk-HRETEZ2Z.cjs} +27 -15
- package/dist/{chunk-ATWHHSY2.cjs → chunk-HRSAQ23K.cjs} +7 -7
- package/dist/{chunk-IAIYV4RZ.mjs → chunk-HXRYZWTA.mjs} +1 -1
- package/dist/{chunk-4P6ULFMD.mjs → chunk-HYTZYOW2.mjs} +222 -103
- package/dist/{chunk-HMRSWN47.mjs → chunk-INL3THCU.mjs} +1 -1
- package/dist/{chunk-FBOJ55OM.mjs → chunk-IVLZZZEI.mjs} +1 -1
- package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
- package/dist/{chunk-PMQHMWZU.cjs → chunk-JCYYXBAJ.cjs} +3 -3
- package/dist/{chunk-K3SAEIM3.mjs → chunk-KTSUBU2E.mjs} +2 -2
- package/dist/{chunk-LPFV45AY.cjs → chunk-LMPAPBUA.cjs} +19 -19
- package/dist/{chunk-EK4QAEFZ.cjs → chunk-LZESP4IR.cjs} +25 -0
- package/dist/{chunk-TW4GYDBJ.mjs → chunk-MLY2RP5R.mjs} +10 -2
- package/dist/{chunk-BHY547NB.cjs → chunk-NBBEQLOK.cjs} +9 -9
- package/dist/{chunk-WQ7T2263.mjs → chunk-OAHTRMIC.mjs} +3 -3
- package/dist/{chunk-HZFM2LWQ.mjs → chunk-P3PLW4FR.mjs} +34 -2
- package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
- package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
- package/dist/{chunk-3KGDJLJK.mjs → chunk-POSPE3IO.mjs} +19 -1
- package/dist/{chunk-FGRYBX5X.mjs → chunk-PVZE2JGJ.mjs} +2 -2
- package/dist/{chunk-TPLJVC7E.mjs → chunk-QFW2IH5E.mjs} +23 -6
- package/dist/{chunk-5BXGGEC7.cjs → chunk-QG775BRV.cjs} +17 -17
- package/dist/{chunk-S3VWVTVA.mjs → chunk-QRKIMN7T.mjs} +13 -1
- package/dist/chunk-QTXBII4Z.cjs +632 -0
- package/dist/{chunk-NQ6QFZWD.cjs → chunk-QUCXCDE2.cjs} +1 -1
- package/dist/{chunk-NFMDCAOS.mjs → chunk-QYMZOOC5.mjs} +3 -3
- package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
- package/dist/{chunk-LOFKRKO7.cjs → chunk-RVXFINNS.cjs} +113 -22
- package/dist/{chunk-7SQ5SGYZ.cjs → chunk-RW63BOV7.cjs} +2 -2
- package/dist/{chunk-U6MPZ35Q.cjs → chunk-RWFLWR5J.cjs} +8 -8
- package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
- package/dist/{chunk-J3ANCZKA.mjs → chunk-SKVTP5PR.mjs} +1 -1
- package/dist/{chunk-YCKO6FRS.mjs → chunk-SOP2EAA6.mjs} +1 -1
- package/dist/{chunk-ND2CWPOD.mjs → chunk-TS4JHGUJ.mjs} +1 -1
- package/dist/chunk-U6QLDL3G.mjs +576 -0
- package/dist/{chunk-OW67PDDS.cjs → chunk-ULASELLA.cjs} +13 -1
- package/dist/{chunk-4GWRFP22.cjs → chunk-UPJLHLJU.cjs} +35 -3
- package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
- package/dist/{chunk-NNSAQX3U.mjs → chunk-VT4WFRHA.mjs} +1 -1
- package/dist/{chunk-JPNFPAZ4.mjs → chunk-VWBHM3F6.mjs} +2 -2
- package/dist/{chunk-ADOAUDQ6.cjs → chunk-VXEEATVD.cjs} +2 -2
- package/dist/{chunk-RRMVL6CJ.mjs → chunk-W36M2BQ4.mjs} +1 -1
- package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
- package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
- package/dist/{chunk-VXAWRDK7.mjs → chunk-WLL43JMO.mjs} +1 -1
- package/dist/chunk-WW46B6HA.cjs +318 -0
- package/dist/{chunk-D3C5LBQY.cjs → chunk-WXJLNP33.cjs} +2 -2
- package/dist/{chunk-NDILNQ4L.cjs → chunk-XKG2BLFN.cjs} +2 -2
- package/dist/{chunk-6TJITR2B.cjs → chunk-YFYUYWL7.cjs} +870 -751
- package/dist/{chunk-XOPOIFTJ.mjs → chunk-YKZRDB5Z.mjs} +25 -7
- package/dist/{chunk-K4I4O5TS.mjs → chunk-ZUPXLIGB.mjs} +790 -671
- package/dist/{chunk-G2TEB74S.cjs → chunk-ZXH4TS3F.cjs} +2 -2
- package/dist/{client-plugins-CV4eJ9De.d.mts → client-plugins-CsCuCLBz.d.mts} +58 -7
- package/dist/{client-plugins-C8DjftDF.d.ts → client-plugins-D0ke-Hc8.d.ts} +58 -7
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +7 -7
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +6 -6
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-KVOY2TCZ.mjs → devtools-5AFIPVUJ.mjs} +8 -6
- package/dist/{devtools-JXFQNWSH.cjs → devtools-LW4QQ5J3.cjs} +9 -7
- package/dist/docs.cjs +12 -10
- package/dist/docs.d.mts +20 -2
- package/dist/docs.d.ts +20 -2
- package/dist/docs.mjs +11 -9
- package/dist/headers.cjs +6 -4
- package/dist/headers.d.mts +11 -1
- package/dist/headers.d.ts +11 -1
- package/dist/headers.mjs +5 -3
- package/dist/index.cjs +55 -42
- package/dist/index.d.mts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.mjs +55 -42
- package/dist/integrations.cjs +5 -3
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +4 -2
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +30 -29
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +29 -28
- package/dist/internal/cli-runtime.cjs +11 -9
- package/dist/internal/cli-runtime.mjs +10 -8
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +9 -7
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +8 -6
- package/dist/internal/docs-precompiled-runtime.cjs +19 -13
- package/dist/internal/docs-precompiled-runtime.d.mts +5 -0
- package/dist/internal/docs-precompiled-runtime.d.ts +5 -0
- package/dist/internal/docs-precompiled-runtime.mjs +14 -8
- package/dist/internal/infra-analytics-runtime.cjs +5 -5
- package/dist/internal/infra-analytics-runtime.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +6 -2
- package/dist/internal/production-node-env.d.mts +10 -1
- package/dist/internal/production-node-env.d.ts +10 -1
- package/dist/internal/production-node-env.mjs +5 -1
- package/dist/internal/production-runtime.cjs +38 -16
- package/dist/internal/production-runtime.d.mts +51 -11
- package/dist/internal/production-runtime.d.ts +51 -11
- package/dist/internal/production-runtime.mjs +40 -18
- package/dist/markdown.cjs +8 -2
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +7 -1
- package/dist/middleware.cjs +10 -8
- package/dist/middleware.d.mts +24 -4
- package/dist/middleware.d.ts +24 -4
- package/dist/middleware.mjs +10 -8
- package/dist/navigation.cjs +6 -6
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +5 -5
- package/dist/plugin.cjs +23 -22
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +22 -21
- package/dist/{production-runtime-C2kkrPVZ.d.ts → production-runtime-BaI3WHnV.d.ts} +1 -1
- package/dist/{production-runtime-Du_FHb2-.d.mts → production-runtime-DfRP0cV0.d.mts} +1 -1
- package/dist/query/client.cjs +8 -8
- package/dist/query/client.mjs +3 -3
- package/dist/{render-plan-BnnPTpus.d.ts → render-plan-CfIdJKAf.d.ts} +1 -1
- package/dist/{render-plan-Cgx7v8tJ.d.mts → render-plan-Dg8RBYFa.d.mts} +1 -1
- package/dist/renderer-client.cjs +5 -5
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/renderer-client.mjs +2 -2
- package/dist/renderer.d.mts +13 -4
- package/dist/renderer.d.ts +13 -4
- package/dist/{request-BNWr7r5e.d.ts → request-CEbHIIl4.d.ts} +4 -2
- package/dist/{request-sKayKcop.d.mts → request-DfE02G_A.d.mts} +4 -2
- package/dist/request.cjs +3 -3
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/request.mjs +2 -2
- package/dist/{route-rendering-DWFp3Yq4.d.mts → route-rendering-BHyOfXjD.d.mts} +1 -1
- package/dist/{route-rendering-Bx4Auw6Q.d.ts → route-rendering-C4oHbv6C.d.ts} +1 -1
- package/dist/{router-BK6K42Ij.d.mts → router-DwhA61SB.d.mts} +1 -1
- package/dist/{router-DnW_2tQi.d.ts → router-uRN_29Em.d.ts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/{runtime-DJDaCMd_.d.mts → runtime-BEdHhN4C.d.mts} +1 -1
- package/dist/{runtime-CA3Ei5k_.d.ts → runtime-COk03hmx.d.ts} +1 -1
- package/dist/server-fn.cjs +3 -3
- package/dist/server-fn.mjs +2 -2
- package/dist/server-plugins.cjs +5 -5
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-plugins.mjs +4 -4
- package/dist/server-query.cjs +4 -4
- package/dist/server-query.mjs +3 -3
- package/dist/server.cjs +49 -48
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +27 -26
- package/dist/{spa-router-Mwbd7g2L.d.ts → spa-router-DrVOBVGg.d.ts} +2 -2
- package/dist/{spa-router-D6fUA4Rn.d.mts → spa-router-w4aFOuyn.d.mts} +2 -2
- package/dist/testing.cjs +5 -5
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +4 -4
- package/dist/theme/server.cjs +4 -4
- package/dist/theme/server.mjs +3 -3
- package/dist/{utils-p9Hs-jCc.d.mts → utils-BtYehqeU.d.mts} +1 -1
- package/dist/{utils-BwVcAfUR.d.ts → utils-Dhuqwmd2.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +23 -22
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +22 -21
- package/package.json +1 -1
- package/dist/chunk-655RLQQL.mjs +0 -43
- package/dist/chunk-MRMI32SN.cjs +0 -1157
- package/dist/chunk-MT763TDW.cjs +0 -43
|
@@ -3,25 +3,31 @@
|
|
|
3
3
|
var _chunkA6WIQH5Zcjs = require('./chunk-A6WIQH5Z.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var _chunkMT763TDWcjs = require('./chunk-MT763TDW.cjs');
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
var
|
|
9
|
+
var _chunkWW46B6HAcjs = require('./chunk-WW46B6HA.cjs');
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
var
|
|
13
|
+
var _chunk5ULKUBIAcjs = require('./chunk-5ULKUBIA.cjs');
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
|
|
19
|
+
var _chunkCIOT4HGTcjs = require('./chunk-CIOT4HGT.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunkPGZDEPTMcjs = require('./chunk-PGZDEPTM.cjs');
|
|
25
31
|
|
|
26
32
|
|
|
27
33
|
|
|
@@ -29,7 +35,7 @@ var _chunkTE2G5IONcjs = require('./chunk-TE2G5ION.cjs');
|
|
|
29
35
|
var _chunkMWWVKDW3cjs = require('./chunk-MWWVKDW3.cjs');
|
|
30
36
|
|
|
31
37
|
|
|
32
|
-
var
|
|
38
|
+
var _chunkWXJLNP33cjs = require('./chunk-WXJLNP33.cjs');
|
|
33
39
|
|
|
34
40
|
|
|
35
41
|
var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
|
|
@@ -38,7 +44,7 @@ var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
|
|
|
38
44
|
|
|
39
45
|
|
|
40
46
|
|
|
41
|
-
var
|
|
47
|
+
var _chunkHRETEZ2Zcjs = require('./chunk-HRETEZ2Z.cjs');
|
|
42
48
|
|
|
43
49
|
|
|
44
50
|
var _chunkKCMTCM6Icjs = require('./chunk-KCMTCM6I.cjs');
|
|
@@ -77,7 +83,7 @@ var _chunk2SJ4RQ6Pcjs = require('./chunk-2SJ4RQ6P.cjs');
|
|
|
77
83
|
|
|
78
84
|
|
|
79
85
|
|
|
80
|
-
var
|
|
86
|
+
var _chunkAS2VPMEEcjs = require('./chunk-AS2VPMEE.cjs');
|
|
81
87
|
|
|
82
88
|
|
|
83
89
|
|
|
@@ -95,12 +101,16 @@ var _chunk5D2JIPLHcjs = require('./chunk-5D2JIPLH.cjs');
|
|
|
95
101
|
|
|
96
102
|
|
|
97
103
|
|
|
98
|
-
var _chunkLOFKRKO7cjs = require('./chunk-LOFKRKO7.cjs');
|
|
99
104
|
|
|
100
105
|
|
|
101
106
|
|
|
102
107
|
|
|
103
|
-
var
|
|
108
|
+
var _chunkRVXFINNScjs = require('./chunk-RVXFINNS.cjs');
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
var _chunkH5CLOUZScjs = require('./chunk-H5CLOUZS.cjs');
|
|
104
114
|
|
|
105
115
|
|
|
106
116
|
var _chunkCXP5U3RWcjs = require('./chunk-CXP5U3RW.cjs');
|
|
@@ -110,7 +120,7 @@ var _chunk3SDFA7UFcjs = require('./chunk-3SDFA7UF.cjs');
|
|
|
110
120
|
|
|
111
121
|
|
|
112
122
|
|
|
113
|
-
var
|
|
123
|
+
var _chunkCY2ZQ5C6cjs = require('./chunk-CY2ZQ5C6.cjs');
|
|
114
124
|
|
|
115
125
|
|
|
116
126
|
|
|
@@ -132,7 +142,8 @@ var _chunkWBKEZXWEcjs = require('./chunk-WBKEZXWE.cjs');
|
|
|
132
142
|
var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
|
|
133
143
|
|
|
134
144
|
|
|
135
|
-
|
|
145
|
+
|
|
146
|
+
var _chunk2ZYGC6SScjs = require('./chunk-2ZYGC6SS.cjs');
|
|
136
147
|
|
|
137
148
|
|
|
138
149
|
|
|
@@ -144,14 +155,14 @@ var _chunk6EXBPJ24cjs = require('./chunk-6EXBPJ24.cjs');
|
|
|
144
155
|
var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
|
|
145
156
|
|
|
146
157
|
|
|
147
|
-
var
|
|
158
|
+
var _chunkEKN7NSZOcjs = require('./chunk-EKN7NSZO.cjs');
|
|
148
159
|
|
|
149
160
|
|
|
150
161
|
|
|
151
162
|
var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
|
|
152
163
|
|
|
153
164
|
|
|
154
|
-
var
|
|
165
|
+
var _chunkSGBJ247Qcjs = require('./chunk-SGBJ247Q.cjs');
|
|
155
166
|
|
|
156
167
|
|
|
157
168
|
|
|
@@ -160,20 +171,15 @@ var _chunkSDOTRX3Vcjs = require('./chunk-SDOTRX3V.cjs');
|
|
|
160
171
|
|
|
161
172
|
|
|
162
173
|
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
var _chunkBWIQR4DHcjs = require('./chunk-BWIQR4DH.cjs');
|
|
167
175
|
|
|
168
|
-
var _chunkLPFV45AYcjs = require('./chunk-LPFV45AY.cjs');
|
|
169
176
|
|
|
170
177
|
|
|
171
178
|
|
|
179
|
+
var _chunkLMPAPBUAcjs = require('./chunk-LMPAPBUA.cjs');
|
|
172
180
|
|
|
173
|
-
var _chunk4GWRFP22cjs = require('./chunk-4GWRFP22.cjs');
|
|
174
181
|
|
|
175
|
-
|
|
176
|
-
var _chunkU6MPZ35Qcjs = require('./chunk-U6MPZ35Q.cjs');
|
|
182
|
+
var _chunkRWFLWR5Jcjs = require('./chunk-RWFLWR5J.cjs');
|
|
177
183
|
|
|
178
184
|
|
|
179
185
|
var _chunkUFDAAQFXcjs = require('./chunk-UFDAAQFX.cjs');
|
|
@@ -200,12 +206,15 @@ var _chunk5QIKR7RRcjs = require('./chunk-5QIKR7RR.cjs');
|
|
|
200
206
|
var _chunkKNBBQHO2cjs = require('./chunk-KNBBQHO2.cjs');
|
|
201
207
|
|
|
202
208
|
|
|
203
|
-
var
|
|
209
|
+
var _chunkQUCXCDE2cjs = require('./chunk-QUCXCDE2.cjs');
|
|
204
210
|
|
|
205
211
|
|
|
206
212
|
var _chunkC5GUTBZKcjs = require('./chunk-C5GUTBZK.cjs');
|
|
207
213
|
|
|
208
214
|
|
|
215
|
+
var _chunk6XWDE2P2cjs = require('./chunk-6XWDE2P2.cjs');
|
|
216
|
+
|
|
217
|
+
|
|
209
218
|
var _chunkNO3WWW3Ncjs = require('./chunk-NO3WWW3N.cjs');
|
|
210
219
|
|
|
211
220
|
|
|
@@ -221,15 +230,15 @@ var _fs = require('fs');
|
|
|
221
230
|
var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
222
231
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
223
232
|
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
224
|
-
const
|
|
233
|
+
const fs3 = await import("fs/promises");
|
|
225
234
|
try {
|
|
226
|
-
const bytes = await
|
|
235
|
+
const bytes = await fs3.readFile(sourcePath);
|
|
227
236
|
if (bytes.length === 0) return null;
|
|
228
237
|
const { createHash } = await import("crypto");
|
|
229
238
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
230
239
|
const name = hashedName(hash);
|
|
231
|
-
await
|
|
232
|
-
await
|
|
240
|
+
await fs3.mkdir(destinationDir, { recursive: true });
|
|
241
|
+
await fs3.writeFile(_path2.default.join(destinationDir, name), bytes);
|
|
233
242
|
return name;
|
|
234
243
|
} catch (e) {
|
|
235
244
|
return null;
|
|
@@ -246,9 +255,9 @@ async function resolveHashedClientCssHref(clientOutputDir) {
|
|
|
246
255
|
}
|
|
247
256
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveHashedClientCssHref, "resolveHashedClientCssHref");
|
|
248
257
|
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
249
|
-
const
|
|
258
|
+
const fs3 = await import("fs/promises");
|
|
250
259
|
try {
|
|
251
|
-
const entries = await
|
|
260
|
+
const entries = await fs3.readdir(clientOutputDir);
|
|
252
261
|
return _nullishCoalesce(entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)), () => ( null));
|
|
253
262
|
} catch (e2) {
|
|
254
263
|
return null;
|
|
@@ -258,10 +267,10 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, findFingerprintedClientEntry, "findFingerp
|
|
|
258
267
|
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
259
268
|
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
260
269
|
if (!entryName) return "/farm-client.js";
|
|
261
|
-
const
|
|
270
|
+
const fs3 = await import("fs/promises");
|
|
262
271
|
const shim = `export * from "./${entryName}";
|
|
263
272
|
`;
|
|
264
|
-
await
|
|
273
|
+
await fs3.writeFile(_path2.default.join(clientOutputDir, "farm-client.js"), shim);
|
|
265
274
|
return `/${entryName}`;
|
|
266
275
|
}
|
|
267
276
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveHashedClientJsSrc, "resolveHashedClientJsSrc");
|
|
@@ -310,7 +319,7 @@ function getDocsTitle(docs) {
|
|
|
310
319
|
}
|
|
311
320
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getDocsTitle, "getDocsTitle");
|
|
312
321
|
function loadPages(contentDir, docs) {
|
|
313
|
-
return
|
|
322
|
+
return _chunkPGZDEPTMcjs.discoverFarmDocsPages.call(void 0, contentDir, docs).map((page) => _chunkPGZDEPTMcjs.loadFarmDocsPage.call(void 0, contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
|
|
314
323
|
}
|
|
315
324
|
_chunkS3JO3N4Hcjs.__name.call(void 0, loadPages, "loadPages");
|
|
316
325
|
function findSocialImagePath(html) {
|
|
@@ -331,31 +340,34 @@ async function addHandlerRoute(routes, pathname, handler, absolutePaths) {
|
|
|
331
340
|
}
|
|
332
341
|
_chunkS3JO3N4Hcjs.__name.call(void 0, addHandlerRoute, "addHandlerRoute");
|
|
333
342
|
async function compileFarmDocsManifest(docs, options) {
|
|
334
|
-
const contentDir =
|
|
343
|
+
const contentDir = _chunkPGZDEPTMcjs.resolveFarmDocsContentDir.call(void 0, docs, options);
|
|
335
344
|
const pages = loadPages(contentDir, docs);
|
|
336
345
|
const absolutePaths = [
|
|
337
346
|
_path2.default.resolve(options.root),
|
|
338
347
|
_path2.default.resolve(contentDir),
|
|
339
348
|
docs.configPath || ""
|
|
340
349
|
];
|
|
341
|
-
const handler =
|
|
350
|
+
const handler = _chunkPGZDEPTMcjs.createFarmDocsHandler.call(void 0, docs, {
|
|
342
351
|
root: options.root,
|
|
343
352
|
srcDir: options.srcDir,
|
|
344
353
|
clientEntry: options.clientEntry,
|
|
345
354
|
fontAssets: options.fontAssets,
|
|
346
355
|
fontStylesheetHref: options.fontStylesheetHref,
|
|
347
|
-
globalStylesheetHref: options.globalStylesheetHref
|
|
356
|
+
globalStylesheetHref: options.globalStylesheetHref,
|
|
357
|
+
isPathGuarded: options.isPathGuarded
|
|
348
358
|
});
|
|
349
|
-
const apiHandler =
|
|
359
|
+
const apiHandler = _chunkCIOT4HGTcjs.createFarmDocsAPIHandler.call(void 0, {
|
|
350
360
|
rootDir: options.root,
|
|
351
361
|
srcDir: options.srcDir,
|
|
352
|
-
docs
|
|
362
|
+
docs,
|
|
363
|
+
isPathGuarded: options.isPathGuarded
|
|
353
364
|
});
|
|
365
|
+
const publicPages = pages.filter((page) => !_optionalChain([options, 'access', _2 => _2.isPathGuarded, 'optionalCall', _3 => _3(page.href)]));
|
|
354
366
|
const routes = {};
|
|
355
367
|
const apiMarkdown = {};
|
|
356
368
|
for (const page of pages) {
|
|
357
369
|
const htmlResponse = await addHandlerRoute(routes, page.href, handler, absolutePaths);
|
|
358
|
-
const markdownPath =
|
|
370
|
+
const markdownPath = _chunkPGZDEPTMcjs.getFarmDocsMarkdownPath.call(void 0, page.href);
|
|
359
371
|
await addHandlerRoute(routes, markdownPath, handler, absolutePaths);
|
|
360
372
|
if (htmlResponse) {
|
|
361
373
|
const socialImagePath = findSocialImagePath(await htmlResponse.text());
|
|
@@ -363,6 +375,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
363
375
|
await addHandlerRoute(routes, socialImagePath, handler, absolutePaths);
|
|
364
376
|
}
|
|
365
377
|
}
|
|
378
|
+
if (_optionalChain([options, 'access', _4 => _4.isPathGuarded, 'optionalCall', _5 => _5(page.href)])) continue;
|
|
366
379
|
const apiResponse = await apiHandler(
|
|
367
380
|
new Request(
|
|
368
381
|
`${FARM_DOCS_COMPILED_ORIGIN}/api/docs?format=markdown&path=${encodeURIComponent(page.slug)}`
|
|
@@ -437,8 +450,8 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
437
450
|
empty: await compileResponse(emptyResponse, absolutePaths),
|
|
438
451
|
post: await compileResponse(postResponse, absolutePaths),
|
|
439
452
|
search: {
|
|
440
|
-
pages:
|
|
441
|
-
...
|
|
453
|
+
pages: publicPages.map((page) => ({
|
|
454
|
+
..._chunkPGZDEPTMcjs.toFarmDocsMarkdownPage.call(void 0, page),
|
|
442
455
|
sourcePath: `farm-docs:${page.slug || "index"}`
|
|
443
456
|
})),
|
|
444
457
|
search: _nullishCoalesce(searchConfig, () => ( true)),
|
|
@@ -450,6 +463,174 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
450
463
|
}
|
|
451
464
|
_chunkS3JO3N4Hcjs.__name.call(void 0, compileFarmDocsManifest, "compileFarmDocsManifest");
|
|
452
465
|
|
|
466
|
+
// src/nitro/client-module-preloads.ts
|
|
467
|
+
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
|
|
468
|
+
|
|
469
|
+
var FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER = "__farm_client_module_preloads__";
|
|
470
|
+
var FARM_CLIENT_MODULE_PRELOADS_FILE = "client-module-preloads.json";
|
|
471
|
+
function collectFarmClientModulePreloads(bundle, options) {
|
|
472
|
+
const chunks = Object.values(bundle).filter(
|
|
473
|
+
(output) => output.type === "chunk"
|
|
474
|
+
);
|
|
475
|
+
const entry = chunks.find((chunk) => chunk.isEntry && chunk.name === options.entryName);
|
|
476
|
+
if (!entry) return null;
|
|
477
|
+
const byFile = new Map(chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
478
|
+
const files = [];
|
|
479
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
480
|
+
const index = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (fileName) => {
|
|
481
|
+
let value = indexOf.get(fileName);
|
|
482
|
+
if (value === void 0) {
|
|
483
|
+
value = files.push(fileName) - 1;
|
|
484
|
+
indexOf.set(fileName, value);
|
|
485
|
+
}
|
|
486
|
+
return value;
|
|
487
|
+
}, "index");
|
|
488
|
+
const staticImports = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (chunk, loaded, into) => {
|
|
489
|
+
for (const fileName of _nullishCoalesce(chunk.imports, () => ( []))) {
|
|
490
|
+
const imported = byFile.get(fileName);
|
|
491
|
+
if (loaded.has(fileName) || !imported) continue;
|
|
492
|
+
loaded.add(fileName);
|
|
493
|
+
into.push(fileName);
|
|
494
|
+
staticImports(imported, loaded, into);
|
|
495
|
+
}
|
|
496
|
+
return into;
|
|
497
|
+
}, "staticImports");
|
|
498
|
+
const entryFiles = staticImports(entry, /* @__PURE__ */ new Set([entry.fileName]), []);
|
|
499
|
+
const entryLoaded = /* @__PURE__ */ new Set([entry.fileName, ...entryFiles]);
|
|
500
|
+
const modules = {};
|
|
501
|
+
for (const chunk of chunks) {
|
|
502
|
+
if (!chunk.isDynamicEntry || !chunk.facadeModuleId || entryLoaded.has(chunk.fileName)) {
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const moduleId = chunk.facadeModuleId.split("?")[0];
|
|
506
|
+
if (!_path2.default.isAbsolute(moduleId)) continue;
|
|
507
|
+
const loaded = /* @__PURE__ */ new Set([...entryLoaded, chunk.fileName]);
|
|
508
|
+
modules[_chunk5QIKR7RRcjs.toViteModuleId.call(void 0, moduleId, options.root)] = [
|
|
509
|
+
chunk.fileName,
|
|
510
|
+
...staticImports(chunk, loaded, [])
|
|
511
|
+
].map(index);
|
|
512
|
+
}
|
|
513
|
+
return { files, entry: entryFiles.map(index), modules };
|
|
514
|
+
}
|
|
515
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, collectFarmClientModulePreloads, "collectFarmClientModulePreloads");
|
|
516
|
+
function createFarmClientModulePreloadPlugin(options) {
|
|
517
|
+
return {
|
|
518
|
+
name: "farm-client-module-preloads",
|
|
519
|
+
async generateBundle(_output, bundle) {
|
|
520
|
+
await _promises2.default.mkdir(options.buildDir, { recursive: true });
|
|
521
|
+
await _promises2.default.writeFile(
|
|
522
|
+
_path2.default.join(options.buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE),
|
|
523
|
+
JSON.stringify(collectFarmClientModulePreloads(bundle, options))
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmClientModulePreloadPlugin, "createFarmClientModulePreloadPlugin");
|
|
529
|
+
async function readFarmClientModulePreloads(buildDir) {
|
|
530
|
+
try {
|
|
531
|
+
return JSON.parse(
|
|
532
|
+
await _promises2.default.readFile(_path2.default.join(buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE), "utf8")
|
|
533
|
+
);
|
|
534
|
+
} catch (e4) {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readFarmClientModulePreloads, "readFarmClientModulePreloads");
|
|
539
|
+
function encodeFarmClientModulePreloads(manifest) {
|
|
540
|
+
return JSON.stringify(JSON.stringify(manifest)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
541
|
+
}
|
|
542
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, encodeFarmClientModulePreloads, "encodeFarmClientModulePreloads");
|
|
543
|
+
|
|
544
|
+
// src/docs/module-preloads.ts
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
var FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER = "__farm_docs_module_preloads__";
|
|
548
|
+
var FARM_DOCS_MODULE_PRELOADS_FILE = "docs-module-preloads.json";
|
|
549
|
+
function normalizeModuleId(id) {
|
|
550
|
+
return id.split("?")[0].replace(/\\/g, "/");
|
|
551
|
+
}
|
|
552
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, normalizeModuleId, "normalizeModuleId");
|
|
553
|
+
function collectFarmDocsModulePreloads(bundle, options) {
|
|
554
|
+
const chunks = Object.values(bundle).filter(
|
|
555
|
+
(output) => output.type === "chunk"
|
|
556
|
+
);
|
|
557
|
+
const byFile = new Map(chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
558
|
+
const byModule = new Map(
|
|
559
|
+
chunks.filter((chunk) => chunk.facadeModuleId).map((chunk) => [normalizeModuleId(chunk.facadeModuleId), chunk])
|
|
560
|
+
);
|
|
561
|
+
const withStaticImports = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (fileName, into) => {
|
|
562
|
+
if (into.has(fileName) || !byFile.has(fileName)) return into;
|
|
563
|
+
into.add(fileName);
|
|
564
|
+
for (const imported of _nullishCoalesce(byFile.get(fileName).imports, () => ( []))) withStaticImports(imported, into);
|
|
565
|
+
return into;
|
|
566
|
+
}, "withStaticImports");
|
|
567
|
+
const runtimeChunks = options.runtimeModuleIds.map((id) => byModule.get(normalizeModuleId(id))).filter((chunk) => Boolean(chunk));
|
|
568
|
+
const entry = chunks.find((chunk) => chunk.isEntry && chunk.name === options.entryName);
|
|
569
|
+
if (!entry || runtimeChunks.length === 0) return null;
|
|
570
|
+
const runtime = withStaticImports(entry.fileName, /* @__PURE__ */ new Set());
|
|
571
|
+
for (const chunk of runtimeChunks) withStaticImports(chunk.fileName, runtime);
|
|
572
|
+
const files = [];
|
|
573
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
574
|
+
const index = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (fileName) => {
|
|
575
|
+
let value = indexOf.get(fileName);
|
|
576
|
+
if (value === void 0) {
|
|
577
|
+
value = files.push(fileName) - 1;
|
|
578
|
+
indexOf.set(fileName, value);
|
|
579
|
+
}
|
|
580
|
+
return value;
|
|
581
|
+
}, "index");
|
|
582
|
+
const pages = {};
|
|
583
|
+
const root = normalizeModuleId(_path2.default.resolve(options.root));
|
|
584
|
+
for (const [moduleId, chunk] of byModule) {
|
|
585
|
+
if (!/\.mdx?$/.test(moduleId) || !moduleId.startsWith(`${root}/`)) continue;
|
|
586
|
+
const own = [...withStaticImports(chunk.fileName, /* @__PURE__ */ new Set())].filter(
|
|
587
|
+
(fileName) => !runtime.has(fileName)
|
|
588
|
+
);
|
|
589
|
+
pages[moduleId.slice(root.length)] = own.map(index);
|
|
590
|
+
}
|
|
591
|
+
return { files, runtime: [...runtime].map(index), pages };
|
|
592
|
+
}
|
|
593
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, collectFarmDocsModulePreloads, "collectFarmDocsModulePreloads");
|
|
594
|
+
function createFarmDocsModulePreloadPlugin(options) {
|
|
595
|
+
let runtimeModuleIds = [];
|
|
596
|
+
return {
|
|
597
|
+
name: "farm-docs-module-preloads",
|
|
598
|
+
async buildStart() {
|
|
599
|
+
const resolved = await Promise.all(
|
|
600
|
+
options.modules.map((specifier) => this.resolve(specifier, options.importer))
|
|
601
|
+
);
|
|
602
|
+
runtimeModuleIds = resolved.filter((value) => value !== null).map((value) => value.id);
|
|
603
|
+
},
|
|
604
|
+
async generateBundle(_output, bundle) {
|
|
605
|
+
const manifest = collectFarmDocsModulePreloads(bundle, {
|
|
606
|
+
root: options.root,
|
|
607
|
+
entryName: options.entryName,
|
|
608
|
+
runtimeModuleIds
|
|
609
|
+
});
|
|
610
|
+
await _promises2.default.mkdir(options.buildDir, { recursive: true });
|
|
611
|
+
await _promises2.default.writeFile(
|
|
612
|
+
_path2.default.join(options.buildDir, FARM_DOCS_MODULE_PRELOADS_FILE),
|
|
613
|
+
JSON.stringify(manifest)
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmDocsModulePreloadPlugin, "createFarmDocsModulePreloadPlugin");
|
|
619
|
+
async function readFarmDocsModulePreloads(buildDir) {
|
|
620
|
+
try {
|
|
621
|
+
return JSON.parse(
|
|
622
|
+
await _promises2.default.readFile(_path2.default.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
|
|
623
|
+
);
|
|
624
|
+
} catch (e5) {
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readFarmDocsModulePreloads, "readFarmDocsModulePreloads");
|
|
629
|
+
function encodeFarmDocsModulePreloads(manifest) {
|
|
630
|
+
return JSON.stringify(JSON.stringify(manifest)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
631
|
+
}
|
|
632
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, encodeFarmDocsModulePreloads, "encodeFarmDocsModulePreloads");
|
|
633
|
+
|
|
453
634
|
// src/route-runtime-manifest.ts
|
|
454
635
|
|
|
455
636
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
@@ -524,10 +705,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
524
705
|
}
|
|
525
706
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
|
|
526
707
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
527
|
-
const
|
|
708
|
+
const fs3 = await import("fs/promises");
|
|
528
709
|
const manifestPath = _path2.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
529
|
-
await
|
|
530
|
-
await
|
|
710
|
+
await fs3.mkdir(directory, { recursive: true });
|
|
711
|
+
await fs3.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
531
712
|
`);
|
|
532
713
|
return manifestPath;
|
|
533
714
|
}
|
|
@@ -547,7 +728,7 @@ function validateFarmRouteRuntimeDeployment(manifest, preset) {
|
|
|
547
728
|
`Route "${route.pattern}" requires the ${route.runtime} runtime, but preset "${preset}" emits ${runtime} functions. Choose a compatible preset or change the route runtime.`
|
|
548
729
|
);
|
|
549
730
|
}
|
|
550
|
-
if (_optionalChain([route, 'access',
|
|
731
|
+
if (_optionalChain([route, 'access', _6 => _6.regions, 'optionalAccess', _7 => _7.length]) && preset !== "vercel" && preset !== "vercel-edge") {
|
|
551
732
|
warnings.add(
|
|
552
733
|
`Preset "${preset}" does not map per-route regions; Farm kept them in ${FARM_ROUTE_RUNTIME_MANIFEST} for deployment adapters.`
|
|
553
734
|
);
|
|
@@ -572,7 +753,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeManifestSource, "normalizeManifes
|
|
|
572
753
|
|
|
573
754
|
// src/nitro/vercel-route-runtime.ts
|
|
574
755
|
|
|
575
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
756
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs3, basePath = "/") {
|
|
576
757
|
const dynamicRoutes = manifest.routes.filter(
|
|
577
758
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
578
759
|
);
|
|
@@ -596,15 +777,15 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs, ba
|
|
|
596
777
|
const destinations = /* @__PURE__ */ new Map();
|
|
597
778
|
let groupIndex = 0;
|
|
598
779
|
for (const [key, group] of groups) {
|
|
599
|
-
if (!_optionalChain([group, 'access',
|
|
780
|
+
if (!_optionalChain([group, 'access', _8 => _8.config, 'access', _9 => _9.regions, 'optionalAccess', _10 => _10.length]) && !group.config.maxDuration) {
|
|
600
781
|
destinations.set(key, "/__nitro");
|
|
601
782
|
continue;
|
|
602
783
|
}
|
|
603
784
|
groupIndex += 1;
|
|
604
785
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
605
786
|
const functionDir = _path2.default.join(functionsDir, `${functionName}.func`);
|
|
606
|
-
await
|
|
607
|
-
await configureVercelFunction(functionDir, group.config,
|
|
787
|
+
await fs3.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
788
|
+
await configureVercelFunction(functionDir, group.config, fs3);
|
|
608
789
|
destinations.set(key, `/${functionName}`);
|
|
609
790
|
}
|
|
610
791
|
const routes = [];
|
|
@@ -653,20 +834,20 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
653
834
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
654
835
|
}
|
|
655
836
|
_chunkS3JO3N4Hcjs.__name.call(void 0, farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
|
|
656
|
-
async function configureVercelFunction(functionDir, config,
|
|
837
|
+
async function configureVercelFunction(functionDir, config, fs3) {
|
|
657
838
|
const configPath = _path2.default.join(functionDir, ".vc-config.json");
|
|
658
|
-
const current = JSON.parse(await
|
|
839
|
+
const current = JSON.parse(await fs3.readFile(configPath, "utf8"));
|
|
659
840
|
const next = {
|
|
660
841
|
...current,
|
|
661
|
-
..._optionalChain([config, 'access',
|
|
842
|
+
..._optionalChain([config, 'access', _11 => _11.regions, 'optionalAccess', _12 => _12.length]) ? { regions: config.regions } : {},
|
|
662
843
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
663
844
|
};
|
|
664
|
-
await
|
|
845
|
+
await fs3.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
665
846
|
`);
|
|
666
847
|
}
|
|
667
848
|
_chunkS3JO3N4Hcjs.__name.call(void 0, configureVercelFunction, "configureVercelFunction");
|
|
668
849
|
function hasVercelFunctionControls(route) {
|
|
669
|
-
return Boolean(_optionalChain([route, 'access',
|
|
850
|
+
return Boolean(_optionalChain([route, 'access', _13 => _13.regions, 'optionalAccess', _14 => _14.length]) || route.maxDuration);
|
|
670
851
|
}
|
|
671
852
|
_chunkS3JO3N4Hcjs.__name.call(void 0, hasVercelFunctionControls, "hasVercelFunctionControls");
|
|
672
853
|
function compareRuntimeRoutes(left, right) {
|
|
@@ -794,278 +975,6 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
794
975
|
}
|
|
795
976
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmNetlifyEntry, "createFarmNetlifyEntry");
|
|
796
977
|
|
|
797
|
-
// src/nitro/node-server-entry.ts
|
|
798
|
-
var FARM_NODE_ENV_MODULE_FILE = "farm-node-env.mjs";
|
|
799
|
-
var FARM_NODE_ENV_MODULE_SOURCE = `if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
|
|
800
|
-
`;
|
|
801
|
-
function createFarmNodeServerEntry(options) {
|
|
802
|
-
const serverConfig = JSON.stringify(options.server);
|
|
803
|
-
const nitroEntryImport = `./${options.nitroEntryFile.replace(/^\.\//, "")}`;
|
|
804
|
-
return `
|
|
805
|
-
import "./${FARM_NODE_ENV_MODULE_FILE}";
|
|
806
|
-
import "#nitro/virtual/polyfills";
|
|
807
|
-
import { NodeRequest, serve } from ${JSON.stringify(options.nodeAdapterModule)};
|
|
808
|
-
import wsAdapter from ${JSON.stringify(options.websocketAdapterModule)};
|
|
809
|
-
import { resolveWebsocketHooks, useNitroApp, useNitroHooks } from "#nitro/runtime/app";
|
|
810
|
-
import { useRuntimeConfig } from "#nitro/runtime/runtime-config";
|
|
811
|
-
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
812
|
-
import { setupCloseHooks } from "#nitro/runtime/shutdown";
|
|
813
|
-
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
814
|
-
import { tracingSrvxPlugins } from "#nitro/virtual/tracing";
|
|
815
|
-
import { farmProductionLifecycle } from ${JSON.stringify(nitroEntryImport)};
|
|
816
|
-
|
|
817
|
-
const farmServerConfig = ${serverConfig};
|
|
818
|
-
if (!process.env.NITRO_SHUTDOWN_TIMEOUT) {
|
|
819
|
-
process.env.NITRO_SHUTDOWN_TIMEOUT = String(farmServerConfig.gracefulShutdownTimeout);
|
|
820
|
-
}
|
|
821
|
-
const shutdownConfig = {
|
|
822
|
-
disabled: Boolean(process.env.NITRO_SHUTDOWN_DISABLED),
|
|
823
|
-
signals: (process.env.NITRO_SHUTDOWN_SIGNALS || "SIGTERM SIGINT")
|
|
824
|
-
.split(" ")
|
|
825
|
-
.map((signal) => signal.trim())
|
|
826
|
-
.filter(Boolean),
|
|
827
|
-
timeout: Number.parseInt(process.env.NITRO_SHUTDOWN_TIMEOUT || "", 10) || 30000,
|
|
828
|
-
forceExit: !process.env.NITRO_SHUTDOWN_NO_FORCE_EXIT,
|
|
829
|
-
};
|
|
830
|
-
|
|
831
|
-
const nitroApp = useNitroApp();
|
|
832
|
-
useNitroHooks().hook("close", async () => {
|
|
833
|
-
try {
|
|
834
|
-
await farmProductionLifecycle.close("production-server-closed");
|
|
835
|
-
} catch (error) {
|
|
836
|
-
process.exitCode = 1;
|
|
837
|
-
throw error;
|
|
838
|
-
}
|
|
839
|
-
});
|
|
840
|
-
|
|
841
|
-
let startupSignal;
|
|
842
|
-
let resolveStartupSignal;
|
|
843
|
-
const startupSignalPromise = new Promise((resolve) => {
|
|
844
|
-
resolveStartupSignal = resolve;
|
|
845
|
-
});
|
|
846
|
-
const startupSignalListeners = new Map();
|
|
847
|
-
if (!shutdownConfig.disabled) {
|
|
848
|
-
for (const signal of shutdownConfig.signals) {
|
|
849
|
-
const listener = (receivedSignal) => {
|
|
850
|
-
if (!startupSignal) {
|
|
851
|
-
startupSignal = receivedSignal;
|
|
852
|
-
resolveStartupSignal(receivedSignal);
|
|
853
|
-
}
|
|
854
|
-
farmProductionLifecycle.beginDrain(receivedSignal);
|
|
855
|
-
};
|
|
856
|
-
startupSignalListeners.set(signal, listener);
|
|
857
|
-
process.once(signal, listener);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
try {
|
|
862
|
-
await Promise.race([
|
|
863
|
-
Promise.resolve().then(() => farmProductionLifecycle.start()),
|
|
864
|
-
startupSignalPromise,
|
|
865
|
-
]);
|
|
866
|
-
} catch (error) {
|
|
867
|
-
await farmProductionLifecycle.close("production-start-failed").catch((closeError) => {
|
|
868
|
-
console.error("[Farm] Runtime cleanup after startup failure failed:", closeError);
|
|
869
|
-
});
|
|
870
|
-
throw error;
|
|
871
|
-
} finally {
|
|
872
|
-
for (const [signal, listener] of startupSignalListeners) {
|
|
873
|
-
process.removeListener(signal, listener);
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
if (startupSignal) {
|
|
878
|
-
let startupCloseTimer;
|
|
879
|
-
const startupCloseCompleted = await Promise.race([
|
|
880
|
-
Promise.resolve()
|
|
881
|
-
.then(() => farmProductionLifecycle.close(startupSignal))
|
|
882
|
-
.then(
|
|
883
|
-
() => true,
|
|
884
|
-
(error) => {
|
|
885
|
-
console.error("[Farm] Runtime shutdown during startup failed:", error);
|
|
886
|
-
process.exitCode = 1;
|
|
887
|
-
return true;
|
|
888
|
-
},
|
|
889
|
-
),
|
|
890
|
-
new Promise((resolve) => {
|
|
891
|
-
startupCloseTimer = setTimeout(() => resolve(false), farmServerConfig.gracefulShutdownTimeout);
|
|
892
|
-
}),
|
|
893
|
-
]);
|
|
894
|
-
clearTimeout(startupCloseTimer);
|
|
895
|
-
if (!startupCloseCompleted) {
|
|
896
|
-
console.warn("[Farm] Runtime startup did not settle before shutdown; forcing cleanup");
|
|
897
|
-
let forcedCloseTimer;
|
|
898
|
-
const forcedCloseCompleted = await Promise.race([
|
|
899
|
-
Promise.resolve()
|
|
900
|
-
.then(() => farmProductionLifecycle.forceClose(startupSignal))
|
|
901
|
-
.then(
|
|
902
|
-
() => true,
|
|
903
|
-
(error) => {
|
|
904
|
-
console.error("[Farm] Forced runtime shutdown during startup failed:", error);
|
|
905
|
-
process.exitCode = 1;
|
|
906
|
-
return true;
|
|
907
|
-
},
|
|
908
|
-
),
|
|
909
|
-
new Promise((resolve) => {
|
|
910
|
-
forcedCloseTimer = setTimeout(
|
|
911
|
-
() => resolve(false),
|
|
912
|
-
farmServerConfig.gracefulShutdownTimeout,
|
|
913
|
-
);
|
|
914
|
-
}),
|
|
915
|
-
]);
|
|
916
|
-
clearTimeout(forcedCloseTimer);
|
|
917
|
-
if (!forcedCloseCompleted) {
|
|
918
|
-
console.error("[Farm] Forced runtime shutdown during startup timed out");
|
|
919
|
-
process.exitCode = 1;
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
process.exit(process.exitCode || 0);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
const cert = process.env.NITRO_SSL_CERT;
|
|
926
|
-
const key = process.env.NITRO_SSL_KEY;
|
|
927
|
-
const configuredPort = Number(process.env.NITRO_PORT || process.env.PORT);
|
|
928
|
-
const port = Number.isFinite(configuredPort) && configuredPort > 0 ? configuredPort : 3000;
|
|
929
|
-
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
930
|
-
const socketPath = process.env.NITRO_UNIX_SOCKET;
|
|
931
|
-
const server = serve({
|
|
932
|
-
manual: true,
|
|
933
|
-
silent: true,
|
|
934
|
-
gracefulShutdown: false,
|
|
935
|
-
port,
|
|
936
|
-
hostname: host,
|
|
937
|
-
node: socketPath ? { path: socketPath } : undefined,
|
|
938
|
-
tls: cert && key ? { cert, key } : undefined,
|
|
939
|
-
fetch: nitroApp.fetch,
|
|
940
|
-
plugins: [...tracingSrvxPlugins],
|
|
941
|
-
});
|
|
942
|
-
const nodeServer = server.node?.server;
|
|
943
|
-
if (!nodeServer) throw new Error("[Farm] Nitro did not create a Node server");
|
|
944
|
-
|
|
945
|
-
nodeServer.headersTimeout = farmServerConfig.headersTimeout;
|
|
946
|
-
nodeServer.requestTimeout = farmServerConfig.requestTimeout;
|
|
947
|
-
nodeServer.keepAliveTimeout = farmServerConfig.keepAliveTimeout;
|
|
948
|
-
|
|
949
|
-
let isShuttingDown = false;
|
|
950
|
-
nodeServer.on("request", (_request, response) => {
|
|
951
|
-
response.once("finish", () => {
|
|
952
|
-
if (isShuttingDown) nodeServer.closeIdleConnections?.();
|
|
953
|
-
});
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
if (import.meta._websocket) {
|
|
957
|
-
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
958
|
-
nodeServer.on("upgrade", (request, socket, head) => {
|
|
959
|
-
handleUpgrade(
|
|
960
|
-
request,
|
|
961
|
-
socket,
|
|
962
|
-
head,
|
|
963
|
-
new NodeRequest({ req: request, upgrade: { socket, head } }),
|
|
964
|
-
);
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
setupCloseHooks(server);
|
|
969
|
-
trapUnhandledErrors();
|
|
970
|
-
|
|
971
|
-
let shutdownPromise;
|
|
972
|
-
async function shutdown(signal) {
|
|
973
|
-
isShuttingDown = true;
|
|
974
|
-
farmProductionLifecycle.beginDrain(signal);
|
|
975
|
-
|
|
976
|
-
const gracefulClose = server.close().then(
|
|
977
|
-
() => true,
|
|
978
|
-
(error) => {
|
|
979
|
-
console.error("[Farm] Runtime shutdown failed:", error);
|
|
980
|
-
process.exitCode = 1;
|
|
981
|
-
return true;
|
|
982
|
-
},
|
|
983
|
-
);
|
|
984
|
-
nodeServer.closeIdleConnections?.();
|
|
985
|
-
let gracefulTimer;
|
|
986
|
-
const gracefullyClosed = await Promise.race([
|
|
987
|
-
gracefulClose,
|
|
988
|
-
new Promise((resolve) => {
|
|
989
|
-
gracefulTimer = setTimeout(() => resolve(false), shutdownConfig.timeout);
|
|
990
|
-
}),
|
|
991
|
-
]);
|
|
992
|
-
clearTimeout(gracefulTimer);
|
|
993
|
-
|
|
994
|
-
if (!gracefullyClosed) {
|
|
995
|
-
console.warn("[Farm] Graceful shutdown timed out; forcing cleanup");
|
|
996
|
-
void server.close(true).catch((error) => {
|
|
997
|
-
console.error("[Farm] Forced server shutdown failed:", error);
|
|
998
|
-
process.exitCode = 1;
|
|
999
|
-
});
|
|
1000
|
-
|
|
1001
|
-
let forceTimer;
|
|
1002
|
-
const forceClosed = await Promise.race([
|
|
1003
|
-
Promise.resolve()
|
|
1004
|
-
.then(() => farmProductionLifecycle.forceClose("production-server-closed"))
|
|
1005
|
-
.then(
|
|
1006
|
-
() => true,
|
|
1007
|
-
(error) => {
|
|
1008
|
-
console.error("[Farm] Forced runtime shutdown failed:", error);
|
|
1009
|
-
process.exitCode = 1;
|
|
1010
|
-
return true;
|
|
1011
|
-
},
|
|
1012
|
-
),
|
|
1013
|
-
new Promise((resolve) => {
|
|
1014
|
-
forceTimer = setTimeout(() => resolve(false), shutdownConfig.timeout);
|
|
1015
|
-
}),
|
|
1016
|
-
]);
|
|
1017
|
-
clearTimeout(forceTimer);
|
|
1018
|
-
if (!forceClosed) {
|
|
1019
|
-
console.error("[Farm] Forced runtime shutdown timed out");
|
|
1020
|
-
process.exitCode = 1;
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
if (shutdownConfig.forceExit) process.exit(process.exitCode || 0);
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
if (!shutdownConfig.disabled) {
|
|
1028
|
-
for (const signal of shutdownConfig.signals) {
|
|
1029
|
-
process.once(signal, (receivedSignal) => {
|
|
1030
|
-
shutdownPromise ||= shutdown(receivedSignal);
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
try {
|
|
1036
|
-
await server.serve();
|
|
1037
|
-
const protocol = cert && key ? "https" : "http";
|
|
1038
|
-
const addressInfo = nodeServer.address();
|
|
1039
|
-
if (typeof addressInfo === "string") {
|
|
1040
|
-
console.log(\`Listening on unix socket \${addressInfo}\`);
|
|
1041
|
-
} else if (addressInfo) {
|
|
1042
|
-
const configuredBaseURL = useRuntimeConfig().app.baseURL || "";
|
|
1043
|
-
const baseURL = configuredBaseURL.endsWith("/")
|
|
1044
|
-
? configuredBaseURL.slice(0, -1)
|
|
1045
|
-
: configuredBaseURL;
|
|
1046
|
-
const address = addressInfo.family === "IPv6"
|
|
1047
|
-
? \`[\${addressInfo.address}]\`
|
|
1048
|
-
: addressInfo.address;
|
|
1049
|
-
console.log(\`Listening on \${protocol}://\${address}:\${addressInfo.port}\${baseURL}\`);
|
|
1050
|
-
}
|
|
1051
|
-
} catch (error) {
|
|
1052
|
-
console.error(error);
|
|
1053
|
-
process.exitCode = 1;
|
|
1054
|
-
await farmProductionLifecycle.close("production-listen-error").catch((closeError) => {
|
|
1055
|
-
console.error("[Farm] Runtime cleanup after listen failure failed:", closeError);
|
|
1056
|
-
});
|
|
1057
|
-
throw error;
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
if (import.meta._tasks) {
|
|
1061
|
-
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
export default {};
|
|
1065
|
-
`.trim();
|
|
1066
|
-
}
|
|
1067
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmNodeServerEntry, "createFarmNodeServerEntry");
|
|
1068
|
-
|
|
1069
978
|
// src/nitro/universal-build.ts
|
|
1070
979
|
function preloadFarmNitroBuilder() {
|
|
1071
980
|
return import("nitro/builder").then(
|
|
@@ -1083,7 +992,7 @@ function findFarmCoreRoot(from) {
|
|
|
1083
992
|
if (_fs.existsSync.call(void 0, manifest)) {
|
|
1084
993
|
try {
|
|
1085
994
|
if (JSON.parse(_fs.readFileSync.call(void 0, manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1086
|
-
} catch (
|
|
995
|
+
} catch (e6) {
|
|
1087
996
|
}
|
|
1088
997
|
}
|
|
1089
998
|
dir = _path2.default.dirname(dir);
|
|
@@ -1103,7 +1012,7 @@ function findInstalledPackageDir(name, from) {
|
|
|
1103
1012
|
if (_fs.existsSync.call(void 0, _path2.default.join(candidate, "package.json"))) {
|
|
1104
1013
|
try {
|
|
1105
1014
|
return _fs.realpathSync.call(void 0, candidate);
|
|
1106
|
-
} catch (
|
|
1015
|
+
} catch (e7) {
|
|
1107
1016
|
return null;
|
|
1108
1017
|
}
|
|
1109
1018
|
}
|
|
@@ -1120,7 +1029,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1120
1029
|
let manifest;
|
|
1121
1030
|
try {
|
|
1122
1031
|
manifest = JSON.parse(_fs.readFileSync.call(void 0, _path2.default.join(dir, "package.json"), "utf8"));
|
|
1123
|
-
} catch (
|
|
1032
|
+
} catch (e8) {
|
|
1124
1033
|
return;
|
|
1125
1034
|
}
|
|
1126
1035
|
for (const field of ["dependencies", "optionalDependencies", "peerDependencies"]) {
|
|
@@ -1136,7 +1045,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1136
1045
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
1137
1046
|
}
|
|
1138
1047
|
}
|
|
1139
|
-
} catch (
|
|
1048
|
+
} catch (e9) {
|
|
1140
1049
|
}
|
|
1141
1050
|
for (let next = queue.pop(); next; next = queue.pop()) {
|
|
1142
1051
|
const dir = findInstalledPackageDir(next.name, next.from);
|
|
@@ -1215,14 +1124,14 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1215
1124
|
return {
|
|
1216
1125
|
name: "farm-prerender-runtime-resolver",
|
|
1217
1126
|
async resolveId(id, _importer, options) {
|
|
1218
|
-
if (_optionalChain([options, 'access',
|
|
1127
|
+
if (_optionalChain([options, 'access', _15 => _15.custom, 'optionalAccess', _16 => _16.farmPrerenderRuntimeResolve])) return null;
|
|
1219
1128
|
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || _path2.default.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1220
1129
|
return null;
|
|
1221
1130
|
}
|
|
1222
1131
|
if (nitroEntry === void 0) {
|
|
1223
1132
|
try {
|
|
1224
1133
|
nitroEntry = resolveNitroEntry(root);
|
|
1225
|
-
} catch (
|
|
1134
|
+
} catch (e10) {
|
|
1226
1135
|
nitroEntry = null;
|
|
1227
1136
|
}
|
|
1228
1137
|
}
|
|
@@ -1241,7 +1150,7 @@ function resolveNitroPackageEntry(root) {
|
|
|
1241
1150
|
let runtimeRequire = projectRequire;
|
|
1242
1151
|
try {
|
|
1243
1152
|
runtimeRequire = _module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core"));
|
|
1244
|
-
} catch (
|
|
1153
|
+
} catch (e11) {
|
|
1245
1154
|
}
|
|
1246
1155
|
return runtimeRequire.resolve("nitro");
|
|
1247
1156
|
}
|
|
@@ -1298,7 +1207,7 @@ async function canUseRolldownBuilder() {
|
|
|
1298
1207
|
try {
|
|
1299
1208
|
await import("rolldown");
|
|
1300
1209
|
return true;
|
|
1301
|
-
} catch (
|
|
1210
|
+
} catch (e12) {
|
|
1302
1211
|
return false;
|
|
1303
1212
|
}
|
|
1304
1213
|
}
|
|
@@ -1314,7 +1223,7 @@ function hasReactDomEdgeServerBuild(root) {
|
|
|
1314
1223
|
try {
|
|
1315
1224
|
_module.createRequire.call(void 0, _path2.default.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1316
1225
|
return true;
|
|
1317
|
-
} catch (
|
|
1226
|
+
} catch (e13) {
|
|
1318
1227
|
return false;
|
|
1319
1228
|
}
|
|
1320
1229
|
}
|
|
@@ -1366,7 +1275,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
1366
1275
|
return {
|
|
1367
1276
|
name: "farm-metadata-image-wasm",
|
|
1368
1277
|
resolveId(source, importer) {
|
|
1369
|
-
if (!source.endsWith(".wasm?module") || !_optionalChain([importer, 'optionalAccess',
|
|
1278
|
+
if (!source.endsWith(".wasm?module") || !_optionalChain([importer, 'optionalAccess', _17 => _17.replace, 'call', _18 => _18(/\\/g, "/"), 'access', _19 => _19.includes, 'call', _20 => _20("/@vercel/og/")])) {
|
|
1370
1279
|
return null;
|
|
1371
1280
|
}
|
|
1372
1281
|
const requestPath = source.slice(0, -"?module".length);
|
|
@@ -1492,9 +1401,9 @@ function restoreLiteralModuleSpecifiers(code, fileName, { parseSync, Visitor })
|
|
|
1492
1401
|
if (needsAst) {
|
|
1493
1402
|
replacements.length = 0;
|
|
1494
1403
|
const restore = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (node) => {
|
|
1495
|
-
if (_optionalChain([node, 'optionalAccess',
|
|
1404
|
+
if (_optionalChain([node, 'optionalAccess', _21 => _21.type]) !== "TemplateLiteral") return;
|
|
1496
1405
|
const template = node;
|
|
1497
|
-
const value = _optionalChain([template, 'access',
|
|
1406
|
+
const value = _optionalChain([template, 'access', _22 => _22.quasis, 'access', _23 => _23[0], 'optionalAccess', _24 => _24.value, 'access', _25 => _25.cooked]);
|
|
1498
1407
|
if (template.expressions.length > 0 || typeof value !== "string") return;
|
|
1499
1408
|
replacements.push({
|
|
1500
1409
|
start: template.start,
|
|
@@ -1546,7 +1455,7 @@ function trimSlashes(value) {
|
|
|
1546
1455
|
}
|
|
1547
1456
|
_chunkS3JO3N4Hcjs.__name.call(void 0, trimSlashes, "trimSlashes");
|
|
1548
1457
|
function resolveBuildDocsContentDir(config, root) {
|
|
1549
|
-
if (!_optionalChain([config, 'access',
|
|
1458
|
+
if (!_optionalChain([config, 'access', _26 => _26.docs, 'optionalAccess', _27 => _27.enabled])) return null;
|
|
1550
1459
|
const configuredContentDir = config.docs.contentDir || config.docs.config.contentDir;
|
|
1551
1460
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
1552
1461
|
const contentDir = _path2.default.isAbsolute(configuredContentDir) ? configuredContentDir : _path2.default.join(root, configuredContentDir);
|
|
@@ -1578,14 +1487,14 @@ function hasProjectPostcssConfig(root) {
|
|
|
1578
1487
|
try {
|
|
1579
1488
|
projectRequire.resolve(`./${file}`);
|
|
1580
1489
|
return true;
|
|
1581
|
-
} catch (
|
|
1490
|
+
} catch (e14) {
|
|
1582
1491
|
return false;
|
|
1583
1492
|
}
|
|
1584
1493
|
});
|
|
1585
1494
|
}
|
|
1586
1495
|
_chunkS3JO3N4Hcjs.__name.call(void 0, hasProjectPostcssConfig, "hasProjectPostcssConfig");
|
|
1587
1496
|
async function findFarmConfigPath(root) {
|
|
1588
|
-
const
|
|
1497
|
+
const fs3 = await import("fs/promises");
|
|
1589
1498
|
const candidates = [
|
|
1590
1499
|
"farm.config.ts",
|
|
1591
1500
|
"farm.config.mts",
|
|
@@ -1599,26 +1508,17 @@ async function findFarmConfigPath(root) {
|
|
|
1599
1508
|
for (const candidate of candidates) {
|
|
1600
1509
|
const resolvedPath = _path2.default.join(root, candidate);
|
|
1601
1510
|
try {
|
|
1602
|
-
await
|
|
1511
|
+
await fs3.access(resolvedPath);
|
|
1603
1512
|
return resolvedPath;
|
|
1604
|
-
} catch (
|
|
1513
|
+
} catch (e15) {
|
|
1605
1514
|
}
|
|
1606
1515
|
}
|
|
1607
1516
|
return null;
|
|
1608
1517
|
}
|
|
1609
1518
|
_chunkS3JO3N4Hcjs.__name.call(void 0, findFarmConfigPath, "findFarmConfigPath");
|
|
1610
|
-
function hasFarmMiddlewareConfig(config) {
|
|
1611
|
-
if (!config) return false;
|
|
1612
|
-
if (Array.isArray(config)) return config.length > 0;
|
|
1613
|
-
const configRecord = config;
|
|
1614
|
-
return Boolean(
|
|
1615
|
-
configRecord.matcher || configRecord.exclude || configRecord.runtime || configRecord.handler || Array.isArray(configRecord.handlers) && configRecord.handlers.length > 0
|
|
1616
|
-
);
|
|
1617
|
-
}
|
|
1618
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0, hasFarmMiddlewareConfig, "hasFarmMiddlewareConfig");
|
|
1619
1519
|
function hasFarmServerRuntimePlugins(config) {
|
|
1620
1520
|
return (config.plugins || []).some((plugin) => {
|
|
1621
|
-
if (
|
|
1521
|
+
if (_chunkBWIQR4DHcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) === false) return false;
|
|
1622
1522
|
return Boolean(
|
|
1623
1523
|
plugin.setup || plugin.init || plugin.ready || plugin.shutdown || plugin.runtime || plugin.router || plugin.render || plugin.beforeRouteMatch || plugin.afterRouteMatch || plugin.beforeRender || plugin.afterRender || plugin.onError || plugin.transformHTML
|
|
1624
1524
|
);
|
|
@@ -1631,19 +1531,19 @@ function hasFarmPluginRoutes(config) {
|
|
|
1631
1531
|
_chunkS3JO3N4Hcjs.__name.call(void 0, hasFarmPluginRoutes, "hasFarmPluginRoutes");
|
|
1632
1532
|
function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
1633
1533
|
return (config.plugins || []).some(
|
|
1634
|
-
(plugin) =>
|
|
1534
|
+
(plugin) => _chunkBWIQR4DHcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false && _chunkAS2VPMEEcjs.farmPluginMayAffectRuntimePath.call(void 0, plugin, pathname)
|
|
1635
1535
|
);
|
|
1636
1536
|
}
|
|
1637
1537
|
_chunkS3JO3N4Hcjs.__name.call(void 0, farmServerRuntimePluginsMayHandlePath, "farmServerRuntimePluginsMayHandlePath");
|
|
1638
1538
|
async function discoverMiddlewareRoutes(appDir) {
|
|
1639
|
-
const
|
|
1539
|
+
const fs3 = await import("fs/promises");
|
|
1640
1540
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
1641
1541
|
const routes = /* @__PURE__ */ new Map();
|
|
1642
1542
|
async function walk(dir, routePath, directory, discovered) {
|
|
1643
1543
|
let entries;
|
|
1644
1544
|
try {
|
|
1645
|
-
entries = await
|
|
1646
|
-
} catch (
|
|
1545
|
+
entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
1546
|
+
} catch (e16) {
|
|
1647
1547
|
return;
|
|
1648
1548
|
}
|
|
1649
1549
|
const middlewareFile = entries.find(
|
|
@@ -1662,8 +1562,8 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1662
1562
|
}
|
|
1663
1563
|
await walk(
|
|
1664
1564
|
_path2.default.join(dir, entry.name),
|
|
1665
|
-
|
|
1666
|
-
|
|
1565
|
+
_chunkLMPAPBUAcjs.appendMiddlewareRoutePath.call(void 0, routePath, entry.name),
|
|
1566
|
+
_chunkLMPAPBUAcjs.appendMiddlewareDirectory.call(void 0, directory, entry.name),
|
|
1667
1567
|
discovered
|
|
1668
1568
|
);
|
|
1669
1569
|
}
|
|
@@ -1676,11 +1576,11 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1676
1576
|
routes.set(route.directory, route);
|
|
1677
1577
|
}
|
|
1678
1578
|
}
|
|
1679
|
-
return Array.from(routes.values()).sort(
|
|
1579
|
+
return Array.from(routes.values()).sort(_chunkLMPAPBUAcjs.compareMiddlewareRouteLocations).map(({ path: routePath, filePath }) => ({ path: routePath, filePath }));
|
|
1680
1580
|
}
|
|
1681
1581
|
_chunkS3JO3N4Hcjs.__name.call(void 0, discoverMiddlewareRoutes, "discoverMiddlewareRoutes");
|
|
1682
1582
|
function assertFarmDocsRuntimeSupported(config, preset) {
|
|
1683
|
-
if (!_optionalChain([config, 'access',
|
|
1583
|
+
if (!_optionalChain([config, 'access', _28 => _28.docs, 'optionalAccess', _29 => _29.enabled]) || !_optionalChain([config, 'access', _30 => _30.docs, 'access', _31 => _31.adapter, 'optionalAccess', _32 => _32.server]) || _chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset) !== "edge" || Boolean(config.docs.adapter.edgeCompiler)) {
|
|
1684
1584
|
return;
|
|
1685
1585
|
}
|
|
1686
1586
|
throw new Error(
|
|
@@ -1694,7 +1594,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1694
1594
|
assertFarmDocsRuntimeSupported(config, preset);
|
|
1695
1595
|
const srcDir = config.srcDir || "src";
|
|
1696
1596
|
const distDir = config.distDir || ".farm";
|
|
1697
|
-
const deployOutputDir =
|
|
1597
|
+
const deployOutputDir = _chunkHRETEZ2Zcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
|
|
1698
1598
|
const lifecyclePluginManager = options.pluginManager;
|
|
1699
1599
|
const productionViteResultPromise = Promise.allSettled([
|
|
1700
1600
|
Promise.resolve(_nullishCoalesce(options.productionVite, () => ( _chunkA6WIQH5Zcjs.loadFarmProductionVite.call(void 0, ))))
|
|
@@ -1713,7 +1613,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1713
1613
|
const routeRuntimeManifestResultPromise = Promise.allSettled([routeRuntimeManifestPromise]);
|
|
1714
1614
|
const pageRoutes = [];
|
|
1715
1615
|
for (const [pattern, entry] of routeManager.getRoutes()) {
|
|
1716
|
-
const markdownSourcePath = entry.markdownSourcePath || (
|
|
1616
|
+
const markdownSourcePath = entry.markdownSourcePath || (_chunkEKN7NSZOcjs.isFarmMarkdownPageFile.call(void 0, entry.modulePath) ? entry.modulePath : void 0);
|
|
1717
1617
|
pageRoutes.push({
|
|
1718
1618
|
pattern,
|
|
1719
1619
|
...entry.directory ? { directory: entry.directory } : {},
|
|
@@ -1738,12 +1638,12 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1738
1638
|
})
|
|
1739
1639
|
);
|
|
1740
1640
|
_chunk5QIKR7RRcjs.logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
1741
|
-
const
|
|
1641
|
+
const fs3 = await import("fs/promises");
|
|
1742
1642
|
const layoutRoutes = [];
|
|
1743
1643
|
const appDir = _path2.default.join(root, srcDir, "app");
|
|
1744
1644
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
1745
1645
|
try {
|
|
1746
|
-
const entries = await
|
|
1646
|
+
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
1747
1647
|
for (const entry of entries) {
|
|
1748
1648
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
1749
1649
|
layoutRoutes.push({
|
|
@@ -1755,7 +1655,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1755
1655
|
await findLayoutsForClient(_path2.default.join(dir, entry.name), childPrefix);
|
|
1756
1656
|
}
|
|
1757
1657
|
}
|
|
1758
|
-
} catch (
|
|
1658
|
+
} catch (e17) {
|
|
1759
1659
|
}
|
|
1760
1660
|
}
|
|
1761
1661
|
_chunkS3JO3N4Hcjs.__name.call(void 0, findLayoutsForClient, "findLayoutsForClient");
|
|
@@ -1896,12 +1796,12 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1896
1796
|
_chunk5QIKR7RRcjs.logger.error(`\u274C Build failed: ${error}`);
|
|
1897
1797
|
throw error;
|
|
1898
1798
|
} finally {
|
|
1899
|
-
_optionalChain([rendererBuild, 'optionalAccess',
|
|
1799
|
+
_optionalChain([rendererBuild, 'optionalAccess', _33 => _33.abort, 'call', _34 => _34()]);
|
|
1900
1800
|
}
|
|
1901
1801
|
}
|
|
1902
1802
|
_chunkS3JO3N4Hcjs.__name.call(void 0, buildUniversal, "buildUniversal");
|
|
1903
1803
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
1904
|
-
const
|
|
1804
|
+
const fs3 = await import("fs/promises");
|
|
1905
1805
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1906
1806
|
if (output.type !== "asset") continue;
|
|
1907
1807
|
if (fileName === "farm-fonts.css") {
|
|
@@ -1909,42 +1809,42 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
1909
1809
|
continue;
|
|
1910
1810
|
}
|
|
1911
1811
|
const filePath = _path2.default.join(outputDir, fileName);
|
|
1912
|
-
await
|
|
1913
|
-
await
|
|
1812
|
+
await fs3.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
1813
|
+
await fs3.writeFile(filePath, output.source);
|
|
1914
1814
|
}
|
|
1915
1815
|
}
|
|
1916
1816
|
_chunkS3JO3N4Hcjs.__name.call(void 0, writeSSRAssetsToClient, "writeSSRAssetsToClient");
|
|
1917
1817
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
1918
|
-
const
|
|
1818
|
+
const fs3 = await import("fs/promises");
|
|
1919
1819
|
await Promise.all(
|
|
1920
1820
|
_chunkHREOKQWTcjs.resolveFarmDocsFontAssets.call(void 0, root).map(async ({ sourcePath, url }) => {
|
|
1921
1821
|
const targetPath = _path2.default.join(outputDir, url.replace(/^\/+/, ""));
|
|
1922
|
-
await
|
|
1923
|
-
await
|
|
1822
|
+
await fs3.mkdir(_path2.default.dirname(targetPath), { recursive: true });
|
|
1823
|
+
await fs3.copyFile(sourcePath, targetPath);
|
|
1924
1824
|
})
|
|
1925
1825
|
);
|
|
1926
1826
|
}
|
|
1927
1827
|
_chunkS3JO3N4Hcjs.__name.call(void 0, copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
|
|
1928
1828
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
1929
|
-
const
|
|
1829
|
+
const fs3 = await import("fs/promises");
|
|
1930
1830
|
const fontCssPath = _path2.default.join(outputDir, "farm-fonts.css");
|
|
1931
1831
|
let fontCss = fontCssSource;
|
|
1932
1832
|
if (fontCss === void 0) {
|
|
1933
1833
|
try {
|
|
1934
|
-
fontCss = await
|
|
1935
|
-
} catch (
|
|
1834
|
+
fontCss = await fs3.readFile(fontCssPath);
|
|
1835
|
+
} catch (e18) {
|
|
1936
1836
|
return;
|
|
1937
1837
|
}
|
|
1938
1838
|
}
|
|
1939
1839
|
const clientCssPath = _path2.default.join(outputDir, "farm-client.css");
|
|
1940
1840
|
let clientCss = "";
|
|
1941
1841
|
try {
|
|
1942
|
-
clientCss = await
|
|
1943
|
-
} catch (
|
|
1842
|
+
clientCss = await fs3.readFile(clientCssPath, "utf8");
|
|
1843
|
+
} catch (e19) {
|
|
1944
1844
|
}
|
|
1945
1845
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
1946
|
-
await
|
|
1947
|
-
await
|
|
1846
|
+
await fs3.writeFile(fontCssPath, normalizedFontCss);
|
|
1847
|
+
await fs3.writeFile(clientCssPath, _chunkAS2VPMEEcjs.mergeFarmFontCss.call(void 0, clientCss, normalizedFontCss));
|
|
1948
1848
|
}
|
|
1949
1849
|
_chunkS3JO3N4Hcjs.__name.call(void 0, mergeBuiltFontCss, "mergeBuiltFontCss");
|
|
1950
1850
|
var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
|
|
@@ -1956,14 +1856,14 @@ var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError
|
|
|
1956
1856
|
_chunkS3JO3N4Hcjs.__name.call(void 0, _IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
|
|
1957
1857
|
var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
|
|
1958
1858
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
1959
|
-
const
|
|
1859
|
+
const fs3 = await import("fs/promises");
|
|
1960
1860
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
1961
1861
|
const clientEntryPath = _path2.default.join(outputDir, _nullishCoalesce(fingerprinted, () => ( "farm-client.js")));
|
|
1962
1862
|
let clientEntrySize = 0;
|
|
1963
1863
|
try {
|
|
1964
|
-
const clientEntry = await
|
|
1864
|
+
const clientEntry = await fs3.stat(clientEntryPath);
|
|
1965
1865
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
1966
|
-
} catch (
|
|
1866
|
+
} catch (e20) {
|
|
1967
1867
|
}
|
|
1968
1868
|
if (clientEntrySize === 0) {
|
|
1969
1869
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
@@ -1972,12 +1872,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
1972
1872
|
const globalsCssPath = _path2.default.join(root, srcDir, "app", "globals.css");
|
|
1973
1873
|
let expectsCss = false;
|
|
1974
1874
|
try {
|
|
1975
|
-
const globalsCss = await
|
|
1875
|
+
const globalsCss = await fs3.readFile(globalsCssPath, "utf8");
|
|
1976
1876
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1977
|
-
} catch (
|
|
1877
|
+
} catch (e21) {
|
|
1978
1878
|
}
|
|
1979
1879
|
try {
|
|
1980
|
-
const clientCss = await
|
|
1880
|
+
const clientCss = await fs3.stat(clientCssPath);
|
|
1981
1881
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
1982
1882
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
1983
1883
|
}
|
|
@@ -1986,7 +1886,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
1986
1886
|
if (expectsCss) {
|
|
1987
1887
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
1988
1888
|
}
|
|
1989
|
-
await
|
|
1889
|
+
await fs3.writeFile(clientCssPath, "");
|
|
1990
1890
|
}
|
|
1991
1891
|
}
|
|
1992
1892
|
_chunkS3JO3N4Hcjs.__name.call(void 0, validateClientBuildOutput, "validateClientBuildOutput");
|
|
@@ -1994,7 +1894,7 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
1994
1894
|
const key = `${_path2.default.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${_path2.default.resolve(modulePath)}`;
|
|
1995
1895
|
let plan = cache.get(key);
|
|
1996
1896
|
if (!plan) {
|
|
1997
|
-
plan =
|
|
1897
|
+
plan = _chunkAS2VPMEEcjs.getClientModuleHydrationPlan.call(void 0, modulePath, root, mode, options);
|
|
1998
1898
|
cache.set(key, plan);
|
|
1999
1899
|
}
|
|
2000
1900
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
@@ -2004,7 +1904,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2004
1904
|
const viteBuild = productionVite.build;
|
|
2005
1905
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.cjs");
|
|
2006
1906
|
const { PluginManager: PluginManager2 } = await import("./plugin.cjs");
|
|
2007
|
-
const
|
|
1907
|
+
const fs3 = await import("fs/promises");
|
|
2008
1908
|
const pluginManager = new PluginManager2({
|
|
2009
1909
|
config,
|
|
2010
1910
|
isDev: false,
|
|
@@ -2012,25 +1912,25 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2012
1912
|
});
|
|
2013
1913
|
pluginManager.addPlugins(config.plugins || []);
|
|
2014
1914
|
const clientPages = [];
|
|
2015
|
-
const integrationProviders =
|
|
1915
|
+
const integrationProviders = _chunkBWIQR4DHcjs.getIntegrationProviders.call(void 0, config.integrations).filter(
|
|
2016
1916
|
(provider) => provider.component || provider.type === "clerk"
|
|
2017
1917
|
);
|
|
2018
1918
|
const unsupportedIntegrationProvider = integrationProviders.find(
|
|
2019
1919
|
(provider) => provider.supportsIsolatedHydration !== true
|
|
2020
1920
|
);
|
|
2021
|
-
if (_optionalChain([config, 'access',
|
|
1921
|
+
if (_optionalChain([config, 'access', _35 => _35.experimental, 'optionalAccess', _36 => _36.isolatedClientHydration]) === "enabled" && _optionalChain([config, 'access', _37 => _37.experimental, 'optionalAccess', _38 => _38.serverComponents]) !== true && unsupportedIntegrationProvider) {
|
|
2022
1922
|
_chunk5QIKR7RRcjs.logger.warn(
|
|
2023
1923
|
`[Farm.js] isolated hydration kept route-wide because integration provider "${unsupportedIntegrationProvider.name}" does not declare supportsIsolatedHydration: true.`
|
|
2024
1924
|
);
|
|
2025
1925
|
}
|
|
2026
|
-
const isolatedMode =
|
|
2027
|
-
_optionalChain([config, 'access',
|
|
1926
|
+
const isolatedMode = _chunkAS2VPMEEcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
|
|
1927
|
+
_optionalChain([config, 'access', _39 => _39.experimental, 'optionalAccess', _40 => _40.isolatedClientHydration]),
|
|
2028
1928
|
{
|
|
2029
|
-
serverComponents: _optionalChain([config, 'access',
|
|
1929
|
+
serverComponents: _optionalChain([config, 'access', _41 => _41.experimental, 'optionalAccess', _42 => _42.serverComponents]) === true,
|
|
2030
1930
|
hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
|
|
2031
1931
|
}
|
|
2032
1932
|
);
|
|
2033
|
-
const planOptions =
|
|
1933
|
+
const planOptions = _chunkAS2VPMEEcjs.getFarmClientHydrationPlanOptions.call(void 0,
|
|
2034
1934
|
config.renderer,
|
|
2035
1935
|
Boolean(unsupportedIntegrationProvider)
|
|
2036
1936
|
);
|
|
@@ -2077,18 +1977,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2077
1977
|
};
|
|
2078
1978
|
}
|
|
2079
1979
|
});
|
|
2080
|
-
const layoutAppliesToRoute =
|
|
1980
|
+
const layoutAppliesToRoute = _chunkRVXFINNScjs.routeBoundaryCoversDirectory;
|
|
2081
1981
|
const routeDirectory = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (route) => _nullishCoalesce(route.directory, () => ( route.pattern)), "routeDirectory");
|
|
2082
1982
|
const adapterOwnsDocsRuntime = Boolean(
|
|
2083
|
-
_chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access',
|
|
1983
|
+
_chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _43 => _43.docs, 'optionalAccess', _44 => _44.enabled]) && _optionalChain([config, 'access', _45 => _45.docs, 'access', _46 => _46.adapter, 'optionalAccess', _47 => _47.server]) && config.docs.adapter.react
|
|
2084
1984
|
);
|
|
2085
|
-
const adapterDocsEntry = _optionalChain([config, 'access',
|
|
1985
|
+
const adapterDocsEntry = _optionalChain([config, 'access', _48 => _48.docs, 'optionalAccess', _49 => _49.enabled]) ? `/${config.docs.entry || "docs"}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/" : null;
|
|
2086
1986
|
const isAdapterDocsRoute = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (routePattern) => Boolean(
|
|
2087
1987
|
adapterOwnsDocsRuntime && adapterDocsEntry && (adapterDocsEntry === "/" || routePattern === adapterDocsEntry || routePattern.startsWith(`${adapterDocsEntry}/`))
|
|
2088
1988
|
), "isAdapterDocsRoute");
|
|
2089
|
-
const syntheticDocsEntry = _optionalChain([config, 'access',
|
|
1989
|
+
const syntheticDocsEntry = _optionalChain([config, 'access', _50 => _50.docs, 'optionalAccess', _51 => _51.enabled]) && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
|
|
2090
1990
|
const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
|
|
2091
|
-
const markdownPagePlan =
|
|
1991
|
+
const markdownPagePlan = _chunkAS2VPMEEcjs.createMarkdownPageHydrationPlanner.call(void 0,
|
|
2092
1992
|
_chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, config.mdx), root),
|
|
2093
1993
|
root,
|
|
2094
1994
|
isolatedMode,
|
|
@@ -2096,7 +1996,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2096
1996
|
);
|
|
2097
1997
|
const routePlans = pageRoutes.map((route) => ({
|
|
2098
1998
|
route,
|
|
2099
|
-
metadata:
|
|
1999
|
+
metadata: _chunkEKN7NSZOcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
2100
2000
|
route.modulePath,
|
|
2101
2001
|
root,
|
|
2102
2002
|
isolatedMode,
|
|
@@ -2104,7 +2004,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2104
2004
|
planOptions
|
|
2105
2005
|
)
|
|
2106
2006
|
}));
|
|
2107
|
-
|
|
2007
|
+
_chunkAS2VPMEEcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
|
|
2108
2008
|
clientLayouts.map((layout) => ({
|
|
2109
2009
|
pattern: layout.pattern,
|
|
2110
2010
|
depth: layout.pattern.split("/").filter(Boolean).length,
|
|
@@ -2113,7 +2013,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2113
2013
|
[
|
|
2114
2014
|
...routePlans.map(({ route, metadata }) => ({
|
|
2115
2015
|
pattern: routeDirectory(route),
|
|
2116
|
-
depth:
|
|
2016
|
+
depth: _chunkRVXFINNScjs.getRouteDirectoryDepth.call(void 0, routeDirectory(route)),
|
|
2117
2017
|
metadata
|
|
2118
2018
|
})),
|
|
2119
2019
|
...syntheticDocsPatterns.map((pattern) => ({
|
|
@@ -2136,7 +2036,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2136
2036
|
for (const layout of clientLayouts) {
|
|
2137
2037
|
const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || Boolean(adapterDocsEntry && layoutAppliesToRoute(layout.pattern, adapterDocsEntry));
|
|
2138
2038
|
if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
|
|
2139
|
-
_chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F ${
|
|
2039
|
+
_chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F ${_chunkAS2VPMEEcjs.describeSuppressedAsyncHydration.call(void 0, layout.pattern, layout.fallbackReason)}`);
|
|
2140
2040
|
}
|
|
2141
2041
|
}
|
|
2142
2042
|
if (isolatedMode === "analyze") {
|
|
@@ -2160,7 +2060,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2160
2060
|
);
|
|
2161
2061
|
if (metadata.suppressedAsyncHydration) {
|
|
2162
2062
|
_chunk5QIKR7RRcjs.logger.warn(
|
|
2163
|
-
`\u26A0\uFE0F ${
|
|
2063
|
+
`\u26A0\uFE0F ${_chunkAS2VPMEEcjs.describeSuppressedAsyncHydration.call(void 0, route.pattern, metadata.fallbackReason)}`
|
|
2164
2064
|
);
|
|
2165
2065
|
}
|
|
2166
2066
|
if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0) {
|
|
@@ -2185,7 +2085,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2185
2085
|
...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries).flatMap((layout) => layout.isolatedBoundaries)
|
|
2186
2086
|
],
|
|
2187
2087
|
// The server renders a server tree only below a hydrating layout.
|
|
2188
|
-
...
|
|
2088
|
+
..._chunkAS2VPMEEcjs.usesFarmServerTree.call(void 0, metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
|
|
2189
2089
|
});
|
|
2190
2090
|
_chunk5QIKR7RRcjs.logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
|
|
2191
2091
|
}
|
|
@@ -2221,7 +2121,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2221
2121
|
}
|
|
2222
2122
|
const clientRouteSlots = routeSlots.filter((slot) => {
|
|
2223
2123
|
try {
|
|
2224
|
-
return
|
|
2124
|
+
return _chunkAS2VPMEEcjs.getClientModuleMetadata.call(void 0, slot.modulePath, root).shouldHydrate;
|
|
2225
2125
|
} catch (error) {
|
|
2226
2126
|
_chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
|
|
2227
2127
|
return false;
|
|
@@ -2231,8 +2131,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2231
2131
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2232
2132
|
);
|
|
2233
2133
|
const clientEntryRoot = _path2.default.join(root, ".farm", "tmp");
|
|
2234
|
-
await
|
|
2235
|
-
const clientEntryDir = await
|
|
2134
|
+
await fs3.mkdir(clientEntryRoot, { recursive: true });
|
|
2135
|
+
const clientEntryDir = await fs3.mkdtemp(_path2.default.join(clientEntryRoot, "client-entry-"));
|
|
2236
2136
|
const clientEntryPath = _path2.default.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2237
2137
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2238
2138
|
clientPages,
|
|
@@ -2242,19 +2142,19 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2242
2142
|
srcDir,
|
|
2243
2143
|
adapterOwnsDocsRuntime ? false : _chunkMWWVKDW3cjs.isFarmDocsSearchEnabled.call(void 0, config.docs),
|
|
2244
2144
|
adapterOwnsDocsRuntime ? void 0 : _chunkMWWVKDW3cjs.resolveFarmDocsSearchClientModule.call(void 0, root),
|
|
2245
|
-
_optionalChain([config, 'access',
|
|
2246
|
-
adapterOwnsDocsRuntime ? _optionalChain([config, 'access',
|
|
2145
|
+
_optionalChain([config, 'access', _52 => _52.docs, 'optionalAccess', _53 => _53.enabled]) ? config.docs.entry : void 0,
|
|
2146
|
+
adapterOwnsDocsRuntime ? _optionalChain([config, 'access', _54 => _54.docs, 'access', _55 => _55.adapter, 'optionalAccess', _56 => _56.react]) : void 0,
|
|
2247
2147
|
config.i18n,
|
|
2248
2148
|
config.plugins,
|
|
2249
2149
|
config.renderer,
|
|
2250
2150
|
config.publicRuntimeConfig,
|
|
2251
2151
|
config.trailingSlash,
|
|
2252
|
-
|
|
2152
|
+
_chunkBWIQR4DHcjs.getIntegrationProviders.call(void 0, config.integrations),
|
|
2253
2153
|
config.basePath,
|
|
2254
|
-
|
|
2255
|
-
adapterOwnsDocsRuntime ?
|
|
2154
|
+
_chunkAS2VPMEEcjs.generateClientCachePersistenceCode.call(void 0, _chunkAS2VPMEEcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, config.cache)),
|
|
2155
|
+
adapterOwnsDocsRuntime ? _chunkCY2ZQ5C6cjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
|
|
2256
2156
|
);
|
|
2257
|
-
await
|
|
2157
|
+
await fs3.writeFile(clientEntryPath, clientHydrationCode);
|
|
2258
2158
|
const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
|
|
2259
2159
|
let postcssSearchPath;
|
|
2260
2160
|
let tailwindVitePlugin = void 0;
|
|
@@ -2266,9 +2166,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2266
2166
|
_chunk5QIKR7RRcjs.logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
2267
2167
|
} else {
|
|
2268
2168
|
const postcssConfigPath = _path2.default.join(clientEntryDir, "postcss.config.cjs");
|
|
2269
|
-
await
|
|
2169
|
+
await fs3.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2270
2170
|
postcssSearchPath = clientEntryDir;
|
|
2271
|
-
tailwindVitePlugin = await
|
|
2171
|
+
tailwindVitePlugin = await _chunkAS2VPMEEcjs.loadTailwindVitePlugin.call(void 0, {
|
|
2272
2172
|
builder: productionVite.builder,
|
|
2273
2173
|
announce: true
|
|
2274
2174
|
});
|
|
@@ -2301,7 +2201,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2301
2201
|
hashCharacters: "hex",
|
|
2302
2202
|
// Use predictable name for CSS so we can reference it in SSR HTML
|
|
2303
2203
|
assetFileNames: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (assetInfo) => {
|
|
2304
|
-
if (_optionalChain([assetInfo, 'access',
|
|
2204
|
+
if (_optionalChain([assetInfo, 'access', _57 => _57.name, 'optionalAccess', _58 => _58.endsWith, 'call', _59 => _59(".css")])) {
|
|
2305
2205
|
return "farm-client.css";
|
|
2306
2206
|
}
|
|
2307
2207
|
return "assets/[name]-h[hash][extname]";
|
|
@@ -2337,13 +2237,30 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2337
2237
|
}
|
|
2338
2238
|
},
|
|
2339
2239
|
plugins: [
|
|
2340
|
-
|
|
2240
|
+
_chunkAS2VPMEEcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
|
|
2241
|
+
createFarmClientModulePreloadPlugin({
|
|
2242
|
+
root,
|
|
2243
|
+
buildDir: _path2.default.dirname(outputDir),
|
|
2244
|
+
entryName: "farm-client"
|
|
2245
|
+
}),
|
|
2246
|
+
...adapterOwnsDocsRuntime ? [
|
|
2247
|
+
createFarmDocsModulePreloadPlugin({
|
|
2248
|
+
root,
|
|
2249
|
+
buildDir: _path2.default.dirname(outputDir),
|
|
2250
|
+
importer: clientEntryPath,
|
|
2251
|
+
entryName: "farm-client",
|
|
2252
|
+
modules: [
|
|
2253
|
+
config.docs.adapter.react,
|
|
2254
|
+
_chunkCY2ZQ5C6cjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs)
|
|
2255
|
+
].filter((specifier) => Boolean(specifier))
|
|
2256
|
+
})
|
|
2257
|
+
] : [],
|
|
2341
2258
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
2342
2259
|
...rendererVitePlugins,
|
|
2343
2260
|
...config.vite.plugins || [],
|
|
2344
2261
|
farmServerOnlyEntriesPlugin(),
|
|
2345
|
-
|
|
2346
|
-
adapterOwnsDocsRuntime ?
|
|
2262
|
+
_chunkAS2VPMEEcjs.farmDocsClientConfigPlugin.call(void 0,
|
|
2263
|
+
adapterOwnsDocsRuntime ? _chunkCY2ZQ5C6cjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
|
|
2347
2264
|
),
|
|
2348
2265
|
// Plugin to redirect @farm.js/core imports to client-only exports
|
|
2349
2266
|
{
|
|
@@ -2401,7 +2318,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2401
2318
|
} : void 0,
|
|
2402
2319
|
// Ensure React is bundled for client
|
|
2403
2320
|
resolve: {
|
|
2404
|
-
alias:
|
|
2321
|
+
alias: _chunkAS2VPMEEcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
|
|
2405
2322
|
dedupe: [...config.renderer.dedupe || []]
|
|
2406
2323
|
},
|
|
2407
2324
|
// Optimize dependencies - exclude server-side code from client bundle
|
|
@@ -2414,13 +2331,13 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2414
2331
|
]
|
|
2415
2332
|
}
|
|
2416
2333
|
};
|
|
2417
|
-
await viteBuild(
|
|
2334
|
+
await viteBuild(_chunkAS2VPMEEcjs.mergeFarmProductionViteConfig.call(void 0, clientViteConfig, config.vite));
|
|
2418
2335
|
await mergeBuiltFontCss(outputDir);
|
|
2419
2336
|
await validateClientBuildOutput(root, srcDir, outputDir);
|
|
2420
2337
|
} finally {
|
|
2421
2338
|
try {
|
|
2422
|
-
await
|
|
2423
|
-
} catch (
|
|
2339
|
+
await fs3.rm(clientEntryDir, { recursive: true, force: true });
|
|
2340
|
+
} catch (e22) {
|
|
2424
2341
|
}
|
|
2425
2342
|
}
|
|
2426
2343
|
}
|
|
@@ -3173,7 +3090,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
3173
3090
|
direction: {}
|
|
3174
3091
|
}, plugins = [], renderer = _chunkPSV6XKPOcjs.REACT_RENDERER, publicRuntimeConfig = void 0, trailingSlash = false, integrationProviders = [], basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule) {
|
|
3175
3092
|
const toImportPath = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (targetPath) => targetPath.replace(/\\/g, "/"), "toImportPath");
|
|
3176
|
-
const clientPluginEntry =
|
|
3093
|
+
const clientPluginEntry = _chunkAS2VPMEEcjs.generateFarmClientPluginEntryCode.call(void 0,
|
|
3177
3094
|
plugins,
|
|
3178
3095
|
root,
|
|
3179
3096
|
srcDir,
|
|
@@ -3184,7 +3101,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
3184
3101
|
import { createRoot, hydrateRoot } from "react-dom/client";` : appSetupPath ? `import React, { createRoot, hydrateRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)};
|
|
3185
3102
|
import __farmAppSetup from ${JSON.stringify(_chunk5QIKR7RRcjs.toPosixPath.call(void 0, appSetupPath))};
|
|
3186
3103
|
__farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
|
|
3187
|
-
const providerClientCode =
|
|
3104
|
+
const providerClientCode = _chunkAS2VPMEEcjs.generateFarmIntegrationProviderClientCode.call(void 0,
|
|
3188
3105
|
integrationProviders,
|
|
3189
3106
|
root,
|
|
3190
3107
|
_nullishCoalesce(renderer.componentExtensions, () => ( []))
|
|
@@ -3196,12 +3113,12 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
3196
3113
|
const hydratingLayoutPatterns = layoutRoutes.filter((layout) => layout.shouldHydrate).map((layout) => layout.pattern);
|
|
3197
3114
|
layoutRoutes.forEach((layout, index) => {
|
|
3198
3115
|
const relativePath = toImportPath(layout.modulePath);
|
|
3199
|
-
const rendersOnClient = !layout.hasIsolatedClientBoundaries && hydratingLayoutPatterns.some((pattern) =>
|
|
3116
|
+
const rendersOnClient = !layout.hasIsolatedClientBoundaries && hydratingLayoutPatterns.some((pattern) => _chunk5ULKUBIAcjs.layoutsCanCoverSamePage.call(void 0, layout.pattern, pattern));
|
|
3200
3117
|
if (rendersOnClient) {
|
|
3201
3118
|
layoutImportStatements.push(`import Layout${index} from "${relativePath}";`);
|
|
3202
3119
|
}
|
|
3203
|
-
const groupScope =
|
|
3204
|
-
const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(
|
|
3120
|
+
const groupScope = _chunkRVXFINNScjs.getRouteGroupScope.call(void 0, layout.pattern);
|
|
3121
|
+
const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(_chunkRVXFINNScjs.stripRouteGroups.call(void 0, layout.pattern))}, groupScope: ${JSON.stringify(groupScope)}` : "";
|
|
3205
3122
|
layoutRegistrations.push(
|
|
3206
3123
|
` { pattern: ${JSON.stringify(layout.pattern)}${groupFields}, Component: ${rendersOnClient ? `Layout${index}` : "null"}, shouldHydrate: ${JSON.stringify(layout.shouldHydrate)}, islandStrategy: ${JSON.stringify(layout.islandStrategy)} }`
|
|
3207
3124
|
);
|
|
@@ -3251,7 +3168,7 @@ function isFarmDocsPath() {
|
|
|
3251
3168
|
return false;
|
|
3252
3169
|
}
|
|
3253
3170
|
`;
|
|
3254
|
-
const docsAdapterRuntime =
|
|
3171
|
+
const docsAdapterRuntime = _chunkCY2ZQ5C6cjs.generateFarmDocsAdapterClientRuntime.call(void 0,
|
|
3255
3172
|
docsAdapterReact,
|
|
3256
3173
|
docsConfigModule
|
|
3257
3174
|
);
|
|
@@ -3704,7 +3621,7 @@ function hasHydratableLayout(pathname) {
|
|
|
3704
3621
|
});
|
|
3705
3622
|
}
|
|
3706
3623
|
|
|
3707
|
-
${
|
|
3624
|
+
${_chunkAS2VPMEEcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
|
|
3708
3625
|
// Wrap a page element with applicable layouts
|
|
3709
3626
|
function wrapWithLayouts(pageElement, pathname, params) {
|
|
3710
3627
|
const layouts = getApplicableLayouts(pathname);
|
|
@@ -4663,7 +4580,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4663
4580
|
const viteBuild = productionVite.build;
|
|
4664
4581
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.cjs");
|
|
4665
4582
|
const { PluginManager: PluginManager2 } = await import("./plugin.cjs");
|
|
4666
|
-
const
|
|
4583
|
+
const fs3 = await import("fs/promises");
|
|
4667
4584
|
const pluginManager = new PluginManager2({
|
|
4668
4585
|
config,
|
|
4669
4586
|
isDev: false,
|
|
@@ -4678,12 +4595,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4678
4595
|
buildLifetime: rendererBuildLifetime
|
|
4679
4596
|
});
|
|
4680
4597
|
if (!hasScopedPostcssConfig) {
|
|
4681
|
-
postcssConfigDir = await
|
|
4682
|
-
await
|
|
4598
|
+
postcssConfigDir = await fs3.mkdtemp(_path2.default.join(_os2.default.tmpdir(), "farm-postcss-"));
|
|
4599
|
+
await fs3.writeFile(
|
|
4683
4600
|
_path2.default.join(postcssConfigDir, "postcss.config.cjs"),
|
|
4684
4601
|
"module.exports = { plugins: [] };\n"
|
|
4685
4602
|
);
|
|
4686
|
-
tailwindVitePlugin = await
|
|
4603
|
+
tailwindVitePlugin = await _chunkAS2VPMEEcjs.loadTailwindVitePlugin.call(void 0, {
|
|
4687
4604
|
builder: productionVite.builder,
|
|
4688
4605
|
label: "for SSR"
|
|
4689
4606
|
});
|
|
@@ -4705,7 +4622,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4705
4622
|
fileName: entry.fileName,
|
|
4706
4623
|
sourceType: "static",
|
|
4707
4624
|
staticInfo: entry.staticInfo,
|
|
4708
|
-
data: (await
|
|
4625
|
+
data: (await fs3.readFile(entry.modulePath)).toString("base64")
|
|
4709
4626
|
});
|
|
4710
4627
|
continue;
|
|
4711
4628
|
}
|
|
@@ -4779,7 +4696,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4779
4696
|
}
|
|
4780
4697
|
const middlewareRoutes = await discoverMiddlewareRoutes(appDirs);
|
|
4781
4698
|
const instrumentationPath = _chunkKCMTCM6Icjs.resolveFarmInstrumentationFile.call(void 0, root, config.srcDir || "src");
|
|
4782
|
-
const notFoundPath =
|
|
4699
|
+
const notFoundPath = _chunkAS2VPMEEcjs.resolveFarmNotFoundComponentPath.call(void 0, config, appDirs);
|
|
4783
4700
|
if (notFoundPath) _chunk5QIKR7RRcjs.logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
|
|
4784
4701
|
layoutRoutes.sort((a, b) => {
|
|
4785
4702
|
const depthA = a.pattern.split("/").filter(Boolean).length;
|
|
@@ -4796,13 +4713,13 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4796
4713
|
const hasServerRuntimeIntegrations = configuredIntegrationValues.some(
|
|
4797
4714
|
(integration) => typeof integration === "object" && integration !== null && (!("serverRuntime" in integration) || integration.serverRuntime !== false)
|
|
4798
4715
|
);
|
|
4799
|
-
const hasIntegrationProviders =
|
|
4716
|
+
const hasIntegrationProviders = _chunkBWIQR4DHcjs.getIntegrationProviders.call(void 0, config.integrations).some(
|
|
4800
4717
|
(provider) => provider.component || provider.type === "clerk"
|
|
4801
4718
|
);
|
|
4802
4719
|
const hasObservabilityHandler = !!config.observability && typeof config.observability === "object" && "onEvent" in config.observability;
|
|
4803
|
-
const hasMdxComponentConfig = Boolean(_optionalChain([config, 'access',
|
|
4804
|
-
const hasMiddlewareConfig = hasFarmMiddlewareConfig(config.middleware);
|
|
4805
|
-
const hasRouteContextConfig =
|
|
4720
|
+
const hasMdxComponentConfig = Boolean(_optionalChain([config, 'access', _60 => _60.mdx, 'optionalAccess', _61 => _61.components]));
|
|
4721
|
+
const hasMiddlewareConfig = _chunkRVXFINNScjs.hasFarmMiddlewareConfig.call(void 0, config.middleware);
|
|
4722
|
+
const hasRouteContextConfig = _chunkHRETEZ2Zcjs.hasCustomFarmRouteContext.call(void 0, config);
|
|
4806
4723
|
const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config);
|
|
4807
4724
|
const hasPluginRoutes = hasFarmPluginRoutes(config);
|
|
4808
4725
|
const hasServerCacheConfig = hasFarmServerCacheConfig(config.cache);
|
|
@@ -4812,20 +4729,39 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4812
4729
|
const hasConfiguredRuntimePlugins = Boolean(
|
|
4813
4730
|
hasRuntimeConfigModule && (config.plugins || []).length > 0
|
|
4814
4731
|
);
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4732
|
+
if (_chunkCIOT4HGTcjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)) {
|
|
4733
|
+
const adapterGuardedPaths = new Set(getFarmDocsGuardedPaths(config, middlewareRoutes));
|
|
4734
|
+
_chunkCIOT4HGTcjs.assertFarmDocsAdapterServesNoGuardedPages.call(void 0,
|
|
4735
|
+
config.docs,
|
|
4736
|
+
{ root, srcDir: config.srcDir },
|
|
4737
|
+
(pathname) => adapterGuardedPaths.has(pathname)
|
|
4738
|
+
);
|
|
4739
|
+
}
|
|
4740
|
+
const farmDocsCspNonceMarker = _chunk2ZYGC6SScjs.createFarmCspNonce.call(void 0, config.security);
|
|
4741
|
+
const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _62 => _62.docs, 'optionalAccess', _63 => _63.enabled]) && _chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? await _chunk6XWDE2P2cjs._runWithFarmCspNonce.call(void 0,
|
|
4742
|
+
farmDocsCspNonceMarker,
|
|
4743
|
+
async () => _optionalChain([config, 'access', _64 => _64.docs, 'access', _65 => _65.adapter, 'optionalAccess', _66 => _66.server]) ? await _chunkCIOT4HGTcjs.compileFarmDocsAdapterEdgeManifest.call(void 0, config.docs, {
|
|
4744
|
+
root,
|
|
4745
|
+
srcDir: config.srcDir,
|
|
4746
|
+
clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
|
|
4747
|
+
fontStylesheetHref: "/farm-fonts.css",
|
|
4748
|
+
globalStylesheetHref: "/assets/globals.css"
|
|
4749
|
+
}) : await (async () => {
|
|
4750
|
+
const guardedPaths = new Set(getFarmDocsGuardedPaths(config, middlewareRoutes));
|
|
4751
|
+
return compileFarmDocsManifest(config.docs, {
|
|
4752
|
+
root,
|
|
4753
|
+
srcDir: config.srcDir,
|
|
4754
|
+
clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
|
|
4755
|
+
fontAssets: _chunkHREOKQWTcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkHREOKQWTcjs.resolveFarmDocsFontAssets.call(void 0, root)),
|
|
4756
|
+
fontStylesheetHref: "/farm-fonts.css",
|
|
4757
|
+
globalStylesheetHref: "/assets/globals.css",
|
|
4758
|
+
isPathGuarded: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (pathname) => guardedPaths.has(pathname), "isPathGuarded")
|
|
4759
|
+
});
|
|
4760
|
+
})()
|
|
4761
|
+
) : null;
|
|
4762
|
+
if (farmDocsPrecompiledManifest && farmDocsCspNonceMarker) {
|
|
4763
|
+
farmDocsPrecompiledManifest.cspNonceMarker = farmDocsCspNonceMarker;
|
|
4764
|
+
}
|
|
4829
4765
|
const virtualEntryCode = generateVirtualEntryCode(
|
|
4830
4766
|
apiRoutes,
|
|
4831
4767
|
pageRoutes,
|
|
@@ -4909,7 +4845,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4909
4845
|
// Adapters can render provider scripts by serializing function source.
|
|
4910
4846
|
// keepNames injects helper calls into those functions; after Nitro
|
|
4911
4847
|
// minifies the server chunk the helper is no longer in script scope.
|
|
4912
|
-
keepNames: !(_optionalChain([config, 'access',
|
|
4848
|
+
keepNames: !(_optionalChain([config, 'access', _67 => _67.docs, 'optionalAccess', _68 => _68.enabled]) && _optionalChain([config, 'access', _69 => _69.docs, 'access', _70 => _70.adapter, 'optionalAccess', _71 => _71.server])),
|
|
4913
4849
|
jsxDev: false
|
|
4914
4850
|
},
|
|
4915
4851
|
// SSR configuration to externalize problematic modules
|
|
@@ -4959,10 +4895,10 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4959
4895
|
define: {
|
|
4960
4896
|
__FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
|
|
4961
4897
|
__FARM_ENV__: JSON.stringify(_chunkVEKFLAQMcjs.createBundledEnv.call(void 0, config.env)),
|
|
4962
|
-
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access',
|
|
4898
|
+
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _72 => _72.env, 'optionalAccess', _73 => _73.public]) || {})
|
|
4963
4899
|
},
|
|
4964
4900
|
plugins: [
|
|
4965
|
-
|
|
4901
|
+
_chunkAS2VPMEEcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
|
|
4966
4902
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
4967
4903
|
...rendererVitePlugins,
|
|
4968
4904
|
...config.vite.plugins || [],
|
|
@@ -5009,7 +4945,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5009
4945
|
resolve: {
|
|
5010
4946
|
alias: [
|
|
5011
4947
|
...shouldAliasReactServerToWebBuild(config.renderer, preset) ? [createFarmReactWebServerAlias(hasReactDomEdgeServerBuild(root))] : [],
|
|
5012
|
-
...Object.entries(
|
|
4948
|
+
...Object.entries(_chunkAS2VPMEEcjs.createFarmSourceAlias.call(void 0, root, config.srcDir)).map(
|
|
5013
4949
|
([find, replacement]) => ({ find, replacement })
|
|
5014
4950
|
)
|
|
5015
4951
|
],
|
|
@@ -5017,12 +4953,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5017
4953
|
dedupe: [...config.renderer.dedupe || []]
|
|
5018
4954
|
}
|
|
5019
4955
|
};
|
|
5020
|
-
await viteBuild(
|
|
4956
|
+
await viteBuild(_chunkAS2VPMEEcjs.mergeFarmProductionViteConfig.call(void 0, serverViteConfig, config.vite));
|
|
5021
4957
|
} finally {
|
|
5022
4958
|
if (postcssConfigDir) {
|
|
5023
4959
|
try {
|
|
5024
|
-
await
|
|
5025
|
-
} catch (
|
|
4960
|
+
await fs3.rm(postcssConfigDir, { recursive: true, force: true });
|
|
4961
|
+
} catch (e23) {
|
|
5026
4962
|
}
|
|
5027
4963
|
}
|
|
5028
4964
|
}
|
|
@@ -5036,7 +4972,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, buildSSRInMemory, "buildSSRInMemory");
|
|
|
5036
4972
|
function readFarmAppPackageIdentity(root) {
|
|
5037
4973
|
try {
|
|
5038
4974
|
return JSON.parse(_fs.readFileSync.call(void 0, _path2.default.join(root, "package.json"), "utf8"));
|
|
5039
|
-
} catch (
|
|
4975
|
+
} catch (e24) {
|
|
5040
4976
|
return {};
|
|
5041
4977
|
}
|
|
5042
4978
|
}
|
|
@@ -5049,22 +4985,35 @@ function readFarmPageLastModified(pageRoutes) {
|
|
|
5049
4985
|
lastModified[route.pattern] = _fs.statSync.call(void 0,
|
|
5050
4986
|
_nullishCoalesce(route.markdownSourcePath, () => ( route.modulePath))
|
|
5051
4987
|
).mtime.toISOString();
|
|
5052
|
-
} catch (
|
|
4988
|
+
} catch (e25) {
|
|
5053
4989
|
}
|
|
5054
4990
|
}
|
|
5055
4991
|
return lastModified;
|
|
5056
4992
|
}
|
|
5057
4993
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readFarmPageLastModified, "readFarmPageLastModified");
|
|
4994
|
+
function getFarmDocsGuardedPaths(config, middlewareRoutes) {
|
|
4995
|
+
if (!_optionalChain([config, 'access', _74 => _74.docs, 'optionalAccess', _75 => _75.enabled])) return [];
|
|
4996
|
+
const contentDir = _chunkPGZDEPTMcjs.resolveFarmDocsContentDir.call(void 0, config.docs, {
|
|
4997
|
+
root: config.root,
|
|
4998
|
+
srcDir: config.srcDir
|
|
4999
|
+
});
|
|
5000
|
+
const guards = {
|
|
5001
|
+
config: { middleware: config.middleware, integrations: config.integrations },
|
|
5002
|
+
middlewareRoutes
|
|
5003
|
+
};
|
|
5004
|
+
return _chunkPGZDEPTMcjs.discoverFarmDocsPages.call(void 0, contentDir, config.docs).flatMap((page) => [page.href, _chunkPGZDEPTMcjs.getFarmDocsMarkdownPath.call(void 0, page.href)]).filter((pathname) => _chunkRVXFINNScjs.farmPathGuardCoversPage.call(void 0, guards, pathname));
|
|
5005
|
+
}
|
|
5006
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmDocsGuardedPaths, "getFarmDocsGuardedPaths");
|
|
5058
5007
|
function getFarmAppOwnedDocsEnginePaths(agent, applicationMetadataRoutes) {
|
|
5059
|
-
const llmsTxt = _optionalChain([agent, 'optionalAccess',
|
|
5008
|
+
const llmsTxt = _optionalChain([agent, 'optionalAccess', _76 => _76.llmsTxt]);
|
|
5060
5009
|
const ownedByFile = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (kind) => applicationMetadataRoutes.some(
|
|
5061
5010
|
(metadata) => metadata.kind === kind && metadata.pattern === "/"
|
|
5062
5011
|
), "ownedByFile");
|
|
5063
5012
|
return [
|
|
5064
|
-
..._optionalChain([llmsTxt, 'optionalAccess',
|
|
5065
|
-
..._optionalChain([llmsTxt, 'optionalAccess',
|
|
5066
|
-
..._optionalChain([agent, 'optionalAccess',
|
|
5067
|
-
..._optionalChain([agent, 'optionalAccess',
|
|
5013
|
+
..._optionalChain([llmsTxt, 'optionalAccess', _77 => _77.enabled]) || ownedByFile("llms") ? ["/llms.txt"] : [],
|
|
5014
|
+
..._optionalChain([llmsTxt, 'optionalAccess', _78 => _78.enabled]) && llmsTxt.full || ownedByFile("llms-full") ? ["/llms-full.txt"] : [],
|
|
5015
|
+
..._optionalChain([agent, 'optionalAccess', _79 => _79.sitemap, 'optionalAccess', _80 => _80.enabled]) || ownedByFile("sitemap") ? ["/sitemap.xml"] : [],
|
|
5016
|
+
..._optionalChain([agent, 'optionalAccess', _81 => _81.crawlers, 'optionalAccess', _82 => _82.enabled]) || ownedByFile("robots") ? ["/robots.txt"] : []
|
|
5068
5017
|
];
|
|
5069
5018
|
}
|
|
5070
5019
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmAppOwnedDocsEnginePaths, "getFarmAppOwnedDocsEnginePaths");
|
|
@@ -5106,7 +5055,7 @@ function toVirtualEntryImportSpecifier(modulePath) {
|
|
|
5106
5055
|
}
|
|
5107
5056
|
_chunkS3JO3N4Hcjs.__name.call(void 0, toVirtualEntryImportSpecifier, "toVirtualEntryImportSpecifier");
|
|
5108
5057
|
function generateNativeAuthIntegrationSource(auth) {
|
|
5109
|
-
if (_optionalChain([auth, 'optionalAccess',
|
|
5058
|
+
if (_optionalChain([auth, 'optionalAccess', _83 => _83.enabled]) !== true) {
|
|
5110
5059
|
return { importSource: "", registerSource: "" };
|
|
5111
5060
|
}
|
|
5112
5061
|
return {
|
|
@@ -5229,7 +5178,7 @@ function parseRouteRenderingDirectiveFromDisk(modulePath) {
|
|
|
5229
5178
|
const directive = _chunk5D2JIPLHcjs.parseRouteRenderingDirective.call(void 0, source);
|
|
5230
5179
|
if (_chunk5D2JIPLHcjs.findRequestBoundSourceBlockers.call(void 0, source).length === 0) return directive;
|
|
5231
5180
|
return { ..._nullishCoalesce(directive, () => ( { ssg: false, ppr: false, directive: "" })), requestBound: true };
|
|
5232
|
-
} catch (
|
|
5181
|
+
} catch (e26) {
|
|
5233
5182
|
return void 0;
|
|
5234
5183
|
}
|
|
5235
5184
|
}
|
|
@@ -5416,19 +5365,19 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
|
|
|
5416
5365
|
_chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmRendererAppSetupServerCode, "generateFarmRendererAppSetupServerCode");
|
|
5417
5366
|
function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlots, errorRoutes, metadataImageRoutes, applicationMetadataRoutes, middlewareRoutes, redirectRoutes, configuredRewriteRoutes, configuredHeaderRoutes, openAPIReference, notFoundPath, instrumentationPath, config, farmDocsPrecompiledManifest, configModulePath, hasServerRuntimeIntegrations, hasRuntimeIntegrationConfig, hasConfiguredRuntimePlugins, hasServerRuntimePlugins, preset, i18nCatalogs, isolatedClientBoundaryModules, hydrationPlanCache) {
|
|
5418
5367
|
const hasCompressionRuntime = config.compress && _chunk2SJ4RQ6Pcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
|
|
5419
|
-
const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access',
|
|
5368
|
+
const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access', _84 => _84.agent, 'optionalAccess', _85 => _85.crawlers, 'optionalAccess', _86 => _86.enabled])) && !applicationMetadataRoutes.some(
|
|
5420
5369
|
(metadata) => metadata.kind === "robots" && metadata.pattern === "/"
|
|
5421
5370
|
);
|
|
5422
|
-
const servesAgentSitemap = Boolean(_optionalChain([config, 'access',
|
|
5371
|
+
const servesAgentSitemap = Boolean(_optionalChain([config, 'access', _87 => _87.agent, 'optionalAccess', _88 => _88.sitemap, 'optionalAccess', _89 => _89.enabled])) && !applicationMetadataRoutes.some(
|
|
5423
5372
|
(metadata) => metadata.kind === "sitemap" && metadata.pattern === "/"
|
|
5424
5373
|
);
|
|
5425
|
-
const servesDefaultMCP = _optionalChain([config, 'access',
|
|
5426
|
-
const servesAiCatalog = _optionalChain([config, 'access',
|
|
5374
|
+
const servesDefaultMCP = _optionalChain([config, 'access', _90 => _90.agent, 'optionalAccess', _91 => _91.mcp]) === true && !_chunkH5CLOUZScjs.farmConfigMountsMCP.call(void 0, config) && !apiRoutes.some((route) => route.path === "/api/mcp");
|
|
5375
|
+
const servesAiCatalog = _optionalChain([config, 'access', _92 => _92.agent, 'optionalAccess', _93 => _93.aiCatalog]) !== false;
|
|
5427
5376
|
const hasPluginRuntime = hasRuntimeIntegrationConfig || hasServerRuntimePlugins;
|
|
5428
5377
|
const hasInfraAnalyticsRuntime = config.analytics !== false && _chunk2SJ4RQ6Pcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
|
|
5429
5378
|
const hasPrecompiledDocs = Boolean(farmDocsPrecompiledManifest);
|
|
5430
5379
|
const adapterOwnsDocsRuntime = Boolean(
|
|
5431
|
-
_chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access',
|
|
5380
|
+
_chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _94 => _94.docs, 'optionalAccess', _95 => _95.enabled]) && _optionalChain([config, 'access', _96 => _96.docs, 'access', _97 => _97.adapter, 'optionalAccess', _98 => _98.server]) && config.docs.adapter.react
|
|
5432
5381
|
);
|
|
5433
5382
|
const docsConfigModulePath = adapterOwnsDocsRuntime && !hasPrecompiledDocs && config.docs.configPath && !config.docs.configPath.endsWith(".json") ? config.docs.configPath : void 0;
|
|
5434
5383
|
const hasIsolatedClientGraphRuntime = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && isolatedClientBoundaryModules.size > 0;
|
|
@@ -5461,9 +5410,9 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5461
5410
|
const hasGeneratedMetadataImages = metadataImageRoutes.some(
|
|
5462
5411
|
(image) => image.sourceType === "module"
|
|
5463
5412
|
);
|
|
5464
|
-
const hasMiddlewareRuntime = middlewareRoutes.length > 0 || hasFarmMiddlewareConfig(config.middleware);
|
|
5465
|
-
const farmDocsFontAssets = _optionalChain([config, 'access',
|
|
5466
|
-
const integrationProviders =
|
|
5413
|
+
const hasMiddlewareRuntime = middlewareRoutes.length > 0 || _chunkRVXFINNScjs.hasFarmMiddlewareConfig.call(void 0, config.middleware);
|
|
5414
|
+
const farmDocsFontAssets = _optionalChain([config, 'access', _99 => _99.docs, 'optionalAccess', _100 => _100.enabled]) ? _chunkHREOKQWTcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkHREOKQWTcjs.resolveFarmDocsFontAssets.call(void 0, config.root)) : [];
|
|
5415
|
+
const integrationProviders = _chunkBWIQR4DHcjs.getIntegrationProviders.call(void 0, config.integrations);
|
|
5467
5416
|
const renderedIntegrationProviders = integrationProviders.filter(
|
|
5468
5417
|
(provider) => provider.component || provider.type === "clerk"
|
|
5469
5418
|
);
|
|
@@ -5472,16 +5421,16 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5472
5421
|
`Integration provider components are not supported by the "${config.renderer.name}" renderer.`
|
|
5473
5422
|
);
|
|
5474
5423
|
}
|
|
5475
|
-
const providerServerModules =
|
|
5424
|
+
const providerServerModules = _chunkAS2VPMEEcjs.generateFarmIntegrationProviderServerModules.call(void 0,
|
|
5476
5425
|
renderedIntegrationProviders,
|
|
5477
5426
|
config.root,
|
|
5478
5427
|
_nullishCoalesce(config.renderer.componentExtensions, () => ( []))
|
|
5479
5428
|
);
|
|
5480
5429
|
const resolvedIntegrationProviderFallback = Object.fromEntries(
|
|
5481
5430
|
Object.entries(config.integrations).flatMap(([name, integration]) => {
|
|
5482
|
-
const configuredProviders = _optionalChain([integration, 'optionalAccess',
|
|
5431
|
+
const configuredProviders = _optionalChain([integration, 'optionalAccess', _101 => _101.providers]);
|
|
5483
5432
|
const providers = Array.isArray(configuredProviders) ? configuredProviders : [];
|
|
5484
|
-
if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess',
|
|
5433
|
+
if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess', _102 => _102.component]) === "function")) {
|
|
5485
5434
|
throw new Error(
|
|
5486
5435
|
`Integration provider components in production must use an importable component reference, for example component: { module: "@/components/provider" }.`
|
|
5487
5436
|
);
|
|
@@ -5492,14 +5441,14 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5492
5441
|
const unsupportedIntegrationProvider = renderedIntegrationProviders.find(
|
|
5493
5442
|
(provider) => provider.supportsIsolatedHydration !== true
|
|
5494
5443
|
);
|
|
5495
|
-
const isolatedHydrationMode =
|
|
5496
|
-
_optionalChain([config, 'access',
|
|
5444
|
+
const isolatedHydrationMode = _chunkAS2VPMEEcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
|
|
5445
|
+
_optionalChain([config, 'access', _103 => _103.experimental, 'optionalAccess', _104 => _104.isolatedClientHydration]),
|
|
5497
5446
|
{
|
|
5498
|
-
serverComponents: _optionalChain([config, 'access',
|
|
5447
|
+
serverComponents: _optionalChain([config, 'access', _105 => _105.experimental, 'optionalAccess', _106 => _106.serverComponents]) === true,
|
|
5499
5448
|
hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
|
|
5500
5449
|
}
|
|
5501
5450
|
);
|
|
5502
|
-
const hydrationPlanOptions =
|
|
5451
|
+
const hydrationPlanOptions = _chunkAS2VPMEEcjs.getFarmClientHydrationPlanOptions.call(void 0,
|
|
5503
5452
|
config.renderer,
|
|
5504
5453
|
Boolean(unsupportedIntegrationProvider)
|
|
5505
5454
|
);
|
|
@@ -5513,7 +5462,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5513
5462
|
hydrationPlanOptions
|
|
5514
5463
|
)
|
|
5515
5464
|
}));
|
|
5516
|
-
const markdownPagePlan =
|
|
5465
|
+
const markdownPagePlan = _chunkAS2VPMEEcjs.createMarkdownPageHydrationPlanner.call(void 0,
|
|
5517
5466
|
_chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, config.mdx), config.root),
|
|
5518
5467
|
config.root,
|
|
5519
5468
|
isolatedHydrationMode,
|
|
@@ -5522,7 +5471,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5522
5471
|
const pageHydrationPlans = new Map(
|
|
5523
5472
|
pageRoutes.map((route) => [
|
|
5524
5473
|
route.modulePath,
|
|
5525
|
-
|
|
5474
|
+
_chunkEKN7NSZOcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
5526
5475
|
route.modulePath,
|
|
5527
5476
|
config.root,
|
|
5528
5477
|
isolatedHydrationMode,
|
|
@@ -5531,7 +5480,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5531
5480
|
)
|
|
5532
5481
|
])
|
|
5533
5482
|
);
|
|
5534
|
-
|
|
5483
|
+
_chunkAS2VPMEEcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
|
|
5535
5484
|
layoutHydrationPlans.map((layout) => ({
|
|
5536
5485
|
pattern: layout.pattern,
|
|
5537
5486
|
depth: layout.pattern.split("/").filter(Boolean).length,
|
|
@@ -5540,10 +5489,10 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5540
5489
|
pageRoutes.map((route) => ({
|
|
5541
5490
|
// Compared by directory so a grouped layout applies only inside its group.
|
|
5542
5491
|
pattern: _nullishCoalesce(route.directory, () => ( route.pattern)),
|
|
5543
|
-
depth:
|
|
5492
|
+
depth: _chunkRVXFINNScjs.getRouteDirectoryDepth.call(void 0, _nullishCoalesce(route.directory, () => ( route.pattern))),
|
|
5544
5493
|
metadata: pageHydrationPlans.get(route.modulePath)
|
|
5545
5494
|
})),
|
|
5546
|
-
|
|
5495
|
+
_chunkRVXFINNScjs.routeBoundaryCoversDirectory
|
|
5547
5496
|
);
|
|
5548
5497
|
const providerServerImports = [
|
|
5549
5498
|
providerServerModules.hasClerkProvider ? `import { ClerkProvider as FarmClerkProvider } from "@clerk/react";` : "",
|
|
@@ -5560,7 +5509,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5560
5509
|
apiRegistrations.push(`
|
|
5561
5510
|
{
|
|
5562
5511
|
path: ${JSON.stringify(route.path)},
|
|
5563
|
-
methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access',
|
|
5512
|
+
methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access', _107 => _107.pluginMethods, 'optionalAccess', _108 => _108.includes, 'call', _109 => _109(method)])))},
|
|
5564
5513
|
endpoints: ${varName},
|
|
5565
5514
|
}`);
|
|
5566
5515
|
});
|
|
@@ -5573,7 +5522,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5573
5522
|
}).map(({ route }) => route);
|
|
5574
5523
|
orderedPageRoutes.forEach((route, index) => {
|
|
5575
5524
|
const varName = `pageRoute${index}`;
|
|
5576
|
-
if (
|
|
5525
|
+
if (_chunkEKN7NSZOcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) {
|
|
5577
5526
|
pageRegistrations.push(`
|
|
5578
5527
|
{
|
|
5579
5528
|
pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
|
|
@@ -5603,8 +5552,9 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5603
5552
|
pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
|
|
5604
5553
|
directory: ${JSON.stringify(route.directory)},` : ""}
|
|
5605
5554
|
module: ${varName},
|
|
5606
|
-
shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)}
|
|
5607
|
-
|
|
5555
|
+
shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)},${clientMetadata.shouldHydrate ? `
|
|
5556
|
+
clientModule: ${JSON.stringify(_chunk5QIKR7RRcjs.toViteModuleId.call(void 0, route.modulePath, config.root))},` : ""}
|
|
5557
|
+
islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${_chunkAS2VPMEEcjs.usesFarmServerTree.call(void 0, clientMetadata) ? "\n serverTree: true," : ""}${renderingDirective ? `
|
|
5608
5558
|
rendering: ${JSON.stringify(renderingDirective)},` : ""}
|
|
5609
5559
|
${route.source !== void 0 ? `markdownSource: {
|
|
5610
5560
|
source: ${JSON.stringify(route.source)},
|
|
@@ -5661,12 +5611,12 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5661
5611
|
errorImports.push(
|
|
5662
5612
|
`import * as ${varName} from ${toVirtualEntryImportSpecifier(errorRoute.modulePath)};`
|
|
5663
5613
|
);
|
|
5664
|
-
const groupScope =
|
|
5614
|
+
const groupScope = _chunkRVXFINNScjs.getRouteGroupScope.call(void 0, errorRoute.pattern);
|
|
5665
5615
|
errorRegistrations.push(`
|
|
5666
5616
|
{
|
|
5667
|
-
pattern: ${JSON.stringify(
|
|
5617
|
+
pattern: ${JSON.stringify(_chunkRVXFINNScjs.stripRouteGroups.call(void 0, errorRoute.pattern))},${groupScope ? `
|
|
5668
5618
|
groupScope: ${JSON.stringify(groupScope)},
|
|
5669
|
-
directoryDepth: ${
|
|
5619
|
+
directoryDepth: ${_chunkRVXFINNScjs.getRouteDirectoryDepth.call(void 0, errorRoute.pattern)},` : ""}
|
|
5670
5620
|
module: ${varName},
|
|
5671
5621
|
}`);
|
|
5672
5622
|
});
|
|
@@ -5724,7 +5674,9 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5724
5674
|
const productionRuntimeImport = `import {
|
|
5725
5675
|
_getRequestReadCount,
|
|
5726
5676
|
_runWithAfterRequest,
|
|
5677
|
+
_resolveCurrentCspNonce,
|
|
5727
5678
|
_runWithCurrentRequest,
|
|
5679
|
+
_runWithFarmCspNonce,
|
|
5728
5680
|
_runWithAPIRequestRuntime,
|
|
5729
5681
|
_runWithMiddlewareContext,
|
|
5730
5682
|
_runWithMiddlewareData,
|
|
@@ -5734,6 +5686,8 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5734
5686
|
appendFarmRedirectQuery,
|
|
5735
5687
|
applyFarmBasePath,
|
|
5736
5688
|
applyFarmCspNonceToResponse,
|
|
5689
|
+
createFarmCspNonce,
|
|
5690
|
+
stampFarmCspNonce,
|
|
5737
5691
|
applyFarmPreviewRobotsTag,
|
|
5738
5692
|
applyFarmThemeDocument,
|
|
5739
5693
|
appendFarmLinkHeader,
|
|
@@ -5755,6 +5709,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5755
5709
|
createFarmAiCatalogResponse,
|
|
5756
5710
|
createFarmApiCatalogResponse,
|
|
5757
5711
|
createFarmAppManifestResponse,
|
|
5712
|
+
farmPathGuardCoversEndpoint,
|
|
5758
5713
|
collectFarmLlmsTxtPages,
|
|
5759
5714
|
createFarmDefaultLlmsTxt,
|
|
5760
5715
|
createFarmLlmsMarkdownReader,
|
|
@@ -5812,25 +5767,25 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5812
5767
|
const infraAnalyticsImport = hasInfraAnalyticsRuntime ? `import { ${hasPluginRuntime ? "createFarmInfraAnalyticsPlugin" : "createFarmInfraAnalyticsRecorder"} } from "@farm.js/core/internal/infra-analytics-runtime";` : "";
|
|
5813
5768
|
const compressionRuntimeImport = hasCompressionRuntime ? `import { compressFarmResponse${hasPluginRuntime ? ", createCompressionPlugin" : ""} } from "@farm.js/core/internal/compression-runtime";` : "";
|
|
5814
5769
|
const i18nServerImport = config.i18n.enabled ? `import { _runWithFarmI18nRequest, _setDefaultFarmI18nRuntime, createFarmI18nRuntime, getFarmI18nClientSnapshot } from "@farm.js/core/i18n/server";` : "";
|
|
5815
|
-
const docsHandlerImport = _optionalChain([config, 'access',
|
|
5770
|
+
const docsHandlerImport = _optionalChain([config, 'access', _110 => _110.docs, 'optionalAccess', _111 => _111.enabled]) ? hasPrecompiledDocs ? `import { createFarmDocsPrecompiledRuntime } from "@farm.js/core/internal/docs-precompiled-runtime";
|
|
5816
5771
|
const isFarmDocsAPIRequest = (requestOrPathname) => {
|
|
5817
5772
|
const pathname = typeof requestOrPathname === "string"
|
|
5818
5773
|
? requestOrPathname
|
|
5819
5774
|
: new URL(requestOrPathname.url).pathname;
|
|
5820
|
-
const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess',
|
|
5775
|
+
const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _112 => _112.apiPath]) || "/api/docs")};
|
|
5821
5776
|
return pathname === apiPath || pathname.startsWith(apiPath + "/");
|
|
5822
5777
|
};` : adapterOwnsDocsRuntime ? `import { isFarmDocsAPIRequest } from "@farm.js/core/docs";
|
|
5823
5778
|
import { createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler } from ${JSON.stringify(config.docs.adapter.server)};
|
|
5824
5779
|
import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
|
|
5825
5780
|
import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
|
|
5826
|
-
const docsFontImport = _optionalChain([config, 'access',
|
|
5827
|
-
const docsRuntimeImport = _optionalChain([config, 'access',
|
|
5781
|
+
const docsFontImport = _optionalChain([config, 'access', _113 => _113.docs, 'optionalAccess', _114 => _114.enabled]) && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
|
|
5782
|
+
const docsRuntimeImport = _optionalChain([config, 'access', _115 => _115.docs, 'optionalAccess', _116 => _116.enabled]) && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
|
|
5828
5783
|
import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
|
|
5829
5784
|
import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
5830
|
-
const markdownHandlerImport = _optionalChain([config, 'access',
|
|
5785
|
+
const markdownHandlerImport = _optionalChain([config, 'access', _117 => _117.md, 'optionalAccess', _118 => _118.enabled]) ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
5831
5786
|
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;";
|
|
5832
|
-
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5833
|
-
const mdxComponentsPath = typeof _optionalChain([config, 'access',
|
|
5787
|
+
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5788
|
+
const mdxComponentsPath = typeof _optionalChain([config, 'access', _119 => _119.mdx, 'optionalAccess', _120 => _120.components]) === "string" ? _path2.default.isAbsolute(config.mdx.components) ? config.mdx.components : _path2.default.join(config.root, config.mdx.components) : null;
|
|
5834
5789
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
5835
5790
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
5836
5791
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -5848,7 +5803,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
5848
5803
|
const integrationRuntimeImport = integrationRuntimeExports.length ? `import { ${integrationRuntimeExports.join(", ")} } from "@farm.js/core/integrations";` : "";
|
|
5849
5804
|
const instrumentationImport = instrumentationPath ? `import * as FarmInstrumentationModule from ${toVirtualEntryImportSpecifier(instrumentationPath)};` : "";
|
|
5850
5805
|
const nativeAuth = generateNativeAuthIntegrationSource(config.auth);
|
|
5851
|
-
const nativeMCP =
|
|
5806
|
+
const nativeMCP = _chunk5ULKUBIAcjs.generateNativeMCPPluginSource.call(void 0, config.mcp);
|
|
5852
5807
|
const integrationImports = `
|
|
5853
5808
|
${configModulePath ? `import * as FarmUserConfigModule from ${toVirtualEntryImportSpecifier(configModulePath)};` : ""}
|
|
5854
5809
|
${layerConfigImports}
|
|
@@ -6035,7 +5990,7 @@ const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
|
|
|
6035
5990
|
|
|
6036
5991
|
function FarmDefault404Page() {
|
|
6037
5992
|
return React.createElement(React.Fragment, null,
|
|
6038
|
-
React.createElement("style", null, ${JSON.stringify(
|
|
5993
|
+
React.createElement("style", null, ${JSON.stringify(_chunkAS2VPMEEcjs.DEFAULT_NOT_FOUND_STYLES)}),
|
|
6039
5994
|
React.createElement("main", {
|
|
6040
5995
|
className: "farm-default-not-found",
|
|
6041
5996
|
"aria-labelledby": "farm-default-not-found-title",
|
|
@@ -6128,7 +6083,7 @@ const serverRuntimeIntegrations = Object.fromEntries(
|
|
|
6128
6083
|
);
|
|
6129
6084
|
const integrationRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs, {
|
|
6130
6085
|
integrations: configuredIntegrations,
|
|
6131
|
-
${JSON.stringify(
|
|
6086
|
+
${JSON.stringify(_chunkBWIQR4DHcjs.FARM_INTEGRATION_API_BASE_PATH_KEY)}: ${JSON.stringify(_chunkKNBBQHO2cjs.resolveFarmAPIServerBasePath.call(void 0, config.api))},
|
|
6132
6087
|
});
|
|
6133
6088
|
const farmInfraAnalytics = ${hasInfraAnalyticsRuntime ? hasPluginRuntime ? "createFarmInfraAnalyticsPlugin()" : "createFarmInfraAnalyticsRecorder()" : "null"};
|
|
6134
6089
|
const configuredPlugins = [
|
|
@@ -6164,14 +6119,14 @@ const farmImageHandler = ${imageRuntime === "none" ? "null" : imageRuntime === "
|
|
|
6164
6119
|
onError(error) { console.error("[Farm Image]", error); },
|
|
6165
6120
|
})`};
|
|
6166
6121
|
const farmMarkdownConfig = ${JSON.stringify(config.md)};
|
|
6167
|
-
const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access',
|
|
6168
|
-
${_optionalChain([config, 'access',
|
|
6122
|
+
const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _121 => _121.agent, 'optionalAccess', _122 => _122.llmsTxt]), () => ( { enabled: false, include: [], exclude: [] })))};
|
|
6123
|
+
${_optionalChain([config, 'access', _123 => _123.agent, 'optionalAccess', _124 => _124.llmsTxt, 'optionalAccess', _125 => _125.enabled]) ? "const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });\n" : ""}${servesAgentRobotsTxt ? `const farmAgentCrawlers = ${JSON.stringify(config.agent.crawlers)};` : ""}
|
|
6169
6124
|
const farmMdxConfig = ${JSON.stringify({
|
|
6170
6125
|
...config.mdx,
|
|
6171
|
-
components: typeof _optionalChain([config, 'access',
|
|
6126
|
+
components: typeof _optionalChain([config, 'access', _126 => _126.mdx, 'optionalAccess', _127 => _127.components]) === "string" ? config.mdx.components : void 0
|
|
6172
6127
|
})};
|
|
6173
6128
|
const configuredFarmMdxComponents = farmUserConfig?.mdx?.components;
|
|
6174
|
-
${_optionalChain([config, 'access',
|
|
6129
|
+
${_optionalChain([config, 'access', _128 => _128.agent, 'optionalAccess', _129 => _129.noindexPreviews]) ? `// agent.noindexPreviews: the runtime environment decides, falling back to the
|
|
6175
6130
|
// environment this was built in, since Netlify exposes its deploy context only
|
|
6176
6131
|
// to the build.
|
|
6177
6132
|
const farmNoindexPreview = resolveFarmPreviewDeployment(
|
|
@@ -6219,7 +6174,7 @@ export const farmProductionLifecycle = createFarmProductionLifecycle({
|
|
|
6219
6174
|
});
|
|
6220
6175
|
const farmI18nRuntime = ${config.i18n.enabled ? `createFarmI18nRuntime(farmI18nConfig, ${JSON.stringify(i18nCatalogs)})` : "null"};
|
|
6221
6176
|
${config.i18n.enabled ? "_setDefaultFarmI18nRuntime(farmI18nRuntime);" : ""}
|
|
6222
|
-
const farmDocsBundledContentDir = ${_optionalChain([config, 'access',
|
|
6177
|
+
const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _130 => _130.docs, 'optionalAccess', _131 => _131.enabled]) && !hasPrecompiledDocs ? `(() => {
|
|
6223
6178
|
try {
|
|
6224
6179
|
const currentDir = farmDocsDirname(farmDocsFileURLToPath(import.meta.url));
|
|
6225
6180
|
const candidates = [
|
|
@@ -6234,13 +6189,42 @@ const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _124 => _1
|
|
|
6234
6189
|
})()` : "null"};
|
|
6235
6190
|
const farmDocsResolvedConfig = ${generateFarmDocsRuntimeConfigExpression(config.docs, hasPrecompiledDocs)};
|
|
6236
6191
|
const farmDocsRuntimeRoot = ${hasPrecompiledDocs ? '"."' : `farmDocsBundledContentDir || ${JSON.stringify(config.root)}`};
|
|
6192
|
+
// Docs pages a path-specific guard covers, decided at build time. The docs API and the
|
|
6193
|
+
// root llms/sitemap files answer anyone, so they leave these pages out.
|
|
6194
|
+
const farmDocsGuardedPaths = ${JSON.stringify(
|
|
6195
|
+
hasPrecompiledDocs ? [] : getFarmDocsGuardedPaths(config, middlewareRoutes)
|
|
6196
|
+
)};
|
|
6197
|
+
const farmDocsGuardedPathSet = new Set(farmDocsGuardedPaths);
|
|
6198
|
+
const isFarmDocsPathGuarded = (pathname) => farmDocsGuardedPathSet.has(pathname);
|
|
6237
6199
|
globalThis.__FARM_DOCS_RUNTIME_CONFIG__ = {
|
|
6238
6200
|
root: farmDocsRuntimeRoot,
|
|
6239
6201
|
srcDir: ${JSON.stringify(config.srcDir)},
|
|
6240
6202
|
docs: farmDocsResolvedConfig,
|
|
6203
|
+
guardedPaths: farmDocsGuardedPaths,
|
|
6241
6204
|
};
|
|
6242
6205
|
const farmDocsPrecompiledRuntime = ${hasPrecompiledDocs ? `createFarmDocsPrecompiledRuntime(${JSON.stringify(farmDocsPrecompiledManifest)})` : "null"};
|
|
6243
|
-
|
|
6206
|
+
// Filled in from the client build once it has finished (see buildNitroUniversal).
|
|
6207
|
+
const farmDocsModulePreloads = (() => {
|
|
6208
|
+
try {
|
|
6209
|
+
return JSON.parse("${FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER}");
|
|
6210
|
+
} catch {
|
|
6211
|
+
return null;
|
|
6212
|
+
}
|
|
6213
|
+
})();
|
|
6214
|
+
// Paths the adapter matches against a page's source path the way the browser
|
|
6215
|
+
// finds the page's module.
|
|
6216
|
+
const farmDocsModulePreloadPaths = farmDocsModulePreloads
|
|
6217
|
+
? {
|
|
6218
|
+
runtime: farmDocsModulePreloads.runtime.map((index) => "/" + farmDocsModulePreloads.files[index]),
|
|
6219
|
+
pages: Object.fromEntries(
|
|
6220
|
+
Object.entries(farmDocsModulePreloads.pages).map(([sourcePath, indexes]) => [
|
|
6221
|
+
sourcePath,
|
|
6222
|
+
indexes.map((index) => "/" + farmDocsModulePreloads.files[index]),
|
|
6223
|
+
]),
|
|
6224
|
+
),
|
|
6225
|
+
}
|
|
6226
|
+
: undefined;
|
|
6227
|
+
const farmDocsHandler = ${_optionalChain([config, 'access', _132 => _132.docs, 'optionalAccess', _133 => _133.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `createFarmDocsAdapterRuntimeHandler({
|
|
6244
6228
|
${docsConfigModulePath ? "...(farmDocsConfigModule.default || farmDocsConfigModule),\n ...farmDocsResolvedConfig.configOverrides," : "...farmDocsResolvedConfig.config,"}
|
|
6245
6229
|
entry: farmDocsResolvedConfig.config?.entry || String(farmDocsResolvedConfig.entry || "/docs").replace(/^\\/+|\\/+$/g, "") || "docs",
|
|
6246
6230
|
docsPath: farmDocsResolvedConfig.entry,
|
|
@@ -6250,6 +6234,9 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _126 => _126.docs, '
|
|
|
6250
6234
|
// A production build's content cannot change, so the adapter reads its
|
|
6251
6235
|
// navigation once instead of scanning the content directory per request.
|
|
6252
6236
|
immutableContent: true,
|
|
6237
|
+
// List the chunks a page needs, so the browser fetches them alongside the
|
|
6238
|
+
// client entry instead of discovering them one import at a time.
|
|
6239
|
+
modulePreloads: farmDocsModulePreloadPaths,
|
|
6253
6240
|
clientEntry: "/__farm_client_js_src__",
|
|
6254
6241
|
// Font CSS is merged into the client stylesheet; farm-fonts.css only exists when the
|
|
6255
6242
|
// app has fonts, so linking it separately 404'd for apps without them.
|
|
@@ -6272,12 +6259,13 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _126 => _126.docs, '
|
|
|
6272
6259
|
),
|
|
6273
6260
|
fontStylesheetHref: "/farm-fonts.css",
|
|
6274
6261
|
globalStylesheetHref: "/assets/globals.css",
|
|
6262
|
+
isPathGuarded: isFarmDocsPathGuarded,
|
|
6275
6263
|
})` : "null"};
|
|
6276
|
-
const farmDocsAPIHandler = ${_optionalChain([config, 'access',
|
|
6264
|
+
const farmDocsAPIHandler = ${_optionalChain([config, 'access', _134 => _134.docs, 'optionalAccess', _135 => _135.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded })` : "null"};
|
|
6277
6265
|
|
|
6278
6266
|
// API routes bundled at build time
|
|
6279
6267
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
6280
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
6268
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path10, methods }) => ({ path: path10, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
6281
6269
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
6282
6270
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
6283
6271
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -6298,15 +6286,25 @@ function fetchFarmInnerRequest(request, context) {
|
|
|
6298
6286
|
}
|
|
6299
6287
|
const farmLocalAPIBasePath = ${JSON.stringify(_chunkKNBBQHO2cjs.resolveFarmAPIServerBasePath.call(void 0, config.api))};
|
|
6300
6288
|
const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
|
|
6301
|
-
${_optionalChain([config, 'access',
|
|
6302
|
-
` : ""}${_optionalChain([config, 'access',
|
|
6303
|
-
|
|
6289
|
+
${_optionalChain([config, 'access', _136 => _136.agent, 'optionalAccess', _137 => _137.apiCatalog]) ? `const farmApiCatalogInput = ${JSON.stringify(_chunkRVXFINNScjs.resolveFarmApiCatalogInput.call(void 0, config))};
|
|
6290
|
+
` : ""}${_optionalChain([config, 'access', _138 => _138.agent, 'optionalAccess', _139 => _139.manifest]) !== false ? `const farmAppManifestInput = ${JSON.stringify(
|
|
6291
|
+
_chunkRVXFINNScjs.resolveFarmAppManifestInput.call(void 0, config, {
|
|
6304
6292
|
build: config.deploymentId,
|
|
6305
|
-
packages:
|
|
6306
|
-
webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ?
|
|
6293
|
+
packages: _chunkAS2VPMEEcjs.resolveFarmAppPackages.call(void 0, config.root),
|
|
6294
|
+
webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? _chunkAS2VPMEEcjs.collectFarmWebMCPTools.call(void 0, config.root, config.srcDir) : []
|
|
6307
6295
|
})
|
|
6308
6296
|
)};
|
|
6309
|
-
${servesDefaultMCP ? "farmAppManifestInput.defaultMCP = getFarmDefaultMCPServer;\n" : ""}
|
|
6297
|
+
${servesDefaultMCP ? "farmAppManifestInput.defaultMCP = getFarmDefaultMCPServer;\n" : ""}// A guard written for an MCP server's path keeps its tools out of the public view.
|
|
6298
|
+
farmAppManifestInput.guardCoversPath = (path) =>
|
|
6299
|
+
farmPathGuardCoversEndpoint(
|
|
6300
|
+
{
|
|
6301
|
+
config: { middleware: farmMiddlewareConfig, integrations: serverRuntimeIntegrations },
|
|
6302
|
+
middlewareRoutes: fileMiddlewareModules,
|
|
6303
|
+
},
|
|
6304
|
+
path,
|
|
6305
|
+
farmLocalAPIBasePath,
|
|
6306
|
+
);
|
|
6307
|
+
` : ""}
|
|
6310
6308
|
function isFarmLocalAPIPathname(pathname) {
|
|
6311
6309
|
return farmLocalAPIBasePath !== "/" &&
|
|
6312
6310
|
(pathname === farmLocalAPIBasePath ||
|
|
@@ -6406,15 +6404,26 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
6406
6404
|
}
|
|
6407
6405
|
return '<script id="__farm_route_slots_data__" type="application/json">' +
|
|
6408
6406
|
serializedRouteSlots +
|
|
6409
|
-
'</script
|
|
6407
|
+
'</script>' + stampFarmCspNonce('<script>' + source + '</script>');
|
|
6410
6408
|
}
|
|
6411
6409
|
|
|
6412
6410
|
function renderFarmRendererHydrationScript() {
|
|
6413
6411
|
return typeof ReactDOMServer.generateHydrationScript === "function"
|
|
6414
|
-
? ReactDOMServer.generateHydrationScript()
|
|
6412
|
+
? stampFarmCspNonce(ReactDOMServer.generateHydrationScript())
|
|
6415
6413
|
: "";
|
|
6416
6414
|
}
|
|
6417
6415
|
|
|
6416
|
+
function renderFarmClientEntryScript() {
|
|
6417
|
+
return stampFarmCspNonce('<script type="module" src="/__farm_client_js_src__"></script>');
|
|
6418
|
+
}
|
|
6419
|
+
|
|
6420
|
+
// Renderer options for the response being rendered: its CSP nonce, which the
|
|
6421
|
+
// renderer puts on the inline scripts it emits.
|
|
6422
|
+
function getFarmRendererRenderOptions() {
|
|
6423
|
+
const nonce = _resolveCurrentCspNonce();
|
|
6424
|
+
return nonce ? { nonce } : undefined;
|
|
6425
|
+
}
|
|
6426
|
+
|
|
6418
6427
|
function escapeFarmHtmlAttribute(value) {
|
|
6419
6428
|
return String(value)
|
|
6420
6429
|
.replace(/&/g, "&")
|
|
@@ -6456,6 +6465,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6456
6465
|
if (farmRendererStreamingCapabilities.web &&
|
|
6457
6466
|
typeof ReactDOMServer.renderToReadableStream === "function") {
|
|
6458
6467
|
const stream = await ReactDOMServer.renderToReadableStream(element, {
|
|
6468
|
+
nonce: _resolveCurrentCspNonce(),
|
|
6459
6469
|
onError(error) {
|
|
6460
6470
|
// redirect()/notFound() are control flow, not render failures: the
|
|
6461
6471
|
// request handler must still receive them to map the response status,
|
|
@@ -6588,6 +6598,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6588
6598
|
},
|
|
6589
6599
|
};
|
|
6590
6600
|
pipeableStream = ReactDOMServer.renderToPipeableStream(element, {
|
|
6601
|
+
nonce: _resolveCurrentCspNonce(),
|
|
6591
6602
|
onShellReady() {
|
|
6592
6603
|
try {
|
|
6593
6604
|
pipeableStream.pipe(destination);
|
|
@@ -6650,7 +6661,10 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6650
6661
|
}
|
|
6651
6662
|
|
|
6652
6663
|
if (ReactDOMServer.renderToStringWithHead) {
|
|
6653
|
-
const rendered = await ReactDOMServer.renderToStringWithHead(
|
|
6664
|
+
const rendered = await ReactDOMServer.renderToStringWithHead(
|
|
6665
|
+
element,
|
|
6666
|
+
getFarmRendererRenderOptions(),
|
|
6667
|
+
);
|
|
6654
6668
|
return {
|
|
6655
6669
|
html: rendered.html,
|
|
6656
6670
|
head: rendered.head || "",
|
|
@@ -6658,7 +6672,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6658
6672
|
streamErrors,
|
|
6659
6673
|
};
|
|
6660
6674
|
}
|
|
6661
|
-
const html = await ReactDOMServer.renderToString(element);
|
|
6675
|
+
const html = await ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
|
|
6662
6676
|
return { html, head: "", shellHtml: html, streamErrors };
|
|
6663
6677
|
}
|
|
6664
6678
|
|
|
@@ -6697,7 +6711,7 @@ function renderFarmElementSync(ReactDOMServer, element, routeKey) {
|
|
|
6697
6711
|
if (typeof ReactDOMServer.renderToString !== "function") return undefined;
|
|
6698
6712
|
let html;
|
|
6699
6713
|
try {
|
|
6700
|
-
html = ReactDOMServer.renderToString(element);
|
|
6714
|
+
html = ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
|
|
6701
6715
|
} catch {
|
|
6702
6716
|
html = undefined;
|
|
6703
6717
|
}
|
|
@@ -6712,6 +6726,8 @@ function renderFarmElementSync(ReactDOMServer, element, routeKey) {
|
|
|
6712
6726
|
function createFarmDocumentStream(contentStream, prefix, suffix, onComplete) {
|
|
6713
6727
|
const encoder = new TextEncoder();
|
|
6714
6728
|
const reader = contentStream.getReader();
|
|
6729
|
+
// The suffix renders after the handler returned, outside its async scope.
|
|
6730
|
+
const cspNonce = _resolveCurrentCspNonce();
|
|
6715
6731
|
return new ReadableStream({
|
|
6716
6732
|
start(controller) {
|
|
6717
6733
|
controller.enqueue(encoder.encode(prefix));
|
|
@@ -6720,7 +6736,9 @@ function createFarmDocumentStream(contentStream, prefix, suffix, onComplete) {
|
|
|
6720
6736
|
try {
|
|
6721
6737
|
const result = await reader.read();
|
|
6722
6738
|
if (result.done) {
|
|
6723
|
-
const tail = typeof suffix === "function"
|
|
6739
|
+
const tail = typeof suffix === "function"
|
|
6740
|
+
? await _runWithFarmCspNonce(cspNonce, suffix)
|
|
6741
|
+
: suffix;
|
|
6724
6742
|
controller.enqueue(encoder.encode(tail));
|
|
6725
6743
|
if (onComplete) onComplete();
|
|
6726
6744
|
controller.close();
|
|
@@ -6748,7 +6766,7 @@ function peelFarmDocumentPrefix(markup) {
|
|
|
6748
6766
|
let inner = markup.replace(/^\\s+/, "");
|
|
6749
6767
|
let hoisted = "";
|
|
6750
6768
|
const wrapper = /^<div\\b[^>]*style=["']display\\s*:\\s*contents["'][^>]*>/i;
|
|
6751
|
-
const hoistable = /${
|
|
6769
|
+
const hoistable = /${_chunkRVXFINNScjs.HOISTED_HEAD_ELEMENT.source}/i;
|
|
6752
6770
|
let match;
|
|
6753
6771
|
while ((match = wrapper.exec(inner) || hoistable.exec(inner))) {
|
|
6754
6772
|
if (!/^<div/i.test(match[0])) hoisted += match[0];
|
|
@@ -6842,18 +6860,18 @@ function createFarmErrorDocument(html, title) {
|
|
|
6842
6860
|
' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
|
|
6843
6861
|
' <link rel="icon" href="data:,">\\n' +
|
|
6844
6862
|
' <title>' + escapedTitle + '</title>\\n' +
|
|
6845
|
-
' <link rel="stylesheet" href="/__farm_client_css_href__"
|
|
6863
|
+
' <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(html) + '\\n' +
|
|
6846
6864
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
6847
6865
|
'</head>\\n<body>\\n' +
|
|
6848
6866
|
' <div id="root">' + html + '</div>\\n' +
|
|
6849
6867
|
' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
6850
|
-
'
|
|
6868
|
+
' ' + renderFarmClientEntryScript() + '\\n' +
|
|
6851
6869
|
'</body>\\n</html>';
|
|
6852
6870
|
}
|
|
6853
6871
|
|
|
6854
6872
|
let fullHtml = ensureFarmDocumentRoot(ensureFarmDocumentHead(fullDocument));
|
|
6855
6873
|
fullHtml = fullHtml
|
|
6856
|
-
.replace(/<head([^>]*)>/i, '<head
|
|
6874
|
+
.replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(fullDocument); })
|
|
6857
6875
|
// Function replacements: dynamic markup may contain $-sequences ($&, $', $$)
|
|
6858
6876
|
// that a string replacement would expand, corrupting the document.
|
|
6859
6877
|
.replace(/<\\/head>/i, function() { return renderFarmRendererHydrationScript() + '\\n</head>'; })
|
|
@@ -6866,7 +6884,7 @@ function createFarmErrorDocument(html, title) {
|
|
|
6866
6884
|
/<\\/body>/i,
|
|
6867
6885
|
function() {
|
|
6868
6886
|
return ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
6869
|
-
'
|
|
6887
|
+
' ' + renderFarmClientEntryScript() + '\\n</body>';
|
|
6870
6888
|
},
|
|
6871
6889
|
);
|
|
6872
6890
|
return fullHtml.trim().startsWith("<!DOCTYPE")
|
|
@@ -6874,6 +6892,53 @@ function createFarmErrorDocument(html, title) {
|
|
|
6874
6892
|
: "<!DOCTYPE html>\\n" + fullHtml;
|
|
6875
6893
|
}
|
|
6876
6894
|
|
|
6895
|
+
// The client modules a page needs before it hydrates, filled in from the client
|
|
6896
|
+
// build once it has finished (see buildNitroUniversal).
|
|
6897
|
+
const farmClientModulePreloads = (() => {
|
|
6898
|
+
try {
|
|
6899
|
+
return JSON.parse("${FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER}");
|
|
6900
|
+
} catch {
|
|
6901
|
+
return null;
|
|
6902
|
+
}
|
|
6903
|
+
})();
|
|
6904
|
+
const farmClientEntryPreloadTags = farmClientModulePreloads
|
|
6905
|
+
? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
|
|
6906
|
+
: "";
|
|
6907
|
+
// The client modules a document's markup loads: its islands' boundaries and the
|
|
6908
|
+
// client references of its server tree.
|
|
6909
|
+
const FARM_CLIENT_MODULE_REFERENCE_PATTERN = /data-farm-client-boundary="([^"]+)"|"r":"(\\/[^"]+)"/g;
|
|
6910
|
+
|
|
6911
|
+
function renderFarmClientModulePreload(index) {
|
|
6912
|
+
return '\\n <link rel="modulepreload" href="/' +
|
|
6913
|
+
escapeFarmHtmlAttribute(farmClientModulePreloads.files[index]) +
|
|
6914
|
+
'" fetchpriority="low">';
|
|
6915
|
+
}
|
|
6916
|
+
|
|
6917
|
+
// The modulepreload links for a document: the entry's static imports, then the
|
|
6918
|
+
// modules its hydrating page and its markup load.
|
|
6919
|
+
function renderFarmClientModulePreloads(markup, pageModule) {
|
|
6920
|
+
// A nonce policy blocks parser-inserted links without the nonce, and the
|
|
6921
|
+
// response filter manages nonces on script elements only, so CSP nonce mode
|
|
6922
|
+
// keeps the documents it had.
|
|
6923
|
+
if (!farmClientModulePreloads || (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce)) return "";
|
|
6924
|
+
const modules = farmClientModulePreloads.modules;
|
|
6925
|
+
const listed = new Set();
|
|
6926
|
+
let tags = farmClientEntryPreloadTags;
|
|
6927
|
+
const add = (moduleId) => {
|
|
6928
|
+
if (!moduleId || !Object.prototype.hasOwnProperty.call(modules, moduleId)) return;
|
|
6929
|
+
for (const index of modules[moduleId]) {
|
|
6930
|
+
if (listed.has(index)) continue;
|
|
6931
|
+
listed.add(index);
|
|
6932
|
+
tags += renderFarmClientModulePreload(index);
|
|
6933
|
+
}
|
|
6934
|
+
};
|
|
6935
|
+
add(pageModule);
|
|
6936
|
+
if (typeof markup === "string") {
|
|
6937
|
+
for (const match of markup.matchAll(FARM_CLIENT_MODULE_REFERENCE_PATTERN)) add(match[1] || match[2]);
|
|
6938
|
+
}
|
|
6939
|
+
return tags;
|
|
6940
|
+
}
|
|
6941
|
+
|
|
6877
6942
|
// The origin hreflang alternates resolve against when the route sets no
|
|
6878
6943
|
// metadataBase. Forwarded authority counts only under server.trustProxy, the
|
|
6879
6944
|
// same rule the development server applies.
|
|
@@ -6906,7 +6971,7 @@ function applyFarmI18nDocument(html, requestPath, snapshot, request, metadata) {
|
|
|
6906
6971
|
});
|
|
6907
6972
|
const runtimeMarkup =
|
|
6908
6973
|
renderFarmI18nAlternateLinks(requestPath, snapshot, request, metadata) +
|
|
6909
|
-
'<script>window.__FARM_I18N__ = ' + serializeFarmInlineValue(snapshot) + ';</script>';
|
|
6974
|
+
stampFarmCspNonce('<script>window.__FARM_I18N__ = ' + serializeFarmInlineValue(snapshot) + ';</script>');
|
|
6910
6975
|
nextHtml = nextHtml.replace(/<head([^>]*)>/i, function(_match, attributes) {
|
|
6911
6976
|
// Function replacement: runtimeMarkup may contain $-sequences ($&, $', $$).
|
|
6912
6977
|
return '<head' + attributes + '>' + runtimeMarkup;
|
|
@@ -6976,6 +7041,26 @@ function hasPrivateFarmRequestHeaders(request, farmLocaleResolution) {
|
|
|
6976
7041
|
);
|
|
6977
7042
|
}
|
|
6978
7043
|
|
|
7044
|
+
// A docs response a guard let this visitor read is theirs, as for pages: one for a
|
|
7045
|
+
// request with credentials, or with middleware request data, never fills a shared cache.
|
|
7046
|
+
// Middleware headers cannot do this, since they never replace a response's own.
|
|
7047
|
+
function withFarmDocsRequestCache(response, request, farmLocaleResolution, middlewareData, middlewareContext) {
|
|
7048
|
+
if (
|
|
7049
|
+
!hasPrivateFarmRequestHeaders(request, farmLocaleResolution) &&
|
|
7050
|
+
!middlewareData?.size &&
|
|
7051
|
+
!middlewareContext?.size
|
|
7052
|
+
) {
|
|
7053
|
+
return response;
|
|
7054
|
+
}
|
|
7055
|
+
const headers = new Headers(response.headers);
|
|
7056
|
+
headers.set("Cache-Control", "private, no-store");
|
|
7057
|
+
return farmOwnedResponse(response.body, {
|
|
7058
|
+
status: response.status,
|
|
7059
|
+
statusText: response.statusText,
|
|
7060
|
+
headers,
|
|
7061
|
+
});
|
|
7062
|
+
}
|
|
7063
|
+
|
|
6979
7064
|
${generateRuntimePathMatcherSource()}
|
|
6980
7065
|
|
|
6981
7066
|
function getMatchingErrorBoundary(pathname) {
|
|
@@ -7206,6 +7291,27 @@ function createFarmAgentRobotsResponse(request) {
|
|
|
7206
7291
|
);
|
|
7207
7292
|
}
|
|
7208
7293
|
` : ""}
|
|
7294
|
+
// Static pages a path-specific guard covers (non-root middleware.ts, a config or
|
|
7295
|
+
// integration middleware matcher naming the path), decided at build time.
|
|
7296
|
+
// sitemap.xml, llms.txt and the default MCP server never list them, nor a page behind
|
|
7297
|
+
// a route guard.
|
|
7298
|
+
const farmAgentGuardedPages = new Set(${JSON.stringify(
|
|
7299
|
+
pageRoutes.map((route) => route.pattern).filter(
|
|
7300
|
+
(pattern) => !pattern.includes("[") && _chunkRVXFINNScjs.farmPathGuardCoversPage.call(void 0,
|
|
7301
|
+
{
|
|
7302
|
+
config: { middleware: config.middleware, integrations: config.integrations },
|
|
7303
|
+
middlewareRoutes
|
|
7304
|
+
},
|
|
7305
|
+
pattern
|
|
7306
|
+
)
|
|
7307
|
+
)
|
|
7308
|
+
)});
|
|
7309
|
+
function getFarmAgentListedPageRoutes() {
|
|
7310
|
+
return pageRoutes.filter(
|
|
7311
|
+
(route) =>
|
|
7312
|
+
!farmAgentGuardedPages.has(route.pattern) && !(route.module && route.module.__farmRouteGuard),
|
|
7313
|
+
);
|
|
7314
|
+
}
|
|
7209
7315
|
${servesAgentSitemap ? `// sitemap.xml from agent.sitemap, built the same way as in development. Each page's
|
|
7210
7316
|
// lastmod is its file's modification time, read at build time.
|
|
7211
7317
|
const farmAgentSitemapConfig = ${JSON.stringify(config.agent.sitemap)};
|
|
@@ -7215,7 +7321,7 @@ function createFarmAgentSitemapResponse(request) {
|
|
|
7215
7321
|
return createFarmMetadataRouteResponse(
|
|
7216
7322
|
"sitemap",
|
|
7217
7323
|
createFarmDefaultSitemap(
|
|
7218
|
-
|
|
7324
|
+
getFarmAgentListedPageRoutes().map((route) => ({
|
|
7219
7325
|
pattern: route.pattern,
|
|
7220
7326
|
module: route.module,
|
|
7221
7327
|
lastModified: farmAgentSitemapLastModified[route.pattern],
|
|
@@ -7238,12 +7344,12 @@ ${servesDefaultMCP ? `// agent.mcp: the default read-only MCP server at /mcp, as
|
|
|
7238
7344
|
// aside for a page route that answers /mcp and for any MCP server published or
|
|
7239
7345
|
// registered at runtime, such as the docs engine's.
|
|
7240
7346
|
const farmDefaultMCPServer = ${JSON.stringify(
|
|
7241
|
-
|
|
7347
|
+
_chunkH5CLOUZScjs.createFarmDefaultMCPServer.call(void 0, readFarmAppPackageIdentity(config.root), _chunkQUCXCDE2cjs.FARM_VERSION)
|
|
7242
7348
|
)};
|
|
7243
7349
|
let farmDefaultMCPRouteFree;
|
|
7244
7350
|
function getFarmDefaultMCPServer() {
|
|
7245
7351
|
if (farmDefaultMCPRouteFree === undefined) {
|
|
7246
|
-
farmDefaultMCPRouteFree = !matchPageRoute(${JSON.stringify(
|
|
7352
|
+
farmDefaultMCPRouteFree = !matchPageRoute(${JSON.stringify(_chunkH5CLOUZScjs.FARM_DEFAULT_MCP_PATH)});
|
|
7247
7353
|
}
|
|
7248
7354
|
return farmDefaultMCPRouteFree ? resolveFarmDefaultMCPServer(farmDefaultMCPServer) : undefined;
|
|
7249
7355
|
}
|
|
@@ -7254,7 +7360,7 @@ async function handleFarmDefaultMCP(request) {
|
|
|
7254
7360
|
basePath: ${JSON.stringify(config.basePath)},
|
|
7255
7361
|
listPages: () =>
|
|
7256
7362
|
collectFarmDefaultMCPPages(
|
|
7257
|
-
|
|
7363
|
+
getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, module: route.module })),
|
|
7258
7364
|
{ origin, basePath: ${JSON.stringify(config.basePath)}, markdown: farmMarkdownConfig },
|
|
7259
7365
|
),
|
|
7260
7366
|
// A fresh request through this handler, so the caller's cookies never shape a page.
|
|
@@ -7274,7 +7380,7 @@ const farmDefaultMCPReadMarkdown = createFarmLlmsMarkdownReader((page) => fetch(
|
|
|
7274
7380
|
function createFarmLlmsTxtContext(request, full) {
|
|
7275
7381
|
const origin = new URL(request.url).origin;
|
|
7276
7382
|
const pages = collectFarmLlmsTxtPages(
|
|
7277
|
-
|
|
7383
|
+
getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, metadata: route.module && route.module.metadata })),
|
|
7278
7384
|
{
|
|
7279
7385
|
origin,
|
|
7280
7386
|
markdown: farmMarkdownConfig,
|
|
@@ -7538,7 +7644,7 @@ function hasLocalRequestRoute(request, routePathname) {
|
|
|
7538
7644
|
if (${imageRuntime === "none" ? "false" : `pathname === ${JSON.stringify(config.images.path)}`}) {
|
|
7539
7645
|
return true;
|
|
7540
7646
|
}
|
|
7541
|
-
${_optionalChain([config, 'access',
|
|
7647
|
+
${_optionalChain([config, 'access', _140 => _140.docs, 'optionalAccess', _141 => _141.enabled]) ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
|
|
7542
7648
|
if (
|
|
7543
7649
|
isFarmDocsAPIRequest(pathname) ||
|
|
7544
7650
|
docsPath === "/" ||
|
|
@@ -7564,7 +7670,7 @@ function getFarmPluginRequestOptions(request) {
|
|
|
7564
7670
|
route: { ...route, pattern: normalizeRuntimePath(farmOpenAPIReference.route) },
|
|
7565
7671
|
};
|
|
7566
7672
|
}
|
|
7567
|
-
const isDocsAPIRequest = ${_optionalChain([config, 'access',
|
|
7673
|
+
const isDocsAPIRequest = ${_optionalChain([config, 'access', _142 => _142.docs, 'optionalAccess', _143 => _143.enabled]) ? "isFarmDocsAPIRequest(pathname)" : "false"};
|
|
7568
7674
|
const integrationMatch = ${hasServerRuntimeIntegrations ? `matchIntegrationRoute(serverRuntimeIntegrations, {
|
|
7569
7675
|
pathname,
|
|
7570
7676
|
method: request.method,
|
|
@@ -7661,7 +7767,7 @@ function getApplicableLayouts(pathname, directory) {
|
|
|
7661
7767
|
return applicable;
|
|
7662
7768
|
}
|
|
7663
7769
|
|
|
7664
|
-
${_optionalChain([config, 'access',
|
|
7770
|
+
${_optionalChain([config, 'access', _144 => _144.docs, 'optionalAccess', _145 => _145.enabled]) ? `async function wrapFarmDocsResponseWithLayouts(request, response) {
|
|
7665
7771
|
if (request.method === "HEAD") return response;
|
|
7666
7772
|
if (response.headers.get("x-farm-docs-adapter")) return response;
|
|
7667
7773
|
|
|
@@ -7751,7 +7857,7 @@ ${_optionalChain([config, 'access', _138 => _138.docs, 'optionalAccess', _139 =>
|
|
|
7751
7857
|
if (!html.includes('src="/__farm_client_js_src__"')) {
|
|
7752
7858
|
html = html.replace(
|
|
7753
7859
|
/<[/]body>/i,
|
|
7754
|
-
'
|
|
7860
|
+
function() { return ' ' + renderFarmClientEntryScript() + '\\n</body>'; },
|
|
7755
7861
|
);
|
|
7756
7862
|
}
|
|
7757
7863
|
if (!html.includes('window._$HY')) {
|
|
@@ -7768,7 +7874,7 @@ ${_optionalChain([config, 'access', _138 => _138.docs, 'optionalAccess', _139 =>
|
|
|
7768
7874
|
}` : ""}
|
|
7769
7875
|
|
|
7770
7876
|
const pprShellCache = getFarmDataCache();
|
|
7771
|
-
const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access',
|
|
7877
|
+
const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access', _146 => _146.experimental, 'optionalAccess', _147 => _147.ppr]) === true)};
|
|
7772
7878
|
|
|
7773
7879
|
function resolveRouteRenderingView(route) {
|
|
7774
7880
|
// The same merge development uses: baked directive config under the
|
|
@@ -7788,6 +7894,9 @@ function resolvePPRConfig(route) {
|
|
|
7788
7894
|
}
|
|
7789
7895
|
|
|
7790
7896
|
function getPPRShellBypassReason(request, middlewareData, middlewareContext) {
|
|
7897
|
+
// A shared shell would carry one response's nonce to every visitor, where
|
|
7898
|
+
// the nonce filter strips it and Farm's scripts stop running.
|
|
7899
|
+
if (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce) return "csp-nonce";
|
|
7791
7900
|
const method = request.method.toUpperCase();
|
|
7792
7901
|
if (method !== "GET" && method !== "HEAD") return "method";
|
|
7793
7902
|
if (request.headers.get("cookie")) return "cookie";
|
|
@@ -7897,7 +8006,7 @@ async function handleFarmRequest(request, adapterContext) {
|
|
|
7897
8006
|
},
|
|
7898
8007
|
{ redirect: !isFarmLocalAPIPathname(requestUrl.pathname) }
|
|
7899
8008
|
)` : "handleFarmRequestInContext(request, null, false, Date.now(), adapterContext, requestUrl)"};
|
|
7900
|
-
${_optionalChain([config, 'access',
|
|
8009
|
+
${_optionalChain([config, 'access', _148 => _148.md, 'optionalAccess', _149 => _149.enabled]) ? `const pathname = getFarmRoutePathname(requestUrl.pathname);
|
|
7901
8010
|
if (matchPageRoute(pathname)) {
|
|
7902
8011
|
// The Link header advertises the public .md URL, like the head alternate.
|
|
7903
8012
|
return applyMarkdownNegotiationHeaders(response, {
|
|
@@ -8053,7 +8162,7 @@ async function handleFarmRequestInContext(
|
|
|
8053
8162
|
}
|
|
8054
8163
|
` : ""}
|
|
8055
8164
|
|
|
8056
|
-
${_optionalChain([config, 'access',
|
|
8165
|
+
${_optionalChain([config, 'access', _150 => _150.docs, 'optionalAccess', _151 => _151.enabled]) ? `
|
|
8057
8166
|
// Docs responses are served after app middleware so route guards and
|
|
8058
8167
|
// middleware headers apply to the docs engine like any other page content.
|
|
8059
8168
|
// An app's own llms.txt, llms-full.txt, sitemap.xml, and robots.txt take
|
|
@@ -8065,11 +8174,17 @@ async function handleFarmRequestInContext(
|
|
|
8065
8174
|
const docsResponse = await farmDocsHandler(cloneFarmRequestWithContext(request));
|
|
8066
8175
|
if (docsResponse) {
|
|
8067
8176
|
if (!docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html")) {
|
|
8068
|
-
return applyProductionMiddlewareHeaders(
|
|
8177
|
+
return applyProductionMiddlewareHeaders(
|
|
8178
|
+
withFarmDocsRequestCache(docsResponse, request, farmLocaleResolution, middlewareData, middlewareContext),
|
|
8179
|
+
middlewareHeaders,
|
|
8180
|
+
);
|
|
8069
8181
|
}
|
|
8070
|
-
const wrappedDocsResponse =
|
|
8182
|
+
const wrappedDocsResponse = withFarmDocsRequestCache(
|
|
8183
|
+
await wrapFarmDocsResponseWithLayouts(request, docsResponse),
|
|
8071
8184
|
request,
|
|
8072
|
-
|
|
8185
|
+
farmLocaleResolution,
|
|
8186
|
+
middlewareData,
|
|
8187
|
+
middlewareContext,
|
|
8073
8188
|
);
|
|
8074
8189
|
const docsHeaders = new Headers(wrappedDocsResponse.headers);
|
|
8075
8190
|
docsHeaders.set("x-farm-preload-buffered", "1");
|
|
@@ -8108,7 +8223,7 @@ async function handleFarmRequestInContext(
|
|
|
8108
8223
|
}
|
|
8109
8224
|
` : ""}
|
|
8110
8225
|
|
|
8111
|
-
${_optionalChain([config, 'access',
|
|
8226
|
+
${_optionalChain([config, 'access', _152 => _152.md, 'optionalAccess', _153 => _153.enabled]) ? `
|
|
8112
8227
|
if (farmMarkdownConfig?.enabled) {
|
|
8113
8228
|
const markdownResponse = await createMarkdownMirrorResponse({
|
|
8114
8229
|
// The mirror helper only reads metadata and creates its own GET request.
|
|
@@ -8170,7 +8285,7 @@ async function handleFarmRequestInContext(
|
|
|
8170
8285
|
) {
|
|
8171
8286
|
const method = request.method.toUpperCase();
|
|
8172
8287
|
const response = method === "GET" || method === "HEAD"
|
|
8173
|
-
? farmOwnedResponse(method === "HEAD" ? null : farmOpenAPIReference.html, {
|
|
8288
|
+
? farmOwnedResponse(method === "HEAD" ? null : stampFarmCspNonce(farmOpenAPIReference.html), {
|
|
8174
8289
|
status: 200,
|
|
8175
8290
|
headers: {
|
|
8176
8291
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -8207,11 +8322,11 @@ async function handleFarmRequestInContext(
|
|
|
8207
8322
|
return applyProductionMiddlewareHeaders(applicationMetadataResponse, middlewareHeaders);
|
|
8208
8323
|
}
|
|
8209
8324
|
` : ""}
|
|
8210
|
-
${_optionalChain([config, 'access',
|
|
8325
|
+
${_optionalChain([config, 'access', _154 => _154.agent, 'optionalAccess', _155 => _155.manifest]) !== false ? `
|
|
8211
8326
|
// agent.manifest: /.well-known/farmjs.json (and 0.1.34's /.well-known/farmjs), the app's
|
|
8212
8327
|
// public manifest; Farm Infra's signed request gets the full view.
|
|
8213
8328
|
if (
|
|
8214
|
-
[${JSON.stringify(
|
|
8329
|
+
[${JSON.stringify(_chunkRVXFINNScjs.FARM_APP_MANIFEST_PATH)}, ${JSON.stringify(_chunkRVXFINNScjs.FARM_APP_MANIFEST_LEGACY_PATH)}].includes(
|
|
8215
8330
|
normalizeRuntimePath(routePathname),
|
|
8216
8331
|
)
|
|
8217
8332
|
) {
|
|
@@ -8221,9 +8336,9 @@ async function handleFarmRequestInContext(
|
|
|
8221
8336
|
);
|
|
8222
8337
|
}
|
|
8223
8338
|
` : ""}
|
|
8224
|
-
${_optionalChain([config, 'access',
|
|
8339
|
+
${_optionalChain([config, 'access', _156 => _156.agent, 'optionalAccess', _157 => _157.apiCatalog]) ? `
|
|
8225
8340
|
// agent.apiCatalog: list the OpenAPI and MCP surfaces at the RFC 9727 path.
|
|
8226
|
-
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(
|
|
8341
|
+
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkRVXFINNScjs.FARM_API_CATALOG_PATH)}) {
|
|
8227
8342
|
return applyProductionMiddlewareHeaders(
|
|
8228
8343
|
createFarmApiCatalogResponse(request.method, farmApiCatalogInput, request),
|
|
8229
8344
|
middlewareHeaders,
|
|
@@ -8248,11 +8363,11 @@ async function handleFarmRequestInContext(
|
|
|
8248
8363
|
);
|
|
8249
8364
|
}
|
|
8250
8365
|
` : ""}
|
|
8251
|
-
${_optionalChain([config, 'access',
|
|
8366
|
+
${_optionalChain([config, 'access', _158 => _158.agent, 'optionalAccess', _159 => _159.llmsTxt, 'optionalAccess', _160 => _160.enabled]) ? `
|
|
8252
8367
|
// agent.llmsTxt with no llms.ts or llms-full.ts: serve the generated files.
|
|
8253
8368
|
const farmGeneratedLlmsKind = normalizeRuntimePath(routePathname) === "/llms.txt"
|
|
8254
8369
|
? "llms"
|
|
8255
|
-
: ${_optionalChain([config, 'access',
|
|
8370
|
+
: ${_optionalChain([config, 'access', _161 => _161.agent, 'optionalAccess', _162 => _162.llmsTxt, 'optionalAccess', _163 => _163.full]) ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
|
|
8256
8371
|
if (farmGeneratedLlmsKind) {
|
|
8257
8372
|
const llmsContext = createFarmLlmsTxtContext(request, farmGeneratedLlmsKind === "llms-full");
|
|
8258
8373
|
const llmsOrigin = new URL(request.url).origin;
|
|
@@ -8287,10 +8402,13 @@ async function handleFarmRequestInContext(
|
|
|
8287
8402
|
}
|
|
8288
8403
|
` : ""}
|
|
8289
8404
|
|
|
8290
|
-
${_optionalChain([config, 'access',
|
|
8405
|
+
${_optionalChain([config, 'access', _164 => _164.docs, 'optionalAccess', _165 => _165.enabled]) ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
|
|
8291
8406
|
const docsAPIResponse = await farmDocsAPIHandler(cloneFarmRequestWithContext(request));
|
|
8292
8407
|
if (docsAPIResponse) {
|
|
8293
|
-
return applyProductionMiddlewareHeaders(
|
|
8408
|
+
return applyProductionMiddlewareHeaders(
|
|
8409
|
+
withFarmDocsRequestCache(docsAPIResponse, request, farmLocaleResolution, middlewareData, middlewareContext),
|
|
8410
|
+
middlewareHeaders,
|
|
8411
|
+
);
|
|
8294
8412
|
}
|
|
8295
8413
|
}` : ""}
|
|
8296
8414
|
|
|
@@ -8745,7 +8863,7 @@ async function handleFarmRequestInContext(
|
|
|
8745
8863
|
);
|
|
8746
8864
|
}
|
|
8747
8865
|
}
|
|
8748
|
-
${_optionalChain([config, 'access',
|
|
8866
|
+
${_optionalChain([config, 'access', _166 => _166.md, 'optionalAccess', _167 => _167.enabled]) ? `
|
|
8749
8867
|
// Advertise the Markdown mirror in the head as well as the Link header,
|
|
8750
8868
|
// using the public path the .md request will be resolved against.
|
|
8751
8869
|
mergedMetadata = addMetadataMarkdownAlternate(
|
|
@@ -8764,7 +8882,7 @@ async function handleFarmRequestInContext(
|
|
|
8764
8882
|
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "request-read" });
|
|
8765
8883
|
}
|
|
8766
8884
|
|
|
8767
|
-
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access',
|
|
8885
|
+
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _168 => _168.agent, 'optionalAccess', _169 => _169.jsonLd]), () => ( false)))} });
|
|
8768
8886
|
const title = renderedMetadata.title;
|
|
8769
8887
|
const metaTags = renderedMetadata.tags;
|
|
8770
8888
|
const hasFavicon = renderedMetadata.hasFavicon;
|
|
@@ -8804,13 +8922,16 @@ async function handleFarmRequestInContext(
|
|
|
8804
8922
|
|
|
8805
8923
|
// Stream a suspended body as soon as React's shell is ready. Full-document
|
|
8806
8924
|
// layouts, localized documents, and cacheable PPR shells still use the
|
|
8807
|
-
// buffered path because they require whole-document transformation
|
|
8925
|
+
// buffered path because they require whole-document transformation, and so
|
|
8926
|
+
// does the anonymous check behind a page's Markdown source: there, a
|
|
8927
|
+
// redirect() under a loading boundary must still decide the status.
|
|
8808
8928
|
if (
|
|
8809
8929
|
pageStatus === 200 &&
|
|
8810
8930
|
renderedPage.stream &&
|
|
8811
8931
|
!hasFullDocument &&
|
|
8812
8932
|
!farmI18nSnapshot &&
|
|
8813
|
-
!pprCacheKey
|
|
8933
|
+
!pprCacheKey &&
|
|
8934
|
+
!_isFarmMarkdownPageCheck(request.headers.get(FARM_MARKDOWN_PAGE_CHECK_HEADER))
|
|
8814
8935
|
) {
|
|
8815
8936
|
const farmThemeDocument = createFarmThemeDocumentParts(
|
|
8816
8937
|
farmThemeConfig,
|
|
@@ -8824,7 +8945,7 @@ async function handleFarmRequestInContext(
|
|
|
8824
8945
|
(hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
|
|
8825
8946
|
' <title>' + title + '</title>' + metaTags + '\\n' +
|
|
8826
8947
|
' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
|
|
8827
|
-
' <link rel="modulepreload" href="/__farm_client_js_src__"
|
|
8948
|
+
' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
|
|
8828
8949
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
8829
8950
|
'</head>\\n<body>\\n <div id="root">';
|
|
8830
8951
|
const streamSuffix = '</div>\\n' +
|
|
@@ -8833,7 +8954,7 @@ async function handleFarmRequestInContext(
|
|
|
8833
8954
|
routeSlotPayload,
|
|
8834
8955
|
clientPageProps
|
|
8835
8956
|
) + '\\n' +
|
|
8836
|
-
'
|
|
8957
|
+
' ' + renderFarmClientEntryScript() + '\\n' +
|
|
8837
8958
|
'</body>\\n</html>';
|
|
8838
8959
|
const themedStreamPrefix = streamPrefix.replace(
|
|
8839
8960
|
'<html lang="en">',
|
|
@@ -8857,7 +8978,8 @@ async function handleFarmRequestInContext(
|
|
|
8857
8978
|
try {
|
|
8858
8979
|
return createLateNotFoundRecovery(
|
|
8859
8980
|
await ReactDOMServer.renderToString(
|
|
8860
|
-
wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname))
|
|
8981
|
+
wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname)),
|
|
8982
|
+
getFarmRendererRenderOptions()
|
|
8861
8983
|
)
|
|
8862
8984
|
) + streamSuffix;
|
|
8863
8985
|
} catch (error) {
|
|
@@ -8865,7 +8987,10 @@ async function handleFarmRequestInContext(
|
|
|
8865
8987
|
// needs their context cannot render alone, so use Farm's.
|
|
8866
8988
|
console.warn("not-found page could not render outside its layout, using Farm's:", error);
|
|
8867
8989
|
return createLateNotFoundRecovery(
|
|
8868
|
-
await ReactDOMServer.renderToString(
|
|
8990
|
+
await ReactDOMServer.renderToString(
|
|
8991
|
+
React.createElement(FarmDefault404Page),
|
|
8992
|
+
getFarmRendererRenderOptions()
|
|
8993
|
+
)
|
|
8869
8994
|
) + streamSuffix;
|
|
8870
8995
|
}
|
|
8871
8996
|
},
|
|
@@ -8914,7 +9039,7 @@ async function handleFarmRequestInContext(
|
|
|
8914
9039
|
);
|
|
8915
9040
|
fullHtml = html
|
|
8916
9041
|
// Inject CSS link after opening head tag or first meta tag
|
|
8917
|
-
.replace(/<head([^>]*)>/i, '<head
|
|
9042
|
+
.replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(html, route.clientModule); })
|
|
8918
9043
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
8919
9044
|
// Explicit metadata wins over renderer and layout titles. Without
|
|
8920
9045
|
// explicit metadata, a renderer title wins over the layout title.
|
|
@@ -8948,7 +9073,7 @@ async function handleFarmRequestInContext(
|
|
|
8948
9073
|
routeSlotPayload,
|
|
8949
9074
|
clientPageProps
|
|
8950
9075
|
) + '\\n' +
|
|
8951
|
-
'
|
|
9076
|
+
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
8952
9077
|
);
|
|
8953
9078
|
|
|
8954
9079
|
// Last, so the charset (and the viewport, unless the layout wrote one) open the head.
|
|
@@ -8967,13 +9092,13 @@ async function handleFarmRequestInContext(
|
|
|
8967
9092
|
\${viewportTags}
|
|
8968
9093
|
\${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
|
|
8969
9094
|
\${suppressDefaultTitle ? "" : "<title>" + title + "</title>"}\${metaTags}\${rendererHead ? "\\n " + rendererHead : ""}
|
|
8970
|
-
<link rel="stylesheet" href="/__farm_client_css_href__"
|
|
9095
|
+
<link rel="stylesheet" href="/__farm_client_css_href__">\${renderFarmClientModulePreloads(html, route.clientModule)}
|
|
8971
9096
|
\${renderFarmRendererHydrationScript()}
|
|
8972
9097
|
</head>
|
|
8973
9098
|
<body>
|
|
8974
9099
|
<div id="root">\${html}</div>
|
|
8975
9100
|
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, routeSlotPayload, clientPageProps)}
|
|
8976
|
-
|
|
9101
|
+
\${renderFarmClientEntryScript()}
|
|
8977
9102
|
</body>
|
|
8978
9103
|
</html>\`;
|
|
8979
9104
|
}
|
|
@@ -9145,14 +9270,14 @@ async function handleFarmRequestInContext(
|
|
|
9145
9270
|
}
|
|
9146
9271
|
}
|
|
9147
9272
|
|
|
9148
|
-
const fallbackHtml = createDefaultErrorMarkup({
|
|
9273
|
+
const fallbackHtml = stampFarmCspNonce(createDefaultErrorMarkup({
|
|
9149
9274
|
statusCode: errorStatus,
|
|
9150
9275
|
statusText: errorStatusText,
|
|
9151
9276
|
requestPath: pathname,
|
|
9152
9277
|
method: request.method,
|
|
9153
9278
|
development: false,
|
|
9154
9279
|
mode: "production",
|
|
9155
|
-
});
|
|
9280
|
+
}));
|
|
9156
9281
|
const fallbackDocument = applyFarmThemeDocument(
|
|
9157
9282
|
applyFarmI18nDocument(
|
|
9158
9283
|
createFarmErrorDocument(
|
|
@@ -9184,7 +9309,7 @@ async function handleFarmRequestInContext(
|
|
|
9184
9309
|
${servesDefaultMCP ? `
|
|
9185
9310
|
// agent.mcp: no app route answered /mcp, so the default read-only server may.
|
|
9186
9311
|
if (
|
|
9187
|
-
normalizeRuntimePath(routePathname) === ${JSON.stringify(
|
|
9312
|
+
normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkH5CLOUZScjs.FARM_DEFAULT_MCP_PATH)} &&
|
|
9188
9313
|
getFarmDefaultMCPServer()
|
|
9189
9314
|
) {
|
|
9190
9315
|
return applyProductionMiddlewareHeaders(
|
|
@@ -9239,7 +9364,7 @@ ${servesDefaultMCP ? `
|
|
|
9239
9364
|
}
|
|
9240
9365
|
notFoundElement = wrapWithFarmIntegrationProviders(notFoundElement);
|
|
9241
9366
|
|
|
9242
|
-
const html = await ReactDOMServer.renderToString(notFoundElement);
|
|
9367
|
+
const html = await ReactDOMServer.renderToString(notFoundElement, getFarmRendererRenderOptions());
|
|
9243
9368
|
// The layouts' and the not-found page's metadata, as the development renderer uses it.
|
|
9244
9369
|
const notFoundMetadata = renderMetadataHead(
|
|
9245
9370
|
await resolveFarmNotFoundMetadata(
|
|
@@ -9264,12 +9389,12 @@ ${servesDefaultMCP ? `
|
|
|
9264
9389
|
"<head" + attrs + ">" +
|
|
9265
9390
|
headContent.replace(/<title\\b[^>]*>[\\s\\S]*?<\\/title>\\s*/gi, "") +
|
|
9266
9391
|
"\\n <title>" + notFoundMetadata.title + "</title>" + notFoundMetadata.tags + "\\n</head>")
|
|
9267
|
-
.replace(/<head([^>]*)>/i, '<head
|
|
9392
|
+
.replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(fullDocument); })
|
|
9268
9393
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
9269
9394
|
.replace(
|
|
9270
9395
|
/<\\/body>/i,
|
|
9271
9396
|
() => ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
9272
|
-
'
|
|
9397
|
+
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
9273
9398
|
);
|
|
9274
9399
|
fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
|
|
9275
9400
|
if (!fullHtml.trim().startsWith('<!DOCTYPE')) {
|
|
@@ -9282,14 +9407,14 @@ ${servesDefaultMCP ? `
|
|
|
9282
9407
|
<meta charset="UTF-8">
|
|
9283
9408
|
\${notFoundMetadata.viewport}
|
|
9284
9409
|
\${notFoundMetadata.hasFavicon ? "" : '<link rel="icon" href="data:,">'}
|
|
9285
|
-
<link rel="stylesheet" href="/__farm_client_css_href__"
|
|
9410
|
+
<link rel="stylesheet" href="/__farm_client_css_href__">\${renderFarmClientModulePreloads(html)}
|
|
9286
9411
|
<title>\${notFoundMetadata.title}</title>\${notFoundMetadata.tags}
|
|
9287
9412
|
\${renderFarmRendererHydrationScript()}
|
|
9288
9413
|
</head>
|
|
9289
9414
|
<body>
|
|
9290
9415
|
<div id="root">\${html}</div>
|
|
9291
9416
|
\${renderFarmClientBootstrapScript()}
|
|
9292
|
-
|
|
9417
|
+
\${renderFarmClientEntryScript()}
|
|
9293
9418
|
</body>
|
|
9294
9419
|
</html>\`;
|
|
9295
9420
|
}
|
|
@@ -9398,11 +9523,11 @@ ${generatePreloadResponseRuntimeSource()}
|
|
|
9398
9523
|
|
|
9399
9524
|
// Export as Web Standard fetch API
|
|
9400
9525
|
export async function fetch(request, context) {
|
|
9401
|
-
${_optionalChain([config, 'access',
|
|
9526
|
+
${_optionalChain([config, 'access', _170 => _170.agent, 'optionalAccess', _171 => _171.noindexPreviews]) ? "const response = await" : "return"} _runWithAPIRequestRuntime({
|
|
9402
9527
|
basePath: farmLocalAPIBasePath,
|
|
9403
9528
|
dispatch: async (localRequest) =>
|
|
9404
9529
|
(await handleAPIRequest(localRequest)) ?? Response.json({ error: "Not Found" }, { status: 404 }),
|
|
9405
|
-
}, () => handleFarmFetch(request, context));${_optionalChain([config, 'access',
|
|
9530
|
+
}, () => handleFarmFetch(request, context));${_optionalChain([config, 'access', _172 => _172.agent, 'optionalAccess', _173 => _173.noindexPreviews]) ? `
|
|
9406
9531
|
// Keep every response of a preview deployment out of search indexes.
|
|
9407
9532
|
return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
|
|
9408
9533
|
}
|
|
@@ -9423,6 +9548,9 @@ async function handleFarmFetch(request, context) {
|
|
|
9423
9548
|
() =>
|
|
9424
9549
|
runWithFarmRequestSpan(request, async () => {
|
|
9425
9550
|
const runtimeOptions = farmPluginRuntime ? getFarmPluginRequestOptions(request) : null;
|
|
9551
|
+
// Created before rendering so only scripts Farm, the renderer, or the
|
|
9552
|
+
// app (through getCspNonce()) give it carry the response nonce.
|
|
9553
|
+
const cspNonce = createFarmCspNonce(farmSecurityConfig);
|
|
9426
9554
|
const prepareResponse = async (runtimeRequest, responsePromise) => {
|
|
9427
9555
|
const response = await responsePromise;
|
|
9428
9556
|
// Headers need the path eagerly; preload reporting needs it only for
|
|
@@ -9434,6 +9562,7 @@ async function handleFarmFetch(request, context) {
|
|
|
9434
9562
|
applyFarmCspNonceToResponse(
|
|
9435
9563
|
applyConfiguredResponseHeaders(response, routePathname),
|
|
9436
9564
|
farmSecurityConfig,
|
|
9565
|
+
cspNonce,
|
|
9437
9566
|
),
|
|
9438
9567
|
routePathname,
|
|
9439
9568
|
runtimeRequest,
|
|
@@ -9466,7 +9595,7 @@ async function handleFarmFetch(request, context) {
|
|
|
9466
9595
|
: ` : ""}prepareResponse(request, handleFarmRequest(request, context));
|
|
9467
9596
|
|
|
9468
9597
|
const response = await _runWithCurrentRequest(request, () =>
|
|
9469
|
-
_runWithAfterRequest(request, runRequest, context),
|
|
9598
|
+
_runWithFarmCspNonce(cspNonce, () => _runWithAfterRequest(request, runRequest, context)),
|
|
9470
9599
|
);
|
|
9471
9600
|
return ${hasCompressionRuntime && !hasPluginRuntime ? "compressFarmResponse(request, response, getFarmOwnedBufferedHtml(response), farmLazyBufferedHtml.has(response))" : "response"};
|
|
9472
9601
|
}),
|
|
@@ -9541,26 +9670,6 @@ function middlewarePatternMatches(pattern, pathname) {
|
|
|
9541
9670
|
return new RegExp(`^${expression}/?$`).test(pathname);
|
|
9542
9671
|
}
|
|
9543
9672
|
_chunkS3JO3N4Hcjs.__name.call(void 0, middlewarePatternMatches, "middlewarePatternMatches");
|
|
9544
|
-
function configMiddlewareMayHandlePath(config, pathname) {
|
|
9545
|
-
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
9546
|
-
const entries = Array.isArray(config) ? config : [config];
|
|
9547
|
-
return entries.some((entry) => {
|
|
9548
|
-
if (!entry.matcher && !entry.exclude) return true;
|
|
9549
|
-
const matchers = entry.matcher ? (Array.isArray(entry.matcher) ? entry.matcher : [entry.matcher]).map(
|
|
9550
|
-
(matcher) => (
|
|
9551
|
-
// A request-aware matcher cannot be proven safe at build time.
|
|
9552
|
-
typeof matcher === "function" ? () => true : matcher
|
|
9553
|
-
)
|
|
9554
|
-
) : void 0;
|
|
9555
|
-
const compiled = _chunk4GWRFP22cjs.compileMiddlewareConfig.call(void 0, { matcher: matchers, exclude: entry.exclude });
|
|
9556
|
-
return _chunk4GWRFP22cjs.matchesCompiledMiddlewareConfig.call(void 0, pathname, compiled, {}).matched;
|
|
9557
|
-
});
|
|
9558
|
-
}
|
|
9559
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0, configMiddlewareMayHandlePath, "configMiddlewareMayHandlePath");
|
|
9560
|
-
function appMiddlewareMayHandlePath(middlewareRoutes, pathname) {
|
|
9561
|
-
return middlewareRoutes.some((route) => _chunk4GWRFP22cjs.matchesMiddlewareRoute.call(void 0, pathname, route).matched);
|
|
9562
|
-
}
|
|
9563
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0, appMiddlewareMayHandlePath, "appMiddlewareMayHandlePath");
|
|
9564
9673
|
function routePatternSpecificity(pattern) {
|
|
9565
9674
|
return pattern.split("/").filter(Boolean).reduce((score, segment) => {
|
|
9566
9675
|
if (segment === "**" || segment.startsWith("[[...")) return score + 1;
|
|
@@ -9596,13 +9705,13 @@ function getPhysicalPrerenderBypassReason(options) {
|
|
|
9596
9705
|
if (rewriteSources.some((source) => middlewarePatternMatches(source, pathname))) {
|
|
9597
9706
|
return "rewrite";
|
|
9598
9707
|
}
|
|
9599
|
-
if (appMiddlewareMayHandlePath(middlewareRoutes, pathname)) return "app middleware";
|
|
9600
|
-
if (configMiddlewareMayHandlePath(config.middleware, pathname)) return "configured middleware";
|
|
9601
|
-
if (
|
|
9708
|
+
if (_chunkRVXFINNScjs.appMiddlewareMayHandlePath.call(void 0, middlewareRoutes, pathname)) return "app middleware";
|
|
9709
|
+
if (_chunkRVXFINNScjs.configMiddlewareMayHandlePath.call(void 0, config.middleware, pathname)) return "configured middleware";
|
|
9710
|
+
if (_chunkHRETEZ2Zcjs.hasCustomFarmRouteContext.call(void 0, config)) return "request context";
|
|
9602
9711
|
if (farmServerRuntimePluginsMayHandlePath(config, pathname)) return "server runtime plugin";
|
|
9603
9712
|
const manifestEntry = getManifestPageEntry(routeRuntimeManifest, pathname);
|
|
9604
|
-
if (_optionalChain([manifestEntry, 'optionalAccess',
|
|
9605
|
-
if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access',
|
|
9713
|
+
if (_optionalChain([manifestEntry, 'optionalAccess', _174 => _174.rendering]) === "dynamic") return "dynamic runtime manifest";
|
|
9714
|
+
if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access', _175 => _175.regions, 'optionalAccess', _176 => _176.length])) || manifestEntry.maxDuration !== void 0)) {
|
|
9606
9715
|
return "route runtime controls";
|
|
9607
9716
|
}
|
|
9608
9717
|
const routeRule = getEffectiveRouteRule(config, pathname);
|
|
@@ -9616,7 +9725,7 @@ function getPhysicalPrerenderBypassReason(options) {
|
|
|
9616
9725
|
}
|
|
9617
9726
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getPhysicalPrerenderBypassReason, "getPhysicalPrerenderBypassReason");
|
|
9618
9727
|
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
|
|
9619
|
-
const [
|
|
9728
|
+
const [fs3, nitroBuilderResult] = await Promise.all([
|
|
9620
9729
|
import("fs/promises"),
|
|
9621
9730
|
nitroBuilderResultPromise
|
|
9622
9731
|
]);
|
|
@@ -9624,7 +9733,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9624
9733
|
const nitroBuilder = nitroBuilderResult.value;
|
|
9625
9734
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
9626
9735
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
9627
|
-
const outputDir =
|
|
9736
|
+
const outputDir = _chunkHRETEZ2Zcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
|
|
9628
9737
|
const runtimeServerOutputDir = isVercel ? _path2.default.join(outputDir, "functions", "__nitro.func") : _path2.default.join(outputDir, "server");
|
|
9629
9738
|
const ssrOutputDir = _path2.default.join(root, distDir, "ssr");
|
|
9630
9739
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
@@ -9695,12 +9804,22 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9695
9804
|
}
|
|
9696
9805
|
const scheduledTasks = _chunk6EXBPJ24cjs.mergeScheduledTasks.call(void 0, farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
|
|
9697
9806
|
const cloudflareCronConfig = _chunk6EXBPJ24cjs.createFarmCronCloudflareConfig.call(void 0, farmCron.jobs);
|
|
9698
|
-
const [clientCssHref, clientJsSrc] = await Promise.all([
|
|
9807
|
+
const [clientCssHref, clientJsSrc, docsModulePreloads, clientModulePreloads] = await Promise.all([
|
|
9699
9808
|
resolveHashedClientCssHref(clientOutputDir),
|
|
9700
|
-
resolveHashedClientJsSrc(clientOutputDir)
|
|
9809
|
+
resolveHashedClientJsSrc(clientOutputDir),
|
|
9810
|
+
readFarmDocsModulePreloads(_path2.default.join(root, distDir)),
|
|
9811
|
+
readFarmClientModulePreloads(_path2.default.join(root, distDir))
|
|
9701
9812
|
]);
|
|
9813
|
+
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
9814
|
+
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
9702
9815
|
for (const output of Object.values(ssrBundle)) {
|
|
9703
9816
|
if (output.type !== "chunk") continue;
|
|
9817
|
+
if (output.code.includes(FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
9818
|
+
output.code = output.code.split(FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER).join(encodedDocsModulePreloads);
|
|
9819
|
+
}
|
|
9820
|
+
if (output.code.includes(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
9821
|
+
output.code = output.code.split(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER).join(encodedClientModulePreloads);
|
|
9822
|
+
}
|
|
9704
9823
|
if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
|
|
9705
9824
|
output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
|
|
9706
9825
|
}
|
|
@@ -9708,11 +9827,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9708
9827
|
output.code = output.code.split(FARM_CLIENT_JS_SRC_PLACEHOLDER).join(clientJsSrc);
|
|
9709
9828
|
}
|
|
9710
9829
|
}
|
|
9711
|
-
await
|
|
9830
|
+
await fs3.mkdir(ssrOutputDir, { recursive: true });
|
|
9712
9831
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
9713
9832
|
const filePath = _path2.default.join(ssrOutputDir, fileName);
|
|
9714
|
-
await
|
|
9715
|
-
await
|
|
9833
|
+
await fs3.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
9834
|
+
await fs3.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
9716
9835
|
}
|
|
9717
9836
|
const nitroEntryPath = _path2.default.join(ssrOutputDir, "nitro-entry.mjs");
|
|
9718
9837
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
@@ -9866,16 +9985,16 @@ function toFarmNodeResponse(request, response) {
|
|
|
9866
9985
|
})
|
|
9867
9986
|
}` : ""}
|
|
9868
9987
|
`.trim();
|
|
9869
|
-
await
|
|
9988
|
+
await fs3.writeFile(nitroEntryPath, nitroEntryCode);
|
|
9870
9989
|
const farmNodeServerEntryPath = preset === "node-server" ? _path2.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
9871
9990
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
9872
|
-
await
|
|
9873
|
-
_path2.default.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
9874
|
-
FARM_NODE_ENV_MODULE_SOURCE
|
|
9991
|
+
await fs3.writeFile(
|
|
9992
|
+
_path2.default.join(ssrOutputDir, _chunkWW46B6HAcjs.FARM_NODE_ENV_MODULE_FILE),
|
|
9993
|
+
_chunkWW46B6HAcjs.FARM_NODE_ENV_MODULE_SOURCE
|
|
9875
9994
|
);
|
|
9876
|
-
await
|
|
9995
|
+
await fs3.writeFile(
|
|
9877
9996
|
farmNodeServerEntryPath,
|
|
9878
|
-
createFarmNodeServerEntry({
|
|
9997
|
+
_chunkWW46B6HAcjs.createFarmNodeServerEntry.call(void 0, {
|
|
9879
9998
|
nitroEntryFile: _path2.default.basename(nitroEntryPath),
|
|
9880
9999
|
nodeAdapterModule,
|
|
9881
10000
|
server: config.server,
|
|
@@ -9885,7 +10004,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9885
10004
|
}
|
|
9886
10005
|
const farmNetlifyEntryPath = preset === "netlify" ? _path2.default.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
9887
10006
|
if (farmNetlifyEntryPath) {
|
|
9888
|
-
await
|
|
10007
|
+
await fs3.writeFile(
|
|
9889
10008
|
farmNetlifyEntryPath,
|
|
9890
10009
|
createFarmNetlifyEntry({
|
|
9891
10010
|
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
@@ -10014,20 +10133,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
10014
10133
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
10015
10134
|
);
|
|
10016
10135
|
const requestedBuilder = _nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER));
|
|
10017
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access',
|
|
10018
|
-
_optionalChain([nitroConfig, 'access',
|
|
10019
|
-
(handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess',
|
|
10136
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access', _177 => _177.rollupConfig, 'optionalAccess', _178 => _178.external]) === nitroRollupExternal && !hasRollupPlugins(_optionalChain([nitroConfig, 'access', _179 => _179.rollupConfig, 'optionalAccess', _180 => _180.plugins])) && customRollupKeys.length === 0 && _path2.default.resolve(_optionalChain([nitroConfig, 'access', _181 => _181.output, 'optionalAccess', _182 => _182.serverDir]) || "") === _path2.default.resolve(expectedServerDir) && Boolean(
|
|
10137
|
+
_optionalChain([nitroConfig, 'access', _183 => _183.handlers, 'optionalAccess', _184 => _184.some, 'call', _185 => _185(
|
|
10138
|
+
(handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess', _186 => _186.handler]) || "") === nitroEntryPath
|
|
10020
10139
|
)])
|
|
10021
10140
|
);
|
|
10022
10141
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
10023
10142
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
10024
10143
|
const useRolldownBuilder = canReusePrebuiltSSR && (_nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER))) === "rolldown";
|
|
10025
10144
|
const shouldMinify = nitroConfig.minify !== false;
|
|
10026
|
-
const keepServerNames = !(_optionalChain([config, 'access',
|
|
10145
|
+
const keepServerNames = !(_optionalChain([config, 'access', _187 => _187.docs, 'optionalAccess', _188 => _188.enabled]) && _optionalChain([config, 'access', _189 => _189.docs, 'access', _190 => _190.adapter, 'optionalAccess', _191 => _191.server]));
|
|
10027
10146
|
const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
|
|
10028
10147
|
const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
|
|
10029
10148
|
if (canReusePrebuiltSSR) {
|
|
10030
|
-
const configuredRollupPlugins = _optionalChain([nitroConfig, 'access',
|
|
10149
|
+
const configuredRollupPlugins = _optionalChain([nitroConfig, 'access', _192 => _192.rollupConfig, 'optionalAccess', _193 => _193.plugins]);
|
|
10031
10150
|
nitroConfig.rollupConfig = {
|
|
10032
10151
|
...nitroConfig.rollupConfig,
|
|
10033
10152
|
plugins: [
|
|
@@ -10038,10 +10157,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
10038
10157
|
}
|
|
10039
10158
|
nitroConfig.minify = useFarmServerMinifier ? false : shouldMinify;
|
|
10040
10159
|
const nitroInstance = await nitroBuilder.createNitro(nitroConfig);
|
|
10041
|
-
if (_optionalChain([config, 'access',
|
|
10160
|
+
if (_optionalChain([config, 'access', _194 => _194.md, 'optionalAccess', _195 => _195.enabled])) {
|
|
10042
10161
|
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
10043
|
-
if (!route.contents || !_optionalChain([route, 'access',
|
|
10044
|
-
const alternatePath =
|
|
10162
|
+
if (!route.contents || !_optionalChain([route, 'access', _196 => _196.contentType, 'optionalAccess', _197 => _197.toLowerCase, 'call', _198 => _198(), 'access', _199 => _199.includes, 'call', _200 => _200("html")])) return;
|
|
10163
|
+
const alternatePath = _chunkSGBJ247Qcjs.getFarmMarkdownAlternatePath.call(void 0, config.md, route.route);
|
|
10045
10164
|
if (!alternatePath) return;
|
|
10046
10165
|
const routeRule = nitroInstance.options.routeRules[route.route] || {};
|
|
10047
10166
|
const alternate = `<${alternatePath}>; rel="alternate"; type="text/markdown"`;
|
|
@@ -10061,8 +10180,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
10061
10180
|
}
|
|
10062
10181
|
if (config.security.csp && config.security.csp.nonce) {
|
|
10063
10182
|
nitroInstance.hooks.hook("prerender:generate", async (route) => {
|
|
10064
|
-
if (!route.contents || !_optionalChain([route, 'access',
|
|
10065
|
-
const staticCsp = await
|
|
10183
|
+
if (!route.contents || !_optionalChain([route, 'access', _201 => _201.contentType, 'optionalAccess', _202 => _202.toLowerCase, 'call', _203 => _203(), 'access', _204 => _204.includes, 'call', _205 => _205("html")])) return;
|
|
10184
|
+
const staticCsp = await _chunk2ZYGC6SScjs.applyFarmCspHashesToHtml.call(void 0, route.contents, config.security);
|
|
10066
10185
|
if (!staticCsp) return;
|
|
10067
10186
|
route.contents = staticCsp.html;
|
|
10068
10187
|
const routeRule = nitroInstance.options.routeRules[route.route] || {};
|
|
@@ -10108,9 +10227,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
10108
10227
|
ssrBundle,
|
|
10109
10228
|
_path2.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
10110
10229
|
null,
|
|
10111
|
-
|
|
10230
|
+
fs3
|
|
10112
10231
|
);
|
|
10113
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
10232
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs3);
|
|
10114
10233
|
});
|
|
10115
10234
|
});
|
|
10116
10235
|
}
|
|
@@ -10132,16 +10251,16 @@ function toFarmNodeResponse(request, response) {
|
|
|
10132
10251
|
}
|
|
10133
10252
|
if (prerenderRoutes.length > 0) {
|
|
10134
10253
|
_chunk5QIKR7RRcjs.logger.info(`\u{1F4C4} Pre-rendering ${prerenderRoutes.length} SSG page(s)`);
|
|
10135
|
-
const previousPrerender = process.env[
|
|
10136
|
-
process.env[
|
|
10254
|
+
const previousPrerender = process.env[_chunkWXJLNP33cjs.FARM_PRERENDER_ENV];
|
|
10255
|
+
process.env[_chunkWXJLNP33cjs.FARM_PRERENDER_ENV] = "1";
|
|
10137
10256
|
try {
|
|
10138
10257
|
await nitroBuilder.prerender(nitroInstance);
|
|
10139
10258
|
} finally {
|
|
10140
|
-
if (previousPrerender === void 0) delete process.env[
|
|
10141
|
-
else process.env[
|
|
10259
|
+
if (previousPrerender === void 0) delete process.env[_chunkWXJLNP33cjs.FARM_PRERENDER_ENV];
|
|
10260
|
+
else process.env[_chunkWXJLNP33cjs.FARM_PRERENDER_ENV] = previousPrerender;
|
|
10142
10261
|
}
|
|
10143
10262
|
}
|
|
10144
|
-
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir,
|
|
10263
|
+
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs3, preset) : Promise.resolve(null);
|
|
10145
10264
|
const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
|
|
10146
10265
|
ssrBundle,
|
|
10147
10266
|
shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
|
|
@@ -10154,7 +10273,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10154
10273
|
await nitroInstance.close();
|
|
10155
10274
|
if (nitroBuildResult.status === "rejected") {
|
|
10156
10275
|
if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
|
|
10157
|
-
await
|
|
10276
|
+
await fs3.rm(sharpRuntimeStageResult.value.stageDir, {
|
|
10158
10277
|
recursive: true,
|
|
10159
10278
|
force: true
|
|
10160
10279
|
});
|
|
@@ -10167,20 +10286,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
10167
10286
|
if (prebuiltSSRFilesResult.status === "rejected") {
|
|
10168
10287
|
throw prebuiltSSRFilesResult.reason;
|
|
10169
10288
|
}
|
|
10170
|
-
const stagedSharpRuntime = await _asyncNullishCoalesce(sharpRuntimeStageResult.value, async () => ( (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir,
|
|
10289
|
+
const stagedSharpRuntime = await _asyncNullishCoalesce(sharpRuntimeStageResult.value, async () => ( (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs3, preset) : null)));
|
|
10171
10290
|
const runtimeCopyPromise = (async () => {
|
|
10172
10291
|
if (stagedSharpRuntime) {
|
|
10173
|
-
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir,
|
|
10292
|
+
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs3);
|
|
10174
10293
|
}
|
|
10175
10294
|
if (useExternalMetadataImageRuntime) {
|
|
10176
|
-
await copyMetadataImageRuntime(root, runtimeServerOutputDir,
|
|
10295
|
+
await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs3);
|
|
10177
10296
|
}
|
|
10178
10297
|
})();
|
|
10179
10298
|
const copyResults = await Promise.allSettled([
|
|
10180
10299
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
10181
10300
|
prebuiltSSRFilesResult.value,
|
|
10182
10301
|
_path2.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
10183
|
-
|
|
10302
|
+
fs3
|
|
10184
10303
|
) : Promise.resolve(),
|
|
10185
10304
|
runtimeCopyPromise
|
|
10186
10305
|
]);
|
|
@@ -10189,7 +10308,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10189
10308
|
);
|
|
10190
10309
|
if (failedCopy) throw failedCopy.reason;
|
|
10191
10310
|
if (canReusePrebuiltSSR) {
|
|
10192
|
-
await registerPrebuiltSSRPackageImport(_path2.default.join(outputDir, "server"), ssrEntryFile,
|
|
10311
|
+
await registerPrebuiltSSRPackageImport(_path2.default.join(outputDir, "server"), ssrEntryFile, fs3);
|
|
10193
10312
|
_chunk5QIKR7RRcjs.logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
10194
10313
|
}
|
|
10195
10314
|
if (useRolldownBuilder) {
|
|
@@ -10204,7 +10323,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10204
10323
|
});
|
|
10205
10324
|
}
|
|
10206
10325
|
if (isVercel) {
|
|
10207
|
-
await postProcessVercelOutput(root, outputDir,
|
|
10326
|
+
await postProcessVercelOutput(root, outputDir, fs3, config, farmWorkflows, routeRuntimeManifest);
|
|
10208
10327
|
}
|
|
10209
10328
|
_chunk5QIKR7RRcjs.logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
|
|
10210
10329
|
}
|
|
@@ -10232,24 +10351,24 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
|
10232
10351
|
);
|
|
10233
10352
|
}
|
|
10234
10353
|
_chunkS3JO3N4Hcjs.__name.call(void 0, prepareSSRBundleFiles, "prepareSSRBundleFiles");
|
|
10235
|
-
async function writeSSRBundleFiles(files, targetDir,
|
|
10236
|
-
await
|
|
10354
|
+
async function writeSSRBundleFiles(files, targetDir, fs3) {
|
|
10355
|
+
await fs3.rm(targetDir, { recursive: true, force: true });
|
|
10237
10356
|
await Promise.all(
|
|
10238
10357
|
files.map(async ({ fileName, contents }) => {
|
|
10239
10358
|
const targetPath = _path2.default.join(targetDir, fileName);
|
|
10240
|
-
await
|
|
10241
|
-
await
|
|
10359
|
+
await fs3.mkdir(_path2.default.dirname(targetPath), { recursive: true });
|
|
10360
|
+
await fs3.writeFile(targetPath, contents);
|
|
10242
10361
|
})
|
|
10243
10362
|
);
|
|
10244
10363
|
}
|
|
10245
10364
|
_chunkS3JO3N4Hcjs.__name.call(void 0, writeSSRBundleFiles, "writeSSRBundleFiles");
|
|
10246
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions,
|
|
10247
|
-
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir,
|
|
10365
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs3) {
|
|
10366
|
+
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs3);
|
|
10248
10367
|
}
|
|
10249
10368
|
_chunkS3JO3N4Hcjs.__name.call(void 0, copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
10250
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
10369
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs3) {
|
|
10251
10370
|
const packagePath = _path2.default.join(serverDir, "package.json");
|
|
10252
|
-
const packageJSON = await
|
|
10371
|
+
const packageJSON = await fs3.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10253
10372
|
if (error.code === "ENOENT") return { type: "module" };
|
|
10254
10373
|
throw error;
|
|
10255
10374
|
});
|
|
@@ -10259,54 +10378,54 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs) {
|
|
|
10259
10378
|
...existingImports,
|
|
10260
10379
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
10261
10380
|
};
|
|
10262
|
-
await
|
|
10263
|
-
await
|
|
10381
|
+
await fs3.mkdir(serverDir, { recursive: true });
|
|
10382
|
+
await fs3.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
10264
10383
|
`);
|
|
10265
10384
|
}
|
|
10266
10385
|
_chunkS3JO3N4Hcjs.__name.call(void 0, registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
|
|
10267
|
-
async function moveVercelOutputPath(src, dest,
|
|
10386
|
+
async function moveVercelOutputPath(src, dest, fs3) {
|
|
10268
10387
|
try {
|
|
10269
|
-
await
|
|
10388
|
+
await fs3.rename(src, dest);
|
|
10270
10389
|
return;
|
|
10271
10390
|
} catch (error) {
|
|
10272
|
-
const code = _optionalChain([error, 'optionalAccess',
|
|
10391
|
+
const code = _optionalChain([error, 'optionalAccess', _206 => _206.code]);
|
|
10273
10392
|
if (code !== "EPERM" && code !== "EACCES" && code !== "EXDEV" && code !== "ENOTEMPTY") {
|
|
10274
10393
|
throw error;
|
|
10275
10394
|
}
|
|
10276
10395
|
}
|
|
10277
|
-
await
|
|
10278
|
-
await
|
|
10396
|
+
await fs3.cp(src, dest, { recursive: true, force: true });
|
|
10397
|
+
await fs3.rm(src, { recursive: true, force: true });
|
|
10279
10398
|
}
|
|
10280
10399
|
_chunkS3JO3N4Hcjs.__name.call(void 0, moveVercelOutputPath, "moveVercelOutputPath");
|
|
10281
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
10400
|
+
async function postProcessVercelOutput(root, outputDir, fs3, config, farmWorkflows, routeRuntimeManifest) {
|
|
10282
10401
|
const serverDir = _path2.default.join(outputDir, "server");
|
|
10283
10402
|
const functionsDir = _path2.default.join(outputDir, "functions");
|
|
10284
10403
|
const nitroFuncDir = _path2.default.join(functionsDir, "__nitro.func");
|
|
10285
10404
|
const staticDir = _path2.default.join(outputDir, "static");
|
|
10286
10405
|
const publicDir = _path2.default.join(outputDir, "public");
|
|
10287
|
-
await
|
|
10288
|
-
const serverContents = await
|
|
10406
|
+
await fs3.mkdir(nitroFuncDir, { recursive: true });
|
|
10407
|
+
const serverContents = await fs3.readdir(serverDir).catch((error) => {
|
|
10289
10408
|
if (error.code === "ENOENT") return [];
|
|
10290
10409
|
throw error;
|
|
10291
10410
|
});
|
|
10292
10411
|
for (const file of serverContents) {
|
|
10293
|
-
await moveVercelOutputPath(_path2.default.join(serverDir, file), _path2.default.join(nitroFuncDir, file),
|
|
10412
|
+
await moveVercelOutputPath(_path2.default.join(serverDir, file), _path2.default.join(nitroFuncDir, file), fs3);
|
|
10294
10413
|
}
|
|
10295
|
-
if (serverContents.length > 0) await
|
|
10414
|
+
if (serverContents.length > 0) await fs3.rm(serverDir, { recursive: true, force: true });
|
|
10296
10415
|
try {
|
|
10297
|
-
await moveVercelOutputPath(publicDir, staticDir,
|
|
10416
|
+
await moveVercelOutputPath(publicDir, staticDir, fs3);
|
|
10298
10417
|
} catch (error) {
|
|
10299
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
10418
|
+
if (_optionalChain([error, 'optionalAccess', _207 => _207.code]) !== "ENOENT") throw error;
|
|
10300
10419
|
}
|
|
10301
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
10302
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
10420
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs3);
|
|
10421
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs3);
|
|
10303
10422
|
const configPath = _path2.default.join(outputDir, "config.json");
|
|
10304
|
-
const configContent = await
|
|
10423
|
+
const configContent = await fs3.readFile(configPath, "utf-8");
|
|
10305
10424
|
const vercelConfig = JSON.parse(configContent);
|
|
10306
10425
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
10307
10426
|
outputDir,
|
|
10308
10427
|
routeRuntimeManifest,
|
|
10309
|
-
|
|
10428
|
+
fs3,
|
|
10310
10429
|
config.basePath
|
|
10311
10430
|
);
|
|
10312
10431
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
@@ -10321,25 +10440,25 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
|
|
|
10321
10440
|
vercelConfigWithWorkflowCrons,
|
|
10322
10441
|
config.cron.jobs
|
|
10323
10442
|
);
|
|
10324
|
-
await
|
|
10443
|
+
await fs3.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
10325
10444
|
_chunk5QIKR7RRcjs.logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
10326
10445
|
}
|
|
10327
10446
|
_chunkS3JO3N4Hcjs.__name.call(void 0, postProcessVercelOutput, "postProcessVercelOutput");
|
|
10328
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
10447
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs3) {
|
|
10329
10448
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
10330
10449
|
if (!docsContentDir) return;
|
|
10331
10450
|
const bundledContentDir = _path2.default.join(nitroFuncDir, "farm-docs-content");
|
|
10332
|
-
const lastModifiedManifest =
|
|
10451
|
+
const lastModifiedManifest = _chunkPGZDEPTMcjs.createFarmDocsLastModifiedManifest.call(void 0, docsContentDir, {
|
|
10333
10452
|
fallback: "now"
|
|
10334
10453
|
});
|
|
10335
|
-
await
|
|
10336
|
-
await
|
|
10337
|
-
await
|
|
10454
|
+
await fs3.rm(bundledContentDir, { recursive: true, force: true });
|
|
10455
|
+
await fs3.mkdir(_path2.default.dirname(bundledContentDir), { recursive: true });
|
|
10456
|
+
await fs3.cp(docsContentDir, bundledContentDir, {
|
|
10338
10457
|
recursive: true,
|
|
10339
10458
|
force: true
|
|
10340
10459
|
});
|
|
10341
|
-
await
|
|
10342
|
-
_path2.default.join(bundledContentDir,
|
|
10460
|
+
await fs3.writeFile(
|
|
10461
|
+
_path2.default.join(bundledContentDir, _chunkPGZDEPTMcjs.FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
10343
10462
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
10344
10463
|
`
|
|
10345
10464
|
);
|
|
@@ -10362,21 +10481,21 @@ function platformFieldAllows(field, value) {
|
|
|
10362
10481
|
return allowed.length === 0 || allowed.includes(value);
|
|
10363
10482
|
}
|
|
10364
10483
|
_chunkS3JO3N4Hcjs.__name.call(void 0, platformFieldAllows, "platformFieldAllows");
|
|
10365
|
-
async function stageSharpRuntime(config, root, distDir,
|
|
10484
|
+
async function stageSharpRuntime(config, root, distDir, fs3, preset) {
|
|
10366
10485
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
10367
10486
|
const projectRequire = _module.createRequire.call(void 0, _path2.default.join(root, "package.json"));
|
|
10368
10487
|
let sharpRequire = projectRequire;
|
|
10369
10488
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
10370
10489
|
try {
|
|
10371
10490
|
sharpRequire = _module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core"));
|
|
10372
|
-
} catch (
|
|
10491
|
+
} catch (e27) {
|
|
10373
10492
|
}
|
|
10374
10493
|
}
|
|
10375
10494
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
10376
10495
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
10377
10496
|
const stageRoot = _path2.default.join(root, distDir, "tmp");
|
|
10378
|
-
await
|
|
10379
|
-
const stageDir = await
|
|
10497
|
+
await fs3.mkdir(stageRoot, { recursive: true });
|
|
10498
|
+
const stageDir = await fs3.mkdtemp(_path2.default.join(stageRoot, "sharp-runtime-"));
|
|
10380
10499
|
const targetNodeModules = _path2.default.join(stageDir, "node_modules");
|
|
10381
10500
|
function copyPackage(packageName, parentRequire) {
|
|
10382
10501
|
const activeCopy = packageCopies.get(packageName);
|
|
@@ -10389,19 +10508,19 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10389
10508
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
10390
10509
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
10391
10510
|
if (!packageJsonPath) return;
|
|
10392
|
-
const packageJson = JSON.parse(await
|
|
10511
|
+
const packageJson = JSON.parse(await fs3.readFile(packageJsonPath, "utf8"));
|
|
10393
10512
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
10394
10513
|
const packageDir = _path2.default.dirname(packageJsonPath);
|
|
10395
10514
|
const targetDir = _path2.default.join(targetNodeModules, ...packageName.split("/"));
|
|
10396
10515
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
10397
|
-
await
|
|
10516
|
+
await fs3.mkdir(_path2.default.dirname(targetDir), { recursive: true });
|
|
10398
10517
|
const packageRequire = _module.createRequire.call(void 0, packageJsonPath);
|
|
10399
10518
|
const dependencies = {
|
|
10400
10519
|
...packageJson.dependencies,
|
|
10401
10520
|
...packageJson.optionalDependencies
|
|
10402
10521
|
};
|
|
10403
10522
|
await settleAllOrThrow([
|
|
10404
|
-
|
|
10523
|
+
fs3.cp(packageDir, targetDir, {
|
|
10405
10524
|
recursive: true,
|
|
10406
10525
|
force: true,
|
|
10407
10526
|
dereference: true,
|
|
@@ -10416,10 +10535,10 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10416
10535
|
try {
|
|
10417
10536
|
await copyPackage("sharp", sharpRequire);
|
|
10418
10537
|
if (!copiedPackages.has("sharp")) {
|
|
10419
|
-
throw new Error(`Farm image optimization requires sharp. ${
|
|
10538
|
+
throw new Error(`Farm image optimization requires sharp. ${_chunkAS2VPMEEcjs.SHARP_INSTALL_HINT}`);
|
|
10420
10539
|
}
|
|
10421
10540
|
} catch (error) {
|
|
10422
|
-
await
|
|
10541
|
+
await fs3.rm(stageDir, { recursive: true, force: true });
|
|
10423
10542
|
throw error;
|
|
10424
10543
|
}
|
|
10425
10544
|
return {
|
|
@@ -10430,19 +10549,19 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10430
10549
|
};
|
|
10431
10550
|
}
|
|
10432
10551
|
_chunkS3JO3N4Hcjs.__name.call(void 0, stageSharpRuntime, "stageSharpRuntime");
|
|
10433
|
-
async function installStagedSharpRuntime(staged, nitroFuncDir,
|
|
10552
|
+
async function installStagedSharpRuntime(staged, nitroFuncDir, fs3) {
|
|
10434
10553
|
const stagedNodeModules = _path2.default.join(staged.stageDir, "node_modules");
|
|
10435
10554
|
const targetNodeModules = _path2.default.join(nitroFuncDir, "node_modules");
|
|
10436
10555
|
try {
|
|
10437
|
-
await mergeStagedDirectory(stagedNodeModules, targetNodeModules,
|
|
10438
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
10556
|
+
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs3);
|
|
10557
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs3);
|
|
10439
10558
|
functionPackage.dependencies = {
|
|
10440
10559
|
...functionPackage.dependencies,
|
|
10441
10560
|
...staged.dependencies
|
|
10442
10561
|
};
|
|
10443
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10562
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs3);
|
|
10444
10563
|
} finally {
|
|
10445
|
-
await
|
|
10564
|
+
await fs3.rm(staged.stageDir, { recursive: true, force: true });
|
|
10446
10565
|
}
|
|
10447
10566
|
_chunk5QIKR7RRcjs.logger.info(
|
|
10448
10567
|
`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
|
|
@@ -10457,15 +10576,15 @@ async function settleAllOrThrow(operations) {
|
|
|
10457
10576
|
if (failure) throw failure.reason;
|
|
10458
10577
|
}
|
|
10459
10578
|
_chunkS3JO3N4Hcjs.__name.call(void 0, settleAllOrThrow, "settleAllOrThrow");
|
|
10460
|
-
async function mergeStagedDirectory(sourceDir, targetDir,
|
|
10461
|
-
await
|
|
10462
|
-
const entries = await
|
|
10579
|
+
async function mergeStagedDirectory(sourceDir, targetDir, fs3) {
|
|
10580
|
+
await fs3.mkdir(targetDir, { recursive: true });
|
|
10581
|
+
const entries = await fs3.readdir(sourceDir, { withFileTypes: true });
|
|
10463
10582
|
await settleAllOrThrow(
|
|
10464
10583
|
entries.map(async (entry) => {
|
|
10465
10584
|
const sourcePath = _path2.default.join(sourceDir, entry.name);
|
|
10466
10585
|
const targetPath = _path2.default.join(targetDir, entry.name);
|
|
10467
10586
|
try {
|
|
10468
|
-
await
|
|
10587
|
+
await fs3.rename(sourcePath, targetPath);
|
|
10469
10588
|
return;
|
|
10470
10589
|
} catch (error) {
|
|
10471
10590
|
const code = error.code;
|
|
@@ -10474,16 +10593,16 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs) {
|
|
|
10474
10593
|
}
|
|
10475
10594
|
}
|
|
10476
10595
|
if (entry.isDirectory()) {
|
|
10477
|
-
await mergeStagedDirectory(sourcePath, targetPath,
|
|
10478
|
-
await
|
|
10596
|
+
await mergeStagedDirectory(sourcePath, targetPath, fs3);
|
|
10597
|
+
await fs3.rm(sourcePath, { recursive: true, force: true });
|
|
10479
10598
|
return;
|
|
10480
10599
|
}
|
|
10481
|
-
await
|
|
10600
|
+
await fs3.cp(sourcePath, targetPath, {
|
|
10482
10601
|
force: true,
|
|
10483
10602
|
dereference: true,
|
|
10484
10603
|
mode: _fs.constants.COPYFILE_FICLONE
|
|
10485
10604
|
});
|
|
10486
|
-
await
|
|
10605
|
+
await fs3.rm(sourcePath, { force: true });
|
|
10487
10606
|
})
|
|
10488
10607
|
);
|
|
10489
10608
|
}
|
|
@@ -10503,44 +10622,44 @@ function resolveMetadataImageRuntimePackageJson(root) {
|
|
|
10503
10622
|
if (packageJsonPath) return packageJsonPath;
|
|
10504
10623
|
try {
|
|
10505
10624
|
return resolvePackageJson(_module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core")), "@vercel/og");
|
|
10506
|
-
} catch (
|
|
10625
|
+
} catch (e28) {
|
|
10507
10626
|
return null;
|
|
10508
10627
|
}
|
|
10509
10628
|
}
|
|
10510
10629
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveMetadataImageRuntimePackageJson, "resolveMetadataImageRuntimePackageJson");
|
|
10511
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
10630
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs3) {
|
|
10512
10631
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
10513
10632
|
if (!packageJsonPath) return;
|
|
10514
|
-
const packageJson = JSON.parse(await
|
|
10633
|
+
const packageJson = JSON.parse(await fs3.readFile(packageJsonPath, "utf8"));
|
|
10515
10634
|
const packageDir = _path2.default.dirname(packageJsonPath);
|
|
10516
10635
|
const targetDir = _path2.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
10517
|
-
await
|
|
10518
|
-
await
|
|
10636
|
+
await fs3.mkdir(_path2.default.dirname(targetDir), { recursive: true });
|
|
10637
|
+
await fs3.cp(packageDir, targetDir, {
|
|
10519
10638
|
recursive: true,
|
|
10520
10639
|
force: true,
|
|
10521
10640
|
dereference: true,
|
|
10522
10641
|
mode: _fs.constants.COPYFILE_FICLONE
|
|
10523
10642
|
});
|
|
10524
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
10643
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs3);
|
|
10525
10644
|
functionPackage.dependencies = {
|
|
10526
10645
|
...functionPackage.dependencies,
|
|
10527
10646
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
10528
10647
|
};
|
|
10529
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10648
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs3);
|
|
10530
10649
|
_chunk5QIKR7RRcjs.logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
10531
10650
|
}
|
|
10532
10651
|
_chunkS3JO3N4Hcjs.__name.call(void 0, copyMetadataImageRuntime, "copyMetadataImageRuntime");
|
|
10533
|
-
async function readNitroOutputPackage(outputDir,
|
|
10652
|
+
async function readNitroOutputPackage(outputDir, fs3) {
|
|
10534
10653
|
const packagePath = _path2.default.join(outputDir, "package.json");
|
|
10535
|
-
return
|
|
10654
|
+
return fs3.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10536
10655
|
if (error.code === "ENOENT") return {};
|
|
10537
10656
|
throw error;
|
|
10538
10657
|
});
|
|
10539
10658
|
}
|
|
10540
10659
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readNitroOutputPackage, "readNitroOutputPackage");
|
|
10541
|
-
async function writeNitroOutputPackage(outputDir, packageJson,
|
|
10542
|
-
await
|
|
10543
|
-
await
|
|
10660
|
+
async function writeNitroOutputPackage(outputDir, packageJson, fs3) {
|
|
10661
|
+
await fs3.mkdir(outputDir, { recursive: true });
|
|
10662
|
+
await fs3.writeFile(
|
|
10544
10663
|
_path2.default.join(outputDir, "package.json"),
|
|
10545
10664
|
`${JSON.stringify(packageJson, null, 2)}
|
|
10546
10665
|
`
|
|
@@ -10554,7 +10673,7 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10554
10673
|
const resolved = parentRequire.resolve(request);
|
|
10555
10674
|
if (resolved.endsWith(".json")) return resolved;
|
|
10556
10675
|
_nullishCoalesce(metadataModule, () => ( (metadataModule = resolved)));
|
|
10557
|
-
} catch (
|
|
10676
|
+
} catch (e29) {
|
|
10558
10677
|
}
|
|
10559
10678
|
}
|
|
10560
10679
|
try {
|
|
@@ -10565,55 +10684,55 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10565
10684
|
try {
|
|
10566
10685
|
const manifest = JSON.parse(_fs.readFileSync.call(void 0, candidate, "utf8"));
|
|
10567
10686
|
if (manifest.name === packageName) return candidate;
|
|
10568
|
-
} catch (
|
|
10687
|
+
} catch (e30) {
|
|
10569
10688
|
}
|
|
10570
10689
|
}
|
|
10571
10690
|
if (_path2.default.basename(directory) === "node_modules") break;
|
|
10572
10691
|
directory = _path2.default.dirname(directory);
|
|
10573
10692
|
}
|
|
10574
|
-
} catch (
|
|
10693
|
+
} catch (e31) {
|
|
10575
10694
|
}
|
|
10576
10695
|
return null;
|
|
10577
10696
|
}
|
|
10578
10697
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolvePackageJson, "resolvePackageJson");
|
|
10579
|
-
async function copyPrismaClientForVercel(root, nitroFuncDir,
|
|
10698
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs3) {
|
|
10580
10699
|
const projectRequire = _module.createRequire.call(void 0, _path2.default.join(root, "package.json"));
|
|
10581
10700
|
let prismaClientDir;
|
|
10582
10701
|
try {
|
|
10583
10702
|
prismaClientDir = _path2.default.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
10584
|
-
} catch (
|
|
10703
|
+
} catch (e32) {
|
|
10585
10704
|
return;
|
|
10586
10705
|
}
|
|
10587
10706
|
const generatedClientDir = _path2.default.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
10588
10707
|
try {
|
|
10589
|
-
await
|
|
10590
|
-
} catch (
|
|
10708
|
+
await fs3.access(generatedClientDir);
|
|
10709
|
+
} catch (e33) {
|
|
10591
10710
|
return;
|
|
10592
10711
|
}
|
|
10593
10712
|
const targetNodeModules = _path2.default.join(nitroFuncDir, "node_modules");
|
|
10594
10713
|
const targetPrismaScopeDir = _path2.default.join(targetNodeModules, "@prisma");
|
|
10595
10714
|
const targetGeneratedDir = _path2.default.join(targetNodeModules, ".prisma", "client");
|
|
10596
10715
|
const targetClientDir = _path2.default.join(targetPrismaScopeDir, "client");
|
|
10597
|
-
await
|
|
10598
|
-
await
|
|
10716
|
+
await fs3.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
10717
|
+
await fs3.cp(prismaClientDir, targetClientDir, {
|
|
10599
10718
|
recursive: true,
|
|
10600
10719
|
force: true
|
|
10601
10720
|
});
|
|
10602
|
-
await
|
|
10721
|
+
await fs3.cp(generatedClientDir, targetGeneratedDir, {
|
|
10603
10722
|
recursive: true,
|
|
10604
10723
|
force: true
|
|
10605
10724
|
});
|
|
10606
10725
|
const clientPackagePath = _path2.default.join(prismaClientDir, "package.json");
|
|
10607
10726
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
10608
|
-
readNitroOutputPackage(nitroFuncDir,
|
|
10609
|
-
|
|
10727
|
+
readNitroOutputPackage(nitroFuncDir, fs3),
|
|
10728
|
+
fs3.readFile(clientPackagePath, "utf-8")
|
|
10610
10729
|
]);
|
|
10611
10730
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
10612
10731
|
functionPackage.dependencies = {
|
|
10613
10732
|
...functionPackage.dependencies,
|
|
10614
10733
|
"@prisma/client": clientPackage.version
|
|
10615
10734
|
};
|
|
10616
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10735
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs3);
|
|
10617
10736
|
}
|
|
10618
10737
|
_chunkS3JO3N4Hcjs.__name.call(void 0, copyPrismaClientForVercel, "copyPrismaClientForVercel");
|
|
10619
10738
|
|
|
@@ -10643,7 +10762,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmProjectModuleSsrEnvironment, "cr
|
|
|
10643
10762
|
|
|
10644
10763
|
// src/build/index.ts
|
|
10645
10764
|
async function build(config, options = {}) {
|
|
10646
|
-
return
|
|
10765
|
+
return _chunkWW46B6HAcjs.withProductionNodeEnv.call(void 0, () => buildWithProductionNodeEnv(config, options));
|
|
10647
10766
|
}
|
|
10648
10767
|
_chunkS3JO3N4Hcjs.__name.call(void 0, build, "build");
|
|
10649
10768
|
function createBuildTargetBaseline(config) {
|
|
@@ -10654,7 +10773,7 @@ function createBuildTargetBaseline(config) {
|
|
|
10654
10773
|
preset,
|
|
10655
10774
|
distDir,
|
|
10656
10775
|
outputDir,
|
|
10657
|
-
outputWasDerived: outputDir ===
|
|
10776
|
+
outputWasDerived: outputDir === _chunkHRETEZ2Zcjs.getDefaultDeployOutputDir.call(void 0, config.deploy.target, preset, distDir)
|
|
10658
10777
|
};
|
|
10659
10778
|
}
|
|
10660
10779
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createBuildTargetBaseline, "createBuildTargetBaseline");
|
|
@@ -10664,8 +10783,8 @@ function resolveBuildTargets(config, options, baseline) {
|
|
|
10664
10783
|
const distDir = config.distDir || ".farm";
|
|
10665
10784
|
const outputWasReplaced = config.deploy.outputDir !== baseline.outputDir;
|
|
10666
10785
|
const shouldRefreshDerivedOutput = baseline.outputWasDerived && !outputWasReplaced && (preset !== baseline.preset || distDir !== baseline.distDir);
|
|
10667
|
-
const deployTarget = preset === config.deploy.preset ? config.deploy.target :
|
|
10668
|
-
const outputDir = shouldRefreshDerivedOutput ?
|
|
10786
|
+
const deployTarget = preset === config.deploy.preset ? config.deploy.target : _chunkHRETEZ2Zcjs.getDeployTargetForPreset.call(void 0, preset);
|
|
10787
|
+
const outputDir = shouldRefreshDerivedOutput ? _chunkHRETEZ2Zcjs.getDefaultDeployOutputDir.call(void 0, deployTarget, preset, distDir) : config.deploy.outputDir;
|
|
10669
10788
|
return {
|
|
10670
10789
|
root,
|
|
10671
10790
|
preset,
|
|
@@ -10673,7 +10792,7 @@ function resolveBuildTargets(config, options, baseline) {
|
|
|
10673
10792
|
distDir,
|
|
10674
10793
|
deployTarget,
|
|
10675
10794
|
outputDir,
|
|
10676
|
-
deployOutputDir:
|
|
10795
|
+
deployOutputDir: _chunkHRETEZ2Zcjs.resolveDeployOutputPath.call(void 0, root, outputDir)
|
|
10677
10796
|
};
|
|
10678
10797
|
}
|
|
10679
10798
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveBuildTargets, "resolveBuildTargets");
|
|
@@ -10682,7 +10801,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10682
10801
|
const targetBaseline = createBuildTargetBaseline(config);
|
|
10683
10802
|
let targets;
|
|
10684
10803
|
const productionViteResultPromise = options.universal === false ? void 0 : Promise.allSettled([Promise.resolve(_nullishCoalesce(options.productionVite, () => ( _chunkA6WIQH5Zcjs.loadFarmProductionVite.call(void 0, ))))]);
|
|
10685
|
-
const pluginManager = new (0,
|
|
10804
|
+
const pluginManager = new (0, _chunkAS2VPMEEcjs.PluginManager)({
|
|
10686
10805
|
config,
|
|
10687
10806
|
isDev: false,
|
|
10688
10807
|
isProd: true
|
|
@@ -10711,12 +10830,12 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10711
10830
|
};
|
|
10712
10831
|
config = {
|
|
10713
10832
|
...config,
|
|
10714
|
-
images:
|
|
10833
|
+
images: _chunkAS2VPMEEcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, {
|
|
10715
10834
|
root: targets.root,
|
|
10716
10835
|
preset: targets.preset
|
|
10717
10836
|
})
|
|
10718
10837
|
};
|
|
10719
|
-
if (_optionalChain([config, 'access',
|
|
10838
|
+
if (_optionalChain([config, 'access', _208 => _208.docs, 'optionalAccess', _209 => _209.enabled])) await _chunkIK6LVLKCcjs.loadFarmDocsEngine.call(void 0, );
|
|
10720
10839
|
pluginManager.updateContext({ config });
|
|
10721
10840
|
const { root, preset, srcDir, distDir, deployOutputDir } = targets;
|
|
10722
10841
|
_chunk5QIKR7RRcjs.logger.info(`\u{1F69C} Building Farm.js application with preset: ${preset}...`);
|
|
@@ -10730,8 +10849,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10730
10849
|
});
|
|
10731
10850
|
_chunk5QIKR7RRcjs.logger.info("\u{1F50D} Discovering routes and API endpoints...");
|
|
10732
10851
|
const productionViteResult = productionViteResultPromise ? (await productionViteResultPromise)[0] : void 0;
|
|
10733
|
-
if (_optionalChain([productionViteResult, 'optionalAccess',
|
|
10734
|
-
const productionVite = _optionalChain([productionViteResult, 'optionalAccess',
|
|
10852
|
+
if (_optionalChain([productionViteResult, 'optionalAccess', _210 => _210.status]) === "rejected") throw productionViteResult.reason;
|
|
10853
|
+
const productionVite = _optionalChain([productionViteResult, 'optionalAccess', _211 => _211.value]);
|
|
10735
10854
|
const createViteServer = productionVite ? productionVite.createServer : (await import("vite")).createServer;
|
|
10736
10855
|
projectModuleServer = await createProjectModuleServer(
|
|
10737
10856
|
createViteServer,
|
|
@@ -10739,7 +10858,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10739
10858
|
root,
|
|
10740
10859
|
rendererBuild.signal
|
|
10741
10860
|
);
|
|
10742
|
-
const farmApp =
|
|
10861
|
+
const farmApp = _chunkAS2VPMEEcjs.createFarmApp.call(void 0, config, projectModuleServer);
|
|
10743
10862
|
await farmApp.initialize();
|
|
10744
10863
|
const routeManager = farmApp.getRouteManager();
|
|
10745
10864
|
const serverRenderer = farmApp.getServerRenderer();
|
|
@@ -10749,8 +10868,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10749
10868
|
layers: config.layers,
|
|
10750
10869
|
plugins: config.plugins,
|
|
10751
10870
|
extraRoutes: [
|
|
10752
|
-
..._optionalChain([config, 'access',
|
|
10753
|
-
...
|
|
10871
|
+
..._optionalChain([config, 'access', _212 => _212.openapi, 'optionalAccess', _213 => _213.enabled]) && config.openapi.route ? [config.openapi.route] : [],
|
|
10872
|
+
..._chunkPGZDEPTMcjs.getFarmDocsRouteTypeEntries.call(void 0, config.docs)
|
|
10754
10873
|
],
|
|
10755
10874
|
suppressLintOnLink: config.suppressLintOnLink,
|
|
10756
10875
|
componentExtensions: config.renderer.componentExtensions,
|
|
@@ -10759,7 +10878,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10759
10878
|
const message = error instanceof Error ? error.message : String(error);
|
|
10760
10879
|
_chunk5QIKR7RRcjs.logger.warn(`Route type generation failed (farm.d.ts may be stale): ${message}`);
|
|
10761
10880
|
});
|
|
10762
|
-
const apiRouteManager = new (0,
|
|
10881
|
+
const apiRouteManager = new (0, _chunkRWFLWR5Jcjs.APIRouteManager)(
|
|
10763
10882
|
_chunkWBKEZXWEcjs.getFarmAppDirectories.call(void 0, config),
|
|
10764
10883
|
projectModuleServer,
|
|
10765
10884
|
{
|
|
@@ -10834,7 +10953,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10834
10953
|
throw error;
|
|
10835
10954
|
} finally {
|
|
10836
10955
|
try {
|
|
10837
|
-
await _optionalChain([projectModuleServer, 'optionalAccess',
|
|
10956
|
+
await _optionalChain([projectModuleServer, 'optionalAccess', _214 => _214.close, 'call', _215 => _215()]);
|
|
10838
10957
|
} finally {
|
|
10839
10958
|
rendererBuild.abort();
|
|
10840
10959
|
}
|
|
@@ -10846,7 +10965,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10846
10965
|
ssr: true,
|
|
10847
10966
|
buildLifetime
|
|
10848
10967
|
});
|
|
10849
|
-
const viteConfig =
|
|
10968
|
+
const viteConfig = _chunkAS2VPMEEcjs.mergeFarmViteConfig.call(void 0,
|
|
10850
10969
|
{
|
|
10851
10970
|
root,
|
|
10852
10971
|
appType: "custom",
|
|
@@ -10858,7 +10977,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10858
10977
|
},
|
|
10859
10978
|
plugins: [
|
|
10860
10979
|
...rendererVitePlugins,
|
|
10861
|
-
|
|
10980
|
+
_chunkAS2VPMEEcjs.farmFontImportsPlugin.call(void 0, {
|
|
10862
10981
|
root,
|
|
10863
10982
|
basePath: config.basePath,
|
|
10864
10983
|
publicDir: config.publicDir
|
|
@@ -10870,7 +10989,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10870
10989
|
hmr: false
|
|
10871
10990
|
},
|
|
10872
10991
|
resolve: {
|
|
10873
|
-
alias:
|
|
10992
|
+
alias: _chunkAS2VPMEEcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
|
|
10874
10993
|
dedupe: [...config.renderer.dedupe || []]
|
|
10875
10994
|
},
|
|
10876
10995
|
optimizeDeps: {
|
|
@@ -10903,10 +11022,10 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10903
11022
|
noDiscovery: true
|
|
10904
11023
|
},
|
|
10905
11024
|
// An app or plugin that brings its own SSR environment keeps it.
|
|
10906
|
-
environments: _optionalChain([viteConfig, 'access',
|
|
11025
|
+
environments: _optionalChain([viteConfig, 'access', _216 => _216.environments, 'optionalAccess', _217 => _217.ssr, 'optionalAccess', _218 => _218.dev, 'optionalAccess', _219 => _219.createEnvironment]) ? viteConfig.environments : {
|
|
10907
11026
|
...viteConfig.environments,
|
|
10908
11027
|
ssr: {
|
|
10909
|
-
..._optionalChain([viteConfig, 'access',
|
|
11028
|
+
..._optionalChain([viteConfig, 'access', _220 => _220.environments, 'optionalAccess', _221 => _221.ssr]),
|
|
10910
11029
|
...await createFarmProjectModuleSsrEnvironment()
|
|
10911
11030
|
}
|
|
10912
11031
|
}
|
|
@@ -10964,7 +11083,7 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
10964
11083
|
define: {
|
|
10965
11084
|
__FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
|
|
10966
11085
|
__FARM_ENV__: JSON.stringify(_chunkVEKFLAQMcjs.createBundledEnv.call(void 0, config.env)),
|
|
10967
|
-
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access',
|
|
11086
|
+
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _222 => _222.env, 'optionalAccess', _223 => _223.public]) || {})
|
|
10968
11087
|
},
|
|
10969
11088
|
plugins: [
|
|
10970
11089
|
farmI18nClientBridgePlugin(),
|
|
@@ -10999,7 +11118,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10999
11118
|
if (pluginManager) {
|
|
11000
11119
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
11001
11120
|
}
|
|
11002
|
-
const outputDir =
|
|
11121
|
+
const outputDir = _chunkHRETEZ2Zcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
|
|
11003
11122
|
const serverOutputDir = _path2.default.join(outputDir, "server");
|
|
11004
11123
|
const publicOutputDir = _path2.default.join(outputDir, "public");
|
|
11005
11124
|
const { mkdir, cp } = await import("fs/promises");
|
|
@@ -11013,10 +11132,10 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11013
11132
|
const manifestPath = _path2.default.join(publicOutputDir, "farm-client-manifest.json");
|
|
11014
11133
|
const assetsDir = _path2.default.join(publicOutputDir, "assets");
|
|
11015
11134
|
const manifestExists = await import("fs/promises").then(
|
|
11016
|
-
(
|
|
11135
|
+
(fs3) => fs3.access(manifestPath).then(() => true).catch(() => false)
|
|
11017
11136
|
);
|
|
11018
11137
|
const assetsExist = await import("fs/promises").then(
|
|
11019
|
-
(
|
|
11138
|
+
(fs3) => fs3.access(assetsDir).then(() => true).catch(() => false)
|
|
11020
11139
|
);
|
|
11021
11140
|
if (manifestExists && assetsExist) {
|
|
11022
11141
|
_chunk5QIKR7RRcjs.logger.info("\u2705 Verified client assets are present");
|
|
@@ -11058,7 +11177,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11058
11177
|
const { readFile } = await import("fs/promises");
|
|
11059
11178
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
11060
11179
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|
|
11061
|
-
} catch (
|
|
11180
|
+
} catch (e34) {
|
|
11062
11181
|
farmRegistry.clientManifest = {};
|
|
11063
11182
|
}
|
|
11064
11183
|
} catch (error) {
|
|
@@ -11070,7 +11189,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11070
11189
|
root,
|
|
11071
11190
|
preset,
|
|
11072
11191
|
distDir,
|
|
11073
|
-
outputDir:
|
|
11192
|
+
outputDir: _chunkHRETEZ2Zcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir)
|
|
11074
11193
|
});
|
|
11075
11194
|
}
|
|
11076
11195
|
}
|