@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
|
@@ -2,26 +2,32 @@ import {
|
|
|
2
2
|
loadFarmProductionVite
|
|
3
3
|
} from "./chunk-S3FNNQHR.mjs";
|
|
4
4
|
import {
|
|
5
|
+
FARM_NODE_ENV_MODULE_FILE,
|
|
6
|
+
FARM_NODE_ENV_MODULE_SOURCE,
|
|
7
|
+
createFarmNodeServerEntry,
|
|
5
8
|
withProductionNodeEnv
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6BK3K2GB.mjs";
|
|
7
10
|
import {
|
|
8
11
|
generateNativeMCPPluginSource,
|
|
9
12
|
layoutsCanCoverSamePage
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-677THUVP.mjs";
|
|
11
14
|
import {
|
|
15
|
+
assertFarmDocsAdapterServesNoGuardedPages,
|
|
12
16
|
compileFarmDocsAdapterEdgeManifest,
|
|
13
|
-
createFarmDocsAPIHandler
|
|
14
|
-
|
|
17
|
+
createFarmDocsAPIHandler,
|
|
18
|
+
hasFarmDocsRuntimeAdapter
|
|
19
|
+
} from "./chunk-YKZRDB5Z.mjs";
|
|
15
20
|
import {
|
|
16
21
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
17
22
|
createFarmDocsHandler,
|
|
18
23
|
createFarmDocsLastModifiedManifest,
|
|
19
24
|
discoverFarmDocsPages,
|
|
25
|
+
getFarmDocsMarkdownPath,
|
|
20
26
|
getFarmDocsRouteTypeEntries,
|
|
21
27
|
loadFarmDocsPage,
|
|
22
28
|
resolveFarmDocsContentDir,
|
|
23
29
|
toFarmDocsMarkdownPage
|
|
24
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-5BWWFHR2.mjs";
|
|
25
31
|
import {
|
|
26
32
|
generateFarmDocsSearchClientRuntime,
|
|
27
33
|
isFarmDocsSearchEnabled,
|
|
@@ -29,7 +35,7 @@ import {
|
|
|
29
35
|
} from "./chunk-UP4CW6WP.mjs";
|
|
30
36
|
import {
|
|
31
37
|
FARM_PRERENDER_ENV
|
|
32
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-BZHXGVMA.mjs";
|
|
33
39
|
import {
|
|
34
40
|
loadFarmDocsEngine
|
|
35
41
|
} from "./chunk-2VQKKQ6D.mjs";
|
|
@@ -38,7 +44,7 @@ import {
|
|
|
38
44
|
getDeployTargetForPreset,
|
|
39
45
|
hasCustomFarmRouteContext,
|
|
40
46
|
resolveDeployOutputPath
|
|
41
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-75HN5IZ3.mjs";
|
|
42
48
|
import {
|
|
43
49
|
resolveFarmInstrumentationFile
|
|
44
50
|
} from "./chunk-ZZSRYEYU.mjs";
|
|
@@ -77,7 +83,7 @@ import {
|
|
|
77
83
|
resolveFarmIsolatedClientHydrationMode,
|
|
78
84
|
resolveFarmNotFoundComponentPath,
|
|
79
85
|
usesFarmServerTree
|
|
80
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-HYTZYOW2.mjs";
|
|
81
87
|
import {
|
|
82
88
|
findRequestBoundSourceBlockers,
|
|
83
89
|
generateFarmTypeArtifacts,
|
|
@@ -89,18 +95,22 @@ import {
|
|
|
89
95
|
FARM_APP_MANIFEST_LEGACY_PATH,
|
|
90
96
|
FARM_APP_MANIFEST_PATH,
|
|
91
97
|
HOISTED_HEAD_ELEMENT,
|
|
98
|
+
appMiddlewareMayHandlePath,
|
|
99
|
+
configMiddlewareMayHandlePath,
|
|
100
|
+
farmPathGuardCoversPage,
|
|
92
101
|
getRouteDirectoryDepth,
|
|
93
102
|
getRouteGroupScope,
|
|
103
|
+
hasFarmMiddlewareConfig,
|
|
94
104
|
resolveFarmApiCatalogInput,
|
|
95
105
|
resolveFarmAppManifestInput,
|
|
96
106
|
routeBoundaryCoversDirectory,
|
|
97
107
|
stripRouteGroups
|
|
98
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-GKBWWRBG.mjs";
|
|
99
109
|
import {
|
|
100
110
|
FARM_DEFAULT_MCP_PATH,
|
|
101
111
|
createFarmDefaultMCPServer,
|
|
102
112
|
farmConfigMountsMCP
|
|
103
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-P664ZVTV.mjs";
|
|
104
114
|
import {
|
|
105
115
|
isFarmPreviewDeploymentEnvironment
|
|
106
116
|
} from "./chunk-BOYNDCZL.mjs";
|
|
@@ -110,7 +120,7 @@ import {
|
|
|
110
120
|
import {
|
|
111
121
|
generateFarmDocsAdapterClientRuntime,
|
|
112
122
|
getFarmDocsAdapterConfigModule
|
|
113
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-J7K2NZD6.mjs";
|
|
114
124
|
import {
|
|
115
125
|
resolveFarmDocsFontAssets,
|
|
116
126
|
toFarmDocsPublicFontAssets
|
|
@@ -131,8 +141,9 @@ import {
|
|
|
131
141
|
resolveFarmRendererAppSetup
|
|
132
142
|
} from "./chunk-DAATZTKJ.mjs";
|
|
133
143
|
import {
|
|
134
|
-
applyFarmCspHashesToHtml
|
|
135
|
-
|
|
144
|
+
applyFarmCspHashesToHtml,
|
|
145
|
+
createFarmCspNonce
|
|
146
|
+
} from "./chunk-U6QLDL3G.mjs";
|
|
136
147
|
import {
|
|
137
148
|
applyFarmCronVercelCrons,
|
|
138
149
|
createFarmCronCloudflareConfig,
|
|
@@ -144,14 +155,14 @@ import {
|
|
|
144
155
|
} from "./chunk-4OOBRCJX.mjs";
|
|
145
156
|
import {
|
|
146
157
|
isFarmMarkdownPageFile
|
|
147
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-QFW2IH5E.mjs";
|
|
148
159
|
import {
|
|
149
160
|
resolveFarmMdxComponentsModulePath,
|
|
150
161
|
resolveMdxConfig
|
|
151
162
|
} from "./chunk-FA2W42OV.mjs";
|
|
152
163
|
import {
|
|
153
164
|
getFarmMarkdownAlternatePath
|
|
154
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-VNGH5MLF.mjs";
|
|
155
166
|
import {
|
|
156
167
|
applyFarmWorkflowVercelCrons,
|
|
157
168
|
prepareFarmWorkflowsForNitro
|
|
@@ -160,20 +171,15 @@ import {
|
|
|
160
171
|
FARM_INTEGRATION_API_BASE_PATH_KEY,
|
|
161
172
|
getFarmIntegrationPluginServerRuntime,
|
|
162
173
|
getIntegrationProviders
|
|
163
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-ATSDUUFK.mjs";
|
|
164
175
|
import {
|
|
165
176
|
appendMiddlewareDirectory,
|
|
166
177
|
appendMiddlewareRoutePath,
|
|
167
178
|
compareMiddlewareRouteLocations
|
|
168
|
-
} from "./chunk-
|
|
169
|
-
import {
|
|
170
|
-
compileMiddlewareConfig,
|
|
171
|
-
matchesCompiledMiddlewareConfig,
|
|
172
|
-
matchesMiddlewareRoute
|
|
173
|
-
} from "./chunk-HZFM2LWQ.mjs";
|
|
179
|
+
} from "./chunk-QYMZOOC5.mjs";
|
|
174
180
|
import {
|
|
175
181
|
APIRouteManager
|
|
176
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-WLL43JMO.mjs";
|
|
177
183
|
import {
|
|
178
184
|
readFarmI18nCatalogs
|
|
179
185
|
} from "./chunk-QCFBDFRS.mjs";
|
|
@@ -200,10 +206,13 @@ import {
|
|
|
200
206
|
} from "./chunk-BTHHUD7Q.mjs";
|
|
201
207
|
import {
|
|
202
208
|
FARM_VERSION
|
|
203
|
-
} from "./chunk-
|
|
209
|
+
} from "./chunk-SOP2EAA6.mjs";
|
|
204
210
|
import {
|
|
205
211
|
getFarmPresetRuntime
|
|
206
212
|
} from "./chunk-2A3EQHXX.mjs";
|
|
213
|
+
import {
|
|
214
|
+
_runWithFarmCspNonce
|
|
215
|
+
} from "./chunk-POSPE3IO.mjs";
|
|
207
216
|
import {
|
|
208
217
|
compareRoutePatternSpecificity
|
|
209
218
|
} from "./chunk-55YI3RRB.mjs";
|
|
@@ -212,7 +221,7 @@ import {
|
|
|
212
221
|
} from "./chunk-LPEX4YW6.mjs";
|
|
213
222
|
|
|
214
223
|
// src/build/index.ts
|
|
215
|
-
import
|
|
224
|
+
import path9 from "path";
|
|
216
225
|
import { existsSync as existsSync3 } from "fs";
|
|
217
226
|
|
|
218
227
|
// src/nitro/client-css-href.ts
|
|
@@ -220,15 +229,15 @@ import path from "path";
|
|
|
220
229
|
var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
221
230
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
222
231
|
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
223
|
-
const
|
|
232
|
+
const fs3 = await import("fs/promises");
|
|
224
233
|
try {
|
|
225
|
-
const bytes = await
|
|
234
|
+
const bytes = await fs3.readFile(sourcePath);
|
|
226
235
|
if (bytes.length === 0) return null;
|
|
227
236
|
const { createHash } = await import("crypto");
|
|
228
237
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
229
238
|
const name = hashedName(hash);
|
|
230
|
-
await
|
|
231
|
-
await
|
|
239
|
+
await fs3.mkdir(destinationDir, { recursive: true });
|
|
240
|
+
await fs3.writeFile(path.join(destinationDir, name), bytes);
|
|
232
241
|
return name;
|
|
233
242
|
} catch {
|
|
234
243
|
return null;
|
|
@@ -245,9 +254,9 @@ async function resolveHashedClientCssHref(clientOutputDir) {
|
|
|
245
254
|
}
|
|
246
255
|
__name(resolveHashedClientCssHref, "resolveHashedClientCssHref");
|
|
247
256
|
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
248
|
-
const
|
|
257
|
+
const fs3 = await import("fs/promises");
|
|
249
258
|
try {
|
|
250
|
-
const entries = await
|
|
259
|
+
const entries = await fs3.readdir(clientOutputDir);
|
|
251
260
|
return entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)) ?? null;
|
|
252
261
|
} catch {
|
|
253
262
|
return null;
|
|
@@ -257,17 +266,17 @@ __name(findFingerprintedClientEntry, "findFingerprintedClientEntry");
|
|
|
257
266
|
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
258
267
|
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
259
268
|
if (!entryName) return "/farm-client.js";
|
|
260
|
-
const
|
|
269
|
+
const fs3 = await import("fs/promises");
|
|
261
270
|
const shim = `export * from "./${entryName}";
|
|
262
271
|
`;
|
|
263
|
-
await
|
|
272
|
+
await fs3.writeFile(path.join(clientOutputDir, "farm-client.js"), shim);
|
|
264
273
|
return `/${entryName}`;
|
|
265
274
|
}
|
|
266
275
|
__name(resolveHashedClientJsSrc, "resolveHashedClientJsSrc");
|
|
267
276
|
|
|
268
277
|
// src/nitro/universal-build.ts
|
|
269
278
|
import os from "os";
|
|
270
|
-
import
|
|
279
|
+
import path8 from "path";
|
|
271
280
|
import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync, statSync } from "fs";
|
|
272
281
|
import { fileURLToPath } from "url";
|
|
273
282
|
import { builtinModules, createRequire } from "module";
|
|
@@ -343,18 +352,21 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
343
352
|
clientEntry: options.clientEntry,
|
|
344
353
|
fontAssets: options.fontAssets,
|
|
345
354
|
fontStylesheetHref: options.fontStylesheetHref,
|
|
346
|
-
globalStylesheetHref: options.globalStylesheetHref
|
|
355
|
+
globalStylesheetHref: options.globalStylesheetHref,
|
|
356
|
+
isPathGuarded: options.isPathGuarded
|
|
347
357
|
});
|
|
348
358
|
const apiHandler = createFarmDocsAPIHandler({
|
|
349
359
|
rootDir: options.root,
|
|
350
360
|
srcDir: options.srcDir,
|
|
351
|
-
docs
|
|
361
|
+
docs,
|
|
362
|
+
isPathGuarded: options.isPathGuarded
|
|
352
363
|
});
|
|
364
|
+
const publicPages = pages.filter((page) => !options.isPathGuarded?.(page.href));
|
|
353
365
|
const routes = {};
|
|
354
366
|
const apiMarkdown = {};
|
|
355
367
|
for (const page of pages) {
|
|
356
368
|
const htmlResponse = await addHandlerRoute(routes, page.href, handler, absolutePaths);
|
|
357
|
-
const markdownPath = page.href
|
|
369
|
+
const markdownPath = getFarmDocsMarkdownPath(page.href);
|
|
358
370
|
await addHandlerRoute(routes, markdownPath, handler, absolutePaths);
|
|
359
371
|
if (htmlResponse) {
|
|
360
372
|
const socialImagePath = findSocialImagePath(await htmlResponse.text());
|
|
@@ -362,6 +374,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
362
374
|
await addHandlerRoute(routes, socialImagePath, handler, absolutePaths);
|
|
363
375
|
}
|
|
364
376
|
}
|
|
377
|
+
if (options.isPathGuarded?.(page.href)) continue;
|
|
365
378
|
const apiResponse = await apiHandler(
|
|
366
379
|
new Request(
|
|
367
380
|
`${FARM_DOCS_COMPILED_ORIGIN}/api/docs?format=markdown&path=${encodeURIComponent(page.slug)}`
|
|
@@ -436,7 +449,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
436
449
|
empty: await compileResponse(emptyResponse, absolutePaths),
|
|
437
450
|
post: await compileResponse(postResponse, absolutePaths),
|
|
438
451
|
search: {
|
|
439
|
-
pages:
|
|
452
|
+
pages: publicPages.map((page) => ({
|
|
440
453
|
...toFarmDocsMarkdownPage(page),
|
|
441
454
|
sourcePath: `farm-docs:${page.slug || "index"}`
|
|
442
455
|
})),
|
|
@@ -449,11 +462,179 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
449
462
|
}
|
|
450
463
|
__name(compileFarmDocsManifest, "compileFarmDocsManifest");
|
|
451
464
|
|
|
452
|
-
// src/
|
|
465
|
+
// src/nitro/client-module-preloads.ts
|
|
466
|
+
import fs from "fs/promises";
|
|
453
467
|
import path3 from "path";
|
|
468
|
+
var FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER = "__farm_client_module_preloads__";
|
|
469
|
+
var FARM_CLIENT_MODULE_PRELOADS_FILE = "client-module-preloads.json";
|
|
470
|
+
function collectFarmClientModulePreloads(bundle, options) {
|
|
471
|
+
const chunks = Object.values(bundle).filter(
|
|
472
|
+
(output) => output.type === "chunk"
|
|
473
|
+
);
|
|
474
|
+
const entry = chunks.find((chunk) => chunk.isEntry && chunk.name === options.entryName);
|
|
475
|
+
if (!entry) return null;
|
|
476
|
+
const byFile = new Map(chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
477
|
+
const files = [];
|
|
478
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
479
|
+
const index = /* @__PURE__ */ __name((fileName) => {
|
|
480
|
+
let value = indexOf.get(fileName);
|
|
481
|
+
if (value === void 0) {
|
|
482
|
+
value = files.push(fileName) - 1;
|
|
483
|
+
indexOf.set(fileName, value);
|
|
484
|
+
}
|
|
485
|
+
return value;
|
|
486
|
+
}, "index");
|
|
487
|
+
const staticImports = /* @__PURE__ */ __name((chunk, loaded, into) => {
|
|
488
|
+
for (const fileName of chunk.imports ?? []) {
|
|
489
|
+
const imported = byFile.get(fileName);
|
|
490
|
+
if (loaded.has(fileName) || !imported) continue;
|
|
491
|
+
loaded.add(fileName);
|
|
492
|
+
into.push(fileName);
|
|
493
|
+
staticImports(imported, loaded, into);
|
|
494
|
+
}
|
|
495
|
+
return into;
|
|
496
|
+
}, "staticImports");
|
|
497
|
+
const entryFiles = staticImports(entry, /* @__PURE__ */ new Set([entry.fileName]), []);
|
|
498
|
+
const entryLoaded = /* @__PURE__ */ new Set([entry.fileName, ...entryFiles]);
|
|
499
|
+
const modules = {};
|
|
500
|
+
for (const chunk of chunks) {
|
|
501
|
+
if (!chunk.isDynamicEntry || !chunk.facadeModuleId || entryLoaded.has(chunk.fileName)) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
const moduleId = chunk.facadeModuleId.split("?")[0];
|
|
505
|
+
if (!path3.isAbsolute(moduleId)) continue;
|
|
506
|
+
const loaded = /* @__PURE__ */ new Set([...entryLoaded, chunk.fileName]);
|
|
507
|
+
modules[toViteModuleId(moduleId, options.root)] = [
|
|
508
|
+
chunk.fileName,
|
|
509
|
+
...staticImports(chunk, loaded, [])
|
|
510
|
+
].map(index);
|
|
511
|
+
}
|
|
512
|
+
return { files, entry: entryFiles.map(index), modules };
|
|
513
|
+
}
|
|
514
|
+
__name(collectFarmClientModulePreloads, "collectFarmClientModulePreloads");
|
|
515
|
+
function createFarmClientModulePreloadPlugin(options) {
|
|
516
|
+
return {
|
|
517
|
+
name: "farm-client-module-preloads",
|
|
518
|
+
async generateBundle(_output, bundle) {
|
|
519
|
+
await fs.mkdir(options.buildDir, { recursive: true });
|
|
520
|
+
await fs.writeFile(
|
|
521
|
+
path3.join(options.buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE),
|
|
522
|
+
JSON.stringify(collectFarmClientModulePreloads(bundle, options))
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
__name(createFarmClientModulePreloadPlugin, "createFarmClientModulePreloadPlugin");
|
|
528
|
+
async function readFarmClientModulePreloads(buildDir) {
|
|
529
|
+
try {
|
|
530
|
+
return JSON.parse(
|
|
531
|
+
await fs.readFile(path3.join(buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE), "utf8")
|
|
532
|
+
);
|
|
533
|
+
} catch {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
__name(readFarmClientModulePreloads, "readFarmClientModulePreloads");
|
|
538
|
+
function encodeFarmClientModulePreloads(manifest) {
|
|
539
|
+
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");
|
|
540
|
+
}
|
|
541
|
+
__name(encodeFarmClientModulePreloads, "encodeFarmClientModulePreloads");
|
|
542
|
+
|
|
543
|
+
// src/docs/module-preloads.ts
|
|
544
|
+
import fs2 from "fs/promises";
|
|
545
|
+
import path4 from "path";
|
|
546
|
+
var FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER = "__farm_docs_module_preloads__";
|
|
547
|
+
var FARM_DOCS_MODULE_PRELOADS_FILE = "docs-module-preloads.json";
|
|
548
|
+
function normalizeModuleId(id) {
|
|
549
|
+
return id.split("?")[0].replace(/\\/g, "/");
|
|
550
|
+
}
|
|
551
|
+
__name(normalizeModuleId, "normalizeModuleId");
|
|
552
|
+
function collectFarmDocsModulePreloads(bundle, options) {
|
|
553
|
+
const chunks = Object.values(bundle).filter(
|
|
554
|
+
(output) => output.type === "chunk"
|
|
555
|
+
);
|
|
556
|
+
const byFile = new Map(chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
557
|
+
const byModule = new Map(
|
|
558
|
+
chunks.filter((chunk) => chunk.facadeModuleId).map((chunk) => [normalizeModuleId(chunk.facadeModuleId), chunk])
|
|
559
|
+
);
|
|
560
|
+
const withStaticImports = /* @__PURE__ */ __name((fileName, into) => {
|
|
561
|
+
if (into.has(fileName) || !byFile.has(fileName)) return into;
|
|
562
|
+
into.add(fileName);
|
|
563
|
+
for (const imported of byFile.get(fileName).imports ?? []) withStaticImports(imported, into);
|
|
564
|
+
return into;
|
|
565
|
+
}, "withStaticImports");
|
|
566
|
+
const runtimeChunks = options.runtimeModuleIds.map((id) => byModule.get(normalizeModuleId(id))).filter((chunk) => Boolean(chunk));
|
|
567
|
+
const entry = chunks.find((chunk) => chunk.isEntry && chunk.name === options.entryName);
|
|
568
|
+
if (!entry || runtimeChunks.length === 0) return null;
|
|
569
|
+
const runtime = withStaticImports(entry.fileName, /* @__PURE__ */ new Set());
|
|
570
|
+
for (const chunk of runtimeChunks) withStaticImports(chunk.fileName, runtime);
|
|
571
|
+
const files = [];
|
|
572
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
573
|
+
const index = /* @__PURE__ */ __name((fileName) => {
|
|
574
|
+
let value = indexOf.get(fileName);
|
|
575
|
+
if (value === void 0) {
|
|
576
|
+
value = files.push(fileName) - 1;
|
|
577
|
+
indexOf.set(fileName, value);
|
|
578
|
+
}
|
|
579
|
+
return value;
|
|
580
|
+
}, "index");
|
|
581
|
+
const pages = {};
|
|
582
|
+
const root = normalizeModuleId(path4.resolve(options.root));
|
|
583
|
+
for (const [moduleId, chunk] of byModule) {
|
|
584
|
+
if (!/\.mdx?$/.test(moduleId) || !moduleId.startsWith(`${root}/`)) continue;
|
|
585
|
+
const own = [...withStaticImports(chunk.fileName, /* @__PURE__ */ new Set())].filter(
|
|
586
|
+
(fileName) => !runtime.has(fileName)
|
|
587
|
+
);
|
|
588
|
+
pages[moduleId.slice(root.length)] = own.map(index);
|
|
589
|
+
}
|
|
590
|
+
return { files, runtime: [...runtime].map(index), pages };
|
|
591
|
+
}
|
|
592
|
+
__name(collectFarmDocsModulePreloads, "collectFarmDocsModulePreloads");
|
|
593
|
+
function createFarmDocsModulePreloadPlugin(options) {
|
|
594
|
+
let runtimeModuleIds = [];
|
|
595
|
+
return {
|
|
596
|
+
name: "farm-docs-module-preloads",
|
|
597
|
+
async buildStart() {
|
|
598
|
+
const resolved = await Promise.all(
|
|
599
|
+
options.modules.map((specifier) => this.resolve(specifier, options.importer))
|
|
600
|
+
);
|
|
601
|
+
runtimeModuleIds = resolved.filter((value) => value !== null).map((value) => value.id);
|
|
602
|
+
},
|
|
603
|
+
async generateBundle(_output, bundle) {
|
|
604
|
+
const manifest = collectFarmDocsModulePreloads(bundle, {
|
|
605
|
+
root: options.root,
|
|
606
|
+
entryName: options.entryName,
|
|
607
|
+
runtimeModuleIds
|
|
608
|
+
});
|
|
609
|
+
await fs2.mkdir(options.buildDir, { recursive: true });
|
|
610
|
+
await fs2.writeFile(
|
|
611
|
+
path4.join(options.buildDir, FARM_DOCS_MODULE_PRELOADS_FILE),
|
|
612
|
+
JSON.stringify(manifest)
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
__name(createFarmDocsModulePreloadPlugin, "createFarmDocsModulePreloadPlugin");
|
|
618
|
+
async function readFarmDocsModulePreloads(buildDir) {
|
|
619
|
+
try {
|
|
620
|
+
return JSON.parse(
|
|
621
|
+
await fs2.readFile(path4.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
|
|
622
|
+
);
|
|
623
|
+
} catch {
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
__name(readFarmDocsModulePreloads, "readFarmDocsModulePreloads");
|
|
628
|
+
function encodeFarmDocsModulePreloads(manifest) {
|
|
629
|
+
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");
|
|
630
|
+
}
|
|
631
|
+
__name(encodeFarmDocsModulePreloads, "encodeFarmDocsModulePreloads");
|
|
632
|
+
|
|
633
|
+
// src/route-runtime-manifest.ts
|
|
634
|
+
import path5 from "path";
|
|
454
635
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
455
636
|
async function createFarmRouteRuntimeManifest(options) {
|
|
456
|
-
const root =
|
|
637
|
+
const root = path5.resolve(options.root || options.config.root || process.cwd());
|
|
457
638
|
const routes = [];
|
|
458
639
|
for (const [pattern, entry] of options.routeManager.getRoutes()) {
|
|
459
640
|
const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
|
|
@@ -523,10 +704,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
523
704
|
}
|
|
524
705
|
__name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
|
|
525
706
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
526
|
-
const
|
|
527
|
-
const manifestPath =
|
|
528
|
-
await
|
|
529
|
-
await
|
|
707
|
+
const fs3 = await import("fs/promises");
|
|
708
|
+
const manifestPath = path5.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
709
|
+
await fs3.mkdir(directory, { recursive: true });
|
|
710
|
+
await fs3.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
530
711
|
`);
|
|
531
712
|
return manifestPath;
|
|
532
713
|
}
|
|
@@ -564,14 +745,14 @@ function normalizeManifestSource(root, modulePath) {
|
|
|
564
745
|
const queryIndex = modulePath.indexOf("?");
|
|
565
746
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
566
747
|
const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
|
|
567
|
-
const relativePath =
|
|
748
|
+
const relativePath = path5.isAbsolute(filePath) ? path5.relative(root, filePath) : filePath;
|
|
568
749
|
return `${relativePath.replace(/\\/g, "/")}${query}`;
|
|
569
750
|
}
|
|
570
751
|
__name(normalizeManifestSource, "normalizeManifestSource");
|
|
571
752
|
|
|
572
753
|
// src/nitro/vercel-route-runtime.ts
|
|
573
|
-
import
|
|
574
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
754
|
+
import path6 from "path";
|
|
755
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs3, basePath = "/") {
|
|
575
756
|
const dynamicRoutes = manifest.routes.filter(
|
|
576
757
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
577
758
|
);
|
|
@@ -590,8 +771,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs, ba
|
|
|
590
771
|
group.routes.push(route);
|
|
591
772
|
groups.set(key, group);
|
|
592
773
|
}
|
|
593
|
-
const functionsDir =
|
|
594
|
-
const baseFunctionDir =
|
|
774
|
+
const functionsDir = path6.join(outputDir, "functions");
|
|
775
|
+
const baseFunctionDir = path6.join(functionsDir, "__nitro.func");
|
|
595
776
|
const destinations = /* @__PURE__ */ new Map();
|
|
596
777
|
let groupIndex = 0;
|
|
597
778
|
for (const [key, group] of groups) {
|
|
@@ -601,9 +782,9 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs, ba
|
|
|
601
782
|
}
|
|
602
783
|
groupIndex += 1;
|
|
603
784
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
604
|
-
const functionDir =
|
|
605
|
-
await
|
|
606
|
-
await configureVercelFunction(functionDir, group.config,
|
|
785
|
+
const functionDir = path6.join(functionsDir, `${functionName}.func`);
|
|
786
|
+
await fs3.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
787
|
+
await configureVercelFunction(functionDir, group.config, fs3);
|
|
607
788
|
destinations.set(key, `/${functionName}`);
|
|
608
789
|
}
|
|
609
790
|
const routes = [];
|
|
@@ -652,15 +833,15 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
652
833
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
653
834
|
}
|
|
654
835
|
__name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
|
|
655
|
-
async function configureVercelFunction(functionDir, config,
|
|
656
|
-
const configPath =
|
|
657
|
-
const current = JSON.parse(await
|
|
836
|
+
async function configureVercelFunction(functionDir, config, fs3) {
|
|
837
|
+
const configPath = path6.join(functionDir, ".vc-config.json");
|
|
838
|
+
const current = JSON.parse(await fs3.readFile(configPath, "utf8"));
|
|
658
839
|
const next = {
|
|
659
840
|
...current,
|
|
660
841
|
...config.regions?.length ? { regions: config.regions } : {},
|
|
661
842
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
662
843
|
};
|
|
663
|
-
await
|
|
844
|
+
await fs3.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
664
845
|
`);
|
|
665
846
|
}
|
|
666
847
|
__name(configureVercelFunction, "configureVercelFunction");
|
|
@@ -737,10 +918,10 @@ __name(buildFarmVercelRoutes, "buildFarmVercelRoutes");
|
|
|
737
918
|
|
|
738
919
|
// src/nitro/netlify-entry.ts
|
|
739
920
|
import { existsSync } from "fs";
|
|
740
|
-
import
|
|
921
|
+
import path7 from "path";
|
|
741
922
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
742
|
-
const entry =
|
|
743
|
-
|
|
923
|
+
const entry = path7.join(
|
|
924
|
+
path7.dirname(nitroRuntimeEntry),
|
|
744
925
|
"..",
|
|
745
926
|
"presets",
|
|
746
927
|
"netlify",
|
|
@@ -752,7 +933,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
752
933
|
`[Farm.js] Could not find Nitro's Netlify function entry at ${entry}. Farm wraps it so private responses are never cached by Netlify's CDN; reinstall dependencies or report the installed Nitro version.`
|
|
753
934
|
);
|
|
754
935
|
}
|
|
755
|
-
return entry.split(
|
|
936
|
+
return entry.split(path7.sep).join("/");
|
|
756
937
|
}
|
|
757
938
|
__name(resolveNitroNetlifyEntry, "resolveNitroNetlifyEntry");
|
|
758
939
|
function createFarmNetlifyEntry(options) {
|
|
@@ -793,278 +974,6 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
793
974
|
}
|
|
794
975
|
__name(createFarmNetlifyEntry, "createFarmNetlifyEntry");
|
|
795
976
|
|
|
796
|
-
// src/nitro/node-server-entry.ts
|
|
797
|
-
var FARM_NODE_ENV_MODULE_FILE = "farm-node-env.mjs";
|
|
798
|
-
var FARM_NODE_ENV_MODULE_SOURCE = `if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
|
|
799
|
-
`;
|
|
800
|
-
function createFarmNodeServerEntry(options) {
|
|
801
|
-
const serverConfig = JSON.stringify(options.server);
|
|
802
|
-
const nitroEntryImport = `./${options.nitroEntryFile.replace(/^\.\//, "")}`;
|
|
803
|
-
return `
|
|
804
|
-
import "./${FARM_NODE_ENV_MODULE_FILE}";
|
|
805
|
-
import "#nitro/virtual/polyfills";
|
|
806
|
-
import { NodeRequest, serve } from ${JSON.stringify(options.nodeAdapterModule)};
|
|
807
|
-
import wsAdapter from ${JSON.stringify(options.websocketAdapterModule)};
|
|
808
|
-
import { resolveWebsocketHooks, useNitroApp, useNitroHooks } from "#nitro/runtime/app";
|
|
809
|
-
import { useRuntimeConfig } from "#nitro/runtime/runtime-config";
|
|
810
|
-
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
811
|
-
import { setupCloseHooks } from "#nitro/runtime/shutdown";
|
|
812
|
-
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
813
|
-
import { tracingSrvxPlugins } from "#nitro/virtual/tracing";
|
|
814
|
-
import { farmProductionLifecycle } from ${JSON.stringify(nitroEntryImport)};
|
|
815
|
-
|
|
816
|
-
const farmServerConfig = ${serverConfig};
|
|
817
|
-
if (!process.env.NITRO_SHUTDOWN_TIMEOUT) {
|
|
818
|
-
process.env.NITRO_SHUTDOWN_TIMEOUT = String(farmServerConfig.gracefulShutdownTimeout);
|
|
819
|
-
}
|
|
820
|
-
const shutdownConfig = {
|
|
821
|
-
disabled: Boolean(process.env.NITRO_SHUTDOWN_DISABLED),
|
|
822
|
-
signals: (process.env.NITRO_SHUTDOWN_SIGNALS || "SIGTERM SIGINT")
|
|
823
|
-
.split(" ")
|
|
824
|
-
.map((signal) => signal.trim())
|
|
825
|
-
.filter(Boolean),
|
|
826
|
-
timeout: Number.parseInt(process.env.NITRO_SHUTDOWN_TIMEOUT || "", 10) || 30000,
|
|
827
|
-
forceExit: !process.env.NITRO_SHUTDOWN_NO_FORCE_EXIT,
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
const nitroApp = useNitroApp();
|
|
831
|
-
useNitroHooks().hook("close", async () => {
|
|
832
|
-
try {
|
|
833
|
-
await farmProductionLifecycle.close("production-server-closed");
|
|
834
|
-
} catch (error) {
|
|
835
|
-
process.exitCode = 1;
|
|
836
|
-
throw error;
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
let startupSignal;
|
|
841
|
-
let resolveStartupSignal;
|
|
842
|
-
const startupSignalPromise = new Promise((resolve) => {
|
|
843
|
-
resolveStartupSignal = resolve;
|
|
844
|
-
});
|
|
845
|
-
const startupSignalListeners = new Map();
|
|
846
|
-
if (!shutdownConfig.disabled) {
|
|
847
|
-
for (const signal of shutdownConfig.signals) {
|
|
848
|
-
const listener = (receivedSignal) => {
|
|
849
|
-
if (!startupSignal) {
|
|
850
|
-
startupSignal = receivedSignal;
|
|
851
|
-
resolveStartupSignal(receivedSignal);
|
|
852
|
-
}
|
|
853
|
-
farmProductionLifecycle.beginDrain(receivedSignal);
|
|
854
|
-
};
|
|
855
|
-
startupSignalListeners.set(signal, listener);
|
|
856
|
-
process.once(signal, listener);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
try {
|
|
861
|
-
await Promise.race([
|
|
862
|
-
Promise.resolve().then(() => farmProductionLifecycle.start()),
|
|
863
|
-
startupSignalPromise,
|
|
864
|
-
]);
|
|
865
|
-
} catch (error) {
|
|
866
|
-
await farmProductionLifecycle.close("production-start-failed").catch((closeError) => {
|
|
867
|
-
console.error("[Farm] Runtime cleanup after startup failure failed:", closeError);
|
|
868
|
-
});
|
|
869
|
-
throw error;
|
|
870
|
-
} finally {
|
|
871
|
-
for (const [signal, listener] of startupSignalListeners) {
|
|
872
|
-
process.removeListener(signal, listener);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
if (startupSignal) {
|
|
877
|
-
let startupCloseTimer;
|
|
878
|
-
const startupCloseCompleted = await Promise.race([
|
|
879
|
-
Promise.resolve()
|
|
880
|
-
.then(() => farmProductionLifecycle.close(startupSignal))
|
|
881
|
-
.then(
|
|
882
|
-
() => true,
|
|
883
|
-
(error) => {
|
|
884
|
-
console.error("[Farm] Runtime shutdown during startup failed:", error);
|
|
885
|
-
process.exitCode = 1;
|
|
886
|
-
return true;
|
|
887
|
-
},
|
|
888
|
-
),
|
|
889
|
-
new Promise((resolve) => {
|
|
890
|
-
startupCloseTimer = setTimeout(() => resolve(false), farmServerConfig.gracefulShutdownTimeout);
|
|
891
|
-
}),
|
|
892
|
-
]);
|
|
893
|
-
clearTimeout(startupCloseTimer);
|
|
894
|
-
if (!startupCloseCompleted) {
|
|
895
|
-
console.warn("[Farm] Runtime startup did not settle before shutdown; forcing cleanup");
|
|
896
|
-
let forcedCloseTimer;
|
|
897
|
-
const forcedCloseCompleted = await Promise.race([
|
|
898
|
-
Promise.resolve()
|
|
899
|
-
.then(() => farmProductionLifecycle.forceClose(startupSignal))
|
|
900
|
-
.then(
|
|
901
|
-
() => true,
|
|
902
|
-
(error) => {
|
|
903
|
-
console.error("[Farm] Forced runtime shutdown during startup failed:", error);
|
|
904
|
-
process.exitCode = 1;
|
|
905
|
-
return true;
|
|
906
|
-
},
|
|
907
|
-
),
|
|
908
|
-
new Promise((resolve) => {
|
|
909
|
-
forcedCloseTimer = setTimeout(
|
|
910
|
-
() => resolve(false),
|
|
911
|
-
farmServerConfig.gracefulShutdownTimeout,
|
|
912
|
-
);
|
|
913
|
-
}),
|
|
914
|
-
]);
|
|
915
|
-
clearTimeout(forcedCloseTimer);
|
|
916
|
-
if (!forcedCloseCompleted) {
|
|
917
|
-
console.error("[Farm] Forced runtime shutdown during startup timed out");
|
|
918
|
-
process.exitCode = 1;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
process.exit(process.exitCode || 0);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
const cert = process.env.NITRO_SSL_CERT;
|
|
925
|
-
const key = process.env.NITRO_SSL_KEY;
|
|
926
|
-
const configuredPort = Number(process.env.NITRO_PORT || process.env.PORT);
|
|
927
|
-
const port = Number.isFinite(configuredPort) && configuredPort > 0 ? configuredPort : 3000;
|
|
928
|
-
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
929
|
-
const socketPath = process.env.NITRO_UNIX_SOCKET;
|
|
930
|
-
const server = serve({
|
|
931
|
-
manual: true,
|
|
932
|
-
silent: true,
|
|
933
|
-
gracefulShutdown: false,
|
|
934
|
-
port,
|
|
935
|
-
hostname: host,
|
|
936
|
-
node: socketPath ? { path: socketPath } : undefined,
|
|
937
|
-
tls: cert && key ? { cert, key } : undefined,
|
|
938
|
-
fetch: nitroApp.fetch,
|
|
939
|
-
plugins: [...tracingSrvxPlugins],
|
|
940
|
-
});
|
|
941
|
-
const nodeServer = server.node?.server;
|
|
942
|
-
if (!nodeServer) throw new Error("[Farm] Nitro did not create a Node server");
|
|
943
|
-
|
|
944
|
-
nodeServer.headersTimeout = farmServerConfig.headersTimeout;
|
|
945
|
-
nodeServer.requestTimeout = farmServerConfig.requestTimeout;
|
|
946
|
-
nodeServer.keepAliveTimeout = farmServerConfig.keepAliveTimeout;
|
|
947
|
-
|
|
948
|
-
let isShuttingDown = false;
|
|
949
|
-
nodeServer.on("request", (_request, response) => {
|
|
950
|
-
response.once("finish", () => {
|
|
951
|
-
if (isShuttingDown) nodeServer.closeIdleConnections?.();
|
|
952
|
-
});
|
|
953
|
-
});
|
|
954
|
-
|
|
955
|
-
if (import.meta._websocket) {
|
|
956
|
-
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
957
|
-
nodeServer.on("upgrade", (request, socket, head) => {
|
|
958
|
-
handleUpgrade(
|
|
959
|
-
request,
|
|
960
|
-
socket,
|
|
961
|
-
head,
|
|
962
|
-
new NodeRequest({ req: request, upgrade: { socket, head } }),
|
|
963
|
-
);
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
setupCloseHooks(server);
|
|
968
|
-
trapUnhandledErrors();
|
|
969
|
-
|
|
970
|
-
let shutdownPromise;
|
|
971
|
-
async function shutdown(signal) {
|
|
972
|
-
isShuttingDown = true;
|
|
973
|
-
farmProductionLifecycle.beginDrain(signal);
|
|
974
|
-
|
|
975
|
-
const gracefulClose = server.close().then(
|
|
976
|
-
() => true,
|
|
977
|
-
(error) => {
|
|
978
|
-
console.error("[Farm] Runtime shutdown failed:", error);
|
|
979
|
-
process.exitCode = 1;
|
|
980
|
-
return true;
|
|
981
|
-
},
|
|
982
|
-
);
|
|
983
|
-
nodeServer.closeIdleConnections?.();
|
|
984
|
-
let gracefulTimer;
|
|
985
|
-
const gracefullyClosed = await Promise.race([
|
|
986
|
-
gracefulClose,
|
|
987
|
-
new Promise((resolve) => {
|
|
988
|
-
gracefulTimer = setTimeout(() => resolve(false), shutdownConfig.timeout);
|
|
989
|
-
}),
|
|
990
|
-
]);
|
|
991
|
-
clearTimeout(gracefulTimer);
|
|
992
|
-
|
|
993
|
-
if (!gracefullyClosed) {
|
|
994
|
-
console.warn("[Farm] Graceful shutdown timed out; forcing cleanup");
|
|
995
|
-
void server.close(true).catch((error) => {
|
|
996
|
-
console.error("[Farm] Forced server shutdown failed:", error);
|
|
997
|
-
process.exitCode = 1;
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
let forceTimer;
|
|
1001
|
-
const forceClosed = await Promise.race([
|
|
1002
|
-
Promise.resolve()
|
|
1003
|
-
.then(() => farmProductionLifecycle.forceClose("production-server-closed"))
|
|
1004
|
-
.then(
|
|
1005
|
-
() => true,
|
|
1006
|
-
(error) => {
|
|
1007
|
-
console.error("[Farm] Forced runtime shutdown failed:", error);
|
|
1008
|
-
process.exitCode = 1;
|
|
1009
|
-
return true;
|
|
1010
|
-
},
|
|
1011
|
-
),
|
|
1012
|
-
new Promise((resolve) => {
|
|
1013
|
-
forceTimer = setTimeout(() => resolve(false), shutdownConfig.timeout);
|
|
1014
|
-
}),
|
|
1015
|
-
]);
|
|
1016
|
-
clearTimeout(forceTimer);
|
|
1017
|
-
if (!forceClosed) {
|
|
1018
|
-
console.error("[Farm] Forced runtime shutdown timed out");
|
|
1019
|
-
process.exitCode = 1;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
if (shutdownConfig.forceExit) process.exit(process.exitCode || 0);
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
if (!shutdownConfig.disabled) {
|
|
1027
|
-
for (const signal of shutdownConfig.signals) {
|
|
1028
|
-
process.once(signal, (receivedSignal) => {
|
|
1029
|
-
shutdownPromise ||= shutdown(receivedSignal);
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
try {
|
|
1035
|
-
await server.serve();
|
|
1036
|
-
const protocol = cert && key ? "https" : "http";
|
|
1037
|
-
const addressInfo = nodeServer.address();
|
|
1038
|
-
if (typeof addressInfo === "string") {
|
|
1039
|
-
console.log(\`Listening on unix socket \${addressInfo}\`);
|
|
1040
|
-
} else if (addressInfo) {
|
|
1041
|
-
const configuredBaseURL = useRuntimeConfig().app.baseURL || "";
|
|
1042
|
-
const baseURL = configuredBaseURL.endsWith("/")
|
|
1043
|
-
? configuredBaseURL.slice(0, -1)
|
|
1044
|
-
: configuredBaseURL;
|
|
1045
|
-
const address = addressInfo.family === "IPv6"
|
|
1046
|
-
? \`[\${addressInfo.address}]\`
|
|
1047
|
-
: addressInfo.address;
|
|
1048
|
-
console.log(\`Listening on \${protocol}://\${address}:\${addressInfo.port}\${baseURL}\`);
|
|
1049
|
-
}
|
|
1050
|
-
} catch (error) {
|
|
1051
|
-
console.error(error);
|
|
1052
|
-
process.exitCode = 1;
|
|
1053
|
-
await farmProductionLifecycle.close("production-listen-error").catch((closeError) => {
|
|
1054
|
-
console.error("[Farm] Runtime cleanup after listen failure failed:", closeError);
|
|
1055
|
-
});
|
|
1056
|
-
throw error;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
if (import.meta._tasks) {
|
|
1060
|
-
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
export default {};
|
|
1064
|
-
`.trim();
|
|
1065
|
-
}
|
|
1066
|
-
__name(createFarmNodeServerEntry, "createFarmNodeServerEntry");
|
|
1067
|
-
|
|
1068
977
|
// src/nitro/universal-build.ts
|
|
1069
978
|
function preloadFarmNitroBuilder() {
|
|
1070
979
|
return import("nitro/builder").then(
|
|
@@ -1074,18 +983,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1074
983
|
}
|
|
1075
984
|
__name(preloadFarmNitroBuilder, "preloadFarmNitroBuilder");
|
|
1076
985
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1077
|
-
var _dirname =
|
|
986
|
+
var _dirname = path8.dirname(_filename);
|
|
1078
987
|
function findFarmCoreRoot(from) {
|
|
1079
|
-
let dir =
|
|
1080
|
-
while (dir !==
|
|
1081
|
-
const manifest =
|
|
988
|
+
let dir = path8.dirname(from);
|
|
989
|
+
while (dir !== path8.dirname(dir)) {
|
|
990
|
+
const manifest = path8.join(dir, "package.json");
|
|
1082
991
|
if (existsSync2(manifest)) {
|
|
1083
992
|
try {
|
|
1084
993
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1085
994
|
} catch {
|
|
1086
995
|
}
|
|
1087
996
|
}
|
|
1088
|
-
dir =
|
|
997
|
+
dir = path8.dirname(dir);
|
|
1089
998
|
}
|
|
1090
999
|
return null;
|
|
1091
1000
|
}
|
|
@@ -1097,16 +1006,16 @@ function toModulePath(file) {
|
|
|
1097
1006
|
}
|
|
1098
1007
|
__name(toModulePath, "toModulePath");
|
|
1099
1008
|
function findInstalledPackageDir(name, from) {
|
|
1100
|
-
for (let dir = from; ; dir =
|
|
1101
|
-
const candidate =
|
|
1102
|
-
if (existsSync2(
|
|
1009
|
+
for (let dir = from; ; dir = path8.dirname(dir)) {
|
|
1010
|
+
const candidate = path8.join(dir, "node_modules", name);
|
|
1011
|
+
if (existsSync2(path8.join(candidate, "package.json"))) {
|
|
1103
1012
|
try {
|
|
1104
1013
|
return realpathSync(candidate);
|
|
1105
1014
|
} catch {
|
|
1106
1015
|
return null;
|
|
1107
1016
|
}
|
|
1108
1017
|
}
|
|
1109
|
-
if (dir ===
|
|
1018
|
+
if (dir === path8.dirname(dir)) return null;
|
|
1110
1019
|
}
|
|
1111
1020
|
}
|
|
1112
1021
|
__name(findInstalledPackageDir, "findInstalledPackageDir");
|
|
@@ -1118,7 +1027,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1118
1027
|
seen.add(dir);
|
|
1119
1028
|
let manifest;
|
|
1120
1029
|
try {
|
|
1121
|
-
manifest = JSON.parse(readFileSync(
|
|
1030
|
+
manifest = JSON.parse(readFileSync(path8.join(dir, "package.json"), "utf8"));
|
|
1122
1031
|
} catch {
|
|
1123
1032
|
return;
|
|
1124
1033
|
}
|
|
@@ -1129,7 +1038,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1129
1038
|
if (farmCoreRoot) visit(realpathSync(farmCoreRoot));
|
|
1130
1039
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1131
1040
|
try {
|
|
1132
|
-
const manifest = JSON.parse(readFileSync(
|
|
1041
|
+
const manifest = JSON.parse(readFileSync(path8.join(root, "package.json"), "utf8"));
|
|
1133
1042
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1134
1043
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1135
1044
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1196,15 +1105,15 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1196
1105
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1197
1106
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1198
1107
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1199
|
-
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1108
|
+
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(path8.sep).join("/");
|
|
1200
1109
|
}
|
|
1201
1110
|
__name(resolveNitroRuntimeDependency, "resolveNitroRuntimeDependency");
|
|
1202
1111
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1203
|
-
const runtimeDir =
|
|
1112
|
+
const runtimeDir = path8.dirname(resolveNitroPackageEntry(root));
|
|
1204
1113
|
return Object.fromEntries(
|
|
1205
1114
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1206
1115
|
`#nitro/runtime/${moduleName}`,
|
|
1207
|
-
|
|
1116
|
+
path8.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path8.sep).join("/")
|
|
1208
1117
|
])
|
|
1209
1118
|
);
|
|
1210
1119
|
}
|
|
@@ -1215,7 +1124,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1215
1124
|
name: "farm-prerender-runtime-resolver",
|
|
1216
1125
|
async resolveId(id, _importer, options) {
|
|
1217
1126
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1218
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1127
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path8.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1219
1128
|
return null;
|
|
1220
1129
|
}
|
|
1221
1130
|
if (nitroEntry === void 0) {
|
|
@@ -1236,7 +1145,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1236
1145
|
}
|
|
1237
1146
|
__name(createPrerenderRuntimeResolverPlugin, "createPrerenderRuntimeResolverPlugin");
|
|
1238
1147
|
function resolveNitroPackageEntry(root) {
|
|
1239
|
-
const projectRequire = createRequire(
|
|
1148
|
+
const projectRequire = createRequire(path8.join(root, "package.json"));
|
|
1240
1149
|
let runtimeRequire = projectRequire;
|
|
1241
1150
|
try {
|
|
1242
1151
|
runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1311,7 +1220,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1311
1220
|
__name(createFarmReactWebServerAlias, "createFarmReactWebServerAlias");
|
|
1312
1221
|
function hasReactDomEdgeServerBuild(root) {
|
|
1313
1222
|
try {
|
|
1314
|
-
createRequire(
|
|
1223
|
+
createRequire(path8.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1315
1224
|
return true;
|
|
1316
1225
|
} catch {
|
|
1317
1226
|
return false;
|
|
@@ -1369,7 +1278,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
1369
1278
|
return null;
|
|
1370
1279
|
}
|
|
1371
1280
|
const requestPath = source.slice(0, -"?module".length);
|
|
1372
|
-
const resolvedPath =
|
|
1281
|
+
const resolvedPath = path8.isAbsolute(requestPath) ? requestPath : path8.resolve(path8.dirname(importer.split("?", 1)[0]), requestPath);
|
|
1373
1282
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
1374
1283
|
},
|
|
1375
1284
|
load(id) {
|
|
@@ -1395,11 +1304,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1395
1304
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
1396
1305
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
1397
1306
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
1398
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
1307
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path8.posix.normalize(path8.posix.join(path8.posix.dirname(fileName), normalizedImportId)) : null;
|
|
1399
1308
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
1400
1309
|
continue;
|
|
1401
1310
|
}
|
|
1402
|
-
if (
|
|
1311
|
+
if (path8.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
1403
1312
|
externalPackages.add(importId);
|
|
1404
1313
|
continue;
|
|
1405
1314
|
}
|
|
@@ -1412,15 +1321,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1412
1321
|
}
|
|
1413
1322
|
__name(collectSSRExternalPackages, "collectSSRExternalPackages");
|
|
1414
1323
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
1415
|
-
const resolvedNitroEntry =
|
|
1416
|
-
const resolvedSSREntry =
|
|
1324
|
+
const resolvedNitroEntry = path8.resolve(nitroEntryPath);
|
|
1325
|
+
const resolvedSSREntry = path8.resolve(ssrOutputDir, ssrEntryFile);
|
|
1417
1326
|
return {
|
|
1418
1327
|
name: "farm-externalize-prebuilt-ssr",
|
|
1419
1328
|
resolveId(source, importer) {
|
|
1420
|
-
if (!importer ||
|
|
1329
|
+
if (!importer || path8.resolve(importer) !== resolvedNitroEntry) {
|
|
1421
1330
|
return null;
|
|
1422
1331
|
}
|
|
1423
|
-
const resolvedImport =
|
|
1332
|
+
const resolvedImport = path8.resolve(path8.dirname(importer), source);
|
|
1424
1333
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
1425
1334
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
1426
1335
|
}
|
|
@@ -1548,13 +1457,13 @@ function resolveBuildDocsContentDir(config, root) {
|
|
|
1548
1457
|
if (!config.docs?.enabled) return null;
|
|
1549
1458
|
const configuredContentDir = config.docs.contentDir || config.docs.config.contentDir;
|
|
1550
1459
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
1551
|
-
const contentDir =
|
|
1460
|
+
const contentDir = path8.isAbsolute(configuredContentDir) ? configuredContentDir : path8.join(root, configuredContentDir);
|
|
1552
1461
|
return existsSync2(contentDir) ? contentDir : null;
|
|
1553
1462
|
}
|
|
1554
1463
|
const entryDir = config.docs.config.entry || trimSlashes(config.docs.entry) || "docs";
|
|
1555
|
-
const appDocsDir =
|
|
1464
|
+
const appDocsDir = path8.join(root, config.srcDir || "src", "app", entryDir);
|
|
1556
1465
|
if (existsSync2(appDocsDir)) return appDocsDir;
|
|
1557
|
-
const rootDocsDir =
|
|
1466
|
+
const rootDocsDir = path8.join(root, entryDir);
|
|
1558
1467
|
return existsSync2(rootDocsDir) ? rootDocsDir : null;
|
|
1559
1468
|
}
|
|
1560
1469
|
__name(resolveBuildDocsContentDir, "resolveBuildDocsContentDir");
|
|
@@ -1572,7 +1481,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
1572
1481
|
".postcssrc.mjs",
|
|
1573
1482
|
".postcssrc.ts"
|
|
1574
1483
|
];
|
|
1575
|
-
const projectRequire = createRequire(
|
|
1484
|
+
const projectRequire = createRequire(path8.join(root, "package.json"));
|
|
1576
1485
|
return candidates.some((file) => {
|
|
1577
1486
|
try {
|
|
1578
1487
|
projectRequire.resolve(`./${file}`);
|
|
@@ -1584,7 +1493,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
1584
1493
|
}
|
|
1585
1494
|
__name(hasProjectPostcssConfig, "hasProjectPostcssConfig");
|
|
1586
1495
|
async function findFarmConfigPath(root) {
|
|
1587
|
-
const
|
|
1496
|
+
const fs3 = await import("fs/promises");
|
|
1588
1497
|
const candidates = [
|
|
1589
1498
|
"farm.config.ts",
|
|
1590
1499
|
"farm.config.mts",
|
|
@@ -1596,9 +1505,9 @@ async function findFarmConfigPath(root) {
|
|
|
1596
1505
|
"config.mjs"
|
|
1597
1506
|
];
|
|
1598
1507
|
for (const candidate of candidates) {
|
|
1599
|
-
const resolvedPath =
|
|
1508
|
+
const resolvedPath = path8.join(root, candidate);
|
|
1600
1509
|
try {
|
|
1601
|
-
await
|
|
1510
|
+
await fs3.access(resolvedPath);
|
|
1602
1511
|
return resolvedPath;
|
|
1603
1512
|
} catch {
|
|
1604
1513
|
}
|
|
@@ -1606,15 +1515,6 @@ async function findFarmConfigPath(root) {
|
|
|
1606
1515
|
return null;
|
|
1607
1516
|
}
|
|
1608
1517
|
__name(findFarmConfigPath, "findFarmConfigPath");
|
|
1609
|
-
function hasFarmMiddlewareConfig(config) {
|
|
1610
|
-
if (!config) return false;
|
|
1611
|
-
if (Array.isArray(config)) return config.length > 0;
|
|
1612
|
-
const configRecord = config;
|
|
1613
|
-
return Boolean(
|
|
1614
|
-
configRecord.matcher || configRecord.exclude || configRecord.runtime || configRecord.handler || Array.isArray(configRecord.handlers) && configRecord.handlers.length > 0
|
|
1615
|
-
);
|
|
1616
|
-
}
|
|
1617
|
-
__name(hasFarmMiddlewareConfig, "hasFarmMiddlewareConfig");
|
|
1618
1518
|
function hasFarmServerRuntimePlugins(config) {
|
|
1619
1519
|
return (config.plugins || []).some((plugin) => {
|
|
1620
1520
|
if (getFarmIntegrationPluginServerRuntime(plugin) === false) return false;
|
|
@@ -1635,13 +1535,13 @@ function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
|
1635
1535
|
}
|
|
1636
1536
|
__name(farmServerRuntimePluginsMayHandlePath, "farmServerRuntimePluginsMayHandlePath");
|
|
1637
1537
|
async function discoverMiddlewareRoutes(appDir) {
|
|
1638
|
-
const
|
|
1538
|
+
const fs3 = await import("fs/promises");
|
|
1639
1539
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
1640
1540
|
const routes = /* @__PURE__ */ new Map();
|
|
1641
1541
|
async function walk(dir, routePath, directory, discovered) {
|
|
1642
1542
|
let entries;
|
|
1643
1543
|
try {
|
|
1644
|
-
entries = await
|
|
1544
|
+
entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
1645
1545
|
} catch {
|
|
1646
1546
|
return;
|
|
1647
1547
|
}
|
|
@@ -1652,7 +1552,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1652
1552
|
discovered.push({
|
|
1653
1553
|
path: routePath,
|
|
1654
1554
|
directory,
|
|
1655
|
-
filePath:
|
|
1555
|
+
filePath: path8.join(dir, middlewareFile.name)
|
|
1656
1556
|
});
|
|
1657
1557
|
}
|
|
1658
1558
|
for (const entry of entries) {
|
|
@@ -1660,7 +1560,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1660
1560
|
continue;
|
|
1661
1561
|
}
|
|
1662
1562
|
await walk(
|
|
1663
|
-
|
|
1563
|
+
path8.join(dir, entry.name),
|
|
1664
1564
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
1665
1565
|
appendMiddlewareDirectory(directory, entry.name),
|
|
1666
1566
|
discovered
|
|
@@ -1737,21 +1637,21 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1737
1637
|
})
|
|
1738
1638
|
);
|
|
1739
1639
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
1740
|
-
const
|
|
1640
|
+
const fs3 = await import("fs/promises");
|
|
1741
1641
|
const layoutRoutes = [];
|
|
1742
|
-
const appDir =
|
|
1642
|
+
const appDir = path8.join(root, srcDir, "app");
|
|
1743
1643
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
1744
1644
|
try {
|
|
1745
|
-
const entries = await
|
|
1645
|
+
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
1746
1646
|
for (const entry of entries) {
|
|
1747
1647
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
1748
1648
|
layoutRoutes.push({
|
|
1749
1649
|
pattern: routePrefix,
|
|
1750
|
-
modulePath:
|
|
1650
|
+
modulePath: path8.join(dir, entry.name)
|
|
1751
1651
|
});
|
|
1752
1652
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
1753
1653
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
1754
|
-
await findLayoutsForClient(
|
|
1654
|
+
await findLayoutsForClient(path8.join(dir, entry.name), childPrefix);
|
|
1755
1655
|
}
|
|
1756
1656
|
}
|
|
1757
1657
|
} catch {
|
|
@@ -1768,7 +1668,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1768
1668
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
|
|
1769
1669
|
const isolatedClientBoundaryModules = routeManager.getIsolatedClientBoundaryModules(root);
|
|
1770
1670
|
const hydrationPlanCache = /* @__PURE__ */ new Map();
|
|
1771
|
-
const clientOutputDir =
|
|
1671
|
+
const clientOutputDir = path8.join(root, distDir, "client");
|
|
1772
1672
|
const [productionViteResult] = await productionViteResultPromise;
|
|
1773
1673
|
if (productionViteResult.status === "rejected") {
|
|
1774
1674
|
await routeRuntimeManifestResultPromise;
|
|
@@ -1877,10 +1777,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1877
1777
|
lifecyclePluginManager
|
|
1878
1778
|
);
|
|
1879
1779
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
1880
|
-
|
|
1780
|
+
path8.join(root, distDir),
|
|
1881
1781
|
routeRuntimeManifest
|
|
1882
1782
|
);
|
|
1883
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
1783
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path8.relative(root, runtimeManifestPath)}`);
|
|
1884
1784
|
} catch (error) {
|
|
1885
1785
|
if (lifecyclePluginManager) {
|
|
1886
1786
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -1900,50 +1800,50 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1900
1800
|
}
|
|
1901
1801
|
__name(buildUniversal, "buildUniversal");
|
|
1902
1802
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
1903
|
-
const
|
|
1803
|
+
const fs3 = await import("fs/promises");
|
|
1904
1804
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1905
1805
|
if (output.type !== "asset") continue;
|
|
1906
1806
|
if (fileName === "farm-fonts.css") {
|
|
1907
1807
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
1908
1808
|
continue;
|
|
1909
1809
|
}
|
|
1910
|
-
const filePath =
|
|
1911
|
-
await
|
|
1912
|
-
await
|
|
1810
|
+
const filePath = path8.join(outputDir, fileName);
|
|
1811
|
+
await fs3.mkdir(path8.dirname(filePath), { recursive: true });
|
|
1812
|
+
await fs3.writeFile(filePath, output.source);
|
|
1913
1813
|
}
|
|
1914
1814
|
}
|
|
1915
1815
|
__name(writeSSRAssetsToClient, "writeSSRAssetsToClient");
|
|
1916
1816
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
1917
|
-
const
|
|
1817
|
+
const fs3 = await import("fs/promises");
|
|
1918
1818
|
await Promise.all(
|
|
1919
1819
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
1920
|
-
const targetPath =
|
|
1921
|
-
await
|
|
1922
|
-
await
|
|
1820
|
+
const targetPath = path8.join(outputDir, url.replace(/^\/+/, ""));
|
|
1821
|
+
await fs3.mkdir(path8.dirname(targetPath), { recursive: true });
|
|
1822
|
+
await fs3.copyFile(sourcePath, targetPath);
|
|
1923
1823
|
})
|
|
1924
1824
|
);
|
|
1925
1825
|
}
|
|
1926
1826
|
__name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
|
|
1927
1827
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
1928
|
-
const
|
|
1929
|
-
const fontCssPath =
|
|
1828
|
+
const fs3 = await import("fs/promises");
|
|
1829
|
+
const fontCssPath = path8.join(outputDir, "farm-fonts.css");
|
|
1930
1830
|
let fontCss = fontCssSource;
|
|
1931
1831
|
if (fontCss === void 0) {
|
|
1932
1832
|
try {
|
|
1933
|
-
fontCss = await
|
|
1833
|
+
fontCss = await fs3.readFile(fontCssPath);
|
|
1934
1834
|
} catch {
|
|
1935
1835
|
return;
|
|
1936
1836
|
}
|
|
1937
1837
|
}
|
|
1938
|
-
const clientCssPath =
|
|
1838
|
+
const clientCssPath = path8.join(outputDir, "farm-client.css");
|
|
1939
1839
|
let clientCss = "";
|
|
1940
1840
|
try {
|
|
1941
|
-
clientCss = await
|
|
1841
|
+
clientCss = await fs3.readFile(clientCssPath, "utf8");
|
|
1942
1842
|
} catch {
|
|
1943
1843
|
}
|
|
1944
1844
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
1945
|
-
await
|
|
1946
|
-
await
|
|
1845
|
+
await fs3.writeFile(fontCssPath, normalizedFontCss);
|
|
1846
|
+
await fs3.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
|
|
1947
1847
|
}
|
|
1948
1848
|
__name(mergeBuiltFontCss, "mergeBuiltFontCss");
|
|
1949
1849
|
var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
|
|
@@ -1955,28 +1855,28 @@ var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError
|
|
|
1955
1855
|
__name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
|
|
1956
1856
|
var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
|
|
1957
1857
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
1958
|
-
const
|
|
1858
|
+
const fs3 = await import("fs/promises");
|
|
1959
1859
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
1960
|
-
const clientEntryPath =
|
|
1860
|
+
const clientEntryPath = path8.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
1961
1861
|
let clientEntrySize = 0;
|
|
1962
1862
|
try {
|
|
1963
|
-
const clientEntry = await
|
|
1863
|
+
const clientEntry = await fs3.stat(clientEntryPath);
|
|
1964
1864
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
1965
1865
|
} catch {
|
|
1966
1866
|
}
|
|
1967
1867
|
if (clientEntrySize === 0) {
|
|
1968
1868
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
1969
1869
|
}
|
|
1970
|
-
const clientCssPath =
|
|
1971
|
-
const globalsCssPath =
|
|
1870
|
+
const clientCssPath = path8.join(outputDir, "farm-client.css");
|
|
1871
|
+
const globalsCssPath = path8.join(root, srcDir, "app", "globals.css");
|
|
1972
1872
|
let expectsCss = false;
|
|
1973
1873
|
try {
|
|
1974
|
-
const globalsCss = await
|
|
1874
|
+
const globalsCss = await fs3.readFile(globalsCssPath, "utf8");
|
|
1975
1875
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1976
1876
|
} catch {
|
|
1977
1877
|
}
|
|
1978
1878
|
try {
|
|
1979
|
-
const clientCss = await
|
|
1879
|
+
const clientCss = await fs3.stat(clientCssPath);
|
|
1980
1880
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
1981
1881
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
1982
1882
|
}
|
|
@@ -1985,12 +1885,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
1985
1885
|
if (expectsCss) {
|
|
1986
1886
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
1987
1887
|
}
|
|
1988
|
-
await
|
|
1888
|
+
await fs3.writeFile(clientCssPath, "");
|
|
1989
1889
|
}
|
|
1990
1890
|
}
|
|
1991
1891
|
__name(validateClientBuildOutput, "validateClientBuildOutput");
|
|
1992
1892
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
1993
|
-
const key = `${
|
|
1893
|
+
const key = `${path8.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${path8.resolve(modulePath)}`;
|
|
1994
1894
|
let plan = cache.get(key);
|
|
1995
1895
|
if (!plan) {
|
|
1996
1896
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2003,7 +1903,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2003
1903
|
const viteBuild = productionVite.build;
|
|
2004
1904
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2005
1905
|
const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
|
|
2006
|
-
const
|
|
1906
|
+
const fs3 = await import("fs/promises");
|
|
2007
1907
|
const pluginManager = new PluginManager2({
|
|
2008
1908
|
config,
|
|
2009
1909
|
isDev: false,
|
|
@@ -2229,10 +2129,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2229
2129
|
logger.info(
|
|
2230
2130
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2231
2131
|
);
|
|
2232
|
-
const clientEntryRoot =
|
|
2233
|
-
await
|
|
2234
|
-
const clientEntryDir = await
|
|
2235
|
-
const clientEntryPath =
|
|
2132
|
+
const clientEntryRoot = path8.join(root, ".farm", "tmp");
|
|
2133
|
+
await fs3.mkdir(clientEntryRoot, { recursive: true });
|
|
2134
|
+
const clientEntryDir = await fs3.mkdtemp(path8.join(clientEntryRoot, "client-entry-"));
|
|
2135
|
+
const clientEntryPath = path8.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2236
2136
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2237
2137
|
clientPages,
|
|
2238
2138
|
clientLayouts,
|
|
@@ -2253,7 +2153,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2253
2153
|
generateClientCachePersistenceCode(resolveFarmClientCacheAdapterEntry(root, config.cache)),
|
|
2254
2154
|
adapterOwnsDocsRuntime ? getFarmDocsAdapterConfigModule(config.docs) : void 0
|
|
2255
2155
|
);
|
|
2256
|
-
await
|
|
2156
|
+
await fs3.writeFile(clientEntryPath, clientHydrationCode);
|
|
2257
2157
|
const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
|
|
2258
2158
|
let postcssSearchPath;
|
|
2259
2159
|
let tailwindVitePlugin = void 0;
|
|
@@ -2264,8 +2164,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2264
2164
|
if (hasScopedPostcssConfig) {
|
|
2265
2165
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
2266
2166
|
} else {
|
|
2267
|
-
const postcssConfigPath =
|
|
2268
|
-
await
|
|
2167
|
+
const postcssConfigPath = path8.join(clientEntryDir, "postcss.config.cjs");
|
|
2168
|
+
await fs3.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2269
2169
|
postcssSearchPath = clientEntryDir;
|
|
2270
2170
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
2271
2171
|
builder: productionVite.builder,
|
|
@@ -2337,6 +2237,23 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2337
2237
|
},
|
|
2338
2238
|
plugins: [
|
|
2339
2239
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
2240
|
+
createFarmClientModulePreloadPlugin({
|
|
2241
|
+
root,
|
|
2242
|
+
buildDir: path8.dirname(outputDir),
|
|
2243
|
+
entryName: "farm-client"
|
|
2244
|
+
}),
|
|
2245
|
+
...adapterOwnsDocsRuntime ? [
|
|
2246
|
+
createFarmDocsModulePreloadPlugin({
|
|
2247
|
+
root,
|
|
2248
|
+
buildDir: path8.dirname(outputDir),
|
|
2249
|
+
importer: clientEntryPath,
|
|
2250
|
+
entryName: "farm-client",
|
|
2251
|
+
modules: [
|
|
2252
|
+
config.docs.adapter.react,
|
|
2253
|
+
getFarmDocsAdapterConfigModule(config.docs)
|
|
2254
|
+
].filter((specifier) => Boolean(specifier))
|
|
2255
|
+
})
|
|
2256
|
+
] : [],
|
|
2340
2257
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
2341
2258
|
...rendererVitePlugins,
|
|
2342
2259
|
...config.vite.plugins || [],
|
|
@@ -2418,7 +2335,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2418
2335
|
await validateClientBuildOutput(root, srcDir, outputDir);
|
|
2419
2336
|
} finally {
|
|
2420
2337
|
try {
|
|
2421
|
-
await
|
|
2338
|
+
await fs3.rm(clientEntryDir, { recursive: true, force: true });
|
|
2422
2339
|
} catch {
|
|
2423
2340
|
}
|
|
2424
2341
|
}
|
|
@@ -2426,12 +2343,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2426
2343
|
__name(buildClient, "buildClient");
|
|
2427
2344
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
2428
2345
|
if (!filePath) return "";
|
|
2429
|
-
if (!
|
|
2430
|
-
const relative =
|
|
2431
|
-
if (!relative || relative.startsWith("..") ||
|
|
2432
|
-
return
|
|
2346
|
+
if (!path8.isAbsolute(filePath)) return filePath.split(path8.sep).join("/");
|
|
2347
|
+
const relative = path8.relative(root, filePath);
|
|
2348
|
+
if (!relative || relative.startsWith("..") || path8.isAbsolute(relative)) {
|
|
2349
|
+
return path8.basename(filePath);
|
|
2433
2350
|
}
|
|
2434
|
-
return relative.split(
|
|
2351
|
+
return relative.split(path8.sep).join("/");
|
|
2435
2352
|
}
|
|
2436
2353
|
__name(toBakedMarkdownSourcePath, "toBakedMarkdownSourcePath");
|
|
2437
2354
|
function generateUniversalRouterStateRuntime() {
|
|
@@ -3188,7 +3105,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
3188
3105
|
root,
|
|
3189
3106
|
renderer.componentExtensions ?? []
|
|
3190
3107
|
);
|
|
3191
|
-
const globalsCssPath =
|
|
3108
|
+
const globalsCssPath = path8.join(root, srcDir, "app", "globals.css");
|
|
3192
3109
|
const cssImport = existsSync2(globalsCssPath) ? `import ${JSON.stringify(toImportPath(globalsCssPath))};` : "";
|
|
3193
3110
|
const layoutImportStatements = [];
|
|
3194
3111
|
const layoutRegistrations = [];
|
|
@@ -4662,7 +4579,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4662
4579
|
const viteBuild = productionVite.build;
|
|
4663
4580
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
4664
4581
|
const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
|
|
4665
|
-
const
|
|
4582
|
+
const fs3 = await import("fs/promises");
|
|
4666
4583
|
const pluginManager = new PluginManager2({
|
|
4667
4584
|
config,
|
|
4668
4585
|
isDev: false,
|
|
@@ -4677,9 +4594,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4677
4594
|
buildLifetime: rendererBuildLifetime
|
|
4678
4595
|
});
|
|
4679
4596
|
if (!hasScopedPostcssConfig) {
|
|
4680
|
-
postcssConfigDir = await
|
|
4681
|
-
await
|
|
4682
|
-
|
|
4597
|
+
postcssConfigDir = await fs3.mkdtemp(path8.join(os.tmpdir(), "farm-postcss-"));
|
|
4598
|
+
await fs3.writeFile(
|
|
4599
|
+
path8.join(postcssConfigDir, "postcss.config.cjs"),
|
|
4683
4600
|
"module.exports = { plugins: [] };\n"
|
|
4684
4601
|
);
|
|
4685
4602
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -4704,7 +4621,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4704
4621
|
fileName: entry.fileName,
|
|
4705
4622
|
sourceType: "static",
|
|
4706
4623
|
staticInfo: entry.staticInfo,
|
|
4707
|
-
data: (await
|
|
4624
|
+
data: (await fs3.readFile(entry.modulePath)).toString("base64")
|
|
4708
4625
|
});
|
|
4709
4626
|
continue;
|
|
4710
4627
|
}
|
|
@@ -4811,20 +4728,39 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4811
4728
|
const hasConfiguredRuntimePlugins = Boolean(
|
|
4812
4729
|
hasRuntimeConfigModule && (config.plugins || []).length > 0
|
|
4813
4730
|
);
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4731
|
+
if (hasFarmDocsRuntimeAdapter(config.docs)) {
|
|
4732
|
+
const adapterGuardedPaths = new Set(getFarmDocsGuardedPaths(config, middlewareRoutes));
|
|
4733
|
+
assertFarmDocsAdapterServesNoGuardedPages(
|
|
4734
|
+
config.docs,
|
|
4735
|
+
{ root, srcDir: config.srcDir },
|
|
4736
|
+
(pathname) => adapterGuardedPaths.has(pathname)
|
|
4737
|
+
);
|
|
4738
|
+
}
|
|
4739
|
+
const farmDocsCspNonceMarker = createFarmCspNonce(config.security);
|
|
4740
|
+
const farmDocsPrecompiledManifest = config.docs?.enabled && getFarmPresetRuntime(preset) === "edge" ? await _runWithFarmCspNonce(
|
|
4741
|
+
farmDocsCspNonceMarker,
|
|
4742
|
+
async () => config.docs.adapter?.server ? await compileFarmDocsAdapterEdgeManifest(config.docs, {
|
|
4743
|
+
root,
|
|
4744
|
+
srcDir: config.srcDir,
|
|
4745
|
+
clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
|
|
4746
|
+
fontStylesheetHref: "/farm-fonts.css",
|
|
4747
|
+
globalStylesheetHref: "/assets/globals.css"
|
|
4748
|
+
}) : await (async () => {
|
|
4749
|
+
const guardedPaths = new Set(getFarmDocsGuardedPaths(config, middlewareRoutes));
|
|
4750
|
+
return compileFarmDocsManifest(config.docs, {
|
|
4751
|
+
root,
|
|
4752
|
+
srcDir: config.srcDir,
|
|
4753
|
+
clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
|
|
4754
|
+
fontAssets: toFarmDocsPublicFontAssets(resolveFarmDocsFontAssets(root)),
|
|
4755
|
+
fontStylesheetHref: "/farm-fonts.css",
|
|
4756
|
+
globalStylesheetHref: "/assets/globals.css",
|
|
4757
|
+
isPathGuarded: /* @__PURE__ */ __name((pathname) => guardedPaths.has(pathname), "isPathGuarded")
|
|
4758
|
+
});
|
|
4759
|
+
})()
|
|
4760
|
+
) : null;
|
|
4761
|
+
if (farmDocsPrecompiledManifest && farmDocsCspNonceMarker) {
|
|
4762
|
+
farmDocsPrecompiledManifest.cspNonceMarker = farmDocsCspNonceMarker;
|
|
4763
|
+
}
|
|
4828
4764
|
const virtualEntryCode = generateVirtualEntryCode(
|
|
4829
4765
|
apiRoutes,
|
|
4830
4766
|
pageRoutes,
|
|
@@ -5020,7 +4956,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5020
4956
|
} finally {
|
|
5021
4957
|
if (postcssConfigDir) {
|
|
5022
4958
|
try {
|
|
5023
|
-
await
|
|
4959
|
+
await fs3.rm(postcssConfigDir, { recursive: true, force: true });
|
|
5024
4960
|
} catch {
|
|
5025
4961
|
}
|
|
5026
4962
|
}
|
|
@@ -5034,7 +4970,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5034
4970
|
__name(buildSSRInMemory, "buildSSRInMemory");
|
|
5035
4971
|
function readFarmAppPackageIdentity(root) {
|
|
5036
4972
|
try {
|
|
5037
|
-
return JSON.parse(readFileSync(
|
|
4973
|
+
return JSON.parse(readFileSync(path8.join(root, "package.json"), "utf8"));
|
|
5038
4974
|
} catch {
|
|
5039
4975
|
return {};
|
|
5040
4976
|
}
|
|
@@ -5054,6 +4990,19 @@ function readFarmPageLastModified(pageRoutes) {
|
|
|
5054
4990
|
return lastModified;
|
|
5055
4991
|
}
|
|
5056
4992
|
__name(readFarmPageLastModified, "readFarmPageLastModified");
|
|
4993
|
+
function getFarmDocsGuardedPaths(config, middlewareRoutes) {
|
|
4994
|
+
if (!config.docs?.enabled) return [];
|
|
4995
|
+
const contentDir = resolveFarmDocsContentDir(config.docs, {
|
|
4996
|
+
root: config.root,
|
|
4997
|
+
srcDir: config.srcDir
|
|
4998
|
+
});
|
|
4999
|
+
const guards = {
|
|
5000
|
+
config: { middleware: config.middleware, integrations: config.integrations },
|
|
5001
|
+
middlewareRoutes
|
|
5002
|
+
};
|
|
5003
|
+
return discoverFarmDocsPages(contentDir, config.docs).flatMap((page) => [page.href, getFarmDocsMarkdownPath(page.href)]).filter((pathname) => farmPathGuardCoversPage(guards, pathname));
|
|
5004
|
+
}
|
|
5005
|
+
__name(getFarmDocsGuardedPaths, "getFarmDocsGuardedPaths");
|
|
5057
5006
|
function getFarmAppOwnedDocsEnginePaths(agent, applicationMetadataRoutes) {
|
|
5058
5007
|
const llmsTxt = agent?.llmsTxt;
|
|
5059
5008
|
const ownedByFile = /* @__PURE__ */ __name((kind) => applicationMetadataRoutes.some(
|
|
@@ -5602,7 +5551,8 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5602
5551
|
pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
|
|
5603
5552
|
directory: ${JSON.stringify(route.directory)},` : ""}
|
|
5604
5553
|
module: ${varName},
|
|
5605
|
-
shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)}
|
|
5554
|
+
shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)},${clientMetadata.shouldHydrate ? `
|
|
5555
|
+
clientModule: ${JSON.stringify(toViteModuleId(route.modulePath, config.root))},` : ""}
|
|
5606
5556
|
islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${usesFarmServerTree(clientMetadata) ? "\n serverTree: true," : ""}${renderingDirective ? `
|
|
5607
5557
|
rendering: ${JSON.stringify(renderingDirective)},` : ""}
|
|
5608
5558
|
${route.source !== void 0 ? `markdownSource: {
|
|
@@ -5723,7 +5673,9 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5723
5673
|
const productionRuntimeImport = `import {
|
|
5724
5674
|
_getRequestReadCount,
|
|
5725
5675
|
_runWithAfterRequest,
|
|
5676
|
+
_resolveCurrentCspNonce,
|
|
5726
5677
|
_runWithCurrentRequest,
|
|
5678
|
+
_runWithFarmCspNonce,
|
|
5727
5679
|
_runWithAPIRequestRuntime,
|
|
5728
5680
|
_runWithMiddlewareContext,
|
|
5729
5681
|
_runWithMiddlewareData,
|
|
@@ -5733,6 +5685,8 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5733
5685
|
appendFarmRedirectQuery,
|
|
5734
5686
|
applyFarmBasePath,
|
|
5735
5687
|
applyFarmCspNonceToResponse,
|
|
5688
|
+
createFarmCspNonce,
|
|
5689
|
+
stampFarmCspNonce,
|
|
5736
5690
|
applyFarmPreviewRobotsTag,
|
|
5737
5691
|
applyFarmThemeDocument,
|
|
5738
5692
|
appendFarmLinkHeader,
|
|
@@ -5754,6 +5708,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5754
5708
|
createFarmAiCatalogResponse,
|
|
5755
5709
|
createFarmApiCatalogResponse,
|
|
5756
5710
|
createFarmAppManifestResponse,
|
|
5711
|
+
farmPathGuardCoversEndpoint,
|
|
5757
5712
|
collectFarmLlmsTxtPages,
|
|
5758
5713
|
createFarmDefaultLlmsTxt,
|
|
5759
5714
|
createFarmLlmsMarkdownReader,
|
|
@@ -5828,8 +5783,8 @@ import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
|
|
|
5828
5783
|
import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
5829
5784
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
5830
5785
|
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;";
|
|
5831
|
-
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5832
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
5786
|
+
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5787
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path8.isAbsolute(config.mdx.components) ? config.mdx.components : path8.join(config.root, config.mdx.components) : null;
|
|
5833
5788
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
5834
5789
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
5835
5790
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -6233,12 +6188,41 @@ const farmDocsBundledContentDir = ${config.docs?.enabled && !hasPrecompiledDocs
|
|
|
6233
6188
|
})()` : "null"};
|
|
6234
6189
|
const farmDocsResolvedConfig = ${generateFarmDocsRuntimeConfigExpression(config.docs, hasPrecompiledDocs)};
|
|
6235
6190
|
const farmDocsRuntimeRoot = ${hasPrecompiledDocs ? '"."' : `farmDocsBundledContentDir || ${JSON.stringify(config.root)}`};
|
|
6191
|
+
// Docs pages a path-specific guard covers, decided at build time. The docs API and the
|
|
6192
|
+
// root llms/sitemap files answer anyone, so they leave these pages out.
|
|
6193
|
+
const farmDocsGuardedPaths = ${JSON.stringify(
|
|
6194
|
+
hasPrecompiledDocs ? [] : getFarmDocsGuardedPaths(config, middlewareRoutes)
|
|
6195
|
+
)};
|
|
6196
|
+
const farmDocsGuardedPathSet = new Set(farmDocsGuardedPaths);
|
|
6197
|
+
const isFarmDocsPathGuarded = (pathname) => farmDocsGuardedPathSet.has(pathname);
|
|
6236
6198
|
globalThis.__FARM_DOCS_RUNTIME_CONFIG__ = {
|
|
6237
6199
|
root: farmDocsRuntimeRoot,
|
|
6238
6200
|
srcDir: ${JSON.stringify(config.srcDir)},
|
|
6239
6201
|
docs: farmDocsResolvedConfig,
|
|
6202
|
+
guardedPaths: farmDocsGuardedPaths,
|
|
6240
6203
|
};
|
|
6241
6204
|
const farmDocsPrecompiledRuntime = ${hasPrecompiledDocs ? `createFarmDocsPrecompiledRuntime(${JSON.stringify(farmDocsPrecompiledManifest)})` : "null"};
|
|
6205
|
+
// Filled in from the client build once it has finished (see buildNitroUniversal).
|
|
6206
|
+
const farmDocsModulePreloads = (() => {
|
|
6207
|
+
try {
|
|
6208
|
+
return JSON.parse("${FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER}");
|
|
6209
|
+
} catch {
|
|
6210
|
+
return null;
|
|
6211
|
+
}
|
|
6212
|
+
})();
|
|
6213
|
+
// Paths the adapter matches against a page's source path the way the browser
|
|
6214
|
+
// finds the page's module.
|
|
6215
|
+
const farmDocsModulePreloadPaths = farmDocsModulePreloads
|
|
6216
|
+
? {
|
|
6217
|
+
runtime: farmDocsModulePreloads.runtime.map((index) => "/" + farmDocsModulePreloads.files[index]),
|
|
6218
|
+
pages: Object.fromEntries(
|
|
6219
|
+
Object.entries(farmDocsModulePreloads.pages).map(([sourcePath, indexes]) => [
|
|
6220
|
+
sourcePath,
|
|
6221
|
+
indexes.map((index) => "/" + farmDocsModulePreloads.files[index]),
|
|
6222
|
+
]),
|
|
6223
|
+
),
|
|
6224
|
+
}
|
|
6225
|
+
: undefined;
|
|
6242
6226
|
const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `createFarmDocsAdapterRuntimeHandler({
|
|
6243
6227
|
${docsConfigModulePath ? "...(farmDocsConfigModule.default || farmDocsConfigModule),\n ...farmDocsResolvedConfig.configOverrides," : "...farmDocsResolvedConfig.config,"}
|
|
6244
6228
|
entry: farmDocsResolvedConfig.config?.entry || String(farmDocsResolvedConfig.entry || "/docs").replace(/^\\/+|\\/+$/g, "") || "docs",
|
|
@@ -6249,6 +6233,9 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
|
|
|
6249
6233
|
// A production build's content cannot change, so the adapter reads its
|
|
6250
6234
|
// navigation once instead of scanning the content directory per request.
|
|
6251
6235
|
immutableContent: true,
|
|
6236
|
+
// List the chunks a page needs, so the browser fetches them alongside the
|
|
6237
|
+
// client entry instead of discovering them one import at a time.
|
|
6238
|
+
modulePreloads: farmDocsModulePreloadPaths,
|
|
6252
6239
|
clientEntry: "/__farm_client_js_src__",
|
|
6253
6240
|
// Font CSS is merged into the client stylesheet; farm-fonts.css only exists when the
|
|
6254
6241
|
// app has fonts, so linking it separately 404'd for apps without them.
|
|
@@ -6271,12 +6258,13 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
|
|
|
6271
6258
|
),
|
|
6272
6259
|
fontStylesheetHref: "/farm-fonts.css",
|
|
6273
6260
|
globalStylesheetHref: "/assets/globals.css",
|
|
6261
|
+
isPathGuarded: isFarmDocsPathGuarded,
|
|
6274
6262
|
})` : "null"};
|
|
6275
|
-
const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig })` : "null"};
|
|
6263
|
+
const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded })` : "null"};
|
|
6276
6264
|
|
|
6277
6265
|
// API routes bundled at build time
|
|
6278
6266
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
6279
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
6267
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path10, methods }) => ({ path: path10, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
6280
6268
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
6281
6269
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
6282
6270
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -6305,7 +6293,17 @@ ${config.agent?.apiCatalog ? `const farmApiCatalogInput = ${JSON.stringify(resol
|
|
|
6305
6293
|
webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? collectFarmWebMCPTools(config.root, config.srcDir) : []
|
|
6306
6294
|
})
|
|
6307
6295
|
)};
|
|
6308
|
-
${servesDefaultMCP ? "farmAppManifestInput.defaultMCP = getFarmDefaultMCPServer;\n" : ""}
|
|
6296
|
+
${servesDefaultMCP ? "farmAppManifestInput.defaultMCP = getFarmDefaultMCPServer;\n" : ""}// A guard written for an MCP server's path keeps its tools out of the public view.
|
|
6297
|
+
farmAppManifestInput.guardCoversPath = (path) =>
|
|
6298
|
+
farmPathGuardCoversEndpoint(
|
|
6299
|
+
{
|
|
6300
|
+
config: { middleware: farmMiddlewareConfig, integrations: serverRuntimeIntegrations },
|
|
6301
|
+
middlewareRoutes: fileMiddlewareModules,
|
|
6302
|
+
},
|
|
6303
|
+
path,
|
|
6304
|
+
farmLocalAPIBasePath,
|
|
6305
|
+
);
|
|
6306
|
+
` : ""}
|
|
6309
6307
|
function isFarmLocalAPIPathname(pathname) {
|
|
6310
6308
|
return farmLocalAPIBasePath !== "/" &&
|
|
6311
6309
|
(pathname === farmLocalAPIBasePath ||
|
|
@@ -6405,15 +6403,26 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
6405
6403
|
}
|
|
6406
6404
|
return '<script id="__farm_route_slots_data__" type="application/json">' +
|
|
6407
6405
|
serializedRouteSlots +
|
|
6408
|
-
'</script
|
|
6406
|
+
'</script>' + stampFarmCspNonce('<script>' + source + '</script>');
|
|
6409
6407
|
}
|
|
6410
6408
|
|
|
6411
6409
|
function renderFarmRendererHydrationScript() {
|
|
6412
6410
|
return typeof ReactDOMServer.generateHydrationScript === "function"
|
|
6413
|
-
? ReactDOMServer.generateHydrationScript()
|
|
6411
|
+
? stampFarmCspNonce(ReactDOMServer.generateHydrationScript())
|
|
6414
6412
|
: "";
|
|
6415
6413
|
}
|
|
6416
6414
|
|
|
6415
|
+
function renderFarmClientEntryScript() {
|
|
6416
|
+
return stampFarmCspNonce('<script type="module" src="/__farm_client_js_src__"></script>');
|
|
6417
|
+
}
|
|
6418
|
+
|
|
6419
|
+
// Renderer options for the response being rendered: its CSP nonce, which the
|
|
6420
|
+
// renderer puts on the inline scripts it emits.
|
|
6421
|
+
function getFarmRendererRenderOptions() {
|
|
6422
|
+
const nonce = _resolveCurrentCspNonce();
|
|
6423
|
+
return nonce ? { nonce } : undefined;
|
|
6424
|
+
}
|
|
6425
|
+
|
|
6417
6426
|
function escapeFarmHtmlAttribute(value) {
|
|
6418
6427
|
return String(value)
|
|
6419
6428
|
.replace(/&/g, "&")
|
|
@@ -6455,6 +6464,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6455
6464
|
if (farmRendererStreamingCapabilities.web &&
|
|
6456
6465
|
typeof ReactDOMServer.renderToReadableStream === "function") {
|
|
6457
6466
|
const stream = await ReactDOMServer.renderToReadableStream(element, {
|
|
6467
|
+
nonce: _resolveCurrentCspNonce(),
|
|
6458
6468
|
onError(error) {
|
|
6459
6469
|
// redirect()/notFound() are control flow, not render failures: the
|
|
6460
6470
|
// request handler must still receive them to map the response status,
|
|
@@ -6587,6 +6597,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6587
6597
|
},
|
|
6588
6598
|
};
|
|
6589
6599
|
pipeableStream = ReactDOMServer.renderToPipeableStream(element, {
|
|
6600
|
+
nonce: _resolveCurrentCspNonce(),
|
|
6590
6601
|
onShellReady() {
|
|
6591
6602
|
try {
|
|
6592
6603
|
pipeableStream.pipe(destination);
|
|
@@ -6649,7 +6660,10 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6649
6660
|
}
|
|
6650
6661
|
|
|
6651
6662
|
if (ReactDOMServer.renderToStringWithHead) {
|
|
6652
|
-
const rendered = await ReactDOMServer.renderToStringWithHead(
|
|
6663
|
+
const rendered = await ReactDOMServer.renderToStringWithHead(
|
|
6664
|
+
element,
|
|
6665
|
+
getFarmRendererRenderOptions(),
|
|
6666
|
+
);
|
|
6653
6667
|
return {
|
|
6654
6668
|
html: rendered.html,
|
|
6655
6669
|
head: rendered.head || "",
|
|
@@ -6657,7 +6671,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
|
6657
6671
|
streamErrors,
|
|
6658
6672
|
};
|
|
6659
6673
|
}
|
|
6660
|
-
const html = await ReactDOMServer.renderToString(element);
|
|
6674
|
+
const html = await ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
|
|
6661
6675
|
return { html, head: "", shellHtml: html, streamErrors };
|
|
6662
6676
|
}
|
|
6663
6677
|
|
|
@@ -6696,7 +6710,7 @@ function renderFarmElementSync(ReactDOMServer, element, routeKey) {
|
|
|
6696
6710
|
if (typeof ReactDOMServer.renderToString !== "function") return undefined;
|
|
6697
6711
|
let html;
|
|
6698
6712
|
try {
|
|
6699
|
-
html = ReactDOMServer.renderToString(element);
|
|
6713
|
+
html = ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
|
|
6700
6714
|
} catch {
|
|
6701
6715
|
html = undefined;
|
|
6702
6716
|
}
|
|
@@ -6711,6 +6725,8 @@ function renderFarmElementSync(ReactDOMServer, element, routeKey) {
|
|
|
6711
6725
|
function createFarmDocumentStream(contentStream, prefix, suffix, onComplete) {
|
|
6712
6726
|
const encoder = new TextEncoder();
|
|
6713
6727
|
const reader = contentStream.getReader();
|
|
6728
|
+
// The suffix renders after the handler returned, outside its async scope.
|
|
6729
|
+
const cspNonce = _resolveCurrentCspNonce();
|
|
6714
6730
|
return new ReadableStream({
|
|
6715
6731
|
start(controller) {
|
|
6716
6732
|
controller.enqueue(encoder.encode(prefix));
|
|
@@ -6719,7 +6735,9 @@ function createFarmDocumentStream(contentStream, prefix, suffix, onComplete) {
|
|
|
6719
6735
|
try {
|
|
6720
6736
|
const result = await reader.read();
|
|
6721
6737
|
if (result.done) {
|
|
6722
|
-
const tail = typeof suffix === "function"
|
|
6738
|
+
const tail = typeof suffix === "function"
|
|
6739
|
+
? await _runWithFarmCspNonce(cspNonce, suffix)
|
|
6740
|
+
: suffix;
|
|
6723
6741
|
controller.enqueue(encoder.encode(tail));
|
|
6724
6742
|
if (onComplete) onComplete();
|
|
6725
6743
|
controller.close();
|
|
@@ -6841,18 +6859,18 @@ function createFarmErrorDocument(html, title) {
|
|
|
6841
6859
|
' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
|
|
6842
6860
|
' <link rel="icon" href="data:,">\\n' +
|
|
6843
6861
|
' <title>' + escapedTitle + '</title>\\n' +
|
|
6844
|
-
' <link rel="stylesheet" href="/__farm_client_css_href__"
|
|
6862
|
+
' <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(html) + '\\n' +
|
|
6845
6863
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
6846
6864
|
'</head>\\n<body>\\n' +
|
|
6847
6865
|
' <div id="root">' + html + '</div>\\n' +
|
|
6848
6866
|
' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
6849
|
-
'
|
|
6867
|
+
' ' + renderFarmClientEntryScript() + '\\n' +
|
|
6850
6868
|
'</body>\\n</html>';
|
|
6851
6869
|
}
|
|
6852
6870
|
|
|
6853
6871
|
let fullHtml = ensureFarmDocumentRoot(ensureFarmDocumentHead(fullDocument));
|
|
6854
6872
|
fullHtml = fullHtml
|
|
6855
|
-
.replace(/<head([^>]*)>/i, '<head
|
|
6873
|
+
.replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(fullDocument); })
|
|
6856
6874
|
// Function replacements: dynamic markup may contain $-sequences ($&, $', $$)
|
|
6857
6875
|
// that a string replacement would expand, corrupting the document.
|
|
6858
6876
|
.replace(/<\\/head>/i, function() { return renderFarmRendererHydrationScript() + '\\n</head>'; })
|
|
@@ -6865,7 +6883,7 @@ function createFarmErrorDocument(html, title) {
|
|
|
6865
6883
|
/<\\/body>/i,
|
|
6866
6884
|
function() {
|
|
6867
6885
|
return ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
6868
|
-
'
|
|
6886
|
+
' ' + renderFarmClientEntryScript() + '\\n</body>';
|
|
6869
6887
|
},
|
|
6870
6888
|
);
|
|
6871
6889
|
return fullHtml.trim().startsWith("<!DOCTYPE")
|
|
@@ -6873,6 +6891,53 @@ function createFarmErrorDocument(html, title) {
|
|
|
6873
6891
|
: "<!DOCTYPE html>\\n" + fullHtml;
|
|
6874
6892
|
}
|
|
6875
6893
|
|
|
6894
|
+
// The client modules a page needs before it hydrates, filled in from the client
|
|
6895
|
+
// build once it has finished (see buildNitroUniversal).
|
|
6896
|
+
const farmClientModulePreloads = (() => {
|
|
6897
|
+
try {
|
|
6898
|
+
return JSON.parse("${FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER}");
|
|
6899
|
+
} catch {
|
|
6900
|
+
return null;
|
|
6901
|
+
}
|
|
6902
|
+
})();
|
|
6903
|
+
const farmClientEntryPreloadTags = farmClientModulePreloads
|
|
6904
|
+
? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
|
|
6905
|
+
: "";
|
|
6906
|
+
// The client modules a document's markup loads: its islands' boundaries and the
|
|
6907
|
+
// client references of its server tree.
|
|
6908
|
+
const FARM_CLIENT_MODULE_REFERENCE_PATTERN = /data-farm-client-boundary="([^"]+)"|"r":"(\\/[^"]+)"/g;
|
|
6909
|
+
|
|
6910
|
+
function renderFarmClientModulePreload(index) {
|
|
6911
|
+
return '\\n <link rel="modulepreload" href="/' +
|
|
6912
|
+
escapeFarmHtmlAttribute(farmClientModulePreloads.files[index]) +
|
|
6913
|
+
'" fetchpriority="low">';
|
|
6914
|
+
}
|
|
6915
|
+
|
|
6916
|
+
// The modulepreload links for a document: the entry's static imports, then the
|
|
6917
|
+
// modules its hydrating page and its markup load.
|
|
6918
|
+
function renderFarmClientModulePreloads(markup, pageModule) {
|
|
6919
|
+
// A nonce policy blocks parser-inserted links without the nonce, and the
|
|
6920
|
+
// response filter manages nonces on script elements only, so CSP nonce mode
|
|
6921
|
+
// keeps the documents it had.
|
|
6922
|
+
if (!farmClientModulePreloads || (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce)) return "";
|
|
6923
|
+
const modules = farmClientModulePreloads.modules;
|
|
6924
|
+
const listed = new Set();
|
|
6925
|
+
let tags = farmClientEntryPreloadTags;
|
|
6926
|
+
const add = (moduleId) => {
|
|
6927
|
+
if (!moduleId || !Object.prototype.hasOwnProperty.call(modules, moduleId)) return;
|
|
6928
|
+
for (const index of modules[moduleId]) {
|
|
6929
|
+
if (listed.has(index)) continue;
|
|
6930
|
+
listed.add(index);
|
|
6931
|
+
tags += renderFarmClientModulePreload(index);
|
|
6932
|
+
}
|
|
6933
|
+
};
|
|
6934
|
+
add(pageModule);
|
|
6935
|
+
if (typeof markup === "string") {
|
|
6936
|
+
for (const match of markup.matchAll(FARM_CLIENT_MODULE_REFERENCE_PATTERN)) add(match[1] || match[2]);
|
|
6937
|
+
}
|
|
6938
|
+
return tags;
|
|
6939
|
+
}
|
|
6940
|
+
|
|
6876
6941
|
// The origin hreflang alternates resolve against when the route sets no
|
|
6877
6942
|
// metadataBase. Forwarded authority counts only under server.trustProxy, the
|
|
6878
6943
|
// same rule the development server applies.
|
|
@@ -6905,7 +6970,7 @@ function applyFarmI18nDocument(html, requestPath, snapshot, request, metadata) {
|
|
|
6905
6970
|
});
|
|
6906
6971
|
const runtimeMarkup =
|
|
6907
6972
|
renderFarmI18nAlternateLinks(requestPath, snapshot, request, metadata) +
|
|
6908
|
-
'<script>window.__FARM_I18N__ = ' + serializeFarmInlineValue(snapshot) + ';</script>';
|
|
6973
|
+
stampFarmCspNonce('<script>window.__FARM_I18N__ = ' + serializeFarmInlineValue(snapshot) + ';</script>');
|
|
6909
6974
|
nextHtml = nextHtml.replace(/<head([^>]*)>/i, function(_match, attributes) {
|
|
6910
6975
|
// Function replacement: runtimeMarkup may contain $-sequences ($&, $', $$).
|
|
6911
6976
|
return '<head' + attributes + '>' + runtimeMarkup;
|
|
@@ -6975,6 +7040,26 @@ function hasPrivateFarmRequestHeaders(request, farmLocaleResolution) {
|
|
|
6975
7040
|
);
|
|
6976
7041
|
}
|
|
6977
7042
|
|
|
7043
|
+
// A docs response a guard let this visitor read is theirs, as for pages: one for a
|
|
7044
|
+
// request with credentials, or with middleware request data, never fills a shared cache.
|
|
7045
|
+
// Middleware headers cannot do this, since they never replace a response's own.
|
|
7046
|
+
function withFarmDocsRequestCache(response, request, farmLocaleResolution, middlewareData, middlewareContext) {
|
|
7047
|
+
if (
|
|
7048
|
+
!hasPrivateFarmRequestHeaders(request, farmLocaleResolution) &&
|
|
7049
|
+
!middlewareData?.size &&
|
|
7050
|
+
!middlewareContext?.size
|
|
7051
|
+
) {
|
|
7052
|
+
return response;
|
|
7053
|
+
}
|
|
7054
|
+
const headers = new Headers(response.headers);
|
|
7055
|
+
headers.set("Cache-Control", "private, no-store");
|
|
7056
|
+
return farmOwnedResponse(response.body, {
|
|
7057
|
+
status: response.status,
|
|
7058
|
+
statusText: response.statusText,
|
|
7059
|
+
headers,
|
|
7060
|
+
});
|
|
7061
|
+
}
|
|
7062
|
+
|
|
6978
7063
|
${generateRuntimePathMatcherSource()}
|
|
6979
7064
|
|
|
6980
7065
|
function getMatchingErrorBoundary(pathname) {
|
|
@@ -7205,6 +7290,27 @@ function createFarmAgentRobotsResponse(request) {
|
|
|
7205
7290
|
);
|
|
7206
7291
|
}
|
|
7207
7292
|
` : ""}
|
|
7293
|
+
// Static pages a path-specific guard covers (non-root middleware.ts, a config or
|
|
7294
|
+
// integration middleware matcher naming the path), decided at build time.
|
|
7295
|
+
// sitemap.xml, llms.txt and the default MCP server never list them, nor a page behind
|
|
7296
|
+
// a route guard.
|
|
7297
|
+
const farmAgentGuardedPages = new Set(${JSON.stringify(
|
|
7298
|
+
pageRoutes.map((route) => route.pattern).filter(
|
|
7299
|
+
(pattern) => !pattern.includes("[") && farmPathGuardCoversPage(
|
|
7300
|
+
{
|
|
7301
|
+
config: { middleware: config.middleware, integrations: config.integrations },
|
|
7302
|
+
middlewareRoutes
|
|
7303
|
+
},
|
|
7304
|
+
pattern
|
|
7305
|
+
)
|
|
7306
|
+
)
|
|
7307
|
+
)});
|
|
7308
|
+
function getFarmAgentListedPageRoutes() {
|
|
7309
|
+
return pageRoutes.filter(
|
|
7310
|
+
(route) =>
|
|
7311
|
+
!farmAgentGuardedPages.has(route.pattern) && !(route.module && route.module.__farmRouteGuard),
|
|
7312
|
+
);
|
|
7313
|
+
}
|
|
7208
7314
|
${servesAgentSitemap ? `// sitemap.xml from agent.sitemap, built the same way as in development. Each page's
|
|
7209
7315
|
// lastmod is its file's modification time, read at build time.
|
|
7210
7316
|
const farmAgentSitemapConfig = ${JSON.stringify(config.agent.sitemap)};
|
|
@@ -7214,7 +7320,7 @@ function createFarmAgentSitemapResponse(request) {
|
|
|
7214
7320
|
return createFarmMetadataRouteResponse(
|
|
7215
7321
|
"sitemap",
|
|
7216
7322
|
createFarmDefaultSitemap(
|
|
7217
|
-
|
|
7323
|
+
getFarmAgentListedPageRoutes().map((route) => ({
|
|
7218
7324
|
pattern: route.pattern,
|
|
7219
7325
|
module: route.module,
|
|
7220
7326
|
lastModified: farmAgentSitemapLastModified[route.pattern],
|
|
@@ -7253,7 +7359,7 @@ async function handleFarmDefaultMCP(request) {
|
|
|
7253
7359
|
basePath: ${JSON.stringify(config.basePath)},
|
|
7254
7360
|
listPages: () =>
|
|
7255
7361
|
collectFarmDefaultMCPPages(
|
|
7256
|
-
|
|
7362
|
+
getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, module: route.module })),
|
|
7257
7363
|
{ origin, basePath: ${JSON.stringify(config.basePath)}, markdown: farmMarkdownConfig },
|
|
7258
7364
|
),
|
|
7259
7365
|
// A fresh request through this handler, so the caller's cookies never shape a page.
|
|
@@ -7273,7 +7379,7 @@ const farmDefaultMCPReadMarkdown = createFarmLlmsMarkdownReader((page) => fetch(
|
|
|
7273
7379
|
function createFarmLlmsTxtContext(request, full) {
|
|
7274
7380
|
const origin = new URL(request.url).origin;
|
|
7275
7381
|
const pages = collectFarmLlmsTxtPages(
|
|
7276
|
-
|
|
7382
|
+
getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, metadata: route.module && route.module.metadata })),
|
|
7277
7383
|
{
|
|
7278
7384
|
origin,
|
|
7279
7385
|
markdown: farmMarkdownConfig,
|
|
@@ -7750,7 +7856,7 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
7750
7856
|
if (!html.includes('src="/__farm_client_js_src__"')) {
|
|
7751
7857
|
html = html.replace(
|
|
7752
7858
|
/<[/]body>/i,
|
|
7753
|
-
'
|
|
7859
|
+
function() { return ' ' + renderFarmClientEntryScript() + '\\n</body>'; },
|
|
7754
7860
|
);
|
|
7755
7861
|
}
|
|
7756
7862
|
if (!html.includes('window._$HY')) {
|
|
@@ -7787,6 +7893,9 @@ function resolvePPRConfig(route) {
|
|
|
7787
7893
|
}
|
|
7788
7894
|
|
|
7789
7895
|
function getPPRShellBypassReason(request, middlewareData, middlewareContext) {
|
|
7896
|
+
// A shared shell would carry one response's nonce to every visitor, where
|
|
7897
|
+
// the nonce filter strips it and Farm's scripts stop running.
|
|
7898
|
+
if (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce) return "csp-nonce";
|
|
7790
7899
|
const method = request.method.toUpperCase();
|
|
7791
7900
|
if (method !== "GET" && method !== "HEAD") return "method";
|
|
7792
7901
|
if (request.headers.get("cookie")) return "cookie";
|
|
@@ -8064,11 +8173,17 @@ async function handleFarmRequestInContext(
|
|
|
8064
8173
|
const docsResponse = await farmDocsHandler(cloneFarmRequestWithContext(request));
|
|
8065
8174
|
if (docsResponse) {
|
|
8066
8175
|
if (!docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html")) {
|
|
8067
|
-
return applyProductionMiddlewareHeaders(
|
|
8176
|
+
return applyProductionMiddlewareHeaders(
|
|
8177
|
+
withFarmDocsRequestCache(docsResponse, request, farmLocaleResolution, middlewareData, middlewareContext),
|
|
8178
|
+
middlewareHeaders,
|
|
8179
|
+
);
|
|
8068
8180
|
}
|
|
8069
|
-
const wrappedDocsResponse =
|
|
8181
|
+
const wrappedDocsResponse = withFarmDocsRequestCache(
|
|
8182
|
+
await wrapFarmDocsResponseWithLayouts(request, docsResponse),
|
|
8070
8183
|
request,
|
|
8071
|
-
|
|
8184
|
+
farmLocaleResolution,
|
|
8185
|
+
middlewareData,
|
|
8186
|
+
middlewareContext,
|
|
8072
8187
|
);
|
|
8073
8188
|
const docsHeaders = new Headers(wrappedDocsResponse.headers);
|
|
8074
8189
|
docsHeaders.set("x-farm-preload-buffered", "1");
|
|
@@ -8169,7 +8284,7 @@ async function handleFarmRequestInContext(
|
|
|
8169
8284
|
) {
|
|
8170
8285
|
const method = request.method.toUpperCase();
|
|
8171
8286
|
const response = method === "GET" || method === "HEAD"
|
|
8172
|
-
? farmOwnedResponse(method === "HEAD" ? null : farmOpenAPIReference.html, {
|
|
8287
|
+
? farmOwnedResponse(method === "HEAD" ? null : stampFarmCspNonce(farmOpenAPIReference.html), {
|
|
8173
8288
|
status: 200,
|
|
8174
8289
|
headers: {
|
|
8175
8290
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -8289,7 +8404,10 @@ async function handleFarmRequestInContext(
|
|
|
8289
8404
|
${config.docs?.enabled ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
|
|
8290
8405
|
const docsAPIResponse = await farmDocsAPIHandler(cloneFarmRequestWithContext(request));
|
|
8291
8406
|
if (docsAPIResponse) {
|
|
8292
|
-
return applyProductionMiddlewareHeaders(
|
|
8407
|
+
return applyProductionMiddlewareHeaders(
|
|
8408
|
+
withFarmDocsRequestCache(docsAPIResponse, request, farmLocaleResolution, middlewareData, middlewareContext),
|
|
8409
|
+
middlewareHeaders,
|
|
8410
|
+
);
|
|
8293
8411
|
}
|
|
8294
8412
|
}` : ""}
|
|
8295
8413
|
|
|
@@ -8803,13 +8921,16 @@ async function handleFarmRequestInContext(
|
|
|
8803
8921
|
|
|
8804
8922
|
// Stream a suspended body as soon as React's shell is ready. Full-document
|
|
8805
8923
|
// layouts, localized documents, and cacheable PPR shells still use the
|
|
8806
|
-
// buffered path because they require whole-document transformation
|
|
8924
|
+
// buffered path because they require whole-document transformation, and so
|
|
8925
|
+
// does the anonymous check behind a page's Markdown source: there, a
|
|
8926
|
+
// redirect() under a loading boundary must still decide the status.
|
|
8807
8927
|
if (
|
|
8808
8928
|
pageStatus === 200 &&
|
|
8809
8929
|
renderedPage.stream &&
|
|
8810
8930
|
!hasFullDocument &&
|
|
8811
8931
|
!farmI18nSnapshot &&
|
|
8812
|
-
!pprCacheKey
|
|
8932
|
+
!pprCacheKey &&
|
|
8933
|
+
!_isFarmMarkdownPageCheck(request.headers.get(FARM_MARKDOWN_PAGE_CHECK_HEADER))
|
|
8813
8934
|
) {
|
|
8814
8935
|
const farmThemeDocument = createFarmThemeDocumentParts(
|
|
8815
8936
|
farmThemeConfig,
|
|
@@ -8823,7 +8944,7 @@ async function handleFarmRequestInContext(
|
|
|
8823
8944
|
(hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
|
|
8824
8945
|
' <title>' + title + '</title>' + metaTags + '\\n' +
|
|
8825
8946
|
' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
|
|
8826
|
-
' <link rel="modulepreload" href="/__farm_client_js_src__"
|
|
8947
|
+
' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
|
|
8827
8948
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
8828
8949
|
'</head>\\n<body>\\n <div id="root">';
|
|
8829
8950
|
const streamSuffix = '</div>\\n' +
|
|
@@ -8832,7 +8953,7 @@ async function handleFarmRequestInContext(
|
|
|
8832
8953
|
routeSlotPayload,
|
|
8833
8954
|
clientPageProps
|
|
8834
8955
|
) + '\\n' +
|
|
8835
|
-
'
|
|
8956
|
+
' ' + renderFarmClientEntryScript() + '\\n' +
|
|
8836
8957
|
'</body>\\n</html>';
|
|
8837
8958
|
const themedStreamPrefix = streamPrefix.replace(
|
|
8838
8959
|
'<html lang="en">',
|
|
@@ -8856,7 +8977,8 @@ async function handleFarmRequestInContext(
|
|
|
8856
8977
|
try {
|
|
8857
8978
|
return createLateNotFoundRecovery(
|
|
8858
8979
|
await ReactDOMServer.renderToString(
|
|
8859
|
-
wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname))
|
|
8980
|
+
wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname)),
|
|
8981
|
+
getFarmRendererRenderOptions()
|
|
8860
8982
|
)
|
|
8861
8983
|
) + streamSuffix;
|
|
8862
8984
|
} catch (error) {
|
|
@@ -8864,7 +8986,10 @@ async function handleFarmRequestInContext(
|
|
|
8864
8986
|
// needs their context cannot render alone, so use Farm's.
|
|
8865
8987
|
console.warn("not-found page could not render outside its layout, using Farm's:", error);
|
|
8866
8988
|
return createLateNotFoundRecovery(
|
|
8867
|
-
await ReactDOMServer.renderToString(
|
|
8989
|
+
await ReactDOMServer.renderToString(
|
|
8990
|
+
React.createElement(FarmDefault404Page),
|
|
8991
|
+
getFarmRendererRenderOptions()
|
|
8992
|
+
)
|
|
8868
8993
|
) + streamSuffix;
|
|
8869
8994
|
}
|
|
8870
8995
|
},
|
|
@@ -8913,7 +9038,7 @@ async function handleFarmRequestInContext(
|
|
|
8913
9038
|
);
|
|
8914
9039
|
fullHtml = html
|
|
8915
9040
|
// Inject CSS link after opening head tag or first meta tag
|
|
8916
|
-
.replace(/<head([^>]*)>/i, '<head
|
|
9041
|
+
.replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(html, route.clientModule); })
|
|
8917
9042
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
8918
9043
|
// Explicit metadata wins over renderer and layout titles. Without
|
|
8919
9044
|
// explicit metadata, a renderer title wins over the layout title.
|
|
@@ -8947,7 +9072,7 @@ async function handleFarmRequestInContext(
|
|
|
8947
9072
|
routeSlotPayload,
|
|
8948
9073
|
clientPageProps
|
|
8949
9074
|
) + '\\n' +
|
|
8950
|
-
'
|
|
9075
|
+
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
8951
9076
|
);
|
|
8952
9077
|
|
|
8953
9078
|
// Last, so the charset (and the viewport, unless the layout wrote one) open the head.
|
|
@@ -8966,13 +9091,13 @@ async function handleFarmRequestInContext(
|
|
|
8966
9091
|
\${viewportTags}
|
|
8967
9092
|
\${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
|
|
8968
9093
|
\${suppressDefaultTitle ? "" : "<title>" + title + "</title>"}\${metaTags}\${rendererHead ? "\\n " + rendererHead : ""}
|
|
8969
|
-
<link rel="stylesheet" href="/__farm_client_css_href__"
|
|
9094
|
+
<link rel="stylesheet" href="/__farm_client_css_href__">\${renderFarmClientModulePreloads(html, route.clientModule)}
|
|
8970
9095
|
\${renderFarmRendererHydrationScript()}
|
|
8971
9096
|
</head>
|
|
8972
9097
|
<body>
|
|
8973
9098
|
<div id="root">\${html}</div>
|
|
8974
9099
|
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, routeSlotPayload, clientPageProps)}
|
|
8975
|
-
|
|
9100
|
+
\${renderFarmClientEntryScript()}
|
|
8976
9101
|
</body>
|
|
8977
9102
|
</html>\`;
|
|
8978
9103
|
}
|
|
@@ -9144,14 +9269,14 @@ async function handleFarmRequestInContext(
|
|
|
9144
9269
|
}
|
|
9145
9270
|
}
|
|
9146
9271
|
|
|
9147
|
-
const fallbackHtml = createDefaultErrorMarkup({
|
|
9272
|
+
const fallbackHtml = stampFarmCspNonce(createDefaultErrorMarkup({
|
|
9148
9273
|
statusCode: errorStatus,
|
|
9149
9274
|
statusText: errorStatusText,
|
|
9150
9275
|
requestPath: pathname,
|
|
9151
9276
|
method: request.method,
|
|
9152
9277
|
development: false,
|
|
9153
9278
|
mode: "production",
|
|
9154
|
-
});
|
|
9279
|
+
}));
|
|
9155
9280
|
const fallbackDocument = applyFarmThemeDocument(
|
|
9156
9281
|
applyFarmI18nDocument(
|
|
9157
9282
|
createFarmErrorDocument(
|
|
@@ -9238,7 +9363,7 @@ ${servesDefaultMCP ? `
|
|
|
9238
9363
|
}
|
|
9239
9364
|
notFoundElement = wrapWithFarmIntegrationProviders(notFoundElement);
|
|
9240
9365
|
|
|
9241
|
-
const html = await ReactDOMServer.renderToString(notFoundElement);
|
|
9366
|
+
const html = await ReactDOMServer.renderToString(notFoundElement, getFarmRendererRenderOptions());
|
|
9242
9367
|
// The layouts' and the not-found page's metadata, as the development renderer uses it.
|
|
9243
9368
|
const notFoundMetadata = renderMetadataHead(
|
|
9244
9369
|
await resolveFarmNotFoundMetadata(
|
|
@@ -9263,12 +9388,12 @@ ${servesDefaultMCP ? `
|
|
|
9263
9388
|
"<head" + attrs + ">" +
|
|
9264
9389
|
headContent.replace(/<title\\b[^>]*>[\\s\\S]*?<\\/title>\\s*/gi, "") +
|
|
9265
9390
|
"\\n <title>" + notFoundMetadata.title + "</title>" + notFoundMetadata.tags + "\\n</head>")
|
|
9266
|
-
.replace(/<head([^>]*)>/i, '<head
|
|
9391
|
+
.replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(fullDocument); })
|
|
9267
9392
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
9268
9393
|
.replace(
|
|
9269
9394
|
/<\\/body>/i,
|
|
9270
9395
|
() => ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
9271
|
-
'
|
|
9396
|
+
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
9272
9397
|
);
|
|
9273
9398
|
fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
|
|
9274
9399
|
if (!fullHtml.trim().startsWith('<!DOCTYPE')) {
|
|
@@ -9281,14 +9406,14 @@ ${servesDefaultMCP ? `
|
|
|
9281
9406
|
<meta charset="UTF-8">
|
|
9282
9407
|
\${notFoundMetadata.viewport}
|
|
9283
9408
|
\${notFoundMetadata.hasFavicon ? "" : '<link rel="icon" href="data:,">'}
|
|
9284
|
-
<link rel="stylesheet" href="/__farm_client_css_href__"
|
|
9409
|
+
<link rel="stylesheet" href="/__farm_client_css_href__">\${renderFarmClientModulePreloads(html)}
|
|
9285
9410
|
<title>\${notFoundMetadata.title}</title>\${notFoundMetadata.tags}
|
|
9286
9411
|
\${renderFarmRendererHydrationScript()}
|
|
9287
9412
|
</head>
|
|
9288
9413
|
<body>
|
|
9289
9414
|
<div id="root">\${html}</div>
|
|
9290
9415
|
\${renderFarmClientBootstrapScript()}
|
|
9291
|
-
|
|
9416
|
+
\${renderFarmClientEntryScript()}
|
|
9292
9417
|
</body>
|
|
9293
9418
|
</html>\`;
|
|
9294
9419
|
}
|
|
@@ -9422,6 +9547,9 @@ async function handleFarmFetch(request, context) {
|
|
|
9422
9547
|
() =>
|
|
9423
9548
|
runWithFarmRequestSpan(request, async () => {
|
|
9424
9549
|
const runtimeOptions = farmPluginRuntime ? getFarmPluginRequestOptions(request) : null;
|
|
9550
|
+
// Created before rendering so only scripts Farm, the renderer, or the
|
|
9551
|
+
// app (through getCspNonce()) give it carry the response nonce.
|
|
9552
|
+
const cspNonce = createFarmCspNonce(farmSecurityConfig);
|
|
9425
9553
|
const prepareResponse = async (runtimeRequest, responsePromise) => {
|
|
9426
9554
|
const response = await responsePromise;
|
|
9427
9555
|
// Headers need the path eagerly; preload reporting needs it only for
|
|
@@ -9433,6 +9561,7 @@ async function handleFarmFetch(request, context) {
|
|
|
9433
9561
|
applyFarmCspNonceToResponse(
|
|
9434
9562
|
applyConfiguredResponseHeaders(response, routePathname),
|
|
9435
9563
|
farmSecurityConfig,
|
|
9564
|
+
cspNonce,
|
|
9436
9565
|
),
|
|
9437
9566
|
routePathname,
|
|
9438
9567
|
runtimeRequest,
|
|
@@ -9465,7 +9594,7 @@ async function handleFarmFetch(request, context) {
|
|
|
9465
9594
|
: ` : ""}prepareResponse(request, handleFarmRequest(request, context));
|
|
9466
9595
|
|
|
9467
9596
|
const response = await _runWithCurrentRequest(request, () =>
|
|
9468
|
-
_runWithAfterRequest(request, runRequest, context),
|
|
9597
|
+
_runWithFarmCspNonce(cspNonce, () => _runWithAfterRequest(request, runRequest, context)),
|
|
9469
9598
|
);
|
|
9470
9599
|
return ${hasCompressionRuntime && !hasPluginRuntime ? "compressFarmResponse(request, response, getFarmOwnedBufferedHtml(response), farmLazyBufferedHtml.has(response))" : "response"};
|
|
9471
9600
|
}),
|
|
@@ -9540,26 +9669,6 @@ function middlewarePatternMatches(pattern, pathname) {
|
|
|
9540
9669
|
return new RegExp(`^${expression}/?$`).test(pathname);
|
|
9541
9670
|
}
|
|
9542
9671
|
__name(middlewarePatternMatches, "middlewarePatternMatches");
|
|
9543
|
-
function configMiddlewareMayHandlePath(config, pathname) {
|
|
9544
|
-
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
9545
|
-
const entries = Array.isArray(config) ? config : [config];
|
|
9546
|
-
return entries.some((entry) => {
|
|
9547
|
-
if (!entry.matcher && !entry.exclude) return true;
|
|
9548
|
-
const matchers = entry.matcher ? (Array.isArray(entry.matcher) ? entry.matcher : [entry.matcher]).map(
|
|
9549
|
-
(matcher) => (
|
|
9550
|
-
// A request-aware matcher cannot be proven safe at build time.
|
|
9551
|
-
typeof matcher === "function" ? () => true : matcher
|
|
9552
|
-
)
|
|
9553
|
-
) : void 0;
|
|
9554
|
-
const compiled = compileMiddlewareConfig({ matcher: matchers, exclude: entry.exclude });
|
|
9555
|
-
return matchesCompiledMiddlewareConfig(pathname, compiled, {}).matched;
|
|
9556
|
-
});
|
|
9557
|
-
}
|
|
9558
|
-
__name(configMiddlewareMayHandlePath, "configMiddlewareMayHandlePath");
|
|
9559
|
-
function appMiddlewareMayHandlePath(middlewareRoutes, pathname) {
|
|
9560
|
-
return middlewareRoutes.some((route) => matchesMiddlewareRoute(pathname, route).matched);
|
|
9561
|
-
}
|
|
9562
|
-
__name(appMiddlewareMayHandlePath, "appMiddlewareMayHandlePath");
|
|
9563
9672
|
function routePatternSpecificity(pattern) {
|
|
9564
9673
|
return pattern.split("/").filter(Boolean).reduce((score, segment) => {
|
|
9565
9674
|
if (segment === "**" || segment.startsWith("[[...")) return score + 1;
|
|
@@ -9615,7 +9724,7 @@ function getPhysicalPrerenderBypassReason(options) {
|
|
|
9615
9724
|
}
|
|
9616
9725
|
__name(getPhysicalPrerenderBypassReason, "getPhysicalPrerenderBypassReason");
|
|
9617
9726
|
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
|
|
9618
|
-
const [
|
|
9727
|
+
const [fs3, nitroBuilderResult] = await Promise.all([
|
|
9619
9728
|
import("fs/promises"),
|
|
9620
9729
|
nitroBuilderResultPromise
|
|
9621
9730
|
]);
|
|
@@ -9624,8 +9733,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9624
9733
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
9625
9734
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
9626
9735
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
9627
|
-
const runtimeServerOutputDir = isVercel ?
|
|
9628
|
-
const ssrOutputDir =
|
|
9736
|
+
const runtimeServerOutputDir = isVercel ? path8.join(outputDir, "functions", "__nitro.func") : path8.join(outputDir, "server");
|
|
9737
|
+
const ssrOutputDir = path8.join(root, distDir, "ssr");
|
|
9629
9738
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
9630
9739
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
9631
9740
|
(image) => image.sourceType === "module"
|
|
@@ -9694,12 +9803,22 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9694
9803
|
}
|
|
9695
9804
|
const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
|
|
9696
9805
|
const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
|
|
9697
|
-
const [clientCssHref, clientJsSrc] = await Promise.all([
|
|
9806
|
+
const [clientCssHref, clientJsSrc, docsModulePreloads, clientModulePreloads] = await Promise.all([
|
|
9698
9807
|
resolveHashedClientCssHref(clientOutputDir),
|
|
9699
|
-
resolveHashedClientJsSrc(clientOutputDir)
|
|
9808
|
+
resolveHashedClientJsSrc(clientOutputDir),
|
|
9809
|
+
readFarmDocsModulePreloads(path8.join(root, distDir)),
|
|
9810
|
+
readFarmClientModulePreloads(path8.join(root, distDir))
|
|
9700
9811
|
]);
|
|
9812
|
+
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
9813
|
+
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
9701
9814
|
for (const output of Object.values(ssrBundle)) {
|
|
9702
9815
|
if (output.type !== "chunk") continue;
|
|
9816
|
+
if (output.code.includes(FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
9817
|
+
output.code = output.code.split(FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER).join(encodedDocsModulePreloads);
|
|
9818
|
+
}
|
|
9819
|
+
if (output.code.includes(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
9820
|
+
output.code = output.code.split(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER).join(encodedClientModulePreloads);
|
|
9821
|
+
}
|
|
9703
9822
|
if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
|
|
9704
9823
|
output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
|
|
9705
9824
|
}
|
|
@@ -9707,13 +9826,13 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9707
9826
|
output.code = output.code.split(FARM_CLIENT_JS_SRC_PLACEHOLDER).join(clientJsSrc);
|
|
9708
9827
|
}
|
|
9709
9828
|
}
|
|
9710
|
-
await
|
|
9829
|
+
await fs3.mkdir(ssrOutputDir, { recursive: true });
|
|
9711
9830
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
9712
|
-
const filePath =
|
|
9713
|
-
await
|
|
9714
|
-
await
|
|
9831
|
+
const filePath = path8.join(ssrOutputDir, fileName);
|
|
9832
|
+
await fs3.mkdir(path8.dirname(filePath), { recursive: true });
|
|
9833
|
+
await fs3.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
9715
9834
|
}
|
|
9716
|
-
const nitroEntryPath =
|
|
9835
|
+
const nitroEntryPath = path8.join(ssrOutputDir, "nitro-entry.mjs");
|
|
9717
9836
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
9718
9837
|
const nitroEntryCode = `
|
|
9719
9838
|
// Farm.js Nitro Entry
|
|
@@ -9865,26 +9984,26 @@ function toFarmNodeResponse(request, response) {
|
|
|
9865
9984
|
})
|
|
9866
9985
|
}` : ""}
|
|
9867
9986
|
`.trim();
|
|
9868
|
-
await
|
|
9869
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
9987
|
+
await fs3.writeFile(nitroEntryPath, nitroEntryCode);
|
|
9988
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path8.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
9870
9989
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
9871
|
-
await
|
|
9872
|
-
|
|
9990
|
+
await fs3.writeFile(
|
|
9991
|
+
path8.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
9873
9992
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
9874
9993
|
);
|
|
9875
|
-
await
|
|
9994
|
+
await fs3.writeFile(
|
|
9876
9995
|
farmNodeServerEntryPath,
|
|
9877
9996
|
createFarmNodeServerEntry({
|
|
9878
|
-
nitroEntryFile:
|
|
9997
|
+
nitroEntryFile: path8.basename(nitroEntryPath),
|
|
9879
9998
|
nodeAdapterModule,
|
|
9880
9999
|
server: config.server,
|
|
9881
10000
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
|
|
9882
10001
|
})
|
|
9883
10002
|
);
|
|
9884
10003
|
}
|
|
9885
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
10004
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path8.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
9886
10005
|
if (farmNetlifyEntryPath) {
|
|
9887
|
-
await
|
|
10006
|
+
await fs3.writeFile(
|
|
9888
10007
|
farmNetlifyEntryPath,
|
|
9889
10008
|
createFarmNetlifyEntry({
|
|
9890
10009
|
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
@@ -9924,7 +10043,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9924
10043
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
9925
10044
|
serverDir: false,
|
|
9926
10045
|
serverEntry: false,
|
|
9927
|
-
buildDir:
|
|
10046
|
+
buildDir: path8.join(root, distDir, ".nitro"),
|
|
9928
10047
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
9929
10048
|
compatibilityDate: "2024-12-01",
|
|
9930
10049
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -10000,7 +10119,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10000
10119
|
if (pluginManager) {
|
|
10001
10120
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
10002
10121
|
}
|
|
10003
|
-
const expectedServerDir =
|
|
10122
|
+
const expectedServerDir = path8.join(outputDir, "server");
|
|
10004
10123
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
10005
10124
|
(key) => key !== "external" && key !== "plugins"
|
|
10006
10125
|
);
|
|
@@ -10013,9 +10132,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
10013
10132
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
10014
10133
|
);
|
|
10015
10134
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
10016
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 &&
|
|
10135
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && path8.resolve(nitroConfig.output?.serverDir || "") === path8.resolve(expectedServerDir) && Boolean(
|
|
10017
10136
|
nitroConfig.handlers?.some(
|
|
10018
|
-
(handler) =>
|
|
10137
|
+
(handler) => path8.resolve(handler?.handler || "") === nitroEntryPath
|
|
10019
10138
|
)
|
|
10020
10139
|
);
|
|
10021
10140
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
@@ -10102,14 +10221,14 @@ function toFarmNodeResponse(request, response) {
|
|
|
10102
10221
|
});
|
|
10103
10222
|
}
|
|
10104
10223
|
prerenderer.hooks.hook("compiled", async () => {
|
|
10105
|
-
const prerenderServerDir =
|
|
10224
|
+
const prerenderServerDir = path8.join(outputDir, "server");
|
|
10106
10225
|
await copyPrebuiltSSRBundle(
|
|
10107
10226
|
ssrBundle,
|
|
10108
|
-
|
|
10227
|
+
path8.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
10109
10228
|
null,
|
|
10110
|
-
|
|
10229
|
+
fs3
|
|
10111
10230
|
);
|
|
10112
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
10231
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs3);
|
|
10113
10232
|
});
|
|
10114
10233
|
});
|
|
10115
10234
|
}
|
|
@@ -10140,7 +10259,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10140
10259
|
else process.env[FARM_PRERENDER_ENV] = previousPrerender;
|
|
10141
10260
|
}
|
|
10142
10261
|
}
|
|
10143
|
-
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir,
|
|
10262
|
+
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs3, preset) : Promise.resolve(null);
|
|
10144
10263
|
const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
|
|
10145
10264
|
ssrBundle,
|
|
10146
10265
|
shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
|
|
@@ -10153,7 +10272,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10153
10272
|
await nitroInstance.close();
|
|
10154
10273
|
if (nitroBuildResult.status === "rejected") {
|
|
10155
10274
|
if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
|
|
10156
|
-
await
|
|
10275
|
+
await fs3.rm(sharpRuntimeStageResult.value.stageDir, {
|
|
10157
10276
|
recursive: true,
|
|
10158
10277
|
force: true
|
|
10159
10278
|
});
|
|
@@ -10166,20 +10285,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
10166
10285
|
if (prebuiltSSRFilesResult.status === "rejected") {
|
|
10167
10286
|
throw prebuiltSSRFilesResult.reason;
|
|
10168
10287
|
}
|
|
10169
|
-
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir,
|
|
10288
|
+
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs3, preset) : null);
|
|
10170
10289
|
const runtimeCopyPromise = (async () => {
|
|
10171
10290
|
if (stagedSharpRuntime) {
|
|
10172
|
-
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir,
|
|
10291
|
+
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs3);
|
|
10173
10292
|
}
|
|
10174
10293
|
if (useExternalMetadataImageRuntime) {
|
|
10175
|
-
await copyMetadataImageRuntime(root, runtimeServerOutputDir,
|
|
10294
|
+
await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs3);
|
|
10176
10295
|
}
|
|
10177
10296
|
})();
|
|
10178
10297
|
const copyResults = await Promise.allSettled([
|
|
10179
10298
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
10180
10299
|
prebuiltSSRFilesResult.value,
|
|
10181
|
-
|
|
10182
|
-
|
|
10300
|
+
path8.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
10301
|
+
fs3
|
|
10183
10302
|
) : Promise.resolve(),
|
|
10184
10303
|
runtimeCopyPromise
|
|
10185
10304
|
]);
|
|
@@ -10188,7 +10307,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10188
10307
|
);
|
|
10189
10308
|
if (failedCopy) throw failedCopy.reason;
|
|
10190
10309
|
if (canReusePrebuiltSSR) {
|
|
10191
|
-
await registerPrebuiltSSRPackageImport(
|
|
10310
|
+
await registerPrebuiltSSRPackageImport(path8.join(outputDir, "server"), ssrEntryFile, fs3);
|
|
10192
10311
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
10193
10312
|
}
|
|
10194
10313
|
if (useRolldownBuilder) {
|
|
@@ -10203,7 +10322,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10203
10322
|
});
|
|
10204
10323
|
}
|
|
10205
10324
|
if (isVercel) {
|
|
10206
|
-
await postProcessVercelOutput(root, outputDir,
|
|
10325
|
+
await postProcessVercelOutput(root, outputDir, fs3, config, farmWorkflows, routeRuntimeManifest);
|
|
10207
10326
|
}
|
|
10208
10327
|
logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
|
|
10209
10328
|
}
|
|
@@ -10213,11 +10332,11 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
10213
10332
|
return {
|
|
10214
10333
|
dir: outputDir,
|
|
10215
10334
|
...preset === "node-server" ? {
|
|
10216
|
-
serverDir:
|
|
10217
|
-
publicDir:
|
|
10335
|
+
serverDir: path8.join(outputDir, "server"),
|
|
10336
|
+
publicDir: path8.join(outputDir, "public")
|
|
10218
10337
|
} : isVercel ? {
|
|
10219
|
-
serverDir:
|
|
10220
|
-
publicDir:
|
|
10338
|
+
serverDir: path8.join(outputDir, "functions", "__nitro.func"),
|
|
10339
|
+
publicDir: path8.join(outputDir, "static")
|
|
10221
10340
|
} : {}
|
|
10222
10341
|
};
|
|
10223
10342
|
}
|
|
@@ -10231,24 +10350,24 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
|
10231
10350
|
);
|
|
10232
10351
|
}
|
|
10233
10352
|
__name(prepareSSRBundleFiles, "prepareSSRBundleFiles");
|
|
10234
|
-
async function writeSSRBundleFiles(files, targetDir,
|
|
10235
|
-
await
|
|
10353
|
+
async function writeSSRBundleFiles(files, targetDir, fs3) {
|
|
10354
|
+
await fs3.rm(targetDir, { recursive: true, force: true });
|
|
10236
10355
|
await Promise.all(
|
|
10237
10356
|
files.map(async ({ fileName, contents }) => {
|
|
10238
|
-
const targetPath =
|
|
10239
|
-
await
|
|
10240
|
-
await
|
|
10357
|
+
const targetPath = path8.join(targetDir, fileName);
|
|
10358
|
+
await fs3.mkdir(path8.dirname(targetPath), { recursive: true });
|
|
10359
|
+
await fs3.writeFile(targetPath, contents);
|
|
10241
10360
|
})
|
|
10242
10361
|
);
|
|
10243
10362
|
}
|
|
10244
10363
|
__name(writeSSRBundleFiles, "writeSSRBundleFiles");
|
|
10245
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions,
|
|
10246
|
-
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir,
|
|
10364
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs3) {
|
|
10365
|
+
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs3);
|
|
10247
10366
|
}
|
|
10248
10367
|
__name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
10249
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
10250
|
-
const packagePath =
|
|
10251
|
-
const packageJSON = await
|
|
10368
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs3) {
|
|
10369
|
+
const packagePath = path8.join(serverDir, "package.json");
|
|
10370
|
+
const packageJSON = await fs3.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10252
10371
|
if (error.code === "ENOENT") return { type: "module" };
|
|
10253
10372
|
throw error;
|
|
10254
10373
|
});
|
|
@@ -10258,14 +10377,14 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs) {
|
|
|
10258
10377
|
...existingImports,
|
|
10259
10378
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
10260
10379
|
};
|
|
10261
|
-
await
|
|
10262
|
-
await
|
|
10380
|
+
await fs3.mkdir(serverDir, { recursive: true });
|
|
10381
|
+
await fs3.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
10263
10382
|
`);
|
|
10264
10383
|
}
|
|
10265
10384
|
__name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
|
|
10266
|
-
async function moveVercelOutputPath(src, dest,
|
|
10385
|
+
async function moveVercelOutputPath(src, dest, fs3) {
|
|
10267
10386
|
try {
|
|
10268
|
-
await
|
|
10387
|
+
await fs3.rename(src, dest);
|
|
10269
10388
|
return;
|
|
10270
10389
|
} catch (error) {
|
|
10271
10390
|
const code = error?.code;
|
|
@@ -10273,39 +10392,39 @@ async function moveVercelOutputPath(src, dest, fs) {
|
|
|
10273
10392
|
throw error;
|
|
10274
10393
|
}
|
|
10275
10394
|
}
|
|
10276
|
-
await
|
|
10277
|
-
await
|
|
10395
|
+
await fs3.cp(src, dest, { recursive: true, force: true });
|
|
10396
|
+
await fs3.rm(src, { recursive: true, force: true });
|
|
10278
10397
|
}
|
|
10279
10398
|
__name(moveVercelOutputPath, "moveVercelOutputPath");
|
|
10280
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
10281
|
-
const serverDir =
|
|
10282
|
-
const functionsDir =
|
|
10283
|
-
const nitroFuncDir =
|
|
10284
|
-
const staticDir =
|
|
10285
|
-
const publicDir =
|
|
10286
|
-
await
|
|
10287
|
-
const serverContents = await
|
|
10399
|
+
async function postProcessVercelOutput(root, outputDir, fs3, config, farmWorkflows, routeRuntimeManifest) {
|
|
10400
|
+
const serverDir = path8.join(outputDir, "server");
|
|
10401
|
+
const functionsDir = path8.join(outputDir, "functions");
|
|
10402
|
+
const nitroFuncDir = path8.join(functionsDir, "__nitro.func");
|
|
10403
|
+
const staticDir = path8.join(outputDir, "static");
|
|
10404
|
+
const publicDir = path8.join(outputDir, "public");
|
|
10405
|
+
await fs3.mkdir(nitroFuncDir, { recursive: true });
|
|
10406
|
+
const serverContents = await fs3.readdir(serverDir).catch((error) => {
|
|
10288
10407
|
if (error.code === "ENOENT") return [];
|
|
10289
10408
|
throw error;
|
|
10290
10409
|
});
|
|
10291
10410
|
for (const file of serverContents) {
|
|
10292
|
-
await moveVercelOutputPath(
|
|
10411
|
+
await moveVercelOutputPath(path8.join(serverDir, file), path8.join(nitroFuncDir, file), fs3);
|
|
10293
10412
|
}
|
|
10294
|
-
if (serverContents.length > 0) await
|
|
10413
|
+
if (serverContents.length > 0) await fs3.rm(serverDir, { recursive: true, force: true });
|
|
10295
10414
|
try {
|
|
10296
|
-
await moveVercelOutputPath(publicDir, staticDir,
|
|
10415
|
+
await moveVercelOutputPath(publicDir, staticDir, fs3);
|
|
10297
10416
|
} catch (error) {
|
|
10298
10417
|
if (error?.code !== "ENOENT") throw error;
|
|
10299
10418
|
}
|
|
10300
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
10301
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
10302
|
-
const configPath =
|
|
10303
|
-
const configContent = await
|
|
10419
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs3);
|
|
10420
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs3);
|
|
10421
|
+
const configPath = path8.join(outputDir, "config.json");
|
|
10422
|
+
const configContent = await fs3.readFile(configPath, "utf-8");
|
|
10304
10423
|
const vercelConfig = JSON.parse(configContent);
|
|
10305
10424
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
10306
10425
|
outputDir,
|
|
10307
10426
|
routeRuntimeManifest,
|
|
10308
|
-
|
|
10427
|
+
fs3,
|
|
10309
10428
|
config.basePath
|
|
10310
10429
|
);
|
|
10311
10430
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
@@ -10320,29 +10439,29 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
|
|
|
10320
10439
|
vercelConfigWithWorkflowCrons,
|
|
10321
10440
|
config.cron.jobs
|
|
10322
10441
|
);
|
|
10323
|
-
await
|
|
10442
|
+
await fs3.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
10324
10443
|
logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
10325
10444
|
}
|
|
10326
10445
|
__name(postProcessVercelOutput, "postProcessVercelOutput");
|
|
10327
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
10446
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs3) {
|
|
10328
10447
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
10329
10448
|
if (!docsContentDir) return;
|
|
10330
|
-
const bundledContentDir =
|
|
10449
|
+
const bundledContentDir = path8.join(nitroFuncDir, "farm-docs-content");
|
|
10331
10450
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
10332
10451
|
fallback: "now"
|
|
10333
10452
|
});
|
|
10334
|
-
await
|
|
10335
|
-
await
|
|
10336
|
-
await
|
|
10453
|
+
await fs3.rm(bundledContentDir, { recursive: true, force: true });
|
|
10454
|
+
await fs3.mkdir(path8.dirname(bundledContentDir), { recursive: true });
|
|
10455
|
+
await fs3.cp(docsContentDir, bundledContentDir, {
|
|
10337
10456
|
recursive: true,
|
|
10338
10457
|
force: true
|
|
10339
10458
|
});
|
|
10340
|
-
await
|
|
10341
|
-
|
|
10459
|
+
await fs3.writeFile(
|
|
10460
|
+
path8.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
10342
10461
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
10343
10462
|
`
|
|
10344
10463
|
);
|
|
10345
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
10464
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path8.relative(root, docsContentDir)}`);
|
|
10346
10465
|
}
|
|
10347
10466
|
__name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
|
|
10348
10467
|
function resolveServerFunctionPlatform(preset) {
|
|
@@ -10361,9 +10480,9 @@ function platformFieldAllows(field, value) {
|
|
|
10361
10480
|
return allowed.length === 0 || allowed.includes(value);
|
|
10362
10481
|
}
|
|
10363
10482
|
__name(platformFieldAllows, "platformFieldAllows");
|
|
10364
|
-
async function stageSharpRuntime(config, root, distDir,
|
|
10483
|
+
async function stageSharpRuntime(config, root, distDir, fs3, preset) {
|
|
10365
10484
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
10366
|
-
const projectRequire = createRequire(
|
|
10485
|
+
const projectRequire = createRequire(path8.join(root, "package.json"));
|
|
10367
10486
|
let sharpRequire = projectRequire;
|
|
10368
10487
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
10369
10488
|
try {
|
|
@@ -10373,10 +10492,10 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10373
10492
|
}
|
|
10374
10493
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
10375
10494
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
10376
|
-
const stageRoot =
|
|
10377
|
-
await
|
|
10378
|
-
const stageDir = await
|
|
10379
|
-
const targetNodeModules =
|
|
10495
|
+
const stageRoot = path8.join(root, distDir, "tmp");
|
|
10496
|
+
await fs3.mkdir(stageRoot, { recursive: true });
|
|
10497
|
+
const stageDir = await fs3.mkdtemp(path8.join(stageRoot, "sharp-runtime-"));
|
|
10498
|
+
const targetNodeModules = path8.join(stageDir, "node_modules");
|
|
10380
10499
|
function copyPackage(packageName, parentRequire) {
|
|
10381
10500
|
const activeCopy = packageCopies.get(packageName);
|
|
10382
10501
|
if (activeCopy) return activeCopy;
|
|
@@ -10388,19 +10507,19 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10388
10507
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
10389
10508
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
10390
10509
|
if (!packageJsonPath) return;
|
|
10391
|
-
const packageJson = JSON.parse(await
|
|
10510
|
+
const packageJson = JSON.parse(await fs3.readFile(packageJsonPath, "utf8"));
|
|
10392
10511
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
10393
|
-
const packageDir =
|
|
10394
|
-
const targetDir =
|
|
10512
|
+
const packageDir = path8.dirname(packageJsonPath);
|
|
10513
|
+
const targetDir = path8.join(targetNodeModules, ...packageName.split("/"));
|
|
10395
10514
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
10396
|
-
await
|
|
10515
|
+
await fs3.mkdir(path8.dirname(targetDir), { recursive: true });
|
|
10397
10516
|
const packageRequire = createRequire(packageJsonPath);
|
|
10398
10517
|
const dependencies = {
|
|
10399
10518
|
...packageJson.dependencies,
|
|
10400
10519
|
...packageJson.optionalDependencies
|
|
10401
10520
|
};
|
|
10402
10521
|
await settleAllOrThrow([
|
|
10403
|
-
|
|
10522
|
+
fs3.cp(packageDir, targetDir, {
|
|
10404
10523
|
recursive: true,
|
|
10405
10524
|
force: true,
|
|
10406
10525
|
dereference: true,
|
|
@@ -10418,7 +10537,7 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10418
10537
|
throw new Error(`Farm image optimization requires sharp. ${SHARP_INSTALL_HINT}`);
|
|
10419
10538
|
}
|
|
10420
10539
|
} catch (error) {
|
|
10421
|
-
await
|
|
10540
|
+
await fs3.rm(stageDir, { recursive: true, force: true });
|
|
10422
10541
|
throw error;
|
|
10423
10542
|
}
|
|
10424
10543
|
return {
|
|
@@ -10429,19 +10548,19 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
10429
10548
|
};
|
|
10430
10549
|
}
|
|
10431
10550
|
__name(stageSharpRuntime, "stageSharpRuntime");
|
|
10432
|
-
async function installStagedSharpRuntime(staged, nitroFuncDir,
|
|
10433
|
-
const stagedNodeModules =
|
|
10434
|
-
const targetNodeModules =
|
|
10551
|
+
async function installStagedSharpRuntime(staged, nitroFuncDir, fs3) {
|
|
10552
|
+
const stagedNodeModules = path8.join(staged.stageDir, "node_modules");
|
|
10553
|
+
const targetNodeModules = path8.join(nitroFuncDir, "node_modules");
|
|
10435
10554
|
try {
|
|
10436
|
-
await mergeStagedDirectory(stagedNodeModules, targetNodeModules,
|
|
10437
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
10555
|
+
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs3);
|
|
10556
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs3);
|
|
10438
10557
|
functionPackage.dependencies = {
|
|
10439
10558
|
...functionPackage.dependencies,
|
|
10440
10559
|
...staged.dependencies
|
|
10441
10560
|
};
|
|
10442
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10561
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs3);
|
|
10443
10562
|
} finally {
|
|
10444
|
-
await
|
|
10563
|
+
await fs3.rm(staged.stageDir, { recursive: true, force: true });
|
|
10445
10564
|
}
|
|
10446
10565
|
logger.info(
|
|
10447
10566
|
`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
|
|
@@ -10456,15 +10575,15 @@ async function settleAllOrThrow(operations) {
|
|
|
10456
10575
|
if (failure) throw failure.reason;
|
|
10457
10576
|
}
|
|
10458
10577
|
__name(settleAllOrThrow, "settleAllOrThrow");
|
|
10459
|
-
async function mergeStagedDirectory(sourceDir, targetDir,
|
|
10460
|
-
await
|
|
10461
|
-
const entries = await
|
|
10578
|
+
async function mergeStagedDirectory(sourceDir, targetDir, fs3) {
|
|
10579
|
+
await fs3.mkdir(targetDir, { recursive: true });
|
|
10580
|
+
const entries = await fs3.readdir(sourceDir, { withFileTypes: true });
|
|
10462
10581
|
await settleAllOrThrow(
|
|
10463
10582
|
entries.map(async (entry) => {
|
|
10464
|
-
const sourcePath =
|
|
10465
|
-
const targetPath =
|
|
10583
|
+
const sourcePath = path8.join(sourceDir, entry.name);
|
|
10584
|
+
const targetPath = path8.join(targetDir, entry.name);
|
|
10466
10585
|
try {
|
|
10467
|
-
await
|
|
10586
|
+
await fs3.rename(sourcePath, targetPath);
|
|
10468
10587
|
return;
|
|
10469
10588
|
} catch (error) {
|
|
10470
10589
|
const code = error.code;
|
|
@@ -10473,16 +10592,16 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs) {
|
|
|
10473
10592
|
}
|
|
10474
10593
|
}
|
|
10475
10594
|
if (entry.isDirectory()) {
|
|
10476
|
-
await mergeStagedDirectory(sourcePath, targetPath,
|
|
10477
|
-
await
|
|
10595
|
+
await mergeStagedDirectory(sourcePath, targetPath, fs3);
|
|
10596
|
+
await fs3.rm(sourcePath, { recursive: true, force: true });
|
|
10478
10597
|
return;
|
|
10479
10598
|
}
|
|
10480
|
-
await
|
|
10599
|
+
await fs3.cp(sourcePath, targetPath, {
|
|
10481
10600
|
force: true,
|
|
10482
10601
|
dereference: true,
|
|
10483
10602
|
mode: fsConstants.COPYFILE_FICLONE
|
|
10484
10603
|
});
|
|
10485
|
-
await
|
|
10604
|
+
await fs3.rm(sourcePath, { force: true });
|
|
10486
10605
|
})
|
|
10487
10606
|
);
|
|
10488
10607
|
}
|
|
@@ -10490,14 +10609,14 @@ __name(mergeStagedDirectory, "mergeStagedDirectory");
|
|
|
10490
10609
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
10491
10610
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
10492
10611
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
10493
|
-
const file = generated.modulePath ? toPosixPath(
|
|
10612
|
+
const file = generated.modulePath ? toPosixPath(path8.relative(root, generated.modulePath)) : "";
|
|
10494
10613
|
throw new Error(
|
|
10495
10614
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
10496
10615
|
);
|
|
10497
10616
|
}
|
|
10498
10617
|
__name(assertMetadataImageRuntimeInstalled, "assertMetadataImageRuntimeInstalled");
|
|
10499
10618
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
10500
|
-
const projectRequire = createRequire(
|
|
10619
|
+
const projectRequire = createRequire(path8.join(root, "package.json"));
|
|
10501
10620
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
10502
10621
|
if (packageJsonPath) return packageJsonPath;
|
|
10503
10622
|
try {
|
|
@@ -10507,40 +10626,40 @@ function resolveMetadataImageRuntimePackageJson(root) {
|
|
|
10507
10626
|
}
|
|
10508
10627
|
}
|
|
10509
10628
|
__name(resolveMetadataImageRuntimePackageJson, "resolveMetadataImageRuntimePackageJson");
|
|
10510
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
10629
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs3) {
|
|
10511
10630
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
10512
10631
|
if (!packageJsonPath) return;
|
|
10513
|
-
const packageJson = JSON.parse(await
|
|
10514
|
-
const packageDir =
|
|
10515
|
-
const targetDir =
|
|
10516
|
-
await
|
|
10517
|
-
await
|
|
10632
|
+
const packageJson = JSON.parse(await fs3.readFile(packageJsonPath, "utf8"));
|
|
10633
|
+
const packageDir = path8.dirname(packageJsonPath);
|
|
10634
|
+
const targetDir = path8.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
10635
|
+
await fs3.mkdir(path8.dirname(targetDir), { recursive: true });
|
|
10636
|
+
await fs3.cp(packageDir, targetDir, {
|
|
10518
10637
|
recursive: true,
|
|
10519
10638
|
force: true,
|
|
10520
10639
|
dereference: true,
|
|
10521
10640
|
mode: fsConstants.COPYFILE_FICLONE
|
|
10522
10641
|
});
|
|
10523
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
10642
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs3);
|
|
10524
10643
|
functionPackage.dependencies = {
|
|
10525
10644
|
...functionPackage.dependencies,
|
|
10526
10645
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
10527
10646
|
};
|
|
10528
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10647
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs3);
|
|
10529
10648
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
10530
10649
|
}
|
|
10531
10650
|
__name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
|
|
10532
|
-
async function readNitroOutputPackage(outputDir,
|
|
10533
|
-
const packagePath =
|
|
10534
|
-
return
|
|
10651
|
+
async function readNitroOutputPackage(outputDir, fs3) {
|
|
10652
|
+
const packagePath = path8.join(outputDir, "package.json");
|
|
10653
|
+
return fs3.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10535
10654
|
if (error.code === "ENOENT") return {};
|
|
10536
10655
|
throw error;
|
|
10537
10656
|
});
|
|
10538
10657
|
}
|
|
10539
10658
|
__name(readNitroOutputPackage, "readNitroOutputPackage");
|
|
10540
|
-
async function writeNitroOutputPackage(outputDir, packageJson,
|
|
10541
|
-
await
|
|
10542
|
-
await
|
|
10543
|
-
|
|
10659
|
+
async function writeNitroOutputPackage(outputDir, packageJson, fs3) {
|
|
10660
|
+
await fs3.mkdir(outputDir, { recursive: true });
|
|
10661
|
+
await fs3.writeFile(
|
|
10662
|
+
path8.join(outputDir, "package.json"),
|
|
10544
10663
|
`${JSON.stringify(packageJson, null, 2)}
|
|
10545
10664
|
`
|
|
10546
10665
|
);
|
|
@@ -10557,9 +10676,9 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10557
10676
|
}
|
|
10558
10677
|
}
|
|
10559
10678
|
try {
|
|
10560
|
-
let directory =
|
|
10561
|
-
while (directory !==
|
|
10562
|
-
const candidate =
|
|
10679
|
+
let directory = path8.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
10680
|
+
while (directory !== path8.dirname(directory)) {
|
|
10681
|
+
const candidate = path8.join(directory, "package.json");
|
|
10563
10682
|
if (existsSync2(candidate)) {
|
|
10564
10683
|
try {
|
|
10565
10684
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
@@ -10567,52 +10686,52 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10567
10686
|
} catch {
|
|
10568
10687
|
}
|
|
10569
10688
|
}
|
|
10570
|
-
if (
|
|
10571
|
-
directory =
|
|
10689
|
+
if (path8.basename(directory) === "node_modules") break;
|
|
10690
|
+
directory = path8.dirname(directory);
|
|
10572
10691
|
}
|
|
10573
10692
|
} catch {
|
|
10574
10693
|
}
|
|
10575
10694
|
return null;
|
|
10576
10695
|
}
|
|
10577
10696
|
__name(resolvePackageJson, "resolvePackageJson");
|
|
10578
|
-
async function copyPrismaClientForVercel(root, nitroFuncDir,
|
|
10579
|
-
const projectRequire = createRequire(
|
|
10697
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs3) {
|
|
10698
|
+
const projectRequire = createRequire(path8.join(root, "package.json"));
|
|
10580
10699
|
let prismaClientDir;
|
|
10581
10700
|
try {
|
|
10582
|
-
prismaClientDir =
|
|
10701
|
+
prismaClientDir = path8.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
10583
10702
|
} catch {
|
|
10584
10703
|
return;
|
|
10585
10704
|
}
|
|
10586
|
-
const generatedClientDir =
|
|
10705
|
+
const generatedClientDir = path8.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
10587
10706
|
try {
|
|
10588
|
-
await
|
|
10707
|
+
await fs3.access(generatedClientDir);
|
|
10589
10708
|
} catch {
|
|
10590
10709
|
return;
|
|
10591
10710
|
}
|
|
10592
|
-
const targetNodeModules =
|
|
10593
|
-
const targetPrismaScopeDir =
|
|
10594
|
-
const targetGeneratedDir =
|
|
10595
|
-
const targetClientDir =
|
|
10596
|
-
await
|
|
10597
|
-
await
|
|
10711
|
+
const targetNodeModules = path8.join(nitroFuncDir, "node_modules");
|
|
10712
|
+
const targetPrismaScopeDir = path8.join(targetNodeModules, "@prisma");
|
|
10713
|
+
const targetGeneratedDir = path8.join(targetNodeModules, ".prisma", "client");
|
|
10714
|
+
const targetClientDir = path8.join(targetPrismaScopeDir, "client");
|
|
10715
|
+
await fs3.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
10716
|
+
await fs3.cp(prismaClientDir, targetClientDir, {
|
|
10598
10717
|
recursive: true,
|
|
10599
10718
|
force: true
|
|
10600
10719
|
});
|
|
10601
|
-
await
|
|
10720
|
+
await fs3.cp(generatedClientDir, targetGeneratedDir, {
|
|
10602
10721
|
recursive: true,
|
|
10603
10722
|
force: true
|
|
10604
10723
|
});
|
|
10605
|
-
const clientPackagePath =
|
|
10724
|
+
const clientPackagePath = path8.join(prismaClientDir, "package.json");
|
|
10606
10725
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
10607
|
-
readNitroOutputPackage(nitroFuncDir,
|
|
10608
|
-
|
|
10726
|
+
readNitroOutputPackage(nitroFuncDir, fs3),
|
|
10727
|
+
fs3.readFile(clientPackagePath, "utf-8")
|
|
10609
10728
|
]);
|
|
10610
10729
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
10611
10730
|
functionPackage.dependencies = {
|
|
10612
10731
|
...functionPackage.dependencies,
|
|
10613
10732
|
"@prisma/client": clientPackage.version
|
|
10614
10733
|
};
|
|
10615
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10734
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs3);
|
|
10616
10735
|
}
|
|
10617
10736
|
__name(copyPrismaClientForVercel, "copyPrismaClientForVercel");
|
|
10618
10737
|
|
|
@@ -10785,9 +10904,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10785
10904
|
} else {
|
|
10786
10905
|
const { build: legacyViteBuild } = await import("vite");
|
|
10787
10906
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
10788
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
10907
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path9.join(root, distDir, "client"));
|
|
10789
10908
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
10790
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
10909
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path9.join(root, distDir, "server"));
|
|
10791
10910
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
10792
10911
|
await buildNitro(
|
|
10793
10912
|
config,
|
|
@@ -10975,12 +11094,12 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
10975
11094
|
}
|
|
10976
11095
|
__name(buildSSR, "buildSSR");
|
|
10977
11096
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
10978
|
-
const appDir =
|
|
11097
|
+
const appDir = path9.join(root, srcDir, "app");
|
|
10979
11098
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
10980
|
-
const candidate =
|
|
11099
|
+
const candidate = path9.join(appDir, `page${extension}`);
|
|
10981
11100
|
if (existsSync3(candidate)) return candidate;
|
|
10982
11101
|
}
|
|
10983
|
-
return
|
|
11102
|
+
return path9.join(appDir, "page.tsx");
|
|
10984
11103
|
}
|
|
10985
11104
|
__name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
|
|
10986
11105
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
@@ -10999,23 +11118,23 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10999
11118
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
11000
11119
|
}
|
|
11001
11120
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
11002
|
-
const serverOutputDir =
|
|
11003
|
-
const publicOutputDir =
|
|
11121
|
+
const serverOutputDir = path9.join(outputDir, "server");
|
|
11122
|
+
const publicOutputDir = path9.join(outputDir, "public");
|
|
11004
11123
|
const { mkdir, cp } = await import("fs/promises");
|
|
11005
11124
|
await mkdir(serverOutputDir, { recursive: true });
|
|
11006
11125
|
await mkdir(publicOutputDir, { recursive: true });
|
|
11007
|
-
const clientDir =
|
|
11126
|
+
const clientDir = path9.join(root, distDir, "client");
|
|
11008
11127
|
try {
|
|
11009
11128
|
await mkdir(publicOutputDir, { recursive: true });
|
|
11010
11129
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
11011
11130
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
11012
|
-
const manifestPath =
|
|
11013
|
-
const assetsDir =
|
|
11131
|
+
const manifestPath = path9.join(publicOutputDir, "farm-client-manifest.json");
|
|
11132
|
+
const assetsDir = path9.join(publicOutputDir, "assets");
|
|
11014
11133
|
const manifestExists = await import("fs/promises").then(
|
|
11015
|
-
(
|
|
11134
|
+
(fs3) => fs3.access(manifestPath).then(() => true).catch(() => false)
|
|
11016
11135
|
);
|
|
11017
11136
|
const assetsExist = await import("fs/promises").then(
|
|
11018
|
-
(
|
|
11137
|
+
(fs3) => fs3.access(assetsDir).then(() => true).catch(() => false)
|
|
11019
11138
|
);
|
|
11020
11139
|
if (manifestExists && assetsExist) {
|
|
11021
11140
|
logger.info("\u2705 Verified client assets are present");
|
|
@@ -11026,8 +11145,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11026
11145
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
11027
11146
|
throw error;
|
|
11028
11147
|
}
|
|
11029
|
-
const serverDir =
|
|
11030
|
-
const nitroServerDir =
|
|
11148
|
+
const serverDir = path9.join(root, distDir, "server");
|
|
11149
|
+
const nitroServerDir = path9.join(root, distDir, ".nitro", "server", "farm");
|
|
11031
11150
|
try {
|
|
11032
11151
|
await mkdir(nitroServerDir, { recursive: true });
|
|
11033
11152
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -11036,7 +11155,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11036
11155
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
11037
11156
|
}
|
|
11038
11157
|
const nitro = await createNitro(nitroConfig);
|
|
11039
|
-
const registryPath =
|
|
11158
|
+
const registryPath = path9.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
11040
11159
|
try {
|
|
11041
11160
|
const { farmRegistry } = await import(
|
|
11042
11161
|
/* @vite-ignore */
|
|
@@ -11053,7 +11172,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11053
11172
|
}
|
|
11054
11173
|
farmRegistry.routePaths = routePaths;
|
|
11055
11174
|
try {
|
|
11056
|
-
const clientManifestPath =
|
|
11175
|
+
const clientManifestPath = path9.join(root, distDir, "client", "farm-client-manifest.json");
|
|
11057
11176
|
const { readFile } = await import("fs/promises");
|
|
11058
11177
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
11059
11178
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|