@farm.js/core 0.1.36 → 0.1.38
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 → agent-mcp-BwKlpnc7.d.mts} +1 -1
- package/dist/{agent-mcp-luzfXK-P.d.ts → agent-mcp-De1imoMS.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 +6 -6
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/route-manager.mjs +5 -5
- 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 +9 -8
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +8 -7
- package/dist/{app-BukwkFIu.d.mts → app-CFZt-srr.d.mts} +21 -3
- package/dist/{app-Yfa2dsFy.d.ts → app-kT_QXTdx.d.ts} +21 -3
- package/dist/app-markdown.cjs +6 -4
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +5 -3
- package/dist/{chunk-ADEA7PN3.cjs → chunk-2DD4JMQC.cjs} +113 -22
- package/dist/chunk-2ZYGC6SS.cjs +576 -0
- package/dist/{chunk-JZVADIOD.cjs → chunk-34UCJRQO.cjs} +2 -2
- package/dist/{chunk-D2BB47NB.cjs → chunk-3LOLJTFV.cjs} +6 -6
- package/dist/{chunk-KXWRO25S.cjs → chunk-472NCAZ7.cjs} +3 -3
- package/dist/chunk-4E5QXOCL.cjs +109 -0
- package/dist/{chunk-Z2HLU4IX.cjs → chunk-4GWRFP22.cjs} +23 -2
- package/dist/{chunk-VQLJWDVW.cjs → chunk-4IE345DM.cjs} +37 -19
- package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
- package/dist/{chunk-JNUWCDTF.cjs → chunk-5D2JIPLH.cjs} +2 -2
- package/dist/{chunk-BO36SELV.cjs → chunk-5OKBARDN.cjs} +2 -2
- package/dist/{chunk-AO6RYU5N.cjs → chunk-5PWXMJOH.cjs} +30 -22
- package/dist/{chunk-AHGECQEW.mjs → chunk-666CKENS.mjs} +1 -1
- package/dist/chunk-6BK3K2GB.mjs +318 -0
- package/dist/{chunk-O6I6VWKK.mjs → chunk-6HB6V3R7.mjs} +1 -1
- package/dist/{chunk-UXFQ3UDA.cjs → chunk-6XWDE2P2.cjs} +61 -4
- package/dist/{chunk-VILIPRS6.mjs → chunk-7FPTZLKH.mjs} +1 -1
- package/dist/{chunk-SC2WYWPF.mjs → chunk-7PEP3BUT.mjs} +3 -3
- package/dist/{chunk-4E5AEDKY.mjs → chunk-A3EAIURZ.mjs} +25 -7
- package/dist/{chunk-YDQZGSDS.mjs → chunk-ARC7I3O2.mjs} +1 -1
- package/dist/{chunk-LSZAVSGY.mjs → chunk-B6G5CKMC.mjs} +101 -10
- package/dist/{chunk-3KZS4SUS.mjs → chunk-BZHXGVMA.mjs} +1 -1
- package/dist/{chunk-KN7K4VQN.mjs → chunk-CNNOLE4O.mjs} +1 -1
- package/dist/{chunk-4GLOOWKE.mjs → chunk-CQMVIOYP.mjs} +1 -1
- package/dist/{chunk-2ELDTQRN.mjs → chunk-CUM5NYL5.mjs} +1 -1
- package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
- package/dist/{chunk-PZNL3WEG.mjs → chunk-DMEPTZTI.mjs} +22 -11
- package/dist/{chunk-QORUJDIV.mjs → chunk-DRLKAXDM.mjs} +2 -2
- package/dist/{chunk-DQQOKWYA.cjs → chunk-EIPC3FDA.cjs} +12 -4
- package/dist/{chunk-HOXTWRGB.mjs → chunk-EKF7KDFD.mjs} +5 -2
- package/dist/{chunk-42NHY7HW.cjs → chunk-EKN7NSZO.cjs} +62 -14
- package/dist/{chunk-YKX5BK66.cjs → chunk-EMO6K4YY.cjs} +7 -7
- package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
- package/dist/{chunk-D227TIEN.cjs → chunk-FWE7LEQC.cjs} +13 -13
- package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
- package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
- package/dist/{chunk-35GKZR22.mjs → chunk-HXRYZWTA.mjs} +1 -1
- package/dist/{chunk-JG6DJF5A.mjs → chunk-HZFM2LWQ.mjs} +22 -1
- package/dist/{chunk-MKYBIIAQ.mjs → chunk-IBUQWVYA.mjs} +17 -1
- package/dist/{chunk-F2SE2VDO.mjs → chunk-IHQIOZLC.mjs} +1 -1
- package/dist/{chunk-W7LF2J2S.mjs → chunk-INL3THCU.mjs} +1 -1
- package/dist/{chunk-WZ77PUAM.mjs → chunk-IVLZZZEI.mjs} +1 -1
- package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
- package/dist/{chunk-BPOF5U4N.mjs → chunk-JCKYH4LG.mjs} +10 -7
- package/dist/{chunk-77GNHH2Z.cjs → chunk-JCYYXBAJ.cjs} +3 -3
- package/dist/{chunk-C4SPBWFM.cjs → chunk-JEZO6VUR.cjs} +10 -1
- package/dist/{chunk-ZWM5KGAA.cjs → chunk-KCQBAKIY.cjs} +23 -20
- package/dist/{chunk-OTC5BDGO.mjs → chunk-KHKLMNI5.mjs} +12 -7
- package/dist/{chunk-DZ5ZVB2K.cjs → chunk-KKSTAEMY.cjs} +1 -1
- package/dist/{chunk-N2NAS2AM.cjs → chunk-L4DD7ODZ.cjs} +2 -2
- package/dist/{chunk-YSCV4SJF.cjs → chunk-L5H2GSUC.cjs} +4 -4
- package/dist/{chunk-OO7GXVSR.mjs → chunk-LI2F57NI.mjs} +1 -1
- package/dist/{chunk-NRSN7G7E.mjs → chunk-MLY2RP5R.mjs} +10 -2
- package/dist/{chunk-BPMATOP2.cjs → chunk-N32CC42M.cjs} +25 -20
- package/dist/{chunk-FNO7A7CM.cjs → chunk-NBBEQLOK.cjs} +34 -16
- package/dist/{chunk-XCMCS4DA.mjs → chunk-ND2CWPOD.mjs} +2 -2
- package/dist/{chunk-GQRWBCWK.mjs → chunk-OAHTRMIC.mjs} +13 -5
- package/dist/{chunk-35WV46VL.mjs → chunk-OCIEZME4.mjs} +876 -685
- package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
- package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
- package/dist/{chunk-FDR64H6B.mjs → chunk-POSPE3IO.mjs} +59 -2
- package/dist/{chunk-UVW64BCB.cjs → chunk-Q3NXS4MU.cjs} +16 -14
- package/dist/{chunk-4WCZJQUO.mjs → chunk-QFW2IH5E.mjs} +57 -9
- package/dist/{chunk-5SJWVY6R.mjs → chunk-QHSH7IH4.mjs} +9 -0
- package/dist/chunk-QRKIMN7T.mjs +48 -0
- package/dist/chunk-QTXBII4Z.cjs +632 -0
- package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
- package/dist/{chunk-BJPBQNIE.cjs → chunk-RW63BOV7.cjs} +2 -2
- package/dist/{chunk-FO427P6I.cjs → chunk-RWFLWR5J.cjs} +10 -10
- package/dist/{chunk-FFFW3OQ7.cjs → chunk-S6FJO323.cjs} +2 -2
- package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
- package/dist/chunk-SGBZPZUW.mjs +75 -0
- package/dist/{chunk-2NNMOPDN.mjs → chunk-SKVTP5PR.mjs} +4 -1
- package/dist/{chunk-2YTDKNH3.cjs → chunk-TGFQVLLF.cjs} +956 -765
- package/dist/{chunk-IHNIDL6H.cjs → chunk-TO4GJ56K.cjs} +22 -11
- package/dist/{chunk-276VJSM6.mjs → chunk-TUBTR2OP.mjs} +250 -118
- package/dist/{chunk-GQ3Z3IZI.cjs → chunk-TYJALEHQ.cjs} +18 -18
- package/dist/chunk-TYMMBFN2.mjs +109 -0
- package/dist/chunk-U6QLDL3G.mjs +576 -0
- package/dist/{chunk-U4KT7QP3.cjs → chunk-ULASELLA.cjs} +26 -1
- package/dist/chunk-UXHS27O6.cjs +75 -0
- package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
- package/dist/{chunk-EZDQRNQ7.mjs → chunk-VT4WFRHA.mjs} +23 -5
- package/dist/{chunk-CBJJH36A.cjs → chunk-VU6AAZVY.cjs} +20 -4
- package/dist/{chunk-27ZWSI3W.cjs → chunk-VXEEATVD.cjs} +2 -2
- package/dist/{chunk-EWET4D2Y.mjs → chunk-W36M2BQ4.mjs} +3 -3
- package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
- package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
- package/dist/{chunk-T4OGRVNS.mjs → chunk-WLL43JMO.mjs} +2 -2
- package/dist/chunk-WW46B6HA.cjs +318 -0
- package/dist/{chunk-TKSCR644.cjs → chunk-WXJLNP33.cjs} +2 -2
- package/dist/{chunk-S6VYG6XU.cjs → chunk-XKG2BLFN.cjs} +2 -2
- package/dist/{chunk-4NU4GGTC.cjs → chunk-XKVVMZP5.cjs} +6 -3
- package/dist/{chunk-NMHWYWDR.cjs → chunk-YR2VBEMO.cjs} +658 -526
- package/dist/{chunk-OHLSEQ57.mjs → chunk-ZJD2PN6Z.mjs} +10 -8
- package/dist/{chunk-3BU22U3M.cjs → chunk-ZXH4TS3F.cjs} +5 -2
- package/dist/{client-plugins-r1mOtSC1.d.ts → client-plugins-BvlNhGEB.d.ts} +54 -7
- package/dist/{client-plugins-C3mK9Pol.d.mts → client-plugins-DUrIYX9B.d.mts} +54 -7
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +8 -8
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +7 -7
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-ERIKFEXX.mjs → devtools-JYJNOLPQ.mjs} +8 -6
- package/dist/{devtools-JZJJY5CK.cjs → devtools-VQWJANJV.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/i18n/client.cjs +11 -11
- package/dist/i18n/client.mjs +3 -3
- package/dist/index.cjs +62 -46
- package/dist/index.d.mts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.mjs +62 -46
- 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 +5 -3
- package/dist/internal/app-markdown-runtime.d.mts +19 -5
- package/dist/internal/app-markdown-runtime.d.ts +19 -5
- package/dist/internal/app-markdown-runtime.mjs +4 -2
- package/dist/internal/build-runtime.cjs +33 -30
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +32 -29
- package/dist/internal/cli-runtime.cjs +14 -12
- package/dist/internal/cli-runtime.mjs +13 -11
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +2 -2
- package/dist/internal/client-runtime.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 +39 -54
- package/dist/internal/production-runtime.d.mts +51 -11
- package/dist/internal/production-runtime.d.ts +51 -11
- package/dist/internal/production-runtime.mjs +39 -54
- 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 +27 -5
- package/dist/middleware.d.ts +27 -5
- package/dist/middleware.mjs +10 -8
- package/dist/navigation.cjs +7 -7
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +6 -6
- package/dist/plugin.cjs +25 -23
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +24 -22
- package/dist/{production-runtime-CCeVZXst.d.mts → production-runtime-BQ4_WLwQ.d.mts} +1 -1
- package/dist/{production-runtime-DPnsggY3.d.ts → production-runtime-D2aMyzjr.d.ts} +1 -1
- package/dist/query/client.cjs +9 -9
- package/dist/query/client.mjs +4 -4
- package/dist/{render-plan-Cw4f5E_R.d.ts → render-plan-25p4hrj4.d.ts} +1 -1
- package/dist/{render-plan-BuGaPFe6.d.mts → render-plan-DtkXMN8D.d.mts} +1 -1
- package/dist/renderer-client.cjs +12 -12
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/renderer-client.mjs +4 -4
- package/dist/renderer.d.mts +13 -4
- package/dist/renderer.d.ts +13 -4
- package/dist/{request-CsGARcAw.d.mts → request-DgCkIdcn.d.mts} +4 -2
- package/dist/{request-Bkg-hERy.d.ts → request-jF4jwx8f.d.ts} +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-BUZMH_64.d.ts → route-rendering-Bji6S6a_.d.ts} +1 -1
- package/dist/{route-rendering-f11yh5dp.d.mts → route-rendering-CSBF78Ya.d.mts} +1 -1
- package/dist/{router-Cp6yRE8A.d.mts → router-B09Ui3Qm.d.mts} +1 -1
- package/dist/{router-B8CR9GbD.d.ts → router-CPB9cXtG.d.ts} +1 -1
- package/dist/routes.cjs +2 -2
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.mjs +1 -1
- package/dist/{runtime-CAEv36S_.d.mts → runtime-CM6E6yuI.d.mts} +1 -1
- package/dist/{runtime-CQVsT330.d.ts → runtime-EDMwLdjv.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 +51 -49
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +29 -27
- package/dist/{spa-router-BuciWGCZ.d.ts → spa-router-B_N8XgVu.d.ts} +2 -2
- package/dist/{spa-router-DwbqGkGj.d.mts → spa-router-Cgimzfbi.d.mts} +2 -2
- package/dist/testing.cjs +8 -8
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +6 -6
- package/dist/theme/server.cjs +4 -4
- package/dist/theme/server.mjs +3 -3
- package/dist/{utils-CaoWKtYM.d.ts → utils-BNxAKAuT.d.ts} +1 -1
- package/dist/{utils-B9V0S_yL.d.mts → utils-DZciYXYl.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +25 -23
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +24 -22
- package/package.json +1 -1
- package/types/middleware.d.ts +5 -1
- package/dist/chunk-655RLQQL.mjs +0 -43
- package/dist/chunk-FXEF4PPL.mjs +0 -47
- package/dist/chunk-IZY3V5XW.mjs +0 -23
- package/dist/chunk-MRMI32SN.cjs +0 -1157
- package/dist/chunk-MT763TDW.cjs +0 -43
- package/dist/chunk-XD32KALF.cjs +0 -47
- /package/dist/{chunk-SJNMVDDF.cjs → chunk-FUCSUGDM.cjs} +0 -0
- /package/dist/{chunk-UDNPLXW7.mjs → chunk-MYIZXDZA.mjs} +0 -0
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverFarmDocsPages,
|
|
3
|
+
getFarmDocsMarkdownPath,
|
|
3
4
|
loadFarmDocsPage,
|
|
4
5
|
resolveFarmDocsContentDir,
|
|
5
6
|
toFarmDocsMarkdownPage
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5BWWFHR2.mjs";
|
|
7
8
|
import {
|
|
8
9
|
docsEngine,
|
|
9
10
|
loadFarmDocsEngine
|
|
10
11
|
} from "./chunk-2VQKKQ6D.mjs";
|
|
11
12
|
import {
|
|
12
13
|
resolveDocsConfig
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZJD2PN6Z.mjs";
|
|
14
15
|
import {
|
|
15
16
|
getFarmDocsAdapterConfigModule,
|
|
16
17
|
isSecretDocsConfigKey
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-J7K2NZD6.mjs";
|
|
18
19
|
import {
|
|
19
20
|
__name
|
|
20
21
|
} from "./chunk-LPEX4YW6.mjs";
|
|
@@ -27,6 +28,15 @@ function hasFarmDocsRuntimeAdapter(docs) {
|
|
|
27
28
|
return Boolean(docs?.enabled && docs.adapter?.server && docs.adapter.react);
|
|
28
29
|
}
|
|
29
30
|
__name(hasFarmDocsRuntimeAdapter, "hasFarmDocsRuntimeAdapter");
|
|
31
|
+
function assertFarmDocsAdapterServesNoGuardedPages(docs, options, isPathGuarded) {
|
|
32
|
+
if (!isPathGuarded || !hasFarmDocsRuntimeAdapter(docs)) return;
|
|
33
|
+
const guarded = discoverFarmDocsPages(resolveFarmDocsContentDir(docs, options), docs).filter((page) => isPathGuarded(page.href) || isPathGuarded(getFarmDocsMarkdownPath(page.href))).map((page) => page.href);
|
|
34
|
+
if (guarded.length === 0) return;
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Docs pages behind a path guard (${guarded.join(", ")}) would be public: the docs adapter ${JSON.stringify(docs.adapter.id)} serves their content in llms-full.txt, search, Markdown, and MCP without running the app's guards. Move those pages out of the docs content directory, or set docs.adapter = false to use Farm's built-in docs runtime, which keeps guarded pages off anonymous surfaces.`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
__name(assertFarmDocsAdapterServesNoGuardedPages, "assertFarmDocsAdapterServesNoGuardedPages");
|
|
30
40
|
async function loadFarmDocsConfigModule(docs, loadModule) {
|
|
31
41
|
const configModule = getFarmDocsAdapterConfigModule(docs);
|
|
32
42
|
if (!configModule) return void 0;
|
|
@@ -99,6 +109,7 @@ async function createFarmDocsAdapterHandler(docs, options) {
|
|
|
99
109
|
if (!hasFarmDocsRuntimeAdapter(docs)) {
|
|
100
110
|
throw new Error("Farm docs adapter requires server and react runtime entrypoints.");
|
|
101
111
|
}
|
|
112
|
+
assertFarmDocsAdapterServesNoGuardedPages(docs, options, options.isPathGuarded);
|
|
102
113
|
const serverModule = await options.loadModule(
|
|
103
114
|
docs.adapter.server
|
|
104
115
|
);
|
|
@@ -277,7 +288,7 @@ function getDocsDescription(docs) {
|
|
|
277
288
|
}
|
|
278
289
|
__name(getDocsDescription, "getDocsDescription");
|
|
279
290
|
function getLoadedDocsPages(context) {
|
|
280
|
-
return discoverFarmDocsPages(context.contentDir, context.docs).map((page) => loadFarmDocsPage(context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
|
|
291
|
+
return discoverFarmDocsPages(context.contentDir, context.docs).filter((page) => !context.isPathGuarded(page.href)).map((page) => loadFarmDocsPage(context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
|
|
281
292
|
}
|
|
282
293
|
__name(getLoadedDocsPages, "getLoadedDocsPages");
|
|
283
294
|
function toDocsSourcePage(page) {
|
|
@@ -389,7 +400,9 @@ __name(renderAgentsDocument, "renderAgentsDocument");
|
|
|
389
400
|
function buildAgentSpec(context, request) {
|
|
390
401
|
const url = new URL(request.url);
|
|
391
402
|
const origin = url.origin;
|
|
392
|
-
const pages = discoverFarmDocsPages(context.contentDir, context.docs)
|
|
403
|
+
const pages = discoverFarmDocsPages(context.contentDir, context.docs).filter(
|
|
404
|
+
(page) => !context.isPathGuarded(page.href)
|
|
405
|
+
);
|
|
393
406
|
const spec = docsEngine().buildDocsAgentDiscoverySpec(getDocsDiscoveryOptions(context, request));
|
|
394
407
|
const title = getDocsTitle(context.docs);
|
|
395
408
|
return {
|
|
@@ -552,12 +565,14 @@ async function resolveAPIContext(options) {
|
|
|
552
565
|
configPath: options.configPath
|
|
553
566
|
};
|
|
554
567
|
const docs = isResolvedDocsConfig(docsInput) ? docsInput : await resolveDocsConfig(docsInput, { root, srcDir });
|
|
568
|
+
const guardedPaths = new Set(runtimeConfig?.guardedPaths ?? []);
|
|
555
569
|
return {
|
|
556
570
|
root,
|
|
557
571
|
srcDir,
|
|
558
572
|
docs,
|
|
559
573
|
contentDir: resolveFarmDocsContentDir(docs, { root, srcDir }),
|
|
560
|
-
diagnostics: options.diagnostics === true
|
|
574
|
+
diagnostics: options.diagnostics === true,
|
|
575
|
+
isPathGuarded: options.isPathGuarded ?? ((pathname) => guardedPaths.has(pathname))
|
|
561
576
|
};
|
|
562
577
|
}
|
|
563
578
|
__name(resolveAPIContext, "resolveAPIContext");
|
|
@@ -616,7 +631,9 @@ async function handleDocsAPIGet(request, context) {
|
|
|
616
631
|
const pathParam = url.searchParams.get("path") || url.searchParams.get("slug");
|
|
617
632
|
const slug = normalizeDocsApiSlug(pathParam ?? pathTarget.slug ?? "", context.docs);
|
|
618
633
|
const page = loadFarmDocsPage(context.contentDir, context.docs, slug);
|
|
619
|
-
if (!page
|
|
634
|
+
if (!page || context.isPathGuarded(page.href)) {
|
|
635
|
+
return text("Docs page not found\n", "text/plain; charset=utf-8", { status: 404 });
|
|
636
|
+
}
|
|
620
637
|
return text(
|
|
621
638
|
docsEngine().renderDocsMarkdownDocument(toFarmDocsMarkdownPage(page), {
|
|
622
639
|
origin: new URL(request.url).origin,
|
|
@@ -688,6 +705,7 @@ __name(createFarmDocsAPIHandler, "createFarmDocsAPIHandler");
|
|
|
688
705
|
|
|
689
706
|
export {
|
|
690
707
|
hasFarmDocsRuntimeAdapter,
|
|
708
|
+
assertFarmDocsAdapterServesNoGuardedPages,
|
|
691
709
|
compileFarmDocsAdapterEdgeManifest,
|
|
692
710
|
createFarmDocsAdapterHandler,
|
|
693
711
|
isFarmDocsAPIRequest,
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FARM_DEFAULT_MCP_TOOLS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P664ZVTV.mjs";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_ERROR_STYLES
|
|
6
6
|
} from "./chunk-XAXTTBUT.mjs";
|
|
7
7
|
import {
|
|
8
8
|
serializeFarmLlmsTxt
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HD5CF3OE.mjs";
|
|
10
|
+
import {
|
|
11
|
+
stampFarmCspNonce
|
|
12
|
+
} from "./chunk-U6QLDL3G.mjs";
|
|
10
13
|
import {
|
|
11
14
|
emitFarmAgentRead
|
|
12
15
|
} from "./chunk-MVL2RAJW.mjs";
|
|
13
16
|
import {
|
|
14
17
|
resolveFarmThemeConfig
|
|
15
18
|
} from "./chunk-AELACLOB.mjs";
|
|
19
|
+
import {
|
|
20
|
+
integrationMiddlewareMayHandlePath
|
|
21
|
+
} from "./chunk-IBUQWVYA.mjs";
|
|
22
|
+
import {
|
|
23
|
+
compileMiddlewareConfig,
|
|
24
|
+
matchesCompiledMiddlewareConfig,
|
|
25
|
+
matchesMiddlewareRoute
|
|
26
|
+
} from "./chunk-HZFM2LWQ.mjs";
|
|
16
27
|
import {
|
|
17
28
|
omitFarmResponseBody
|
|
18
29
|
} from "./chunk-5WI2S4CO.mjs";
|
|
@@ -25,12 +36,13 @@ import {
|
|
|
25
36
|
matchesFarmIfNoneMatch
|
|
26
37
|
} from "./chunk-ZMMBIVQM.mjs";
|
|
27
38
|
import {
|
|
39
|
+
createFarmAPIMiddlewarePathnames,
|
|
28
40
|
resolveFarmAPIServerBasePath,
|
|
29
41
|
resolveFarmAPIServerRoutePath
|
|
30
42
|
} from "./chunk-BTHHUD7Q.mjs";
|
|
31
43
|
import {
|
|
32
44
|
FARM_VERSION
|
|
33
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-LI2F57NI.mjs";
|
|
34
46
|
import {
|
|
35
47
|
localizeFarmPathname
|
|
36
48
|
} from "./chunk-L3KT7IXV.mjs";
|
|
@@ -219,6 +231,71 @@ ${html}`;
|
|
|
219
231
|
}
|
|
220
232
|
__name(composeFarmFullDocument, "composeFarmFullDocument");
|
|
221
233
|
|
|
234
|
+
// src/middleware/may-handle.ts
|
|
235
|
+
function hasFarmMiddlewareConfig(config) {
|
|
236
|
+
if (!config) return false;
|
|
237
|
+
if (Array.isArray(config)) return config.length > 0;
|
|
238
|
+
const configRecord = config;
|
|
239
|
+
return Boolean(
|
|
240
|
+
configRecord.matcher || configRecord.exclude || configRecord.runtime || configRecord.handler || Array.isArray(configRecord.handlers) && configRecord.handlers.length > 0
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
__name(hasFarmMiddlewareConfig, "hasFarmMiddlewareConfig");
|
|
244
|
+
function configMiddlewareMayHandlePath(config, pathname) {
|
|
245
|
+
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
246
|
+
const entries = Array.isArray(config) ? config : [config];
|
|
247
|
+
return entries.some((entry) => {
|
|
248
|
+
if (!entry.matcher && !entry.exclude) return true;
|
|
249
|
+
const matchers = entry.matcher ? (Array.isArray(entry.matcher) ? entry.matcher : [entry.matcher]).map(
|
|
250
|
+
(matcher) => (
|
|
251
|
+
// A request-aware matcher cannot be proven safe at build time.
|
|
252
|
+
typeof matcher === "function" ? () => true : matcher
|
|
253
|
+
)
|
|
254
|
+
) : void 0;
|
|
255
|
+
const compiled = compileMiddlewareConfig({ matcher: matchers, exclude: entry.exclude });
|
|
256
|
+
return matchesCompiledMiddlewareConfig(pathname, compiled, {}).matched;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
__name(configMiddlewareMayHandlePath, "configMiddlewareMayHandlePath");
|
|
260
|
+
function appMiddlewareMayHandlePath(middlewareRoutes, pathname) {
|
|
261
|
+
return middlewareRoutes.some((route) => matchesMiddlewareRoute(pathname, route).matched);
|
|
262
|
+
}
|
|
263
|
+
__name(appMiddlewareMayHandlePath, "appMiddlewareMayHandlePath");
|
|
264
|
+
var CATCH_ALL_PROBE = "/__farm-listing-probe__/0";
|
|
265
|
+
function isPathSpecificMatcher(matcher) {
|
|
266
|
+
if (typeof matcher === "function") return false;
|
|
267
|
+
const compiled = compileMiddlewareConfig({ matcher });
|
|
268
|
+
return !matchesCompiledMiddlewareConfig(CATCH_ALL_PROBE, compiled, {}).matched;
|
|
269
|
+
}
|
|
270
|
+
__name(isPathSpecificMatcher, "isPathSpecificMatcher");
|
|
271
|
+
function pathSpecificConfigMiddlewareCovers(config, pathname) {
|
|
272
|
+
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
273
|
+
const entries = Array.isArray(config) ? config : [config];
|
|
274
|
+
return entries.some((entry) => {
|
|
275
|
+
if (!entry.matcher) return false;
|
|
276
|
+
const matchers = (Array.isArray(entry.matcher) ? entry.matcher : [entry.matcher]).filter(
|
|
277
|
+
isPathSpecificMatcher
|
|
278
|
+
);
|
|
279
|
+
if (matchers.length === 0) return false;
|
|
280
|
+
const compiled = compileMiddlewareConfig({ matcher: matchers, exclude: entry.exclude });
|
|
281
|
+
return matchesCompiledMiddlewareConfig(pathname, compiled, {}).matched;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
__name(pathSpecificConfigMiddlewareCovers, "pathSpecificConfigMiddlewareCovers");
|
|
285
|
+
function farmPathGuardCoversPage(options, pathname) {
|
|
286
|
+
return appMiddlewareMayHandlePath(
|
|
287
|
+
options.middlewareRoutes.filter((route) => route.path !== "/"),
|
|
288
|
+
pathname
|
|
289
|
+
) || pathSpecificConfigMiddlewareCovers(options.config.middleware, pathname) || integrationMiddlewareMayHandlePath(options.config.integrations, pathname, CATCH_ALL_PROBE);
|
|
290
|
+
}
|
|
291
|
+
__name(farmPathGuardCoversPage, "farmPathGuardCoversPage");
|
|
292
|
+
function farmPathGuardCoversEndpoint(options, path, apiServerBasePath) {
|
|
293
|
+
return createFarmAPIMiddlewarePathnames(apiServerBasePath)(path).some(
|
|
294
|
+
(pathname) => farmPathGuardCoversPage(options, pathname)
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
__name(farmPathGuardCoversEndpoint, "farmPathGuardCoversEndpoint");
|
|
298
|
+
|
|
222
299
|
// src/i18n/alternates.ts
|
|
223
300
|
function renderFarmLocaleAlternateLinks(pathname, config, options = {}) {
|
|
224
301
|
if (config.routing === "none") return "";
|
|
@@ -269,13 +346,19 @@ function isLateRedirectTarget(url) {
|
|
|
269
346
|
}
|
|
270
347
|
}
|
|
271
348
|
__name(isLateRedirectTarget, "isLateRedirectTarget");
|
|
272
|
-
function createLateRedirectRecovery(url) {
|
|
349
|
+
function createLateRedirectRecovery(url, nonce) {
|
|
273
350
|
if (!isLateRedirectTarget(url)) return "";
|
|
274
|
-
return
|
|
351
|
+
return stampFarmCspNonce(
|
|
352
|
+
`<script>window.location.replace(${serializeForInlineScript(url)})</script>`,
|
|
353
|
+
nonce
|
|
354
|
+
);
|
|
275
355
|
}
|
|
276
356
|
__name(createLateRedirectRecovery, "createLateRedirectRecovery");
|
|
277
|
-
function createLateNotFoundRecovery(content) {
|
|
278
|
-
return `<template id="${TEMPLATE_ID}">${content}</template
|
|
357
|
+
function createLateNotFoundRecovery(content, nonce) {
|
|
358
|
+
return `<template id="${TEMPLATE_ID}">${content}</template>` + stampFarmCspNonce(
|
|
359
|
+
`<script>(function(){var t=document.getElementById("${TEMPLATE_ID}");var p=document.getElementById("${PAGE_CONTAINER_ID}");if(t&&p){p.replaceChildren(t.content.cloneNode(true));}if(t)t.remove();document.documentElement.dataset.farmLateNotFound="true";var m=document.createElement("meta");m.name="robots";m.content="noindex";document.head.appendChild(m);})();</script>`,
|
|
360
|
+
nonce
|
|
361
|
+
);
|
|
279
362
|
}
|
|
280
363
|
__name(createLateNotFoundRecovery, "createLateNotFoundRecovery");
|
|
281
364
|
|
|
@@ -763,7 +846,9 @@ function createFarmThemeDocumentParts(input, basePath = "/", serverTheme) {
|
|
|
763
846
|
const script = createFarmThemeBootstrapScript(config, hydrationTheme);
|
|
764
847
|
return {
|
|
765
848
|
attributes: ` data-theme="${initialTheme}"`,
|
|
766
|
-
head:
|
|
849
|
+
head: stampFarmCspNonce(
|
|
850
|
+
`<style id="${THEME_STYLE_ID}">:root[data-theme="light"]{color-scheme:light}:root[data-theme="dark"]{color-scheme:dark}</style><script id="${THEME_SCRIPT_ID}">${script}</script>`
|
|
851
|
+
)
|
|
767
852
|
};
|
|
768
853
|
}
|
|
769
854
|
__name(createFarmThemeDocumentParts, "createFarmThemeDocumentParts");
|
|
@@ -920,12 +1005,13 @@ function createFarmAppManifest(input, { full = false } = {}) {
|
|
|
920
1005
|
packages: input.packages,
|
|
921
1006
|
mcp: {
|
|
922
1007
|
servers: _listFarmMCPCatalogs().map(({ server, tools, details }) => {
|
|
923
|
-
const
|
|
1008
|
+
const open = details?.public === true && !input.guardCoversPath?.(server.path);
|
|
1009
|
+
const listed = full || open;
|
|
924
1010
|
return {
|
|
925
1011
|
name: server.name,
|
|
926
1012
|
version: server.version,
|
|
927
1013
|
path: server.path,
|
|
928
|
-
authorization:
|
|
1014
|
+
authorization: open ? "none" : "required",
|
|
929
1015
|
resources: listed ? [...details?.resources ?? []] : [],
|
|
930
1016
|
prompts: listed ? [...details?.prompts ?? []] : [],
|
|
931
1017
|
tools: (listed ? tools : []).map((tool) => {
|
|
@@ -1078,6 +1164,11 @@ export {
|
|
|
1078
1164
|
removeFarmDocumentTitles,
|
|
1079
1165
|
ensureFarmDocumentMeta,
|
|
1080
1166
|
composeFarmFullDocument,
|
|
1167
|
+
hasFarmMiddlewareConfig,
|
|
1168
|
+
configMiddlewareMayHandlePath,
|
|
1169
|
+
appMiddlewareMayHandlePath,
|
|
1170
|
+
farmPathGuardCoversPage,
|
|
1171
|
+
farmPathGuardCoversEndpoint,
|
|
1081
1172
|
renderFarmLocaleAlternateLinks,
|
|
1082
1173
|
createLateRedirectRecovery,
|
|
1083
1174
|
createLateNotFoundRecovery,
|
|
@@ -20,15 +20,16 @@ async function hydrateFarmDocsAdapterRuntime() {
|
|
|
20
20
|
async function hydrateFarmDocsAdapterRuntime() {
|
|
21
21
|
const runtime = window.__FARM_DOCS_ADAPTER__;
|
|
22
22
|
if (!runtime) return false;
|
|
23
|
-
|
|
23
|
+
// The docs server flags pages whose config holds what its JSON copy cannot (icons,
|
|
24
|
+
// MDX components, callbacks); the adapter restores those from the module itself.
|
|
25
|
+
// Fetch it alongside the adapter rather than after it: they don't depend on each other.
|
|
26
|
+
const [FarmDocsAdapterReact, configModule] = await Promise.all([
|
|
27
|
+
import(${JSON.stringify(reactModule)}),
|
|
28
|
+
runtime.configModule ? ${configModule ? `import(${JSON.stringify(configModule)})` : "undefined"} : undefined,
|
|
29
|
+
]);
|
|
24
30
|
if (typeof FarmDocsAdapterReact.hydrateFarmDocs !== "function") {
|
|
25
31
|
throw new Error("The configured Farm docs adapter does not export hydrateFarmDocs().");
|
|
26
32
|
}
|
|
27
|
-
// The docs server flags pages whose config holds what its JSON copy cannot (icons,
|
|
28
|
-
// MDX components, callbacks); the adapter restores those from the module itself.
|
|
29
|
-
const configModule = runtime.configModule
|
|
30
|
-
? ${configModule ? `await import(${JSON.stringify(configModule)})` : "undefined"}
|
|
31
|
-
: undefined;
|
|
32
33
|
FarmDocsAdapterReact.hydrateFarmDocs({
|
|
33
34
|
config: runtime.config || {},
|
|
34
35
|
data: runtime.data,
|
|
@@ -569,6 +569,10 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
|
|
|
569
569
|
if (routeDataKey == null) {
|
|
570
570
|
return dataHooks.main(context);
|
|
571
571
|
}
|
|
572
|
+
const revalidate = normalizeProgrammaticRouteStaleTime(dataHooks.staleTime, route.path);
|
|
573
|
+
if (revalidate === 0) {
|
|
574
|
+
return dataHooks.main(context);
|
|
575
|
+
}
|
|
572
576
|
const cacheKey = createFarmCacheKey(["route-data", routeDataKey]);
|
|
573
577
|
const cacheOptions = {
|
|
574
578
|
tags: [
|
|
@@ -579,7 +583,7 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
|
|
|
579
583
|
...typeof context.path === "string" ? [context.path] : [],
|
|
580
584
|
...await resolveProgrammaticRouteDataKeys(dataHooks.paths, context)
|
|
581
585
|
],
|
|
582
|
-
revalidate
|
|
586
|
+
revalidate
|
|
583
587
|
};
|
|
584
588
|
return getFarmDataCache().getOrSet(cacheKey, () => dataHooks.main(context), cacheOptions);
|
|
585
589
|
}
|
|
@@ -590,20 +594,26 @@ async function resolveProgrammaticRouteDataKeys(input, context) {
|
|
|
590
594
|
return value.filter((item) => typeof item === "string" && item.trim().length > 0);
|
|
591
595
|
}
|
|
592
596
|
__name(resolveProgrammaticRouteDataKeys, "resolveProgrammaticRouteDataKeys");
|
|
593
|
-
function normalizeProgrammaticRouteStaleTime(staleTime) {
|
|
597
|
+
function normalizeProgrammaticRouteStaleTime(staleTime, routePath) {
|
|
594
598
|
if (staleTime === void 0) return void 0;
|
|
595
599
|
if (staleTime === false) return false;
|
|
600
|
+
let milliseconds;
|
|
596
601
|
if (typeof staleTime === "number") {
|
|
597
|
-
|
|
598
|
-
|
|
602
|
+
milliseconds = staleTime;
|
|
603
|
+
} else {
|
|
604
|
+
const match = typeof staleTime === "string" && staleTime.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)$/);
|
|
605
|
+
if (!match) {
|
|
606
|
+
throw new TypeError(
|
|
607
|
+
`Route "${routePath}" data.staleTime must be milliseconds or a duration like "250ms", "30s", "5m", or "1h".`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
const unit = match[2];
|
|
611
|
+
milliseconds = Number(match[1]) * (unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5);
|
|
612
|
+
}
|
|
613
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) {
|
|
614
|
+
throw new TypeError(`Route "${routePath}" data.staleTime must be a non-negative duration.`);
|
|
599
615
|
}
|
|
600
|
-
|
|
601
|
-
if (!match) return void 0;
|
|
602
|
-
const value = Number(match[1]);
|
|
603
|
-
if (!Number.isFinite(value) || value <= 0) return void 0;
|
|
604
|
-
const unit = match[2];
|
|
605
|
-
const milliseconds = unit === "ms" ? value : unit === "s" ? value * 1e3 : unit === "m" ? value * 6e4 : value * 36e5;
|
|
606
|
-
return Math.max(1, Math.ceil(milliseconds / 1e3));
|
|
616
|
+
return milliseconds === 0 ? 0 : Math.max(1, Math.ceil(milliseconds / 1e3));
|
|
607
617
|
}
|
|
608
618
|
__name(normalizeProgrammaticRouteStaleTime, "normalizeProgrammaticRouteStaleTime");
|
|
609
619
|
function isProgrammaticRoutePropsResolved(value) {
|
|
@@ -662,6 +672,7 @@ function normalizeProgrammaticRoute(route) {
|
|
|
662
672
|
};
|
|
663
673
|
}
|
|
664
674
|
const routeActions = route.kind === "page" ? normalizeProgrammaticRouteActions(route) : void 0;
|
|
675
|
+
normalizeProgrammaticRouteStaleTime(route.data?.staleTime, route.path);
|
|
665
676
|
return {
|
|
666
677
|
...route,
|
|
667
678
|
...routeActions,
|
|
@@ -3,18 +3,21 @@
|
|
|
3
3
|
var _chunkAI7QMY7Ocjs = require('./chunk-AI7QMY7O.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk6XWDE2P2cjs = require('./chunk-6XWDE2P2.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkULASELLAcjs = require('./chunk-ULASELLA.cjs');
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
10
13
|
|
|
11
14
|
// src/headers.ts
|
|
12
15
|
function headers() {
|
|
13
|
-
return new Headers(
|
|
16
|
+
return new Headers(_chunk6XWDE2P2cjs.getCurrentRequest.call(void 0, ).headers);
|
|
14
17
|
}
|
|
15
18
|
_chunkS3JO3N4Hcjs.__name.call(void 0, headers, "headers");
|
|
16
19
|
function cookies() {
|
|
17
|
-
const cookieHeader =
|
|
20
|
+
const cookieHeader = _chunk6XWDE2P2cjs.getCurrentRequest.call(void 0, ).headers.get("cookie") || "";
|
|
18
21
|
const parsed = _chunkAI7QMY7Ocjs.parseRequestCookieHeader.call(void 0, cookieHeader);
|
|
19
22
|
return {
|
|
20
23
|
get(name) {
|
|
@@ -35,8 +38,13 @@ function cookies() {
|
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
_chunkS3JO3N4Hcjs.__name.call(void 0, cookies, "cookies");
|
|
41
|
+
function getCspNonce() {
|
|
42
|
+
return _chunkULASELLAcjs._resolveCurrentCspNonce.call(void 0, );
|
|
43
|
+
}
|
|
44
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getCspNonce, "getCspNonce");
|
|
45
|
+
|
|
38
46
|
|
|
39
47
|
|
|
40
48
|
|
|
41
49
|
|
|
42
|
-
exports.headers = headers; exports.cookies = cookies;
|
|
50
|
+
exports.headers = headers; exports.cookies = cookies; exports.getCspNonce = getCspNonce;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MiddlewareManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JCKYH4LG.mjs";
|
|
4
|
+
import {
|
|
5
|
+
matchesMiddlewarePredicate
|
|
6
|
+
} from "./chunk-HZFM2LWQ.mjs";
|
|
4
7
|
import {
|
|
5
8
|
resolveFarmI18nConfig
|
|
6
9
|
} from "./chunk-BCMSYSN2.mjs";
|
|
@@ -210,7 +213,7 @@ var _MiddlewareChainImpl = class _MiddlewareChainImpl {
|
|
|
210
213
|
*/
|
|
211
214
|
when(condition, fn) {
|
|
212
215
|
const conditionalMiddleware = /* @__PURE__ */ __name(async (ctx, next) => {
|
|
213
|
-
const shouldRun = typeof condition === "function" ? condition
|
|
216
|
+
const shouldRun = typeof condition === "function" ? matchesMiddlewarePredicate(condition, ctx) : condition;
|
|
214
217
|
if (!shouldRun) {
|
|
215
218
|
return next();
|
|
216
219
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkSGBJ247Qcjs = require('./chunk-SGBJ247Q.cjs');
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -119,7 +121,6 @@ var ANONYMOUS_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
|
119
121
|
"cache-control",
|
|
120
122
|
"connection",
|
|
121
123
|
"dnt",
|
|
122
|
-
"forwarded",
|
|
123
124
|
"host",
|
|
124
125
|
"if-match",
|
|
125
126
|
"if-modified-since",
|
|
@@ -141,12 +142,9 @@ var ANONYMOUS_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
|
141
142
|
"tracestate",
|
|
142
143
|
"upgrade-insecure-requests",
|
|
143
144
|
"user-agent",
|
|
144
|
-
"via",
|
|
145
|
-
"x-forwarded-for",
|
|
146
145
|
"x-forwarded-host",
|
|
147
146
|
"x-forwarded-port",
|
|
148
147
|
"x-forwarded-proto",
|
|
149
|
-
"x-real-ip",
|
|
150
148
|
"x-request-id"
|
|
151
149
|
]);
|
|
152
150
|
function isAnonymousRequestHeader(name) {
|
|
@@ -154,6 +152,41 @@ function isAnonymousRequestHeader(name) {
|
|
|
154
152
|
return ANONYMOUS_REQUEST_HEADERS.has(lower) || lower.startsWith("sec-fetch-") || lower.startsWith("sec-ch-");
|
|
155
153
|
}
|
|
156
154
|
_chunkS3JO3N4Hcjs.__name.call(void 0, isAnonymousRequestHeader, "isAnonymousRequestHeader");
|
|
155
|
+
var PAGE_CHECK_DROPPED_HEADERS = /* @__PURE__ */ new Set([
|
|
156
|
+
"accept-encoding",
|
|
157
|
+
"if-match",
|
|
158
|
+
"if-modified-since",
|
|
159
|
+
"if-none-match",
|
|
160
|
+
"if-range",
|
|
161
|
+
"if-unmodified-since",
|
|
162
|
+
"range"
|
|
163
|
+
]);
|
|
164
|
+
var PAGE_SEGMENT_MARKER = /<div\s[^>]*\bid=["']?__farm_page__["'\s>]/i;
|
|
165
|
+
async function anonymousVisitorOpensPage(options, url, targetPathname) {
|
|
166
|
+
const pageUrl = new URL(url);
|
|
167
|
+
pageUrl.pathname = targetPathname;
|
|
168
|
+
const headers = new Headers();
|
|
169
|
+
for (const [name, value] of options.request.headers) {
|
|
170
|
+
if (!PAGE_CHECK_DROPPED_HEADERS.has(name.toLowerCase())) headers.append(name, value);
|
|
171
|
+
}
|
|
172
|
+
headers.set("accept", "text/html");
|
|
173
|
+
headers.set(_chunkSGBJ247Qcjs.FARM_MARKDOWN_PAGE_CHECK_HEADER, _chunkSGBJ247Qcjs._getFarmMarkdownPageCheckToken.call(void 0, ));
|
|
174
|
+
const response = await options.renderPage(
|
|
175
|
+
new Request(pageUrl, {
|
|
176
|
+
method: "GET",
|
|
177
|
+
headers,
|
|
178
|
+
redirect: "manual",
|
|
179
|
+
signal: options.request.signal
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
if (response.status < 200 || response.status >= 300 || !_optionalChain([response, 'access', _9 => _9.headers, 'access', _10 => _10.get, 'call', _11 => _11("content-type"), 'optionalAccess', _12 => _12.toLowerCase, 'call', _13 => _13(), 'access', _14 => _14.includes, 'call', _15 => _15("text/html")])) {
|
|
183
|
+
void _optionalChain([response, 'access', _16 => _16.body, 'optionalAccess', _17 => _17.cancel, 'call', _18 => _18(), 'access', _19 => _19.catch, 'call', _20 => _20(() => {
|
|
184
|
+
})]);
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
return PAGE_SEGMENT_MARKER.test(await response.text());
|
|
188
|
+
}
|
|
189
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, anonymousVisitorOpensPage, "anonymousVisitorOpensPage");
|
|
157
190
|
function hasOnlyAnonymousHeaders(headers) {
|
|
158
191
|
for (const name of headers.keys()) {
|
|
159
192
|
if (!isAnonymousRequestHeader(name)) return false;
|
|
@@ -161,16 +194,17 @@ function hasOnlyAnonymousHeaders(headers) {
|
|
|
161
194
|
return true;
|
|
162
195
|
}
|
|
163
196
|
_chunkS3JO3N4Hcjs.__name.call(void 0, hasOnlyAnonymousHeaders, "hasOnlyAnonymousHeaders");
|
|
197
|
+
var FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS = "192.0.2.1";
|
|
164
198
|
async function createFarmMarkdownSourceResponse(options) {
|
|
165
199
|
if (options.request.method !== "GET" && options.request.method !== "HEAD") {
|
|
166
200
|
return null;
|
|
167
201
|
}
|
|
168
|
-
if (_optionalChain([options, 'access',
|
|
202
|
+
if (_optionalChain([options, 'access', _21 => _21.config, 'optionalAccess', _22 => _22.markdownRoutes]) === false) {
|
|
169
203
|
return null;
|
|
170
204
|
}
|
|
171
205
|
const url = new URL(options.request.url);
|
|
172
206
|
const hasMarkdownExtension = url.pathname.toLowerCase().endsWith(".md");
|
|
173
|
-
if (!hasMarkdownExtension && !
|
|
207
|
+
if (!hasMarkdownExtension && !_chunkSGBJ247Qcjs.requestAcceptsMarkdown.call(void 0, options.request.headers.get("accept"))) {
|
|
174
208
|
return null;
|
|
175
209
|
}
|
|
176
210
|
const targetPathname = normalizeFarmMarkdownRoutePath(url.pathname);
|
|
@@ -178,7 +212,7 @@ async function createFarmMarkdownSourceResponse(options) {
|
|
|
178
212
|
if (!source) {
|
|
179
213
|
return null;
|
|
180
214
|
}
|
|
181
|
-
const anonymous = hasOnlyAnonymousHeaders(options.request.headers);
|
|
215
|
+
const anonymous = hasOnlyAnonymousHeaders(options.request.headers) && (!options.clientAddress || options.clientAddress === FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS);
|
|
182
216
|
if (options.renderPage && (hasMarkdownExtension || !anonymous)) {
|
|
183
217
|
const publicUrl = new URL(url);
|
|
184
218
|
publicUrl.pathname = targetPathname;
|
|
@@ -194,11 +228,21 @@ async function createFarmMarkdownSourceResponse(options) {
|
|
|
194
228
|
signal: options.request.signal
|
|
195
229
|
})
|
|
196
230
|
);
|
|
197
|
-
if (publicResponse.headers.get("X-Farm-Markdown-Route") === targetPathname) {
|
|
198
|
-
|
|
199
|
-
|
|
231
|
+
if (publicResponse.headers.get("X-Farm-Markdown-Route") === targetPathname && publicResponse.headers.has("X-Farm-Markdown-Source")) {
|
|
232
|
+
let response = publicResponse;
|
|
233
|
+
if (options.request.headers.has("cookie") || options.request.headers.has("authorization")) {
|
|
234
|
+
const headers2 = new Headers(publicResponse.headers);
|
|
235
|
+
headers2.set("Cache-Control", "private, no-store");
|
|
236
|
+
response = new Response(publicResponse.body, {
|
|
237
|
+
status: publicResponse.status,
|
|
238
|
+
statusText: publicResponse.statusText,
|
|
239
|
+
headers: headers2
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
publicSourceResponses.add(response);
|
|
243
|
+
return response;
|
|
200
244
|
}
|
|
201
|
-
await _optionalChain([publicResponse, 'access',
|
|
245
|
+
await _optionalChain([publicResponse, 'access', _23 => _23.body, 'optionalAccess', _24 => _24.cancel, 'call', _25 => _25()]);
|
|
202
246
|
if (!hasMarkdownExtension) return null;
|
|
203
247
|
return new Response(`No public Markdown version of ${targetPathname}.
|
|
204
248
|
`, {
|
|
@@ -209,6 +253,9 @@ async function createFarmMarkdownSourceResponse(options) {
|
|
|
209
253
|
}
|
|
210
254
|
});
|
|
211
255
|
}
|
|
256
|
+
if (options.renderPage && !await anonymousVisitorOpensPage(options, url, targetPathname)) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
212
259
|
const headers = new Headers({
|
|
213
260
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
214
261
|
"Content-Location": targetPathname === "/" ? "/index.md" : `${targetPathname}.md`,
|
|
@@ -219,7 +266,7 @@ async function createFarmMarkdownSourceResponse(options) {
|
|
|
219
266
|
if (!hasMarkdownExtension) {
|
|
220
267
|
headers.set("Vary", "Accept");
|
|
221
268
|
}
|
|
222
|
-
return
|
|
269
|
+
return _chunkSGBJ247Qcjs.createFarmMarkdownViewResponse.call(void 0, {
|
|
223
270
|
request: options.request,
|
|
224
271
|
requestUrl: url,
|
|
225
272
|
markdown: source.source,
|
|
@@ -239,4 +286,5 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmMarkdownSourceResponse, "createF
|
|
|
239
286
|
|
|
240
287
|
|
|
241
288
|
|
|
242
|
-
|
|
289
|
+
|
|
290
|
+
exports.isFarmMarkdownPageFile = isFarmMarkdownPageFile; exports.normalizeFarmMarkdownRoutePath = normalizeFarmMarkdownRoutePath; exports.parseMarkdownFrontmatter = parseMarkdownFrontmatter; exports.titleFromMarkdown = titleFromMarkdown; exports.createMarkdownMetadata = createMarkdownMetadata; exports.createFarmMarkdownRouteModule = createFarmMarkdownRouteModule; exports.isFarmMarkdownPublicSourceResponse = isFarmMarkdownPublicSourceResponse; exports.FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS = FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS; exports.createFarmMarkdownSourceResponse = createFarmMarkdownSourceResponse;
|