@farm.js/core 0.1.34 → 0.1.35
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-runtime.cjs +3 -3
- package/dist/agent-runtime.d.mts +4 -5
- package/dist/agent-runtime.d.ts +4 -5
- package/dist/agent-runtime.mjs +2 -2
- package/dist/api/route-manager.cjs +5 -5
- package/dist/api/route-manager.d.mts +6 -7
- package/dist/api/route-manager.d.ts +6 -7
- package/dist/api/route-manager.mjs +4 -4
- package/dist/api/runtime.cjs +6 -4
- package/dist/api/runtime.d.mts +4 -5
- package/dist/api/runtime.d.ts +4 -5
- package/dist/api/runtime.mjs +6 -4
- package/dist/api.cjs +6 -6
- package/dist/api.d.mts +7 -8
- package/dist/api.d.ts +7 -8
- package/dist/api.mjs +5 -5
- package/dist/{app-DgotYGbq.d.ts → app-BXB3JZYc.d.ts} +38 -12
- package/dist/{app-q4rmZlXK.d.mts → app-D_j9AAVL.d.mts} +38 -12
- package/dist/app-markdown.cjs +5 -5
- package/dist/app-markdown.d.mts +5 -6
- package/dist/app-markdown.d.ts +5 -6
- package/dist/app-markdown.mjs +4 -4
- package/dist/{chunk-LMJ7VRHZ.mjs → chunk-22LTEMGQ.mjs} +1 -1
- package/dist/{chunk-AQZFOP7S.mjs → chunk-2G2NNLE2.mjs} +1 -1
- package/dist/{chunk-QJ3J6MZT.cjs → chunk-3BHT4WMP.cjs} +2 -2
- package/dist/{chunk-X242HVD5.mjs → chunk-3PXS2MHU.mjs} +1 -1
- package/dist/{chunk-A5FGU2WU.cjs → chunk-3UH7MRCP.cjs} +19 -23
- package/dist/{chunk-AGC75XAE.mjs → chunk-4JHOT46A.mjs} +1 -1
- package/dist/{chunk-XV5DJTBX.mjs → chunk-4KU5Q7C2.mjs} +424 -230
- package/dist/{chunk-TA5G2HWD.cjs → chunk-4MMGO7YW.cjs} +21 -21
- package/dist/{chunk-7BT4H4P7.cjs → chunk-62XKI4Z3.cjs} +2 -2
- package/dist/{chunk-ZKP7C2B6.mjs → chunk-6DU6UFUE.mjs} +12 -11
- package/dist/{chunk-GOABMOX3.mjs → chunk-6ETPZTJI.mjs} +366 -4
- package/dist/{chunk-7Y6ZNFPX.mjs → chunk-6TJOML4E.mjs} +13 -3
- package/dist/{chunk-3ATMYLLJ.mjs → chunk-6WCPV6G2.mjs} +1 -1
- package/dist/{chunk-BTAG7LI7.cjs → chunk-73MC7ZL6.cjs} +2 -2
- package/dist/chunk-75RZHGLS.cjs +135 -0
- package/dist/{chunk-VKNHTSAP.cjs → chunk-7GLPRTTF.cjs} +2 -2
- package/dist/{chunk-7M52YUMY.cjs → chunk-7L5V3KQO.cjs} +2 -2
- package/dist/{chunk-LI2LMOLR.mjs → chunk-C35ZBVRD.mjs} +12 -3
- package/dist/{chunk-YQVSHTMR.mjs → chunk-CP6X4AEU.mjs} +1 -1
- package/dist/{chunk-QZCT2CQ4.mjs → chunk-CXEN47J3.mjs} +64 -2
- package/dist/{chunk-ATK2R4CH.cjs → chunk-D227TIEN.cjs} +14 -4
- package/dist/{chunk-ROUTX2E5.cjs → chunk-DBNKI4NF.cjs} +12 -3
- package/dist/{chunk-UX5S4JEO.cjs → chunk-EFCQPQMG.cjs} +3 -3
- package/dist/{chunk-K3F2E6GS.cjs → chunk-EJQT6KZN.cjs} +2 -2
- package/dist/{chunk-3LUF2PE2.cjs → chunk-EK4QAEFZ.cjs} +67 -5
- package/dist/{chunk-VVBO3QH7.mjs → chunk-ENLZ4R3Y.mjs} +10 -1
- package/dist/{chunk-XXJU7FCC.cjs → chunk-EUV4YR3V.cjs} +2 -2
- package/dist/{chunk-WNNYOOIB.mjs → chunk-F6Z3Y5KL.mjs} +1 -1
- package/dist/{chunk-PQDFUSXD.cjs → chunk-F7JZENPF.cjs} +33 -32
- package/dist/{chunk-TDFPACVX.cjs → chunk-FTFYRMQQ.cjs} +18 -18
- package/dist/{chunk-657WJNRY.mjs → chunk-G5RT7EXW.mjs} +1 -1
- package/dist/{chunk-MOKLYNHV.cjs → chunk-GFHLGIYC.cjs} +6 -6
- package/dist/{chunk-AWC4VUZL.cjs → chunk-GQ3Z3IZI.cjs} +14 -14
- package/dist/{chunk-75WGQVQA.cjs → chunk-HITLGIAO.cjs} +10 -1
- package/dist/{chunk-GNSDTTWZ.mjs → chunk-HMIJDL7S.mjs} +1 -1
- package/dist/{chunk-PXKIEXZD.mjs → chunk-HUMR6LSU.mjs} +1 -1
- package/dist/{chunk-SJVKK4JE.cjs → chunk-ICUQICNC.cjs} +912 -718
- package/dist/{chunk-P64MIF5B.cjs → chunk-IPXLADVO.cjs} +387 -25
- package/dist/{chunk-KROWKCUH.cjs → chunk-JGLC4TO3.cjs} +8 -1
- package/dist/{chunk-2NQQ5H5G.cjs → chunk-M7MKQXAF.cjs} +2 -1
- package/dist/chunk-NRDBW4MP.mjs +45 -0
- package/dist/chunk-OFZUJMCU.mjs +601 -0
- package/dist/{chunk-VCCUOMQN.mjs → chunk-OKZUAXHF.mjs} +1 -1
- package/dist/{chunk-EM6SBQKM.cjs → chunk-OMVAU7NT.cjs} +27 -2
- package/dist/{chunk-O27L4YAA.mjs → chunk-PDOCJ6RY.mjs} +2 -2
- package/dist/{chunk-36MK5YCW.cjs → chunk-PFQKNERH.cjs} +346 -206
- package/dist/{chunk-HR5KPHC2.mjs → chunk-Q3VLETLE.mjs} +1 -1
- package/dist/{chunk-LR5QSC2P.mjs → chunk-QAU5JD57.mjs} +211 -71
- package/dist/{chunk-LHODW25H.mjs → chunk-QORUJDIV.mjs} +2 -2
- package/dist/{chunk-UBO4SGH4.mjs → chunk-RHAZ22ZN.mjs} +2 -1
- package/dist/{chunk-ZHPHJPQP.cjs → chunk-RU3M2FIK.cjs} +18 -14
- package/dist/{chunk-JDPAKVS4.mjs → chunk-SAZVVAJH.mjs} +3 -3
- package/dist/{chunk-6VVL3MHY.mjs → chunk-SC2WYWPF.mjs} +1 -1
- package/dist/{chunk-QCFFHV5H.mjs → chunk-SMHH4VDG.mjs} +1 -1
- package/dist/{chunk-U4PTAHW3.mjs → chunk-SOMHP6GF.mjs} +7 -11
- package/dist/{chunk-VHANUNEG.mjs → chunk-UAORZ7QA.mjs} +2 -2
- package/dist/{chunk-NGVORZVZ.mjs → chunk-UJD4PHYB.mjs} +15 -11
- package/dist/{chunk-U74I55WB.cjs → chunk-ULAWS2PA.cjs} +13 -3
- package/dist/{chunk-MPEYMSCF.cjs → chunk-VFQT3LAO.cjs} +5 -5
- package/dist/{chunk-Z2YLTERK.cjs → chunk-VZJR7UTG.cjs} +6 -6
- package/dist/chunk-WWFTAUFG.cjs +45 -0
- package/dist/{chunk-ZUSJDQ2Q.mjs → chunk-WWIKMBRN.mjs} +1 -1
- package/dist/{chunk-QGYRXFU2.cjs → chunk-X6W5FFH6.cjs} +8 -8
- package/dist/{chunk-MIDIZJZC.cjs → chunk-XBML5KMG.cjs} +8 -8
- package/dist/{chunk-G26MUMKL.cjs → chunk-XCACDAZZ.cjs} +4 -4
- package/dist/{chunk-CLJYVZAD.mjs → chunk-XCMCS4DA.mjs} +11 -1
- package/dist/{chunk-XF7Q24PF.mjs → chunk-Y7RKTKYI.mjs} +25 -0
- package/dist/{chunk-ODBZYBAB.cjs → chunk-YC6V7PWE.cjs} +1 -1
- package/dist/{chunk-F6OHXPWR.mjs → chunk-YFILVET3.mjs} +8 -1
- package/dist/{chunk-DZ4DTRJ5.cjs → chunk-YKX5BK66.cjs} +7 -7
- package/dist/chunk-YSLWRWWP.cjs +601 -0
- package/dist/{chunk-3VSKDFAT.mjs → chunk-YULD7ICZ.mjs} +1 -1
- package/dist/chunk-ZLAT2CWY.mjs +135 -0
- package/dist/{chunk-T5CERMEH.cjs → chunk-ZXGAFZDO.cjs} +2 -2
- package/dist/{client-plugins-CLObcuCq.d.mts → client-plugins-CvIslxWi.d.mts} +207 -7
- package/dist/{client-plugins-DZjHC4Mi.d.ts → client-plugins-HIyulDym.d.ts} +207 -7
- package/dist/client-plugins.d.mts +4 -5
- package/dist/client-plugins.d.ts +4 -5
- package/dist/client.cjs +5 -5
- package/dist/client.d.mts +8 -9
- package/dist/client.d.ts +8 -9
- package/dist/client.mjs +4 -4
- package/dist/config.d.mts +4 -5
- package/dist/config.d.ts +4 -5
- package/dist/{devtools-HU6Y2MNV.cjs → devtools-EAUY43BS.cjs} +9 -9
- package/dist/{devtools-RNXCTS4R.mjs → devtools-EE5RIBTH.mjs} +8 -8
- package/dist/docs.cjs +12 -12
- package/dist/docs.d.mts +41 -4
- package/dist/docs.d.ts +41 -4
- package/dist/docs.mjs +11 -11
- package/dist/i18n/client.d.mts +2 -2
- package/dist/i18n/client.d.ts +2 -2
- package/dist/i18n/index.d.mts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/server.d.mts +5 -5
- package/dist/i18n/server.d.ts +5 -5
- package/dist/image/server.cjs +3 -3
- package/dist/image/server.mjs +2 -2
- package/dist/image/sharp.cjs +10 -10
- package/dist/image/sharp.mjs +2 -2
- package/dist/{index-a-8Z5kZU.d.mts → index-BJJfLxJo.d.mts} +2 -2
- package/dist/{index-BWVfxIsO.d.ts → index-CwoOP-MW.d.ts} +2 -2
- package/dist/index.cjs +38 -35
- package/dist/index.d.mts +19 -20
- package/dist/index.d.ts +19 -20
- package/dist/index.mjs +37 -34
- package/dist/integrations.cjs +3 -3
- package/dist/integrations.d.mts +4 -5
- package/dist/integrations.d.ts +4 -5
- package/dist/integrations.mjs +2 -2
- package/dist/internal/app-markdown-runtime.cjs +4 -4
- package/dist/internal/app-markdown-runtime.d.mts +5 -6
- package/dist/internal/app-markdown-runtime.d.ts +5 -6
- package/dist/internal/app-markdown-runtime.mjs +3 -3
- package/dist/internal/build-runtime.cjs +26 -26
- package/dist/internal/build-runtime.d.mts +6 -7
- package/dist/internal/build-runtime.d.ts +6 -7
- package/dist/internal/build-runtime.mjs +25 -25
- package/dist/internal/cli-runtime.cjs +13 -13
- package/dist/internal/cli-runtime.mjs +12 -12
- package/dist/internal/client-error-overlay.cjs +6 -6
- package/dist/internal/client-error-overlay.mjs +2 -2
- package/dist/internal/client-runtime.cjs +2 -2
- package/dist/internal/client-runtime.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +4 -5
- package/dist/internal/compression-runtime.d.ts +4 -5
- package/dist/internal/config-runtime.cjs +9 -9
- package/dist/internal/config-runtime.d.mts +5 -6
- package/dist/internal/config-runtime.d.ts +5 -6
- package/dist/internal/config-runtime.mjs +8 -8
- package/dist/internal/isolated-boundary.cjs +3 -2
- package/dist/internal/isolated-boundary.d.mts +1 -0
- package/dist/internal/isolated-boundary.d.ts +1 -0
- package/dist/internal/isolated-boundary.mjs +2 -1
- package/dist/internal/metadata-image-runtime.cjs +3 -3
- package/dist/internal/metadata-image-runtime.mjs +2 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +47 -23
- package/dist/internal/production-runtime.d.mts +58 -18
- package/dist/internal/production-runtime.d.ts +58 -18
- package/dist/internal/production-runtime.mjs +43 -19
- package/dist/internal/server-tree.cjs +12 -0
- package/dist/internal/server-tree.d.mts +27 -0
- package/dist/internal/server-tree.d.ts +27 -0
- package/dist/internal/server-tree.mjs +12 -0
- package/dist/markdown.cjs +3 -3
- package/dist/markdown.d.mts +4 -5
- package/dist/markdown.d.ts +4 -5
- package/dist/markdown.mjs +2 -2
- package/dist/{metadata-Cjs8JMRM.d.ts → metadata-BnLDsUOS.d.ts} +16 -2
- package/dist/{metadata-2HSU2i_w.d.mts → metadata-WGpBYcGn.d.mts} +16 -2
- package/dist/middleware.cjs +4 -4
- package/dist/middleware.d.mts +6 -7
- package/dist/middleware.d.ts +6 -7
- package/dist/middleware.mjs +3 -3
- package/dist/navigation.cjs +5 -5
- package/dist/navigation.d.mts +7 -8
- package/dist/navigation.d.ts +7 -8
- package/dist/navigation.mjs +4 -4
- package/dist/{nitro-4XGPNIK4.mjs → nitro-MXRDCXWZ.mjs} +2 -2
- package/dist/{nitro-HSAQFXSS.cjs → nitro-OVPLKPE2.cjs} +3 -3
- package/dist/{observability-BupkiN0m.d.mts → observability-CoXunYhS.d.mts} +4 -3
- package/dist/{observability-BupkiN0m.d.ts → observability-CoXunYhS.d.ts} +4 -3
- package/dist/observability.d.mts +1 -1
- package/dist/observability.d.ts +1 -1
- package/dist/plugin.cjs +22 -22
- package/dist/plugin.d.mts +4 -5
- package/dist/plugin.d.ts +4 -5
- package/dist/plugin.mjs +21 -21
- package/dist/{production-runtime-CysZl3EV.d.mts → production-runtime-0sRnuYc-.d.mts} +4 -4
- package/dist/{production-runtime-BU5ETAK9.d.ts → production-runtime-Crq6CJ-2.d.ts} +4 -4
- package/dist/query/client.cjs +6 -6
- package/dist/query/client.mjs +2 -2
- package/dist/{render-plan-D72O1qm4.d.ts → render-plan-8ozZh2Qv.d.ts} +1 -1
- package/dist/{render-plan-CKr4ltOd.d.mts → render-plan-gs9GGPzw.d.mts} +1 -1
- package/dist/renderer/react/server.cjs +10 -4
- package/dist/renderer/react/server.d.mts +2 -1
- package/dist/renderer/react/server.d.ts +2 -1
- package/dist/renderer/react/server.mjs +7 -1
- package/dist/renderer-client.cjs +5 -5
- package/dist/renderer-client.d.mts +6 -7
- package/dist/renderer-client.d.ts +6 -7
- package/dist/renderer-client.mjs +2 -2
- package/dist/renderer.d.mts +2 -0
- package/dist/renderer.d.ts +2 -0
- package/dist/{request-DbyOYI2j.d.ts → request-B5G8rLBH.d.ts} +1 -1
- package/dist/{request-Be83WafN.d.mts → request-fkhiynXe.d.mts} +1 -1
- package/dist/request.d.mts +5 -6
- package/dist/request.d.ts +5 -6
- package/dist/{resolver-PPEeiJ6M.d.ts → resolver-DadfRL6F.d.ts} +1 -1
- package/dist/{resolver-DhW0CqZN.d.mts → resolver-khasx3fU.d.mts} +1 -1
- package/dist/{route-rendering-BG56SzvJ.d.mts → route-rendering-CLnS7AZj.d.mts} +1 -1
- package/dist/{route-rendering-CtVMpV-k.d.ts → route-rendering-lS5nUMua.d.ts} +1 -1
- package/dist/{router-D94-SDlW.d.ts → router-4iuiYnOW.d.ts} +1 -1
- package/dist/{router-ALUvm8gC.d.mts → router-ifU8Dui1.d.mts} +1 -1
- package/dist/routes.d.mts +4 -5
- package/dist/routes.d.ts +4 -5
- package/dist/{runtime-BirxPwbZ.d.ts → runtime-BgDQzBiu.d.ts} +2 -2
- package/dist/{runtime-AOJge4vQ.d.mts → runtime-CV2UCV-5.d.mts} +2 -2
- package/dist/server-action-security.cjs +3 -3
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn.cjs +4 -4
- package/dist/server-fn.mjs +3 -3
- package/dist/server-plugins.d.mts +5 -6
- package/dist/server-plugins.d.ts +5 -6
- package/dist/server-query.cjs +5 -5
- package/dist/server-query.mjs +4 -4
- package/dist/server.cjs +41 -41
- package/dist/server.d.mts +13 -14
- package/dist/server.d.ts +13 -14
- package/dist/server.mjs +24 -24
- package/dist/{spa-router-DbxNRKOB.d.mts → spa-router-Bq7VCOwx.d.mts} +3 -3
- package/dist/{spa-router-CxK3USIz.d.ts → spa-router-DaJk5Re4.d.ts} +3 -3
- package/dist/testing.cjs +7 -7
- package/dist/testing.d.mts +4 -5
- package/dist/testing.d.ts +4 -5
- package/dist/testing.mjs +5 -5
- package/dist/{types-Z0aotQ8w.d.mts → types-CnH8DOqo.d.mts} +1 -1
- package/dist/{types-Z0aotQ8w.d.ts → types-CnH8DOqo.d.ts} +1 -1
- package/dist/{utils-311Y8eoK.d.ts → utils-BXLmFsVR.d.ts} +1 -1
- package/dist/{utils-4wVRcpOw.d.mts → utils-XJn0c9bj.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +22 -22
- package/dist/vite.d.mts +4 -5
- package/dist/vite.d.ts +4 -5
- package/dist/vite.mjs +21 -21
- package/dist/{workflows-CR9ex-gz.d.ts → workflows-jZ4BcdoZ.d.mts} +1 -1
- package/dist/{workflows-CR9ex-gz.d.mts → workflows-jZ4BcdoZ.d.ts} +1 -1
- package/dist/workflows.cjs +3 -3
- package/dist/workflows.d.mts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.mjs +2 -2
- package/package.json +9 -1
- package/dist/chunk-M64YUMA4.cjs +0 -58
- package/dist/chunk-QLQ32WC4.mjs +0 -58
- package/dist/types-DFbjpjXX.d.mts +0 -105
- package/dist/types-DFbjpjXX.d.ts +0 -105
|
@@ -6,7 +6,7 @@ var _chunk4PPEPOZZcjs = require('./chunk-4PPEPOZZ.cjs');
|
|
|
6
6
|
var _chunkMQ3H6LT5cjs = require('./chunk-MQ3H6LT5.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkXBML5KMGcjs = require('./chunk-XBML5KMG.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkSJNMVDDFcjs = require('./chunk-SJNMVDDF.cjs');
|
|
@@ -20,7 +20,7 @@ var _chunk2CQ74SP6cjs = require('./chunk-2CQ74SP6.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkXCACDAZZcjs = require('./chunk-XCACDAZZ.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
|
|
@@ -28,7 +28,7 @@ var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var _chunkOMVAU7NTcjs = require('./chunk-OMVAU7NT.cjs');
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
var _chunkM2L4MYDQcjs = require('./chunk-M2L4MYDQ.cjs');
|
|
@@ -58,7 +58,7 @@ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
|
58
58
|
function farmApiPlugin(options = {}) {
|
|
59
59
|
const srcDir = _nullishCoalesce(options.srcDir, () => ( "src"));
|
|
60
60
|
const debug = _nullishCoalesce(options.debug, () => ( false));
|
|
61
|
-
const bodySizeLimit =
|
|
61
|
+
const bodySizeLimit = _chunkOMVAU7NTcjs.resolveFarmServerConfig.call(void 0, {
|
|
62
62
|
bodySizeLimit: options.bodySizeLimit
|
|
63
63
|
}).bodySizeLimit;
|
|
64
64
|
const basePath = options.basePath;
|
|
@@ -110,7 +110,7 @@ function farmApiPlugin(options = {}) {
|
|
|
110
110
|
const existing = apiRoutesCache.get(routePath);
|
|
111
111
|
const existingFile = _optionalChain([endpointSources, 'access', _ => _.get, 'call', _2 => _2(routePath), 'optionalAccess', _3 => _3.get, 'call', _4 => _4(normalizedMethod)]);
|
|
112
112
|
if (existingFile) {
|
|
113
|
-
throw new (0,
|
|
113
|
+
throw new (0, _chunkXBML5KMGcjs.APIRouteConflictError)(routePath, normalizedMethod, existingFile, filePath);
|
|
114
114
|
}
|
|
115
115
|
if (existing) {
|
|
116
116
|
if (!existing.methods.includes(normalizedMethod)) {
|
|
@@ -186,7 +186,7 @@ function farmApiPlugin(options = {}) {
|
|
|
186
186
|
const createRouter = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
|
|
187
187
|
const plugins = options.plugins ? await (_nullishCoalesce(routePlugins, () => ( (routePlugins = Promise.resolve(options.plugins({ root: projectRoot })))))) : [];
|
|
188
188
|
pluginMergedRoutes = plugins.length ? new Map(
|
|
189
|
-
|
|
189
|
+
_chunkXCACDAZZcjs.mergePluginAPIRoutes.call(void 0, [...apiRoutesCache.values()], plugins, void 0, {
|
|
190
190
|
bodySizeLimit
|
|
191
191
|
}).map((route) => [route.path, route])
|
|
192
192
|
) : null;
|
|
@@ -200,7 +200,7 @@ function farmApiPlugin(options = {}) {
|
|
|
200
200
|
const url = new URL(request.url);
|
|
201
201
|
const method = request.method.toUpperCase();
|
|
202
202
|
const pathname = url.pathname;
|
|
203
|
-
const match =
|
|
203
|
+
const match = _chunkXCACDAZZcjs.matchAPIRouteAtBasePath.call(void 0, servedRoutes(), pathname, basePath);
|
|
204
204
|
if (!match) {
|
|
205
205
|
return new Response(JSON.stringify({ error: "Not Found" }), {
|
|
206
206
|
status: 404,
|
|
@@ -208,18 +208,18 @@ function farmApiPlugin(options = {}) {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
const { route, params } = match;
|
|
211
|
-
const endpoint =
|
|
211
|
+
const endpoint = _chunkXCACDAZZcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
|
|
212
212
|
if (!endpoint) {
|
|
213
213
|
return new Response(JSON.stringify({ error: "Method Not Allowed" }), {
|
|
214
214
|
status: 405,
|
|
215
215
|
headers: {
|
|
216
|
-
Allow:
|
|
216
|
+
Allow: _chunkXCACDAZZcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
|
|
217
217
|
"Content-Type": "application/json"
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
try {
|
|
222
|
-
return await
|
|
222
|
+
return await _chunkXCACDAZZcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, bodySizeLimit);
|
|
223
223
|
} catch (error) {
|
|
224
224
|
return new Response(JSON.stringify({ error: error.message || "Internal Server Error" }), {
|
|
225
225
|
status: 500,
|
|
@@ -267,7 +267,7 @@ function farmApiPlugin(options = {}) {
|
|
|
267
267
|
const routeModule = await _chunkBMWDEBXOcjs.loadFarmDevModule.call(void 0, server, filePath);
|
|
268
268
|
const endpoints = {};
|
|
269
269
|
const availableMethods = [];
|
|
270
|
-
for (const method of
|
|
270
|
+
for (const method of _chunkXCACDAZZcjs.API_ROUTE_METHODS) {
|
|
271
271
|
if (routeModule[method]) {
|
|
272
272
|
availableMethods.push(method);
|
|
273
273
|
endpoints[method] = routeModule[method];
|
|
@@ -280,7 +280,7 @@ function farmApiPlugin(options = {}) {
|
|
|
280
280
|
log(`API route discovered: ${availableMethods.join(", ")} ${routePath}`);
|
|
281
281
|
}
|
|
282
282
|
} catch (e) {
|
|
283
|
-
if (e instanceof
|
|
283
|
+
if (e instanceof _chunkXBML5KMGcjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
284
284
|
log(`API route load failed at ${filePath}: ${e.message}`);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
@@ -307,7 +307,7 @@ function farmApiPlugin(options = {}) {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
} catch (e) {
|
|
310
|
-
if (e instanceof
|
|
310
|
+
if (e instanceof _chunkXBML5KMGcjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
311
311
|
log(`Root routes.ts load failed: ${e.message}`);
|
|
312
312
|
}
|
|
313
313
|
break;
|
|
@@ -338,7 +338,7 @@ function farmApiPlugin(options = {}) {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
} catch (e) {
|
|
341
|
-
if (e instanceof
|
|
341
|
+
if (e instanceof _chunkXBML5KMGcjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
342
342
|
log(`Programmatic routes file load failed at ${routeFile}: ${e.message}`);
|
|
343
343
|
}
|
|
344
344
|
}
|
|
@@ -390,7 +390,7 @@ function farmApiPlugin(options = {}) {
|
|
|
390
390
|
const pathname = url.split("?")[0];
|
|
391
391
|
const method = req.method || "GET";
|
|
392
392
|
if (discoveryPromise) await waitForDiscovery();
|
|
393
|
-
if (!
|
|
393
|
+
if (!_chunkXCACDAZZcjs.matchAPIRouteAtBasePath.call(void 0, servedRoutes(), pathname, basePath)) {
|
|
394
394
|
return next();
|
|
395
395
|
}
|
|
396
396
|
if (!apiRouterHandler) {
|
|
@@ -411,7 +411,7 @@ function farmApiPlugin(options = {}) {
|
|
|
411
411
|
}
|
|
412
412
|
const currentUrl = req.url || url;
|
|
413
413
|
const currentPathname = currentUrl.split("?")[0];
|
|
414
|
-
if (currentPathname !== pathname && !
|
|
414
|
+
if (currentPathname !== pathname && !_chunkXCACDAZZcjs.matchAPIRouteAtBasePath.call(void 0, servedRoutes(), currentPathname, basePath)) {
|
|
415
415
|
return next();
|
|
416
416
|
}
|
|
417
417
|
const fullUrl = _chunkUXFQ3UDAcjs.resolveFarmRequestURL.call(void 0, req);
|
|
@@ -423,7 +423,7 @@ function farmApiPlugin(options = {}) {
|
|
|
423
423
|
}
|
|
424
424
|
let body;
|
|
425
425
|
if (method !== "GET" && method !== "HEAD") {
|
|
426
|
-
body = await
|
|
426
|
+
body = await _chunkOMVAU7NTcjs.readNodeRequestBody.call(void 0, req, bodySizeLimit);
|
|
427
427
|
}
|
|
428
428
|
const request = new Request(fullUrl, {
|
|
429
429
|
method,
|
|
@@ -438,7 +438,7 @@ function farmApiPlugin(options = {}) {
|
|
|
438
438
|
logResponse(method, currentPathname, response.status, duration);
|
|
439
439
|
await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response);
|
|
440
440
|
} catch (error) {
|
|
441
|
-
const bodyErrorResponse =
|
|
441
|
+
const bodyErrorResponse = _chunkOMVAU7NTcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
|
|
442
442
|
if (bodyErrorResponse) {
|
|
443
443
|
await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, bodyErrorResponse);
|
|
444
444
|
return;
|
|
@@ -515,7 +515,7 @@ function farmApiPlugin(options = {}) {
|
|
|
515
515
|
log(`API router recreated`);
|
|
516
516
|
} catch (e) {
|
|
517
517
|
restoreRouteState(previousState);
|
|
518
|
-
if (e instanceof
|
|
518
|
+
if (e instanceof _chunkXBML5KMGcjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
519
519
|
log(`Root routes.ts HMR failed: ${e.message}`);
|
|
520
520
|
}
|
|
521
521
|
return [];
|
|
@@ -543,7 +543,7 @@ function farmApiPlugin(options = {}) {
|
|
|
543
543
|
const routeModule = await _chunkBMWDEBXOcjs.loadFarmDevModule.call(void 0, server, file);
|
|
544
544
|
removeEndpointsFromFile(file);
|
|
545
545
|
const availableMethods = [];
|
|
546
|
-
for (const method of
|
|
546
|
+
for (const method of _chunkXCACDAZZcjs.API_ROUTE_METHODS) {
|
|
547
547
|
if (!routeModule[method]) continue;
|
|
548
548
|
availableMethods.push(method);
|
|
549
549
|
addEndpoint(routePath, file, method, routeModule[method]);
|
|
@@ -553,7 +553,7 @@ function farmApiPlugin(options = {}) {
|
|
|
553
553
|
log(`API router recreated`);
|
|
554
554
|
} catch (e) {
|
|
555
555
|
restoreRouteState(previousState);
|
|
556
|
-
if (e instanceof
|
|
556
|
+
if (e instanceof _chunkXBML5KMGcjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
557
557
|
log(`API route HMR failed: ${e.message}`);
|
|
558
558
|
}
|
|
559
559
|
return [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkULAWS2PAcjs = require('./chunk-ULAWS2PA.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkHLJ6MBUZcjs = require('./chunk-HLJ6MBUZ.cjs');
|
|
@@ -415,7 +415,7 @@ function farmMiddlewarePlugin(options = {}) {
|
|
|
415
415
|
mode: server.config.mode === "production" ? "production" : "development",
|
|
416
416
|
basePath: _nullishCoalesce(options.basePath, () => ( "/"))
|
|
417
417
|
});
|
|
418
|
-
manager = new (0,
|
|
418
|
+
manager = new (0, _chunkULAWS2PAcjs.MiddlewareManager)(
|
|
419
419
|
getMiddlewareAppDirectory(server.config.root, srcDir),
|
|
420
420
|
server,
|
|
421
421
|
options.middleware,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
resolveFarmNoindexPreviews,
|
|
30
30
|
resolveFarmPerformanceConfig,
|
|
31
31
|
resolveFarmSecurityConfig
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-UJD4PHYB.mjs";
|
|
33
33
|
import {
|
|
34
34
|
resolveFarmImageConfig
|
|
35
35
|
} from "./chunk-G2KY33I6.mjs";
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from "./chunk-YHOCRI4H.mjs";
|
|
39
39
|
import {
|
|
40
40
|
resolveServerActionsConfig
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-SMHH4VDG.mjs";
|
|
42
42
|
import {
|
|
43
43
|
resolveEnv,
|
|
44
44
|
setEnv
|
|
@@ -48,22 +48,22 @@ import {
|
|
|
48
48
|
} from "./chunk-FA2W42OV.mjs";
|
|
49
49
|
import {
|
|
50
50
|
resolveMarkdownConfig
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-WWIKMBRN.mjs";
|
|
52
52
|
import {
|
|
53
53
|
bundleNodeModule
|
|
54
54
|
} from "./chunk-SFGWNC43.mjs";
|
|
55
55
|
import {
|
|
56
56
|
resolveWorkflowsConfig
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-6WCPV6G2.mjs";
|
|
58
58
|
import {
|
|
59
59
|
resolveFarmThemeConfig
|
|
60
60
|
} from "./chunk-AELACLOB.mjs";
|
|
61
61
|
import {
|
|
62
62
|
resolveIntegrationPlugins
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-HMIJDL7S.mjs";
|
|
64
64
|
import {
|
|
65
65
|
resolveFarmServerConfig
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-Y7RKTKYI.mjs";
|
|
67
67
|
import {
|
|
68
68
|
resolveFarmI18nConfig
|
|
69
69
|
} from "./chunk-BCMSYSN2.mjs";
|
|
@@ -140,16 +140,17 @@ function resolveFarmAgentConfig(input, context = {}) {
|
|
|
140
140
|
// llms-full.txt renders every listed page, so it stays opt-in.
|
|
141
141
|
llmsTxt: resolveFarmLlmsTxtConfig(input?.llmsTxt ?? (context.docs ? false : { full: false })),
|
|
142
142
|
crawlers: resolveFarmAgentCrawlers(input?.crawlers),
|
|
143
|
-
apiCatalog:
|
|
143
|
+
apiCatalog: resolveFarmAgentBoolean(input?.apiCatalog, "apiCatalog", false),
|
|
144
|
+
aiCatalog: resolveFarmAgentBoolean(input?.aiCatalog, "aiCatalog", true)
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
__name(resolveFarmAgentConfig, "resolveFarmAgentConfig");
|
|
147
|
-
function
|
|
148
|
-
if (input === void 0) return
|
|
149
|
-
if (typeof input !== "boolean") throw new TypeError(
|
|
148
|
+
function resolveFarmAgentBoolean(input, key, fallback) {
|
|
149
|
+
if (input === void 0) return fallback;
|
|
150
|
+
if (typeof input !== "boolean") throw new TypeError(`agent.${key} must be a boolean.`);
|
|
150
151
|
return input;
|
|
151
152
|
}
|
|
152
|
-
__name(
|
|
153
|
+
__name(resolveFarmAgentBoolean, "resolveFarmAgentBoolean");
|
|
153
154
|
|
|
154
155
|
// src/docs/framework-detect.ts
|
|
155
156
|
import { readFile } from "fs/promises";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-XAXTTBUT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
serializeFarmLlmsTxt
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UJD4PHYB.mjs";
|
|
7
7
|
import {
|
|
8
8
|
emitFarmAgentRead
|
|
9
9
|
} from "./chunk-MVL2RAJW.mjs";
|
|
@@ -14,15 +14,19 @@ import {
|
|
|
14
14
|
omitFarmResponseBody
|
|
15
15
|
} from "./chunk-5WI2S4CO.mjs";
|
|
16
16
|
import {
|
|
17
|
-
_listFarmMCPCatalogs
|
|
18
|
-
|
|
17
|
+
_listFarmMCPCatalogs,
|
|
18
|
+
_listFarmRegisteredMCPServers
|
|
19
|
+
} from "./chunk-ZLAT2CWY.mjs";
|
|
20
|
+
import {
|
|
21
|
+
matchesFarmIfNoneMatch
|
|
22
|
+
} from "./chunk-Y7RKTKYI.mjs";
|
|
19
23
|
import {
|
|
20
24
|
resolveFarmAPIServerBasePath,
|
|
21
25
|
resolveFarmAPIServerRoutePath
|
|
22
26
|
} from "./chunk-BTHHUD7Q.mjs";
|
|
23
27
|
import {
|
|
24
28
|
FARM_VERSION
|
|
25
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3PXS2MHU.mjs";
|
|
26
30
|
import {
|
|
27
31
|
localizeFarmPathname
|
|
28
32
|
} from "./chunk-L3KT7IXV.mjs";
|
|
@@ -33,6 +37,184 @@ import {
|
|
|
33
37
|
__name
|
|
34
38
|
} from "./chunk-LPEX4YW6.mjs";
|
|
35
39
|
|
|
40
|
+
// src/routing/route-groups.ts
|
|
41
|
+
function isRouteGroupSegment(part) {
|
|
42
|
+
return part.startsWith("(") && part.endsWith(")");
|
|
43
|
+
}
|
|
44
|
+
__name(isRouteGroupSegment, "isRouteGroupSegment");
|
|
45
|
+
function formatRouteSegment(segment) {
|
|
46
|
+
if (!segment.isDynamic) return segment.segment;
|
|
47
|
+
if (segment.isCatchAll) {
|
|
48
|
+
return segment.isOptional ? `[[...${segment.segment}]]` : `[...${segment.segment}]`;
|
|
49
|
+
}
|
|
50
|
+
return `[${segment.segment}]`;
|
|
51
|
+
}
|
|
52
|
+
__name(formatRouteSegment, "formatRouteSegment");
|
|
53
|
+
function createRouteDirectoryPattern(route) {
|
|
54
|
+
const parts = route.filePath.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
55
|
+
parts.pop();
|
|
56
|
+
if (parts.length === 0) return "/";
|
|
57
|
+
let segmentIndex = 0;
|
|
58
|
+
const directory = parts.map((part) => {
|
|
59
|
+
if (isRouteGroupSegment(part)) return part;
|
|
60
|
+
const segment = route.segments[segmentIndex++];
|
|
61
|
+
return segment ? formatRouteSegment(segment) : part;
|
|
62
|
+
});
|
|
63
|
+
return `/${directory.join("/")}`;
|
|
64
|
+
}
|
|
65
|
+
__name(createRouteDirectoryPattern, "createRouteDirectoryPattern");
|
|
66
|
+
function stripRouteGroups(pattern) {
|
|
67
|
+
if (!pattern.includes("(")) return pattern;
|
|
68
|
+
const parts = pattern.split("/").filter((part) => part && !isRouteGroupSegment(part));
|
|
69
|
+
return parts.length === 0 ? "/" : `/${parts.join("/")}`;
|
|
70
|
+
}
|
|
71
|
+
__name(stripRouteGroups, "stripRouteGroups");
|
|
72
|
+
function getRouteGroupScope(pattern) {
|
|
73
|
+
if (!pattern.includes("(")) return null;
|
|
74
|
+
const parts = pattern.split("/");
|
|
75
|
+
for (let index = parts.length - 1; index > 0; index--) {
|
|
76
|
+
if (isRouteGroupSegment(parts[index])) return parts.slice(0, index + 1).join("/");
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
__name(getRouteGroupScope, "getRouteGroupScope");
|
|
81
|
+
function isInRouteGroupScope(directory, scope) {
|
|
82
|
+
if (scope === null) return true;
|
|
83
|
+
if (typeof directory !== "string") return false;
|
|
84
|
+
return directory === scope || directory.startsWith(`${scope}/`);
|
|
85
|
+
}
|
|
86
|
+
__name(isInRouteGroupScope, "isInRouteGroupScope");
|
|
87
|
+
function getRouteDirectoryDepth(pattern) {
|
|
88
|
+
return pattern.split("/").filter(Boolean).length;
|
|
89
|
+
}
|
|
90
|
+
__name(getRouteDirectoryDepth, "getRouteDirectoryDepth");
|
|
91
|
+
function routeBoundaryCoversDirectory(boundaryPattern, directory) {
|
|
92
|
+
const boundaryUrl = stripRouteGroups(boundaryPattern);
|
|
93
|
+
const routeUrl = stripRouteGroups(directory);
|
|
94
|
+
return (boundaryUrl === "/" || routeUrl === boundaryUrl || routeUrl.startsWith(`${boundaryUrl.replace(/\/$/, "")}/`)) && isInRouteGroupScope(directory, getRouteGroupScope(boundaryPattern));
|
|
95
|
+
}
|
|
96
|
+
__name(routeBoundaryCoversDirectory, "routeBoundaryCoversDirectory");
|
|
97
|
+
|
|
98
|
+
// src/server/full-document.ts
|
|
99
|
+
var CONTENTS_WRAPPER = /^<div\b[^>]*style="display\s*:\s*contents"[^>]*>/i;
|
|
100
|
+
var HOISTED_HEAD_ELEMENT = /^(?:<(?:meta|link|base)\b[^>]*>|<title\b[^>]*>[\s\S]*?<\/title>|<script\b[^>]*\basync\b[^>]*><\/script>|<style\b[^>]*\bdata-precedence\b[^>]*>[\s\S]*?<\/style>)/i;
|
|
101
|
+
function peelDocumentPrefix(markup) {
|
|
102
|
+
let inner = markup.replace(/^\s+/, "");
|
|
103
|
+
let hoisted = "";
|
|
104
|
+
let match;
|
|
105
|
+
while (match = CONTENTS_WRAPPER.exec(inner) ?? HOISTED_HEAD_ELEMENT.exec(inner)) {
|
|
106
|
+
if (!/^<div/i.test(match[0])) hoisted += match[0];
|
|
107
|
+
inner = inner.slice(match[0].length).replace(/^\s+/, "");
|
|
108
|
+
}
|
|
109
|
+
return { inner, hoisted };
|
|
110
|
+
}
|
|
111
|
+
__name(peelDocumentPrefix, "peelDocumentPrefix");
|
|
112
|
+
function restoreHoistedHead(document, hoisted) {
|
|
113
|
+
if (!hoisted) return document;
|
|
114
|
+
if (/<head[\s>]/i.test(document)) {
|
|
115
|
+
return document.replace(/<head\b[^>]*>/i, (open) => open + hoisted);
|
|
116
|
+
}
|
|
117
|
+
return document.replace(/<html\b[^>]*>/i, (open) => `${open}<head>${hoisted}</head>`);
|
|
118
|
+
}
|
|
119
|
+
__name(restoreHoistedHead, "restoreHoistedHead");
|
|
120
|
+
function extractFarmFullDocument(markup) {
|
|
121
|
+
const { inner, hoisted } = peelDocumentPrefix(markup);
|
|
122
|
+
if (!/^<!doctype/i.test(inner) && !/^<html[\s>]/i.test(inner)) return null;
|
|
123
|
+
const start = markup.search(/<!doctype|<html[\s>]/i);
|
|
124
|
+
const lower = markup.toLowerCase();
|
|
125
|
+
let closeIndex = lower.lastIndexOf("</html>");
|
|
126
|
+
if (lower.length !== markup.length) {
|
|
127
|
+
closeIndex = -1;
|
|
128
|
+
const closing = /<\/html>/gi;
|
|
129
|
+
let match;
|
|
130
|
+
while (match = closing.exec(markup)) closeIndex = match.index;
|
|
131
|
+
}
|
|
132
|
+
if (start < 0 || closeIndex < 0) return null;
|
|
133
|
+
const closeEnd = closeIndex + "</html>".length;
|
|
134
|
+
let document = markup.slice(start, closeEnd);
|
|
135
|
+
const streamedTail = markup.slice(closeEnd).replace(/^(?:\s*<\/div>)+/i, "").trim();
|
|
136
|
+
if (streamedTail) {
|
|
137
|
+
document = document.replace(/<\/body>/i, () => `${streamedTail}</body>`);
|
|
138
|
+
}
|
|
139
|
+
return restoreHoistedHead(document, hoisted);
|
|
140
|
+
}
|
|
141
|
+
__name(extractFarmFullDocument, "extractFarmFullDocument");
|
|
142
|
+
function classifyFarmDocumentPrefix(markup) {
|
|
143
|
+
const { inner } = peelDocumentPrefix(markup);
|
|
144
|
+
if (/^<!doctype/i.test(inner) || /^<html[\s>]/i.test(inner)) return "document";
|
|
145
|
+
return inner === "" ? "pending" : "fragment";
|
|
146
|
+
}
|
|
147
|
+
__name(classifyFarmDocumentPrefix, "classifyFarmDocumentPrefix");
|
|
148
|
+
function ensureFarmDocumentHead(markup) {
|
|
149
|
+
if (/<head[\s>]/i.test(markup)) return markup;
|
|
150
|
+
return markup.replace(/<html([^>]*)>/i, (_match, attributes) => {
|
|
151
|
+
return `<html${attributes}><head></head>`;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
__name(ensureFarmDocumentHead, "ensureFarmDocumentHead");
|
|
155
|
+
function ensureFarmDocumentRoot(markup) {
|
|
156
|
+
if (/\sid=["']root["']/i.test(markup)) return markup;
|
|
157
|
+
return markup.replace(
|
|
158
|
+
/<body\b([^>]*)>/i,
|
|
159
|
+
(_match, attributes) => `<body${attributes}><div id="root">`
|
|
160
|
+
).replace(/<\/body>/i, () => "</div></body>");
|
|
161
|
+
}
|
|
162
|
+
__name(ensureFarmDocumentRoot, "ensureFarmDocumentRoot");
|
|
163
|
+
function hasFarmDocumentIcon(markup) {
|
|
164
|
+
return /<link\b[^>]*\brel=["']?(?:shortcut )?icon\b/i.test(markup);
|
|
165
|
+
}
|
|
166
|
+
__name(hasFarmDocumentIcon, "hasFarmDocumentIcon");
|
|
167
|
+
function removeFarmDocumentTitles(markup) {
|
|
168
|
+
return markup.replace(/<title\b[^>]*>[\s\S]*?<\/title>\s*/gi, "");
|
|
169
|
+
}
|
|
170
|
+
__name(removeFarmDocumentTitles, "removeFarmDocumentTitles");
|
|
171
|
+
function ensureFarmDocumentMeta(markup, viewport = "") {
|
|
172
|
+
const head = /<head\b[^>]*>([\s\S]*?)<\/head>/i.exec(markup)?.[1] ?? "";
|
|
173
|
+
const hasNamedMeta = /* @__PURE__ */ __name((name) => new RegExp(`<meta\\b[^>]*\\bname=["']?${name}(?=["'\\s/>])`, "i").test(head), "hasNamedMeta");
|
|
174
|
+
const tags = [
|
|
175
|
+
/<meta\b[^>]*\bcharset\s*=/i.test(head) ? "" : '<meta charset="utf-8">',
|
|
176
|
+
...(viewport.match(/<meta\b[^>]*>/gi) ?? []).filter((tag) => {
|
|
177
|
+
const name = /\bname="([\w-]+)"/.exec(tag)?.[1];
|
|
178
|
+
return !name || !hasNamedMeta(name);
|
|
179
|
+
})
|
|
180
|
+
].filter(Boolean);
|
|
181
|
+
if (tags.length === 0) return markup;
|
|
182
|
+
return markup.replace(/<head\b[^>]*>/i, (open) => `${open}${tags.join("")}`);
|
|
183
|
+
}
|
|
184
|
+
__name(ensureFarmDocumentMeta, "ensureFarmDocumentMeta");
|
|
185
|
+
function composeFarmFullDocument(documentHtml, assets) {
|
|
186
|
+
let html = ensureFarmDocumentMeta(ensureFarmDocumentHead(documentHtml), assets.viewport);
|
|
187
|
+
if (assets.htmlAttributes) {
|
|
188
|
+
html = html.replace(/<html\b([^>]*)>/i, (_match, attrs) => {
|
|
189
|
+
let nextAttributes = attrs;
|
|
190
|
+
for (const name of assets.replaceHtmlAttributes ?? []) {
|
|
191
|
+
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
192
|
+
nextAttributes = nextAttributes.replace(
|
|
193
|
+
new RegExp("\\s+" + escapedName + `=(?:"[^"]*"|'[^']*'|[^\\s>]+)`, "gi"),
|
|
194
|
+
""
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return `<html${nextAttributes}${assets.htmlAttributes}>`;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
html = ensureFarmDocumentRoot(html);
|
|
201
|
+
const headAssets = [
|
|
202
|
+
assets.fallbackIcon && !hasFarmDocumentIcon(html) ? '<link rel="icon" href="data:,">' : "",
|
|
203
|
+
assets.headAssets
|
|
204
|
+
].filter(Boolean).join("\n ");
|
|
205
|
+
if (headAssets) {
|
|
206
|
+
html = html.replace(/<\/head>/i, () => ` ${headAssets}
|
|
207
|
+
</head>`);
|
|
208
|
+
}
|
|
209
|
+
if (assets.bodyFooter) {
|
|
210
|
+
html = html.replace(/<\/body>/i, () => ` ${assets.bodyFooter}
|
|
211
|
+
</body>`);
|
|
212
|
+
}
|
|
213
|
+
return /^\s*<!doctype/i.test(html) ? html : `<!DOCTYPE html>
|
|
214
|
+
${html}`;
|
|
215
|
+
}
|
|
216
|
+
__name(composeFarmFullDocument, "composeFarmFullDocument");
|
|
217
|
+
|
|
36
218
|
// src/i18n/alternates.ts
|
|
37
219
|
function renderFarmLocaleAlternateLinks(pathname, config, options = {}) {
|
|
38
220
|
if (config.routing === "none") return "";
|
|
@@ -228,6 +410,171 @@ function createFarmMetadataRouteResponse(kind, value, routeModule = {}, options
|
|
|
228
410
|
}
|
|
229
411
|
__name(createFarmMetadataRouteResponse, "createFarmMetadataRouteResponse");
|
|
230
412
|
|
|
413
|
+
// src/ai-catalog.ts
|
|
414
|
+
var FARM_AI_CATALOG_PATH = "/.well-known/ai-catalog.json";
|
|
415
|
+
var FARM_ARD_PATH = "/.well-known/ard.json";
|
|
416
|
+
var FARM_MCP_SERVER_CARD_SUFFIX = "/server-card";
|
|
417
|
+
var SERVER_CARD_SCHEMA = "https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json";
|
|
418
|
+
var SERVER_CARD_TYPE = "application/mcp-server-card+json";
|
|
419
|
+
var AI_CATALOG_TYPE = "application/ai-catalog+json";
|
|
420
|
+
var CARD_DESCRIPTION_MAX = 100;
|
|
421
|
+
var REVERSE_DNS_NAME = /^[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+$/;
|
|
422
|
+
function listFarmMCPServerSources(input) {
|
|
423
|
+
const sources = /* @__PURE__ */ new Map();
|
|
424
|
+
for (const { server, details } of _listFarmMCPCatalogs()) {
|
|
425
|
+
const endpoint = resolveFarmAPIServerRoutePath(server.path, input.apiServerBasePath);
|
|
426
|
+
if (sources.has(endpoint)) continue;
|
|
427
|
+
sources.set(endpoint, {
|
|
428
|
+
...server,
|
|
429
|
+
protocolVersions: details?.protocolVersions,
|
|
430
|
+
endpoint,
|
|
431
|
+
local: true
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
for (const server of _listFarmRegisteredMCPServers()) {
|
|
435
|
+
const endpoint = server.path ? applyFarmBasePath(server.path, input.basePath) : server.url;
|
|
436
|
+
if (sources.has(endpoint)) continue;
|
|
437
|
+
sources.set(endpoint, { ...server, endpoint, local: Boolean(server.path) });
|
|
438
|
+
}
|
|
439
|
+
return [...sources.values()];
|
|
440
|
+
}
|
|
441
|
+
__name(listFarmMCPServerSources, "listFarmMCPServerSources");
|
|
442
|
+
function serverCardLocation(endpoint) {
|
|
443
|
+
return `${endpoint.replace(/\/$/, "")}${FARM_MCP_SERVER_CARD_SUFFIX}`;
|
|
444
|
+
}
|
|
445
|
+
__name(serverCardLocation, "serverCardLocation");
|
|
446
|
+
function listFarmMCPServerCards(origin, input = {}) {
|
|
447
|
+
const host = new URL(origin).hostname;
|
|
448
|
+
return listFarmMCPServerSources(input).map((server) => {
|
|
449
|
+
const endpointUrl = server.local ? `${origin}${server.endpoint}` : server.endpoint;
|
|
450
|
+
const cardPath = server.local ? serverCardLocation(server.endpoint) : void 0;
|
|
451
|
+
const slug = cardSlug(server.name);
|
|
452
|
+
const description = truncate(server.description?.trim() || `MCP server for ${host}`);
|
|
453
|
+
const card = {
|
|
454
|
+
$schema: SERVER_CARD_SCHEMA,
|
|
455
|
+
// The card's name is reverse-DNS; a plain server name is namespaced by the host.
|
|
456
|
+
name: REVERSE_DNS_NAME.test(server.name) ? server.name : `${cardNamespace(host)}/${slug}`,
|
|
457
|
+
version: server.version,
|
|
458
|
+
description,
|
|
459
|
+
...server.title ? { title: server.title } : {},
|
|
460
|
+
websiteUrl: `${origin}${applyFarmBasePath("/", input.basePath).replace(/(.)\/$/, "$1")}`,
|
|
461
|
+
remotes: [
|
|
462
|
+
{
|
|
463
|
+
type: "streamable-http",
|
|
464
|
+
url: endpointUrl,
|
|
465
|
+
...server.protocolVersions?.length ? { supportedProtocolVersions: [...server.protocolVersions] } : {}
|
|
466
|
+
}
|
|
467
|
+
]
|
|
468
|
+
};
|
|
469
|
+
return {
|
|
470
|
+
...cardPath ? { cardPath } : {},
|
|
471
|
+
card,
|
|
472
|
+
entry: {
|
|
473
|
+
identifier: `urn:air:${host}:mcp:${slug}`,
|
|
474
|
+
type: SERVER_CARD_TYPE,
|
|
475
|
+
url: cardPath ? `${origin}${cardPath}` : serverCardLocation(endpointUrl),
|
|
476
|
+
displayName: server.title ?? server.name,
|
|
477
|
+
description,
|
|
478
|
+
version: server.version
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
__name(listFarmMCPServerCards, "listFarmMCPServerCards");
|
|
484
|
+
function listFarmMCPLlmsTxtLinks(origin, input = {}) {
|
|
485
|
+
const servers = listFarmMCPServerCards(origin, input);
|
|
486
|
+
if (!servers.length) return [];
|
|
487
|
+
return [
|
|
488
|
+
...servers.map(({ card, entry }) => ({
|
|
489
|
+
title: entry.displayName,
|
|
490
|
+
url: card.remotes[0].url,
|
|
491
|
+
description: `${card.description} (Streamable HTTP MCP endpoint; server card at ${entry.url})`
|
|
492
|
+
})),
|
|
493
|
+
{
|
|
494
|
+
title: "AI catalog",
|
|
495
|
+
url: `${origin}${applyFarmBasePath(FARM_AI_CATALOG_PATH, input.basePath)}`,
|
|
496
|
+
description: "MCP server cards for this site"
|
|
497
|
+
}
|
|
498
|
+
];
|
|
499
|
+
}
|
|
500
|
+
__name(listFarmMCPLlmsTxtLinks, "listFarmMCPLlmsTxtLinks");
|
|
501
|
+
function createFarmAiCatalogResponse(request, input = {}, requestUrl) {
|
|
502
|
+
let url;
|
|
503
|
+
try {
|
|
504
|
+
url = requestUrl ?? new URL(request.url);
|
|
505
|
+
} catch {
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
const { pathname } = url;
|
|
509
|
+
if (!pathname.endsWith(FARM_MCP_SERVER_CARD_SUFFIX) && !pathname.includes("/.well-known/")) {
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
const ard = pathname === applyFarmBasePath(FARM_ARD_PATH, input.basePath);
|
|
513
|
+
const catalogPath = ard || pathname === applyFarmBasePath(FARM_AI_CATALOG_PATH, input.basePath);
|
|
514
|
+
if (!catalogPath && !pathname.endsWith(FARM_MCP_SERVER_CARD_SUFFIX)) return null;
|
|
515
|
+
const servers = listFarmMCPServerCards(url.origin, input);
|
|
516
|
+
const card = catalogPath ? void 0 : servers.find((server) => server.cardPath === pathname);
|
|
517
|
+
if (!servers.length || !catalogPath && !card) return null;
|
|
518
|
+
const method = request.method.toUpperCase();
|
|
519
|
+
if (method === "OPTIONS") return new Response(null, { status: 204, headers: corsHeaders() });
|
|
520
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
521
|
+
return new Response("Method Not Allowed", {
|
|
522
|
+
status: 405,
|
|
523
|
+
headers: { ...corsHeaders(), Allow: "GET, HEAD, OPTIONS", "Content-Type": "text/plain" }
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
const body = JSON.stringify(
|
|
527
|
+
card ? card.card : { specVersion: "1.0", entries: servers.map(({ entry }) => entry) }
|
|
528
|
+
);
|
|
529
|
+
const etag = `W/"${fnv1a(body)}"`;
|
|
530
|
+
const headers = {
|
|
531
|
+
...corsHeaders(),
|
|
532
|
+
"Content-Type": card ? `${SERVER_CARD_TYPE}; charset=utf-8` : ard ? "application/json; charset=utf-8" : `${AI_CATALOG_TYPE}; charset=utf-8`,
|
|
533
|
+
// The body names the request's origin, so caches revalidate rather than reuse it.
|
|
534
|
+
"Cache-Control": "public, max-age=0, must-revalidate",
|
|
535
|
+
ETag: etag,
|
|
536
|
+
"X-Content-Type-Options": "nosniff"
|
|
537
|
+
};
|
|
538
|
+
if (matchesFarmIfNoneMatch(request.headers.get("if-none-match"), etag)) {
|
|
539
|
+
return new Response(null, { status: 304, headers });
|
|
540
|
+
}
|
|
541
|
+
emitFarmAgentRead(request, card ? "mcp-server-card" : "ai-catalog", 200);
|
|
542
|
+
return new Response(method === "HEAD" ? null : body, { status: 200, headers });
|
|
543
|
+
}
|
|
544
|
+
__name(createFarmAiCatalogResponse, "createFarmAiCatalogResponse");
|
|
545
|
+
function corsHeaders() {
|
|
546
|
+
return {
|
|
547
|
+
"Access-Control-Allow-Origin": "*",
|
|
548
|
+
"Access-Control-Allow-Methods": "GET, HEAD, OPTIONS",
|
|
549
|
+
"Access-Control-Allow-Headers": "Content-Type, If-None-Match",
|
|
550
|
+
"Access-Control-Expose-Headers": "ETag"
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
__name(corsHeaders, "corsHeaders");
|
|
554
|
+
function cardNamespace(host) {
|
|
555
|
+
if (host.includes(":") || /^\d+(?:\.\d+){3}$/.test(host)) return "local";
|
|
556
|
+
return host.split(".").reverse().join(".");
|
|
557
|
+
}
|
|
558
|
+
__name(cardNamespace, "cardNamespace");
|
|
559
|
+
function cardSlug(name) {
|
|
560
|
+
const last = name.includes("/") ? name.slice(name.lastIndexOf("/") + 1) : name;
|
|
561
|
+
return last.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "mcp";
|
|
562
|
+
}
|
|
563
|
+
__name(cardSlug, "cardSlug");
|
|
564
|
+
function truncate(text) {
|
|
565
|
+
return text.length <= CARD_DESCRIPTION_MAX ? text : `${text.slice(0, CARD_DESCRIPTION_MAX - 1).trimEnd()}\u2026`;
|
|
566
|
+
}
|
|
567
|
+
__name(truncate, "truncate");
|
|
568
|
+
function fnv1a(value) {
|
|
569
|
+
let hash = 2166136261;
|
|
570
|
+
for (let index = 0; index < value.length; index++) {
|
|
571
|
+
hash ^= value.charCodeAt(index);
|
|
572
|
+
hash = Math.imul(hash, 16777619);
|
|
573
|
+
}
|
|
574
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
575
|
+
}
|
|
576
|
+
__name(fnv1a, "fnv1a");
|
|
577
|
+
|
|
231
578
|
// src/components/error-page.ts
|
|
232
579
|
var ERROR_STATUS_TEXT = {
|
|
233
580
|
400: "Bad Request",
|
|
@@ -660,10 +1007,25 @@ async function createFarmAppManifestResponse(request, input, options) {
|
|
|
660
1007
|
__name(createFarmAppManifestResponse, "createFarmAppManifestResponse");
|
|
661
1008
|
|
|
662
1009
|
export {
|
|
1010
|
+
formatRouteSegment,
|
|
1011
|
+
createRouteDirectoryPattern,
|
|
1012
|
+
stripRouteGroups,
|
|
1013
|
+
getRouteGroupScope,
|
|
1014
|
+
isInRouteGroupScope,
|
|
1015
|
+
getRouteDirectoryDepth,
|
|
1016
|
+
routeBoundaryCoversDirectory,
|
|
1017
|
+
HOISTED_HEAD_ELEMENT,
|
|
1018
|
+
extractFarmFullDocument,
|
|
1019
|
+
classifyFarmDocumentPrefix,
|
|
1020
|
+
removeFarmDocumentTitles,
|
|
1021
|
+
ensureFarmDocumentMeta,
|
|
1022
|
+
composeFarmFullDocument,
|
|
663
1023
|
renderFarmLocaleAlternateLinks,
|
|
664
1024
|
createLateRedirectRecovery,
|
|
665
1025
|
createLateNotFoundRecovery,
|
|
666
1026
|
createFarmMetadataRouteResponse,
|
|
1027
|
+
listFarmMCPLlmsTxtLinks,
|
|
1028
|
+
createFarmAiCatalogResponse,
|
|
667
1029
|
resolveDefaultErrorStatus,
|
|
668
1030
|
getDefaultErrorStatusText,
|
|
669
1031
|
createDefaultErrorMarkup,
|