@farm.js/core 0.1.34 → 0.1.36
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-BVExL8rZ.d.mts +109 -0
- package/dist/agent-mcp-handler-LPJ2CADR.mjs +19 -0
- package/dist/agent-mcp-handler-SJAHFSPI.cjs +19 -0
- package/dist/agent-mcp-luzfXK-P.d.ts +109 -0
- package/dist/agent-runtime.cjs +5 -3
- package/dist/agent-runtime.d.mts +4 -5
- package/dist/agent-runtime.d.ts +4 -5
- package/dist/agent-runtime.mjs +4 -2
- package/dist/api/route-manager.cjs +7 -7
- package/dist/api/route-manager.d.mts +15 -10
- package/dist/api/route-manager.d.ts +15 -10
- package/dist/api/route-manager.mjs +6 -6
- package/dist/api/runtime.cjs +7 -5
- package/dist/api/runtime.d.mts +7 -66
- package/dist/api/runtime.d.ts +7 -66
- package/dist/api/runtime.mjs +7 -5
- package/dist/api.cjs +9 -9
- package/dist/api.d.mts +8 -9
- package/dist/api.d.ts +8 -9
- package/dist/api.mjs +8 -8
- package/dist/{app-q4rmZlXK.d.mts → app-BukwkFIu.d.mts} +52 -12
- package/dist/{app-DgotYGbq.d.ts → app-Yfa2dsFy.d.ts} +52 -12
- package/dist/app-markdown.cjs +6 -6
- package/dist/app-markdown.d.mts +5 -6
- package/dist/app-markdown.d.ts +5 -6
- package/dist/app-markdown.mjs +5 -5
- package/dist/{chunk-XV5DJTBX.mjs → chunk-276VJSM6.mjs} +627 -260
- package/dist/{chunk-36MK5YCW.cjs → chunk-2YTDKNH3.cjs} +547 -240
- package/dist/{chunk-VHANUNEG.mjs → chunk-35GKZR22.mjs} +2 -2
- package/dist/{chunk-LR5QSC2P.mjs → chunk-35WV46VL.mjs} +399 -92
- package/dist/{chunk-UX5S4JEO.cjs → chunk-42NHY7HW.cjs} +57 -7
- package/dist/{chunk-U4PTAHW3.mjs → chunk-4E5AEDKY.mjs} +7 -11
- package/dist/{chunk-NGVORZVZ.mjs → chunk-4E5WBPEG.mjs} +73 -351
- package/dist/{chunk-AQZFOP7S.mjs → chunk-4GLOOWKE.mjs} +5 -5
- package/dist/{chunk-7BT4H4P7.cjs → chunk-4NU4GGTC.cjs} +2 -2
- package/dist/{chunk-AGC75XAE.mjs → chunk-4WCZJQUO.mjs} +55 -5
- package/dist/chunk-4WQ6PGSJ.cjs +367 -0
- package/dist/{chunk-QCFFHV5H.mjs → chunk-4WVJLURN.mjs} +1 -1
- package/dist/chunk-6SJ2KJTA.mjs +314 -0
- package/dist/chunk-75RZHGLS.cjs +135 -0
- package/dist/{chunk-P64MIF5B.cjs → chunk-ADEA7PN3.cjs} +483 -60
- package/dist/{chunk-YQVSHTMR.mjs → chunk-AJQTP4OO.mjs} +1 -1
- package/dist/{chunk-TA5G2HWD.cjs → chunk-AO6RYU5N.cjs} +31 -28
- package/dist/{chunk-MOKLYNHV.cjs → chunk-BO36SELV.cjs} +6 -6
- package/dist/{chunk-7Y6ZNFPX.mjs → chunk-BPOF5U4N.mjs} +17 -7
- package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
- package/dist/{chunk-TDFPACVX.cjs → chunk-CBJJH36A.cjs} +50 -25
- package/dist/{chunk-VKNHTSAP.cjs → chunk-CGBDNNSM.cjs} +2 -2
- package/dist/chunk-CI6E3UOH.cjs +314 -0
- package/dist/{chunk-QZCT2CQ4.mjs → chunk-CXEN47J3.mjs} +64 -2
- package/dist/{chunk-ATK2R4CH.cjs → chunk-D227TIEN.cjs} +14 -4
- package/dist/{chunk-QGYRXFU2.cjs → chunk-D2BB47NB.cjs} +8 -8
- package/dist/chunk-DTSROJ5J.mjs +367 -0
- package/dist/{chunk-ODBZYBAB.cjs → chunk-DZ5ZVB2K.cjs} +1 -1
- package/dist/{chunk-ROUTX2E5.cjs → chunk-ECKF2BAM.cjs} +18 -5
- 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-HR5KPHC2.mjs → chunk-EWET4D2Y.mjs} +1 -1
- package/dist/{chunk-PXKIEXZD.mjs → chunk-F5QO4FNE.mjs} +1 -1
- package/dist/{chunk-MIDIZJZC.cjs → chunk-FO427P6I.cjs} +22 -12
- package/dist/{chunk-AWC4VUZL.cjs → chunk-GQ3Z3IZI.cjs} +14 -14
- package/dist/{chunk-JDPAKVS4.mjs → chunk-GQRWBCWK.mjs} +8 -5
- package/dist/{chunk-75WGQVQA.cjs → chunk-HITLGIAO.cjs} +10 -1
- package/dist/{chunk-WNNYOOIB.mjs → chunk-HOXTWRGB.mjs} +1 -1
- package/dist/{chunk-KROWKCUH.cjs → chunk-JGLC4TO3.cjs} +8 -1
- package/dist/{chunk-QJ3J6MZT.cjs → chunk-JNUWCDTF.cjs} +8 -8
- package/dist/{chunk-BTAG7LI7.cjs → chunk-JZVADIOD.cjs} +2 -2
- package/dist/{chunk-EM6SBQKM.cjs → chunk-KIIMAWOJ.cjs} +37 -2
- package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
- package/dist/{chunk-GOABMOX3.mjs → chunk-LSZAVSGY.mjs} +468 -45
- package/dist/{chunk-2NQQ5H5G.cjs → chunk-M7MKQXAF.cjs} +2 -1
- package/dist/{chunk-GNSDTTWZ.mjs → chunk-MKYBIIAQ.mjs} +30 -5
- package/dist/{chunk-ZHPHJPQP.cjs → chunk-MRMI32SN.cjs} +88 -366
- package/dist/{chunk-7M52YUMY.cjs → chunk-N2NAS2AM.cjs} +2 -2
- package/dist/{chunk-SJVKK4JE.cjs → chunk-NMHWYWDR.cjs} +1144 -777
- package/dist/chunk-NRDBW4MP.mjs +45 -0
- package/dist/{chunk-657WJNRY.mjs → chunk-O6I6VWKK.mjs} +20 -5
- package/dist/{chunk-O27L4YAA.mjs → chunk-O6WAEAX3.mjs} +2 -2
- package/dist/chunk-OFZUJMCU.mjs +601 -0
- package/dist/{chunk-ZKP7C2B6.mjs → chunk-OHLSEQ57.mjs} +22 -13
- package/dist/{chunk-X242HVD5.mjs → chunk-OO7GXVSR.mjs} +1 -1
- package/dist/chunk-PTZ2TVNE.cjs +178 -0
- package/dist/{chunk-3ATMYLLJ.mjs → chunk-Q2KB32T4.mjs} +1 -1
- package/dist/{chunk-LHODW25H.mjs → chunk-QORUJDIV.mjs} +2 -2
- package/dist/{chunk-UBO4SGH4.mjs → chunk-RHAZ22ZN.mjs} +2 -1
- package/dist/{chunk-G26MUMKL.cjs → chunk-S6VYG6XU.cjs} +23 -8
- package/dist/{chunk-6VVL3MHY.mjs → chunk-SC2WYWPF.mjs} +1 -1
- package/dist/{chunk-MPEYMSCF.cjs → chunk-SDOTRX3V.cjs} +5 -5
- package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
- package/dist/{chunk-LMJ7VRHZ.mjs → chunk-T4OGRVNS.mjs} +13 -3
- package/dist/{chunk-T5CERMEH.cjs → chunk-T5OJPTVN.cjs} +2 -2
- package/dist/{chunk-Z2YLTERK.cjs → chunk-TE2G5ION.cjs} +6 -6
- package/dist/chunk-UH6QN5NL.mjs +178 -0
- package/dist/{chunk-PQDFUSXD.cjs → chunk-UVW64BCB.cjs} +44 -35
- package/dist/{chunk-VCCUOMQN.mjs → chunk-VILIPRS6.mjs} +1 -1
- package/dist/{chunk-A5FGU2WU.cjs → chunk-VQLJWDVW.cjs} +19 -23
- package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
- package/dist/{chunk-K3F2E6GS.cjs → chunk-WC5UV2HQ.cjs} +2 -2
- package/dist/chunk-WWFTAUFG.cjs +45 -0
- package/dist/{chunk-ZUSJDQ2Q.mjs → chunk-WWIKMBRN.mjs} +1 -1
- package/dist/{chunk-3VSKDFAT.mjs → chunk-WZ77PUAM.mjs} +1 -1
- package/dist/{chunk-CLJYVZAD.mjs → chunk-XCMCS4DA.mjs} +11 -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-LI2LMOLR.mjs → chunk-YWMZUGIS.mjs} +18 -5
- package/dist/chunk-ZLAT2CWY.mjs +135 -0
- package/dist/{chunk-XF7Q24PF.mjs → chunk-ZMMBIVQM.mjs} +35 -0
- package/dist/{chunk-U74I55WB.cjs → chunk-ZWM5KGAA.cjs} +19 -9
- package/dist/{client-plugins-CLObcuCq.d.mts → client-plugins-C3mK9Pol.d.mts} +300 -7
- package/dist/{client-plugins-DZjHC4Mi.d.ts → client-plugins-r1mOtSC1.d.ts} +300 -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-RNXCTS4R.mjs → devtools-ERIKFEXX.mjs} +11 -10
- package/dist/{devtools-HU6Y2MNV.cjs → devtools-JZJJY5CK.cjs} +12 -11
- package/dist/docs.cjs +15 -14
- package/dist/docs.d.mts +41 -4
- package/dist/docs.d.ts +41 -4
- package/dist/docs.mjs +14 -13
- 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 +51 -44
- package/dist/index.d.mts +20 -21
- package/dist/index.d.ts +20 -21
- package/dist/index.mjs +50 -43
- package/dist/integrations.cjs +7 -3
- package/dist/integrations.d.mts +4 -5
- package/dist/integrations.d.ts +4 -5
- package/dist/integrations.mjs +6 -2
- package/dist/internal/app-markdown-runtime.cjs +5 -5
- 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 +4 -4
- package/dist/internal/build-runtime.cjs +32 -30
- package/dist/internal/build-runtime.d.mts +6 -7
- package/dist/internal/build-runtime.d.ts +6 -7
- package/dist/internal/build-runtime.mjs +31 -29
- package/dist/internal/cli-runtime.cjs +17 -16
- package/dist/internal/cli-runtime.mjs +16 -15
- 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 +12 -11
- package/dist/internal/config-runtime.d.mts +5 -6
- package/dist/internal/config-runtime.d.ts +5 -6
- package/dist/internal/config-runtime.mjs +11 -10
- package/dist/internal/isolated-boundary.cjs +3 -2
- package/dist/internal/isolated-boundary.d.mts +1 -1
- package/dist/internal/isolated-boundary.d.ts +1 -1
- 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 +63 -25
- package/dist/internal/production-runtime.d.mts +117 -37
- package/dist/internal/production-runtime.d.ts +117 -37
- package/dist/internal/production-runtime.mjs +65 -27
- 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/{layers-BRQF5ETU.mjs → layers-UTB43B7A.mjs} +1 -1
- package/dist/layers-VUWIOFEO.cjs +18 -0
- package/dist/markdown.cjs +4 -4
- package/dist/markdown.d.mts +4 -5
- package/dist/markdown.d.ts +4 -5
- package/dist/markdown.mjs +3 -3
- package/dist/middleware.cjs +7 -7
- package/dist/middleware.d.mts +6 -7
- package/dist/middleware.d.ts +6 -7
- package/dist/middleware.mjs +6 -6
- 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-HSAQFXSS.cjs → nitro-7F65EZZS.cjs} +3 -3
- package/dist/{nitro-4XGPNIK4.mjs → nitro-MPZJGPXK.mjs} +2 -2
- 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 +28 -26
- package/dist/plugin.d.mts +4 -5
- package/dist/plugin.d.ts +4 -5
- package/dist/plugin.mjs +27 -25
- package/dist/{production-runtime-CysZl3EV.d.mts → production-runtime-CCeVZXst.d.mts} +4 -4
- package/dist/{production-runtime-BU5ETAK9.d.ts → production-runtime-DPnsggY3.d.ts} +4 -4
- package/dist/query/client.cjs +6 -6
- package/dist/query/client.mjs +2 -2
- package/dist/{render-plan-CKr4ltOd.d.mts → render-plan-BuGaPFe6.d.mts} +1 -1
- package/dist/{render-plan-D72O1qm4.d.ts → render-plan-Cw4f5E_R.d.ts} +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-Bkg-hERy.d.ts} +1 -1
- package/dist/{request-Be83WafN.d.mts → request-CsGARcAw.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-CtVMpV-k.d.ts → route-rendering-BUZMH_64.d.ts} +1 -1
- package/dist/{route-rendering-BG56SzvJ.d.mts → route-rendering-f11yh5dp.d.mts} +1 -1
- package/dist/{router-D94-SDlW.d.ts → router-B8CR9GbD.d.ts} +1 -1
- package/dist/{router-ALUvm8gC.d.mts → router-Cp6yRE8A.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-CAEv36S_.d.mts +69 -0
- package/dist/runtime-CQVsT330.d.ts +69 -0
- 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 +47 -45
- package/dist/server.d.mts +13 -14
- package/dist/server.d.ts +13 -14
- package/dist/server.mjs +30 -28
- package/dist/{spa-router-CxK3USIz.d.ts → spa-router-BuciWGCZ.d.ts} +3 -3
- package/dist/{spa-router-DbxNRKOB.d.mts → spa-router-DwbqGkGj.d.mts} +3 -3
- package/dist/testing.cjs +9 -9
- package/dist/testing.d.mts +4 -5
- package/dist/testing.d.ts +4 -5
- package/dist/testing.mjs +7 -7
- 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-4wVRcpOw.d.mts → utils-B9V0S_yL.d.mts} +1 -1
- package/dist/{utils-311Y8eoK.d.ts → utils-CaoWKtYM.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +28 -26
- package/dist/vite.d.mts +4 -5
- package/dist/vite.d.ts +4 -5
- package/dist/vite.mjs +27 -25
- 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/layers-4PNE2HOY.cjs +0 -18
- package/dist/metadata-2HSU2i_w.d.mts +0 -52
- package/dist/metadata-Cjs8JMRM.d.ts +0 -52
- package/dist/types-DFbjpjXX.d.mts +0 -105
- package/dist/types-DFbjpjXX.d.ts +0 -105
- package/dist/{chunk-2F2ER724.cjs → chunk-BPMATOP2.cjs} +2 -2
- package/dist/{chunk-IHNMMXHV.mjs → chunk-OTC5BDGO.mjs} +3 -3
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkPTZ2TVNEcjs = require('./chunk-PTZ2TVNE.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
12
|
+
|
|
13
|
+
// src/agent-mcp-handler.ts
|
|
14
|
+
var INSTRUCTIONS = "This server reads the site's public pages. Call list_pages or search_pages to find a page, then read_page with its path to get the page as Markdown. It cannot change anything.";
|
|
15
|
+
var MAX_BODY_BYTES = 64 * 1024;
|
|
16
|
+
var MAX_BATCH = 16;
|
|
17
|
+
var READ_TIMEOUT_MS = 3e4;
|
|
18
|
+
var _FarmMCPRequestError = class _FarmMCPRequestError extends Error {
|
|
19
|
+
constructor(code, message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _FarmMCPRequestError, "FarmMCPRequestError");
|
|
25
|
+
var FarmMCPRequestError = _FarmMCPRequestError;
|
|
26
|
+
var PARSE_ERROR = -32700;
|
|
27
|
+
var INVALID_REQUEST = -32600;
|
|
28
|
+
var METHOD_NOT_FOUND = -32601;
|
|
29
|
+
var INVALID_PARAMS = -32602;
|
|
30
|
+
var INTERNAL_ERROR = -32603;
|
|
31
|
+
var TRANSPORT_ERROR = -32e3;
|
|
32
|
+
async function handleFarmDefaultMCPRequest(request, context) {
|
|
33
|
+
const method = request.method.toUpperCase();
|
|
34
|
+
if (method !== "POST") {
|
|
35
|
+
return transportError(405, "Method not allowed. Send MCP requests with POST.", {
|
|
36
|
+
Allow: "POST"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const origin = request.headers.get("origin");
|
|
40
|
+
if (origin && !isSameOrigin(origin, request.url)) {
|
|
41
|
+
return transportError(403, "Cross-origin requests are not allowed.");
|
|
42
|
+
}
|
|
43
|
+
const protocolHeader = request.headers.get("mcp-protocol-version");
|
|
44
|
+
if (protocolHeader && !_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.includes(protocolHeader.trim())) {
|
|
45
|
+
return transportError(
|
|
46
|
+
400,
|
|
47
|
+
`Unsupported MCP-Protocol-Version: ${protocolHeader.slice(0, 32)}. Supported: ${_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.join(", ")}.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const contentType = _nullishCoalesce(request.headers.get("content-type"), () => ( ""));
|
|
51
|
+
if (!/^application\/json\s*(?:;|$)/i.test(contentType.trim())) {
|
|
52
|
+
return transportError(415, "Content-Type must be application/json.");
|
|
53
|
+
}
|
|
54
|
+
const text = await readBody(request);
|
|
55
|
+
if (text === null) return transportError(413, "The request body is too large.");
|
|
56
|
+
let message;
|
|
57
|
+
try {
|
|
58
|
+
message = JSON.parse(text);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return json(400, rpcError(null, { code: PARSE_ERROR, message: "Parse error." }));
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(message)) {
|
|
63
|
+
if (message.length === 0 || message.length > MAX_BATCH) {
|
|
64
|
+
return json(
|
|
65
|
+
400,
|
|
66
|
+
rpcError(null, { code: INVALID_REQUEST, message: "Invalid batch of JSON-RPC messages." })
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const replies = (await Promise.all(message.map((item) => answerMessage(item, request, context)))).filter((reply2) => reply2 !== void 0);
|
|
70
|
+
return replies.length ? json(200, replies) : new Response(null, { status: 202 });
|
|
71
|
+
}
|
|
72
|
+
const reply = await answerMessage(message, request, context);
|
|
73
|
+
return reply === void 0 ? new Response(null, { status: 202 }) : json(200, reply);
|
|
74
|
+
}
|
|
75
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, handleFarmDefaultMCPRequest, "handleFarmDefaultMCPRequest");
|
|
76
|
+
async function answerMessage(message, request, context) {
|
|
77
|
+
if (!isRecord(message) || message.jsonrpc !== "2.0") {
|
|
78
|
+
return rpcError(readId(message), { code: INVALID_REQUEST, message: "Invalid Request." });
|
|
79
|
+
}
|
|
80
|
+
const hasId = "id" in message;
|
|
81
|
+
if (typeof message.method !== "string") {
|
|
82
|
+
if (hasId && ("result" in message || "error" in message)) return void 0;
|
|
83
|
+
return rpcError(readId(message), { code: INVALID_REQUEST, message: "Invalid Request." });
|
|
84
|
+
}
|
|
85
|
+
if (!hasId) return void 0;
|
|
86
|
+
const id = readId(message);
|
|
87
|
+
if (id === void 0) {
|
|
88
|
+
return rpcError(null, { code: INVALID_REQUEST, message: "Invalid Request id." });
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const result = await dispatch(message.method, message.params, request, context);
|
|
92
|
+
return { jsonrpc: "2.0", id, result };
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error instanceof FarmMCPRequestError) {
|
|
95
|
+
return rpcError(id, { code: error.code, message: error.message });
|
|
96
|
+
}
|
|
97
|
+
return rpcError(id, { code: INTERNAL_ERROR, message: "Internal error." });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, answerMessage, "answerMessage");
|
|
101
|
+
async function dispatch(method, params, request, context) {
|
|
102
|
+
switch (method) {
|
|
103
|
+
case "initialize": {
|
|
104
|
+
const requested = isRecord(params) ? params.protocolVersion : void 0;
|
|
105
|
+
const protocolVersion = typeof requested === "string" && _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS[0];
|
|
106
|
+
return {
|
|
107
|
+
protocolVersion,
|
|
108
|
+
capabilities: { tools: { listChanged: false } },
|
|
109
|
+
serverInfo: {
|
|
110
|
+
name: context.server.name,
|
|
111
|
+
version: context.server.version,
|
|
112
|
+
...context.server.title ? { title: context.server.title } : {},
|
|
113
|
+
description: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_DESCRIPTION
|
|
114
|
+
},
|
|
115
|
+
instructions: INSTRUCTIONS
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
case "ping":
|
|
119
|
+
return {};
|
|
120
|
+
case "tools/list":
|
|
121
|
+
return { tools: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS };
|
|
122
|
+
case "tools/call":
|
|
123
|
+
return callTool(params, request, context);
|
|
124
|
+
default:
|
|
125
|
+
throw new FarmMCPRequestError(METHOD_NOT_FOUND, `Method not found: ${method.slice(0, 64)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, dispatch, "dispatch");
|
|
129
|
+
async function callTool(params, request, context) {
|
|
130
|
+
if (!isRecord(params) || typeof params.name !== "string") {
|
|
131
|
+
throw new FarmMCPRequestError(INVALID_PARAMS, "tools/call needs a tool name.");
|
|
132
|
+
}
|
|
133
|
+
const tool = _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS.find(({ name }) => name === params.name);
|
|
134
|
+
if (!tool) {
|
|
135
|
+
throw new FarmMCPRequestError(INVALID_PARAMS, `Unknown tool: ${params.name.slice(0, 64)}`);
|
|
136
|
+
}
|
|
137
|
+
const args = _nullishCoalesce(params.arguments, () => ( {}));
|
|
138
|
+
if (!isRecord(args)) return toolError("Arguments must be an object.");
|
|
139
|
+
const allowed = new Set(Object.keys(tool.inputSchema.properties));
|
|
140
|
+
const unknown = Object.keys(args).find((key) => !allowed.has(key));
|
|
141
|
+
if (unknown) return toolError(`Unknown argument: ${unknown.slice(0, 64)}.`);
|
|
142
|
+
if (tool.name === "list_pages") return pagesResult(await context.listPages());
|
|
143
|
+
if (tool.name === "search_pages") {
|
|
144
|
+
const query = args.query;
|
|
145
|
+
if (typeof query !== "string" || !query.trim() || query.length > 200) {
|
|
146
|
+
return toolError("query must be a non-empty string of at most 200 characters.");
|
|
147
|
+
}
|
|
148
|
+
const limit = _nullishCoalesce(args.limit, () => ( 10));
|
|
149
|
+
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1 || limit > 50) {
|
|
150
|
+
return toolError("limit must be a whole number from 1 to 50.");
|
|
151
|
+
}
|
|
152
|
+
return pagesResult(searchPages(await context.listPages(), query, limit));
|
|
153
|
+
}
|
|
154
|
+
const path = args.path;
|
|
155
|
+
if (typeof path !== "string" || !path.trim() || path.length > 2048) {
|
|
156
|
+
return toolError('path must be a page path such as "/about".');
|
|
157
|
+
}
|
|
158
|
+
const pagePath = toPagePath(path, request.url, context.basePath);
|
|
159
|
+
const pages = await context.listPages();
|
|
160
|
+
const page = pagePath ? pages.find((candidate) => candidate.path === pagePath) : void 0;
|
|
161
|
+
if (!page) {
|
|
162
|
+
return toolError(
|
|
163
|
+
`No public page at ${JSON.stringify(path.slice(0, 200))}. Call list_pages for the pages this server can read.`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const markdown = await readWithTimeout(context.readMarkdown, page.markdownUrl);
|
|
167
|
+
if (markdown === null) {
|
|
168
|
+
return toolError(`${page.path} did not answer with Markdown. Try again later.`);
|
|
169
|
+
}
|
|
170
|
+
return { content: [{ type: "text", text: markdown }] };
|
|
171
|
+
}
|
|
172
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, callTool, "callTool");
|
|
173
|
+
function pagesResult(pages) {
|
|
174
|
+
const structured = {
|
|
175
|
+
pages: pages.map(({ path, title, url, description }) => ({
|
|
176
|
+
path,
|
|
177
|
+
title,
|
|
178
|
+
url,
|
|
179
|
+
...description ? { description } : {}
|
|
180
|
+
}))
|
|
181
|
+
};
|
|
182
|
+
return {
|
|
183
|
+
content: [{ type: "text", text: JSON.stringify(structured) }],
|
|
184
|
+
structuredContent: structured
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, pagesResult, "pagesResult");
|
|
188
|
+
function toolError(text) {
|
|
189
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
190
|
+
}
|
|
191
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, toolError, "toolError");
|
|
192
|
+
function searchPages(pages, query, limit) {
|
|
193
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean).slice(0, 16);
|
|
194
|
+
return pages.map((page) => {
|
|
195
|
+
const title = page.title.toLowerCase();
|
|
196
|
+
const rest = `${_nullishCoalesce(page.description, () => ( ""))} ${page.path}`.toLowerCase();
|
|
197
|
+
let score = 0;
|
|
198
|
+
for (const term of terms) {
|
|
199
|
+
if (title.includes(term)) score += 2;
|
|
200
|
+
else if (rest.includes(term)) score += 1;
|
|
201
|
+
else return null;
|
|
202
|
+
}
|
|
203
|
+
return { page, score };
|
|
204
|
+
}).filter((match) => match !== null).sort(
|
|
205
|
+
(left, right) => right.score - left.score || left.page.path.localeCompare(right.page.path)
|
|
206
|
+
).slice(0, limit).map(({ page }) => page);
|
|
207
|
+
}
|
|
208
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, searchPages, "searchPages");
|
|
209
|
+
function toPagePath(input, requestUrl, basePath) {
|
|
210
|
+
let url;
|
|
211
|
+
try {
|
|
212
|
+
url = new URL(input.trim(), requestUrl);
|
|
213
|
+
} catch (e2) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
if (url.origin !== new URL(requestUrl).origin) return null;
|
|
217
|
+
let path = url.pathname;
|
|
218
|
+
try {
|
|
219
|
+
path = decodeURI(path);
|
|
220
|
+
} catch (e3) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
path = _chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, path, basePath);
|
|
224
|
+
if (path === "/index.md") return "/";
|
|
225
|
+
if (path.toLowerCase().endsWith(".md")) path = path.slice(0, -3) || "/";
|
|
226
|
+
return path.length > 1 ? path.replace(/\/+$/, "") || "/" : path;
|
|
227
|
+
}
|
|
228
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, toPagePath, "toPagePath");
|
|
229
|
+
async function readWithTimeout(read, url) {
|
|
230
|
+
let timer;
|
|
231
|
+
const timedOut = new Promise((resolve) => {
|
|
232
|
+
timer = setTimeout(resolve, READ_TIMEOUT_MS, null);
|
|
233
|
+
});
|
|
234
|
+
try {
|
|
235
|
+
return await Promise.race([read(url), timedOut]);
|
|
236
|
+
} finally {
|
|
237
|
+
clearTimeout(timer);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readWithTimeout, "readWithTimeout");
|
|
241
|
+
async function readBody(request) {
|
|
242
|
+
const declared = Number(request.headers.get("content-length"));
|
|
243
|
+
if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
|
|
244
|
+
await _optionalChain([request, 'access', _ => _.body, 'optionalAccess', _2 => _2.cancel, 'call', _3 => _3(), 'access', _4 => _4.catch, 'call', _5 => _5(() => {
|
|
245
|
+
})]);
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
if (!request.body) return "";
|
|
249
|
+
const reader = request.body.getReader();
|
|
250
|
+
const chunks = [];
|
|
251
|
+
let size = 0;
|
|
252
|
+
for (; ; ) {
|
|
253
|
+
const { done, value } = await reader.read();
|
|
254
|
+
if (done) break;
|
|
255
|
+
size += value.byteLength;
|
|
256
|
+
if (size > MAX_BODY_BYTES) {
|
|
257
|
+
await reader.cancel().catch(() => {
|
|
258
|
+
});
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
chunks.push(value);
|
|
262
|
+
}
|
|
263
|
+
const body = new Uint8Array(size);
|
|
264
|
+
let offset = 0;
|
|
265
|
+
for (const chunk of chunks) {
|
|
266
|
+
body.set(chunk, offset);
|
|
267
|
+
offset += chunk.byteLength;
|
|
268
|
+
}
|
|
269
|
+
return new TextDecoder().decode(body);
|
|
270
|
+
}
|
|
271
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readBody, "readBody");
|
|
272
|
+
function isSameOrigin(origin, requestUrl) {
|
|
273
|
+
try {
|
|
274
|
+
return new URL(origin).host === new URL(requestUrl).host;
|
|
275
|
+
} catch (e4) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isSameOrigin, "isSameOrigin");
|
|
280
|
+
function readId(message) {
|
|
281
|
+
if (!isRecord(message)) return null;
|
|
282
|
+
const { id } = message;
|
|
283
|
+
return typeof id === "string" || typeof id === "number" && Number.isFinite(id) || id === null ? id : void 0;
|
|
284
|
+
}
|
|
285
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readId, "readId");
|
|
286
|
+
function rpcError(id, error) {
|
|
287
|
+
return { jsonrpc: "2.0", id: _nullishCoalesce(id, () => ( null)), error };
|
|
288
|
+
}
|
|
289
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, rpcError, "rpcError");
|
|
290
|
+
function json(status, body) {
|
|
291
|
+
return new Response(JSON.stringify(body), {
|
|
292
|
+
status,
|
|
293
|
+
headers: {
|
|
294
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
295
|
+
"Cache-Control": "no-store",
|
|
296
|
+
"X-Content-Type-Options": "nosniff"
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, json, "json");
|
|
301
|
+
function transportError(status, message, headers = {}) {
|
|
302
|
+
const response = json(status, rpcError(null, { code: TRANSPORT_ERROR, message }));
|
|
303
|
+
for (const [name, value] of Object.entries(headers)) response.headers.set(name, value);
|
|
304
|
+
return response;
|
|
305
|
+
}
|
|
306
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, transportError, "transportError");
|
|
307
|
+
function isRecord(value) {
|
|
308
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
309
|
+
}
|
|
310
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isRecord, "isRecord");
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
exports.handleFarmDefaultMCPRequest = handleFarmDefaultMCPRequest;
|
|
@@ -17,6 +17,7 @@ async function resolveFarmNotFoundMetadata(layoutModules, notFoundModule) {
|
|
|
17
17
|
if (typeof layout.generateMetadata === "function") {
|
|
18
18
|
metadata = mergeMetadata(metadata, await layout.generateMetadata({ params: {} }));
|
|
19
19
|
}
|
|
20
|
+
metadata = await mergeModuleViewport(metadata, layout, { params: {} });
|
|
20
21
|
}
|
|
21
22
|
let own = {};
|
|
22
23
|
let latestTitle;
|
|
@@ -28,6 +29,7 @@ async function resolveFarmNotFoundMetadata(layoutModules, notFoundModule) {
|
|
|
28
29
|
own = mergeMetadata(own, generated);
|
|
29
30
|
if (generated?.title !== void 0) latestTitle = generated.title;
|
|
30
31
|
}
|
|
32
|
+
own = await mergeModuleViewport(own, notFoundModule, { params: {}, searchParams: {} });
|
|
31
33
|
}
|
|
32
34
|
const title = isRecord(latestTitle) && normalizeContent(latestTitle.absolute) ? latestTitle : own.title;
|
|
33
35
|
return mergeMetadata(metadata, { ...own, title: title ?? FARM_NOT_FOUND_TITLE });
|
|
@@ -46,10 +48,67 @@ function mergeMetadata(base, next) {
|
|
|
46
48
|
twitter: mergeNestedMetadata(base.twitter, next.twitter),
|
|
47
49
|
alternates: mergeNestedMetadata(base.alternates, next.alternates),
|
|
48
50
|
icons: mergeNestedMetadata(base.icons, next.icons),
|
|
49
|
-
verification: mergeNestedMetadata(base.verification, next.verification)
|
|
51
|
+
verification: mergeNestedMetadata(base.verification, next.verification),
|
|
52
|
+
viewport: mergeNestedMetadata(base.viewport, next.viewport)
|
|
50
53
|
};
|
|
51
54
|
}
|
|
52
55
|
__name(mergeMetadata, "mergeMetadata");
|
|
56
|
+
async function mergeModuleViewport(metadata, module, props) {
|
|
57
|
+
let merged = metadata;
|
|
58
|
+
if (isRecord(module?.viewport)) {
|
|
59
|
+
merged = mergeMetadata(merged, { viewport: module.viewport });
|
|
60
|
+
}
|
|
61
|
+
if (typeof module?.generateViewport === "function") {
|
|
62
|
+
const generated = await module.generateViewport(props);
|
|
63
|
+
if (isRecord(generated)) merged = mergeMetadata(merged, { viewport: generated });
|
|
64
|
+
}
|
|
65
|
+
return merged;
|
|
66
|
+
}
|
|
67
|
+
__name(mergeModuleViewport, "mergeModuleViewport");
|
|
68
|
+
var DEFAULT_VIEWPORT = { width: "device-width", initialScale: 1 };
|
|
69
|
+
var VIEWPORT_CONTENT_KEYS = [
|
|
70
|
+
["width", "width"],
|
|
71
|
+
["height", "height"],
|
|
72
|
+
["initialScale", "initial-scale"],
|
|
73
|
+
["minimumScale", "minimum-scale"],
|
|
74
|
+
["maximumScale", "maximum-scale"],
|
|
75
|
+
["userScalable", "user-scalable"],
|
|
76
|
+
["viewportFit", "viewport-fit"],
|
|
77
|
+
["interactiveWidget", "interactive-widget"]
|
|
78
|
+
];
|
|
79
|
+
function renderViewportHead(viewport) {
|
|
80
|
+
const marker = ` ${FARM_METADATA_ATTRIBUTE}`;
|
|
81
|
+
if (typeof viewport === "string") {
|
|
82
|
+
return `<meta name="viewport" content="${escapeAttribute(viewport)}"${marker}>`;
|
|
83
|
+
}
|
|
84
|
+
const resolved = {
|
|
85
|
+
...DEFAULT_VIEWPORT,
|
|
86
|
+
...isRecord(viewport) ? viewport : {}
|
|
87
|
+
};
|
|
88
|
+
const content = VIEWPORT_CONTENT_KEYS.flatMap(([key, name]) => {
|
|
89
|
+
const value = resolved[key];
|
|
90
|
+
if (value === void 0 || value === null || value === "") return [];
|
|
91
|
+
if (typeof value === "boolean") return [`${name}=${value ? "yes" : "no"}`];
|
|
92
|
+
return [`${name}=${String(value)}`];
|
|
93
|
+
}).join(", ");
|
|
94
|
+
const tags = content ? [`<meta name="viewport" content="${escapeAttribute(content)}"${marker}>`] : [];
|
|
95
|
+
const themeColors = Array.isArray(resolved.themeColor) ? resolved.themeColor : resolved.themeColor === void 0 ? [] : [resolved.themeColor];
|
|
96
|
+
for (const entry of themeColors) {
|
|
97
|
+
const color = typeof entry === "string" ? entry : isRecord(entry) ? entry.color : void 0;
|
|
98
|
+
const content2 = normalizeContent(color);
|
|
99
|
+
if (!content2) continue;
|
|
100
|
+
const media = isRecord(entry) ? normalizeContent(entry.media) : void 0;
|
|
101
|
+
tags.push(
|
|
102
|
+
`<meta name="theme-color" content="${escapeAttribute(content2)}"${media ? ` media="${escapeAttribute(media)}"` : ""}${marker}>`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const colorScheme = normalizeContent(resolved.colorScheme);
|
|
106
|
+
if (colorScheme) {
|
|
107
|
+
tags.push(`<meta name="color-scheme" content="${escapeAttribute(colorScheme)}"${marker}>`);
|
|
108
|
+
}
|
|
109
|
+
return tags.join("\n ");
|
|
110
|
+
}
|
|
111
|
+
__name(renderViewportHead, "renderViewportHead");
|
|
53
112
|
function mergeMetadataTitle(base, next) {
|
|
54
113
|
if (next === void 0) return base;
|
|
55
114
|
const parentTemplate = isRecord(base) ? normalizeContent(base.template) : void 0;
|
|
@@ -209,7 +268,8 @@ function renderMetadataHead(metadata, options = {}) {
|
|
|
209
268
|
tags: tags.length > 0 ? `
|
|
210
269
|
${tags.join("\n ")}` : "",
|
|
211
270
|
hasFavicon,
|
|
212
|
-
hasExplicitTitle: Boolean(explicitTitle)
|
|
271
|
+
hasExplicitTitle: Boolean(explicitTitle),
|
|
272
|
+
viewport: renderViewportHead(resolvedMetadata.viewport)
|
|
213
273
|
};
|
|
214
274
|
}
|
|
215
275
|
__name(renderMetadataHead, "renderMetadataHead");
|
|
@@ -481,6 +541,8 @@ export {
|
|
|
481
541
|
FARM_METADATA_ATTRIBUTE,
|
|
482
542
|
resolveFarmNotFoundMetadata,
|
|
483
543
|
mergeMetadata,
|
|
544
|
+
mergeModuleViewport,
|
|
545
|
+
renderViewportHead,
|
|
484
546
|
addMetadataImageReference,
|
|
485
547
|
addMetadataMarkdownAlternate,
|
|
486
548
|
renderMetadataHead,
|
|
@@ -17,7 +17,7 @@ var _chunkJ7FSKED3cjs = require('./chunk-J7FSKED3.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkEK4QAEFZcjs = require('./chunk-EK4QAEFZ.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -31,7 +31,7 @@ var _chunkQBK2AA4Ucjs = require('./chunk-QBK2AA4U.cjs');
|
|
|
31
31
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
32
32
|
|
|
33
33
|
// src/client/metadata-reconciler.ts
|
|
34
|
-
var MANAGED_ATTRIBUTE =
|
|
34
|
+
var MANAGED_ATTRIBUTE = _chunkEK4QAEFZcjs.FARM_METADATA_ATTRIBUTE;
|
|
35
35
|
var OWNED_SELECTORS = [
|
|
36
36
|
'meta[name="description"]',
|
|
37
37
|
'meta[name="keywords"]',
|
|
@@ -66,11 +66,21 @@ function removeAll(selector) {
|
|
|
66
66
|
}
|
|
67
67
|
_chunkS3JO3N4Hcjs.__name.call(void 0, removeAll, "removeAll");
|
|
68
68
|
function applyFarmMetadataToDocument(metadata, pathname) {
|
|
69
|
-
document.title =
|
|
70
|
-
const rendered =
|
|
69
|
+
document.title = _chunkEK4QAEFZcjs.resolveMetadataTitle.call(void 0, _optionalChain([metadata, 'optionalAccess', _ => _.title])) || "Farm.js App";
|
|
70
|
+
const rendered = _chunkEK4QAEFZcjs.renderMetadataHead.call(void 0, metadata, { pathname });
|
|
71
71
|
const template = document.createElement("template");
|
|
72
72
|
template.innerHTML = rendered.tags;
|
|
73
|
+
const viewport = document.createElement("template");
|
|
74
|
+
viewport.innerHTML = rendered.viewport;
|
|
73
75
|
removeAll(OWNED_SELECTORS);
|
|
76
|
+
const charset = document.head.querySelector("meta[charset]");
|
|
77
|
+
for (const element of Array.from(viewport.content.children).reverse()) {
|
|
78
|
+
const name = element.getAttribute("name");
|
|
79
|
+
if (name && document.head.querySelector(`meta[name="${name}"]:not([${MANAGED_ATTRIBUTE}])`)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
document.head.insertBefore(element, charset ? charset.nextSibling : document.head.firstChild);
|
|
83
|
+
}
|
|
74
84
|
removeAll(PAGE_JSON_LD_SELECTOR);
|
|
75
85
|
if (_optionalChain([metadata, 'optionalAccess', _2 => _2.icons])) removeAll(ICON_SELECTORS);
|
|
76
86
|
if (_optionalChain([metadata, 'optionalAccess', _3 => _3.manifest])) removeAll(MANIFEST_SELECTOR);
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkBO36SELVcjs = require('./chunk-BO36SELV.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkSK35NQKKcjs = require('./chunk-SK35NQKK.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkT5OJPTVNcjs = require('./chunk-T5OJPTVN.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ function createServerQuery(options) {
|
|
|
35
35
|
throw new TypeError("createServerQuery requires a key function");
|
|
36
36
|
}
|
|
37
37
|
const staleTime = normalizeServerQueryStaleTime(options.staleTime);
|
|
38
|
-
const execute =
|
|
38
|
+
const execute = _chunkBO36SELVcjs.createServerFn.call(void 0, {
|
|
39
39
|
input: options.input,
|
|
40
40
|
middleware: options.middleware,
|
|
41
41
|
handler: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (context) => {
|
|
@@ -45,7 +45,7 @@ function createServerQuery(options) {
|
|
|
45
45
|
const cacheKey = _chunkNYJMY3JAcjs.createFarmCacheKey.call(void 0, ["route-data", routeKey]);
|
|
46
46
|
const producer = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
|
|
47
47
|
const value = await options.handler(context);
|
|
48
|
-
return
|
|
48
|
+
return _chunkBO36SELVcjs._parseServerFnSchema.call(void 0, options.output, value, "output", "createServerQuery");
|
|
49
49
|
}, "producer");
|
|
50
50
|
let data;
|
|
51
51
|
let updatedAt;
|
|
@@ -70,7 +70,7 @@ function createServerQuery(options) {
|
|
|
70
70
|
});
|
|
71
71
|
const query = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (input) => {
|
|
72
72
|
const result = await execute(input);
|
|
73
|
-
return
|
|
73
|
+
return _chunkT5OJPTVNcjs.getServerActionExecutionContext.call(void 0, ) ? result : result.data;
|
|
74
74
|
}, "query");
|
|
75
75
|
Object.defineProperties(query, {
|
|
76
76
|
[FARM_SERVER_QUERY_SYMBOL]: {
|
|
@@ -90,10 +90,10 @@ function createServerQuery(options) {
|
|
|
90
90
|
enumerable: false
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
|
|
93
|
+
_chunkBO36SELVcjs._attachServerFunctionDescriptor.call(void 0,
|
|
94
94
|
query,
|
|
95
|
-
|
|
96
|
-
const result = await
|
|
95
|
+
_chunkBO36SELVcjs.createServerFunctionDescriptor.call(void 0, "query", options, async (value) => {
|
|
96
|
+
const result = await _chunkBO36SELVcjs._runServerFunctionForCaller.call(void 0,
|
|
97
97
|
execute,
|
|
98
98
|
value
|
|
99
99
|
);
|