@farm.js/core 0.1.28 → 0.1.29
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.d.mts +2 -2
- package/dist/agent-runtime.d.ts +2 -2
- package/dist/api/route-manager.d.mts +1 -1
- package/dist/api/route-manager.d.ts +1 -1
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api.cjs +2 -2
- package/dist/api.d.mts +18 -4
- package/dist/api.d.ts +18 -4
- package/dist/api.mjs +1 -1
- package/dist/{app-DSSq6wiN.d.mts → app-DAuUTIZf.d.mts} +3 -3
- package/dist/app-markdown.cjs +5 -4
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +4 -3
- package/dist/{app-M8nVWvNU.d.ts → app-sUJ3jnTZ.d.ts} +3 -3
- package/dist/{chunk-N6UROPT7.mjs → chunk-2FQHH5SC.mjs} +12 -13
- package/dist/{chunk-2CNBR3EB.mjs → chunk-2UABTL3Y.mjs} +2 -2
- package/dist/{chunk-JUFRXDTK.cjs → chunk-3FCFQP5V.cjs} +17 -5
- package/dist/{chunk-FVCSLZWT.mjs → chunk-5KDPVSS3.mjs} +268 -152
- package/dist/{chunk-XSPGWQWA.cjs → chunk-6CNX6Q3K.cjs} +96 -24
- package/dist/{chunk-NVBS5WSZ.mjs → chunk-6G3ZZ2IE.mjs} +1 -1
- package/dist/{chunk-QBPXNZGV.cjs → chunk-6MVFL3R5.cjs} +25 -6
- package/dist/{chunk-F52CDFJM.cjs → chunk-74T3CEA7.cjs} +388 -272
- package/dist/{chunk-PZPDGOU5.mjs → chunk-7CXKSRKL.mjs} +11 -7
- package/dist/{chunk-K3YEZLSY.mjs → chunk-ATXI6LGT.mjs} +96 -24
- package/dist/{chunk-2DLN6HG4.mjs → chunk-BZ3CHOFX.mjs} +1 -1
- package/dist/{chunk-EWZ3XHKQ.cjs → chunk-BZAGKCKB.cjs} +2 -2
- package/dist/{chunk-FB3H4INL.mjs → chunk-D234YWNA.mjs} +1 -1
- package/dist/{chunk-KXGDXYUC.mjs → chunk-DGXN3L4D.mjs} +17 -5
- package/dist/{chunk-UX2DD2VK.mjs → chunk-E7UN576T.mjs} +1 -1
- package/dist/chunk-FJ3M4CUX.cjs +46 -0
- package/dist/chunk-FXEF4PPL.mjs +47 -0
- package/dist/{chunk-KOQ555NR.cjs → chunk-JFHKNFEO.cjs} +24 -20
- package/dist/{chunk-BYODCJD6.cjs → chunk-K7CELQLK.cjs} +12 -13
- package/dist/{chunk-A672WZEG.cjs → chunk-NPPL5YDT.cjs} +2 -2
- package/dist/{chunk-TII23GJC.cjs → chunk-NXG66MR7.cjs} +3 -3
- package/dist/{chunk-R6AIILII.cjs → chunk-OZVEHHMA.cjs} +15 -14
- package/dist/{chunk-T7HQ3I4C.mjs → chunk-PQD2AI3B.mjs} +1 -1
- package/dist/{chunk-VQXDC5UV.cjs → chunk-Q5JFU33Q.cjs} +4 -4
- package/dist/{chunk-FZC7EEPM.mjs → chunk-RSOJ7DRT.mjs} +26 -7
- package/dist/{chunk-Y7GW7J46.cjs → chunk-WPPX4G7Q.cjs} +1 -1
- package/dist/{chunk-ID6OVSLH.cjs → chunk-X4ZV4QC5.cjs} +175 -171
- package/dist/chunk-XD32KALF.cjs +47 -0
- package/dist/{chunk-RDV44SED.mjs → chunk-XJJVLDM6.mjs} +15 -14
- package/dist/{chunk-55ZY4ZA7.cjs → chunk-XLTV4VOG.cjs} +21 -16
- package/dist/{chunk-REGFZJEJ.mjs → chunk-YMUE7L3D.mjs} +18 -13
- package/dist/chunk-Z3HATSKO.mjs +46 -0
- package/dist/{chunk-MH24QDVJ.cjs → chunk-ZDILFMWN.cjs} +13 -13
- package/dist/{chunk-ZRIE4KMG.mjs → chunk-ZYVFAOBT.mjs} +17 -13
- package/dist/{client-plugins-CgYNY7jF.d.mts → client-plugins-BX2ptm4H.d.mts} +7 -2
- package/dist/{client-plugins-Fl9Og3yB.d.ts → client-plugins-BmxM5KW_.d.ts} +7 -2
- package/dist/client-plugins.d.mts +2 -2
- package/dist/client-plugins.d.ts +2 -2
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/{devtools-5AREISIA.cjs → devtools-GGVPZHJX.cjs} +95 -20
- package/dist/{devtools-3E7ZANMZ.mjs → devtools-THVNPI2M.mjs} +79 -4
- package/dist/{devtools-client-4WAPJY5L.cjs → devtools-client-CXQ6PXI6.cjs} +1 -1
- package/dist/{devtools-client-LEUIHHAS.mjs → devtools-client-HJS2T34Y.mjs} +1 -1
- package/dist/docs.cjs +8 -7
- package/dist/docs.mjs +7 -6
- package/dist/index.cjs +18 -16
- package/dist/index.d.mts +24 -14
- package/dist/index.d.ts +24 -14
- package/dist/index.mjs +17 -15
- package/dist/integrations.d.mts +2 -2
- package/dist/integrations.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.cjs +4 -3
- package/dist/internal/app-markdown-runtime.d.mts +3 -3
- package/dist/internal/app-markdown-runtime.d.ts +3 -3
- package/dist/internal/app-markdown-runtime.mjs +3 -2
- package/dist/internal/build-runtime.cjs +15 -13
- package/dist/internal/build-runtime.d.mts +4 -4
- package/dist/internal/build-runtime.d.ts +4 -4
- package/dist/internal/build-runtime.mjs +14 -12
- package/dist/internal/cli-runtime.cjs +7 -6
- package/dist/internal/cli-runtime.mjs +6 -5
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.cjs +3 -2
- package/dist/internal/compression-runtime.d.mts +5 -3
- package/dist/internal/compression-runtime.d.ts +5 -3
- package/dist/internal/compression-runtime.mjs +2 -1
- package/dist/internal/config-runtime.cjs +6 -5
- package/dist/internal/config-runtime.d.mts +3 -3
- package/dist/internal/config-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.mjs +5 -4
- package/dist/internal/product-telemetry-runtime.cjs +10 -6
- package/dist/internal/product-telemetry-runtime.mjs +9 -5
- package/dist/internal/production-runtime.cjs +19 -5
- package/dist/internal/production-runtime.d.mts +35 -8
- package/dist/internal/production-runtime.d.ts +35 -8
- package/dist/internal/production-runtime.mjs +18 -4
- package/dist/markdown.cjs +3 -2
- package/dist/markdown.d.mts +2 -2
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.mjs +2 -1
- package/dist/{metadata-B0X-qtcQ.d.mts → metadata-DsEaK7mQ.d.mts} +1 -1
- package/dist/{metadata-BdDKgd7K.d.ts → metadata-fwZ3gfG6.d.ts} +1 -1
- package/dist/middleware.cjs +3 -2
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.mjs +2 -1
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/plugin.cjs +10 -9
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.mjs +9 -8
- package/dist/{production-runtime-BjgFgDIg.d.mts → production-runtime-Baqgwtvc.d.mts} +1 -1
- package/dist/{production-runtime-Dx_qMA3t.d.ts → production-runtime-DNkpFnmg.d.ts} +1 -1
- package/dist/{render-plan-_1TAWODt.d.mts → render-plan-DhwQnmmX.d.mts} +1 -1
- package/dist/{render-plan-B41EWmBb.d.ts → render-plan-rkIK9wd9.d.ts} +1 -1
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/{request-Dbf3G0zM.d.ts → request-BcY4RYPC.d.ts} +1 -1
- package/dist/{request-BhE4luLv.d.mts → request-CFy1BltJ.d.mts} +1 -1
- package/dist/request.d.mts +3 -3
- package/dist/request.d.ts +3 -3
- package/dist/{route-rendering-zzfx_GHf.d.mts → route-rendering-BkS0TBlB.d.mts} +1 -1
- package/dist/{route-rendering-Z7PveTZE.d.ts → route-rendering-D4XpMjam.d.ts} +1 -1
- package/dist/{router-BatNMsa1.d.mts → router-C4zPlC3V.d.mts} +1 -1
- package/dist/{router-DtNRhQl3.d.ts → router-Cq7BcZxg.d.ts} +1 -1
- package/dist/routes.d.mts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/server-plugins.cjs +3 -2
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-plugins.mjs +2 -1
- package/dist/server.cjs +33 -28
- package/dist/server.d.mts +8 -8
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +16 -11
- package/dist/{spa-router-BE3bwU-J.d.ts → spa-router-B1HI3X9k.d.ts} +2 -2
- package/dist/{spa-router-DQOnHZVj.d.mts → spa-router-DzPZH-AO.d.mts} +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{utils-DLK1ERNl.d.mts → utils-CEBktlBG.d.mts} +1 -1
- package/dist/{utils-u7ZBSWAK.d.ts → utils-DMD1Hzta.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +10 -9
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.mjs +9 -8
- package/package.json +1 -1
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
assertPluginDependencies,
|
|
3
3
|
resolveFarmAuthConfig,
|
|
4
4
|
resolveFarmAuthIntegration,
|
|
5
|
-
resolveFarmDevIndicatorsConfig
|
|
6
|
-
|
|
5
|
+
resolveFarmDevIndicatorsConfig,
|
|
6
|
+
setFarmProjectSourceDir
|
|
7
|
+
} from "./chunk-RSOJ7DRT.mjs";
|
|
7
8
|
import {
|
|
8
9
|
resolveFarmDevtoolsConfig
|
|
9
10
|
} from "./chunk-JBSVKMC5.mjs";
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
resolveFarmNoindexPreviews,
|
|
29
30
|
resolveFarmPerformanceConfig,
|
|
30
31
|
resolveFarmSecurityConfig
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-YMUE7L3D.mjs";
|
|
32
33
|
import {
|
|
33
34
|
resolveFarmImageConfig
|
|
34
35
|
} from "./chunk-G2KY33I6.mjs";
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
} from "./chunk-FA2W42OV.mjs";
|
|
48
49
|
import {
|
|
49
50
|
resolveMarkdownConfig
|
|
50
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-ATXI6LGT.mjs";
|
|
51
52
|
import {
|
|
52
53
|
bundleNodeModule
|
|
53
54
|
} from "./chunk-SFGWNC43.mjs";
|
|
@@ -88,9 +89,6 @@ import {
|
|
|
88
89
|
__name
|
|
89
90
|
} from "./chunk-LPEX4YW6.mjs";
|
|
90
91
|
|
|
91
|
-
// src/config.ts
|
|
92
|
-
import path3 from "path";
|
|
93
|
-
|
|
94
92
|
// src/mcp-config.ts
|
|
95
93
|
import { createRequire } from "module";
|
|
96
94
|
import path from "path";
|
|
@@ -128,6 +126,9 @@ async function resolveFarmMCPPlugin(config, options) {
|
|
|
128
126
|
}
|
|
129
127
|
__name(resolveFarmMCPPlugin, "resolveFarmMCPPlugin");
|
|
130
128
|
|
|
129
|
+
// src/config.ts
|
|
130
|
+
import path3 from "path";
|
|
131
|
+
|
|
131
132
|
// src/agent-config.ts
|
|
132
133
|
var DEFAULT_JSON_LD = { type: "WebSite" };
|
|
133
134
|
function resolveFarmAgentConfig(input, context = {}) {
|
|
@@ -697,6 +698,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
697
698
|
const deploy = resolveDeployConfig(userConfig);
|
|
698
699
|
const root = userConfig.root || process.cwd();
|
|
699
700
|
const srcDir = userConfig.srcDir || "src";
|
|
701
|
+
setFarmProjectSourceDir(root, srcDir);
|
|
700
702
|
const docs = await resolveDocsConfig(userConfig.docs, { root, srcDir });
|
|
701
703
|
const md = resolveMarkdownConfig(userConfig.md);
|
|
702
704
|
const mdx = resolveMdxConfig(userConfig.mdx);
|
|
@@ -882,6 +884,8 @@ async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "
|
|
|
882
884
|
__name(loadConfig, "loadConfig");
|
|
883
885
|
|
|
884
886
|
export {
|
|
887
|
+
resolveFarmMCPConfig,
|
|
888
|
+
resolveFarmMCPPlugin,
|
|
885
889
|
hasCustomFarmRouteContext,
|
|
886
890
|
isResolvedFarmConfig,
|
|
887
891
|
normalizeDeployTarget,
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
_findFarmMCPEndpointTool
|
|
6
6
|
} from "./chunk-O6XNAMBV.mjs";
|
|
7
|
+
import {
|
|
8
|
+
_withFarmResponseHeaders
|
|
9
|
+
} from "./chunk-Z3HATSKO.mjs";
|
|
7
10
|
import {
|
|
8
11
|
stripFarmBasePath
|
|
9
12
|
} from "./chunk-4RB44K6Z.mjs";
|
|
@@ -14,8 +17,7 @@ import {
|
|
|
14
17
|
// src/markdown-view.ts
|
|
15
18
|
var FENCE = /^\s{0,3}(`{3,}|~{3,})/;
|
|
16
19
|
var ATX_HEADING = /^\s{0,3}(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/;
|
|
17
|
-
function
|
|
18
|
-
const lines = markdown.split("\n");
|
|
20
|
+
function parseMarkdownHeadingsFromLines(lines) {
|
|
19
21
|
const headings = [];
|
|
20
22
|
const used = /* @__PURE__ */ new Map();
|
|
21
23
|
let index = 0;
|
|
@@ -57,7 +59,7 @@ function parseFarmMarkdownHeadings(markdown) {
|
|
|
57
59
|
}
|
|
58
60
|
return headings;
|
|
59
61
|
}
|
|
60
|
-
__name(
|
|
62
|
+
__name(parseMarkdownHeadingsFromLines, "parseMarkdownHeadingsFromLines");
|
|
61
63
|
function slugifyHeading(text) {
|
|
62
64
|
return text.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[`*_~]/g, "").toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").trim().replace(/\s/g, "-");
|
|
63
65
|
}
|
|
@@ -97,7 +99,7 @@ function selectFarmMarkdownView(markdown, searchParams, markdownPath) {
|
|
|
97
99
|
), "withinBudget");
|
|
98
100
|
if (!wantsOutline && sectionId === null) return withinBudget(markdown);
|
|
99
101
|
const lines = markdown.split("\n");
|
|
100
|
-
const headings =
|
|
102
|
+
const headings = parseMarkdownHeadingsFromLines(lines);
|
|
101
103
|
const sectionText = /* @__PURE__ */ __name((heading) => lines.slice(heading.start, heading.end).join("\n").trim(), "sectionText");
|
|
102
104
|
if (sectionId !== null) {
|
|
103
105
|
const heading = headings.find((candidate) => candidate.id === sectionId);
|
|
@@ -116,10 +118,20 @@ ${available}
|
|
|
116
118
|
` : "This page has no sections.\n")
|
|
117
119
|
};
|
|
118
120
|
}
|
|
121
|
+
const offsets = [];
|
|
122
|
+
let offset = 0;
|
|
123
|
+
for (const line of lines) {
|
|
124
|
+
offsets.push(offset);
|
|
125
|
+
offset += line.length + 1;
|
|
126
|
+
}
|
|
119
127
|
const minLevel = headings.reduce((min, heading) => Math.min(min, heading.level), 6);
|
|
120
128
|
const entries = headings.map((heading) => {
|
|
121
129
|
const indent = " ".repeat(heading.level - minLevel);
|
|
122
|
-
|
|
130
|
+
let last = heading.end - 1;
|
|
131
|
+
while (last > heading.start && lines[last].trim().length === 0) last--;
|
|
132
|
+
const first = lines[heading.start];
|
|
133
|
+
const length = offsets[last] + lines[last].trimEnd().length - offsets[heading.start] - (first.length - first.trimStart().length);
|
|
134
|
+
const tokens = Math.ceil(length / 4);
|
|
123
135
|
return `${indent}- [${heading.text}](${viewUrl({ section: heading.id })}) ~${tokens} tokens`;
|
|
124
136
|
});
|
|
125
137
|
return {
|
|
@@ -211,7 +223,9 @@ The page changed after this cursor was issued. Start again at ${partUrl()}.
|
|
|
211
223
|
const part = `${head}${lines.slice(start, end).join("\n").replace(/\n+$/, "")}${open ? `
|
|
212
224
|
${open.closer}` : ""}`;
|
|
213
225
|
const next = partUrl(`${end}.${version}`);
|
|
214
|
-
|
|
226
|
+
let remainingLength = lines.length - end - 1;
|
|
227
|
+
for (let index = end; index < lines.length; index++) remainingLength += lines[index].length;
|
|
228
|
+
const remaining = Math.ceil(remainingLength / 4);
|
|
215
229
|
return {
|
|
216
230
|
status: 200,
|
|
217
231
|
body: `${part}
|
|
@@ -423,19 +437,24 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
423
437
|
}
|
|
424
438
|
const html = await pageResponse.text();
|
|
425
439
|
const markdownPath = target.pathname === "/" ? "/index.md" : `${target.pathname}.md`;
|
|
426
|
-
const
|
|
440
|
+
const region = pageResponse.status < 400 && /<form\b/i.test(html) ? readHtmlContentRegion(html) : void 0;
|
|
441
|
+
const actions = region === void 0 ? [] : extractPageActionsFromRegion(region, pageUrl);
|
|
427
442
|
for (const form of actions) {
|
|
428
443
|
if (!form.action?.startsWith("/")) continue;
|
|
429
444
|
const pathname = new URL(form.action, pageUrl.origin).pathname;
|
|
430
445
|
const tool = _findFarmMCPEndpointTool(form.method, pathname, options.apiServerBasePath) ?? _findFarmMCPEndpointTool(form.method, stripFarmBasePath(pathname), options.apiServerBasePath);
|
|
431
446
|
if (tool) form.tool = tool;
|
|
432
447
|
}
|
|
433
|
-
const markdown =
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
448
|
+
const markdown = pageResponse.status < 400 && requestUrl.searchParams.has("actions") ? "" : convertHtmlToMarkdown(
|
|
449
|
+
html,
|
|
450
|
+
{
|
|
451
|
+
title: target.route?.title,
|
|
452
|
+
includeMetadata: options.config?.includeMetadata ?? true,
|
|
453
|
+
sourcePath: target.pathname,
|
|
454
|
+
actionsPath: actions.length > 0 ? `${markdownPath}?actions` : void 0
|
|
455
|
+
},
|
|
456
|
+
region
|
|
457
|
+
);
|
|
439
458
|
const headersOut = new Headers({
|
|
440
459
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
441
460
|
"Content-Location": markdownPath,
|
|
@@ -537,13 +556,9 @@ function applyMarkdownNegotiationHeaders(response, options) {
|
|
|
537
556
|
if (!alternatePath) {
|
|
538
557
|
return response;
|
|
539
558
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return new Response(response.body, {
|
|
544
|
-
status: response.status,
|
|
545
|
-
statusText: response.statusText,
|
|
546
|
-
headers
|
|
559
|
+
return _withFarmResponseHeaders(response, (headers) => {
|
|
560
|
+
appendHeaderToken(headers, "Vary", "Accept");
|
|
561
|
+
headers.append("Link", `<${alternatePath}>; rel="alternate"; type="text/markdown"`);
|
|
547
562
|
});
|
|
548
563
|
}
|
|
549
564
|
__name(applyMarkdownNegotiationHeaders, "applyMarkdownNegotiationHeaders");
|
|
@@ -551,9 +566,61 @@ var CODE_BLOCK_MARK = "\0";
|
|
|
551
566
|
var CODE_BLOCK_PLACEHOLDER = /\u0000(\d+)\u0000/g;
|
|
552
567
|
var BLOCK_TAGS = /<\/?(ul|ol|main|section|article|header|footer|nav|aside|div|form|fieldset|legend|figure|figcaption|table|thead|tbody|tfoot|tr|dl|dt|dd|details|summary|address)\b[^>]*>/gi;
|
|
553
568
|
var BOX_TAGS = /<\/?(label|button|input|select|textarea|option|output|meter|progress|td|th)\b[^>]*>/gi;
|
|
569
|
+
var LAYOUT_ROW = /<(div|nav|section|header|footer|aside|main|article|figure|figcaption|dt|dd)\b([^>]*)>((?:(?!<\/?(?:div|nav|section|header|footer|aside|main|article|figure|figcaption|dt|dd|p|h[1-6]|ul|ol|li|table|pre|blockquote)\b)[\s\S])*?)<\/\1>/gi;
|
|
570
|
+
var HTML_TOKEN = /<\/?([a-zA-Z][\w:-]*)\b[^>]*?(\/?)>|[^<]+/g;
|
|
571
|
+
function separateLayoutRowItems(source) {
|
|
572
|
+
return source.replace(
|
|
573
|
+
LAYOUT_ROW,
|
|
574
|
+
(container, tag, attributes, content) => {
|
|
575
|
+
const boundaries = [];
|
|
576
|
+
const items = [];
|
|
577
|
+
let depth = 0;
|
|
578
|
+
let previousEnd = -1;
|
|
579
|
+
let item = "";
|
|
580
|
+
for (const match of content.matchAll(HTML_TOKEN)) {
|
|
581
|
+
const [token, name, selfClosing] = match;
|
|
582
|
+
const index = match.index ?? 0;
|
|
583
|
+
if (name === void 0) {
|
|
584
|
+
if (depth === 0) {
|
|
585
|
+
if (token.trim()) return container;
|
|
586
|
+
previousEnd = -1;
|
|
587
|
+
} else {
|
|
588
|
+
item += token;
|
|
589
|
+
}
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
const closing = token.startsWith("</");
|
|
593
|
+
const isVoid = selfClosing === "/" || VOID_TAGS.has(name.toLowerCase());
|
|
594
|
+
if (closing) {
|
|
595
|
+
depth = Math.max(0, depth - 1);
|
|
596
|
+
} else {
|
|
597
|
+
if (depth === 0 && previousEnd === index) boundaries.push(index);
|
|
598
|
+
if (!isVoid) depth += 1;
|
|
599
|
+
}
|
|
600
|
+
if (depth === 0) {
|
|
601
|
+
previousEnd = index + token.length;
|
|
602
|
+
items.push(decodeHtml(item).trim());
|
|
603
|
+
item = "";
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (boundaries.length === 0) return container;
|
|
607
|
+
if (items.filter(Boolean).every((text) => text.length === 1)) return container;
|
|
608
|
+
let separated = content;
|
|
609
|
+
for (const boundary of boundaries.reverse()) {
|
|
610
|
+
separated = `${separated.slice(0, boundary)} ${separated.slice(boundary)}`;
|
|
611
|
+
}
|
|
612
|
+
return `<${tag}${attributes}>${separated}</${tag}>`;
|
|
613
|
+
}
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
__name(separateLayoutRowItems, "separateLayoutRowItems");
|
|
554
617
|
function htmlToMarkdown(html, options = {}) {
|
|
618
|
+
return convertHtmlToMarkdown(html, options);
|
|
619
|
+
}
|
|
620
|
+
__name(htmlToMarkdown, "htmlToMarkdown");
|
|
621
|
+
function convertHtmlToMarkdown(html, options, region) {
|
|
555
622
|
const title = options.title ?? extractHtmlTitle(html);
|
|
556
|
-
let source = readHtmlContentRegion(html);
|
|
623
|
+
let source = region ?? readHtmlContentRegion(html);
|
|
557
624
|
const codeBlocks = [];
|
|
558
625
|
const setAsideCodeBlock = /* @__PURE__ */ __name((code, attributes) => {
|
|
559
626
|
const content = decodeHtml(stripTags(code)).trim();
|
|
@@ -594,6 +661,7 @@ ${CODE_BLOCK_MARK}${codeBlocks.length - 1}${CODE_BLOCK_MARK}
|
|
|
594
661
|
`;
|
|
595
662
|
}
|
|
596
663
|
);
|
|
664
|
+
source = separateLayoutRowItems(source);
|
|
597
665
|
source = source.replace(/<h([1-6])\b[^>]*>([\s\S]*?)<\/h\1>/gi, (_, level, content) => {
|
|
598
666
|
return `
|
|
599
667
|
|
|
@@ -664,7 +732,7 @@ ${markdown}` : ""}`;
|
|
|
664
732
|
return `${markdown}
|
|
665
733
|
`;
|
|
666
734
|
}
|
|
667
|
-
__name(
|
|
735
|
+
__name(convertHtmlToMarkdown, "convertHtmlToMarkdown");
|
|
668
736
|
function normalizeMarkdownRouteInput(input) {
|
|
669
737
|
if (typeof input === "string") {
|
|
670
738
|
return {
|
|
@@ -861,7 +929,10 @@ var FORM_ENCTYPES = /* @__PURE__ */ new Set([
|
|
|
861
929
|
]);
|
|
862
930
|
function extractFarmPageActions(html, pageUrl) {
|
|
863
931
|
if (!/<form\b/i.test(html)) return [];
|
|
864
|
-
|
|
932
|
+
return extractPageActionsFromRegion(readHtmlContentRegion(html), pageUrl);
|
|
933
|
+
}
|
|
934
|
+
__name(extractFarmPageActions, "extractFarmPageActions");
|
|
935
|
+
function extractPageActionsFromRegion(region, pageUrl) {
|
|
865
936
|
const labelsFor = /* @__PURE__ */ new Map();
|
|
866
937
|
for (const match of region.matchAll(/<label\b([^>]*)>([\s\S]*?)<\/label>/gi)) {
|
|
867
938
|
const target = readDecodedAttribute(match[1], "for");
|
|
@@ -874,7 +945,7 @@ function extractFarmPageActions(html, pageUrl) {
|
|
|
874
945
|
}
|
|
875
946
|
return actions;
|
|
876
947
|
}
|
|
877
|
-
__name(
|
|
948
|
+
__name(extractPageActionsFromRegion, "extractPageActionsFromRegion");
|
|
878
949
|
function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
879
950
|
const method = readDecodedAttribute(attributes, "method")?.trim().toLowerCase();
|
|
880
951
|
if (method === "dialog") return void 0;
|
|
@@ -1109,6 +1180,7 @@ var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
|
1109
1180
|
"wbr"
|
|
1110
1181
|
]);
|
|
1111
1182
|
function removeHiddenElements(html) {
|
|
1183
|
+
if (!/hidden/i.test(html)) return html;
|
|
1112
1184
|
const openingTag = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
1113
1185
|
let closingTags;
|
|
1114
1186
|
let result = "";
|
|
@@ -1,6 +1,6 @@
|
|
|
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkNXG66MR7cjs = require('./chunk-NXG66MR7.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -11,7 +11,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
11
11
|
var _url = require('url');
|
|
12
12
|
async function createFarmMarkdownRouteModuleFromFile(filePath, options = {}) {
|
|
13
13
|
const source = await _promises.readFile.call(void 0, filePath, "utf8");
|
|
14
|
-
return
|
|
14
|
+
return _chunkNXG66MR7cjs.createFarmMarkdownRouteModule.call(void 0, {
|
|
15
15
|
source,
|
|
16
16
|
filePath,
|
|
17
17
|
components: options.components,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getAllowedAPIRouteMethods,
|
|
19
19
|
invokeAPIRouteEndpoint,
|
|
20
20
|
matchAPIRouteAtBasePath,
|
|
21
|
+
mergePluginAPIRoutes,
|
|
21
22
|
resolveAPIRouteEndpoint
|
|
22
23
|
} from "./chunk-X7WVQMIB.mjs";
|
|
23
24
|
import {
|
|
@@ -63,6 +64,10 @@ function farmApiPlugin(options = {}) {
|
|
|
63
64
|
const basePath = options.basePath;
|
|
64
65
|
let apiRoutesCache = /* @__PURE__ */ new Map();
|
|
65
66
|
let apiRouterHandler = null;
|
|
67
|
+
let projectRoot = process.cwd();
|
|
68
|
+
let pluginMergedRoutes = null;
|
|
69
|
+
const servedRoutes = /* @__PURE__ */ __name(() => pluginMergedRoutes ?? apiRoutesCache, "servedRoutes");
|
|
70
|
+
let routePlugins;
|
|
66
71
|
let discoveryComplete = false;
|
|
67
72
|
let discoveryPromise = null;
|
|
68
73
|
let discoveryError;
|
|
@@ -179,7 +184,13 @@ function farmApiPlugin(options = {}) {
|
|
|
179
184
|
}
|
|
180
185
|
}, "restoreRouteState");
|
|
181
186
|
const createRouter = /* @__PURE__ */ __name(async () => {
|
|
182
|
-
const
|
|
187
|
+
const plugins = options.plugins ? await (routePlugins ?? (routePlugins = Promise.resolve(options.plugins({ root: projectRoot })))) : [];
|
|
188
|
+
pluginMergedRoutes = plugins.length ? new Map(
|
|
189
|
+
mergePluginAPIRoutes([...apiRoutesCache.values()], plugins, void 0, {
|
|
190
|
+
bodySizeLimit
|
|
191
|
+
}).map((route) => [route.path, route])
|
|
192
|
+
) : null;
|
|
193
|
+
const totalEndpoints = Array.from(servedRoutes().values()).reduce(
|
|
183
194
|
(sum, route) => sum + route.methods.length,
|
|
184
195
|
0
|
|
185
196
|
);
|
|
@@ -189,7 +200,7 @@ function farmApiPlugin(options = {}) {
|
|
|
189
200
|
const url = new URL(request.url);
|
|
190
201
|
const method = request.method.toUpperCase();
|
|
191
202
|
const pathname = url.pathname;
|
|
192
|
-
const match = matchAPIRouteAtBasePath(
|
|
203
|
+
const match = matchAPIRouteAtBasePath(servedRoutes(), pathname, basePath);
|
|
193
204
|
if (!match) {
|
|
194
205
|
return new Response(JSON.stringify({ error: "Not Found" }), {
|
|
195
206
|
status: 404,
|
|
@@ -223,6 +234,7 @@ function farmApiPlugin(options = {}) {
|
|
|
223
234
|
name: "@farm.js/core:api",
|
|
224
235
|
enforce: "pre",
|
|
225
236
|
configureServer(server) {
|
|
237
|
+
projectRoot = server.config.root;
|
|
226
238
|
const discoverFileRoutes = /* @__PURE__ */ __name(async (apiDir) => {
|
|
227
239
|
const fs = await import("fs");
|
|
228
240
|
const path = await import("path");
|
|
@@ -368,7 +380,7 @@ function farmApiPlugin(options = {}) {
|
|
|
368
380
|
}, "recoverFailedDiscovery");
|
|
369
381
|
server.__farmApi__ = {
|
|
370
382
|
getHandler: /* @__PURE__ */ __name(() => apiRouterHandler, "getHandler"),
|
|
371
|
-
getRoutes: /* @__PURE__ */ __name(() =>
|
|
383
|
+
getRoutes: /* @__PURE__ */ __name(() => servedRoutes(), "getRoutes"),
|
|
372
384
|
isReady: /* @__PURE__ */ __name(() => discoveryComplete, "isReady"),
|
|
373
385
|
waitForDiscovery
|
|
374
386
|
};
|
|
@@ -378,7 +390,7 @@ function farmApiPlugin(options = {}) {
|
|
|
378
390
|
const pathname = url.split("?")[0];
|
|
379
391
|
const method = req.method || "GET";
|
|
380
392
|
if (discoveryPromise) await waitForDiscovery();
|
|
381
|
-
if (!matchAPIRouteAtBasePath(
|
|
393
|
+
if (!matchAPIRouteAtBasePath(servedRoutes(), pathname, basePath)) {
|
|
382
394
|
return next();
|
|
383
395
|
}
|
|
384
396
|
if (!apiRouterHandler) {
|
|
@@ -399,7 +411,7 @@ function farmApiPlugin(options = {}) {
|
|
|
399
411
|
}
|
|
400
412
|
const currentUrl = req.url || url;
|
|
401
413
|
const currentPathname = currentUrl.split("?")[0];
|
|
402
|
-
if (currentPathname !== pathname && !matchAPIRouteAtBasePath(
|
|
414
|
+
if (currentPathname !== pathname && !matchAPIRouteAtBasePath(servedRoutes(), currentPathname, basePath)) {
|
|
403
415
|
return next();
|
|
404
416
|
}
|
|
405
417
|
const fullUrl = resolveFarmRequestURL(req);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
4
|
+
|
|
5
|
+
// src/owned-response.ts
|
|
6
|
+
var OWNED_RESPONSES = /* @__PURE__ */ Symbol.for("farm.ownedResponses");
|
|
7
|
+
function registry() {
|
|
8
|
+
const state = globalThis;
|
|
9
|
+
return _nullishCoalesce(state[OWNED_RESPONSES], () => ( (state[OWNED_RESPONSES] = /* @__PURE__ */ new WeakSet())));
|
|
10
|
+
}
|
|
11
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, registry, "registry");
|
|
12
|
+
function _markFarmOwnedResponse(response) {
|
|
13
|
+
registry().add(response);
|
|
14
|
+
return response;
|
|
15
|
+
}
|
|
16
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _markFarmOwnedResponse, "_markFarmOwnedResponse");
|
|
17
|
+
function _isFarmOwnedResponse(response) {
|
|
18
|
+
return registry().has(response);
|
|
19
|
+
}
|
|
20
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _isFarmOwnedResponse, "_isFarmOwnedResponse");
|
|
21
|
+
function _withFarmResponseHeaders(response, edit) {
|
|
22
|
+
if (registry().has(response)) {
|
|
23
|
+
try {
|
|
24
|
+
edit(response.headers);
|
|
25
|
+
return response;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (!(error instanceof TypeError)) throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const headers = new Headers(response.headers);
|
|
31
|
+
edit(headers);
|
|
32
|
+
return _markFarmOwnedResponse(
|
|
33
|
+
new Response(response.body, {
|
|
34
|
+
status: response.status,
|
|
35
|
+
statusText: response.statusText,
|
|
36
|
+
headers
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _withFarmResponseHeaders, "_withFarmResponseHeaders");
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
exports._markFarmOwnedResponse = _markFarmOwnedResponse; exports._isFarmOwnedResponse = _isFarmOwnedResponse; exports._withFarmResponseHeaders = _withFarmResponseHeaders;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-LPEX4YW6.mjs";
|
|
4
|
+
|
|
5
|
+
// src/nitro/native-mcp-source.ts
|
|
6
|
+
function generateNativeMCPPluginSource(mcp) {
|
|
7
|
+
if (mcp?.enabled !== true) {
|
|
8
|
+
return { importSource: "", registerSource: "", pluginSource: "" };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
importSource: `import { createFarmMCPPlugin as __farmCreateMCPPlugin } from "@farm.js/mcp/internal";`,
|
|
12
|
+
registerSource: `function __farmMCPIsPlainObject(value) {
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
14
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15
|
+
return prototype === Object.prototype || prototype === null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function __farmMergeMCPConfig(base, override) {
|
|
19
|
+
const output = { ...base };
|
|
20
|
+
for (const [key, value] of Object.entries(override)) {
|
|
21
|
+
if (value === undefined) continue;
|
|
22
|
+
output[key] =
|
|
23
|
+
__farmMCPIsPlainObject(output[key]) && __farmMCPIsPlainObject(value)
|
|
24
|
+
? __farmMergeMCPConfig(output[key], value)
|
|
25
|
+
: value;
|
|
26
|
+
}
|
|
27
|
+
return output;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const farmNativeMCPConfig = farmRuntimeConfigs.reduce((merged, runtimeConfig) => {
|
|
31
|
+
const value = runtimeConfig?.mcp;
|
|
32
|
+
if (value === undefined) return merged;
|
|
33
|
+
if (value === false) return false;
|
|
34
|
+
return __farmMergeMCPConfig(merged && merged !== false ? merged : {}, value);
|
|
35
|
+
}, undefined);
|
|
36
|
+
const farmNativeMCPPlugin =
|
|
37
|
+
farmNativeMCPConfig && farmNativeMCPConfig.enabled !== false
|
|
38
|
+
? __farmCreateMCPPlugin(farmNativeMCPConfig)
|
|
39
|
+
: null;`,
|
|
40
|
+
pluginSource: `...(farmNativeMCPPlugin ? [farmNativeMCPPlugin] : []),`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
__name(generateNativeMCPPluginSource, "generateNativeMCPPluginSource");
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
generateNativeMCPPluginSource
|
|
47
|
+
};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
var _chunk6MVFL3R5cjs = require('./chunk-6MVFL3R5.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
var _chunkYJRZR7VUcjs = require('./chunk-YJRZR7VU.cjs');
|
|
@@ -28,7 +29,7 @@ var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
+
var _chunkXLTV4VOGcjs = require('./chunk-XLTV4VOG.cjs');
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
var _chunkYFPGHF5Fcjs = require('./chunk-YFPGHF5F.cjs');
|
|
@@ -47,7 +48,7 @@ var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
|
|
|
47
48
|
var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
var
|
|
51
|
+
var _chunk6CNX6Q3Kcjs = require('./chunk-6CNX6Q3K.cjs');
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
var _chunkUYIHRDE4cjs = require('./chunk-UYIHRDE4.cjs');
|
|
@@ -88,12 +89,9 @@ var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
|
|
|
88
89
|
|
|
89
90
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
90
91
|
|
|
91
|
-
// src/config.ts
|
|
92
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
93
|
-
|
|
94
92
|
// src/mcp-config.ts
|
|
95
93
|
var _module = require('module');
|
|
96
|
-
|
|
94
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
97
95
|
var _url = require('url');
|
|
98
96
|
function resolveFarmMCPConfig(input) {
|
|
99
97
|
if (input === false || input === void 0) return { enabled: false };
|
|
@@ -128,17 +126,20 @@ async function resolveFarmMCPPlugin(config, options) {
|
|
|
128
126
|
}
|
|
129
127
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmMCPPlugin, "resolveFarmMCPPlugin");
|
|
130
128
|
|
|
129
|
+
// src/config.ts
|
|
130
|
+
|
|
131
|
+
|
|
131
132
|
// src/agent-config.ts
|
|
132
133
|
var DEFAULT_JSON_LD = { type: "WebSite" };
|
|
133
134
|
function resolveFarmAgentConfig(input, context = {}) {
|
|
134
135
|
const jsonLd = _optionalChain([input, 'optionalAccess', _ => _.jsonLd]);
|
|
135
136
|
return {
|
|
136
137
|
jsonLd: jsonLd === void 0 ? { ...DEFAULT_JSON_LD } : !jsonLd ? false : jsonLd === true ? {} : jsonLd,
|
|
137
|
-
noindexPreviews:
|
|
138
|
+
noindexPreviews: _chunkXLTV4VOGcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
|
|
138
139
|
// The docs engine answers /llms.txt with its own pages; a default here would replace it.
|
|
139
140
|
// llms-full.txt renders every listed page, so it stays opt-in.
|
|
140
|
-
llmsTxt:
|
|
141
|
-
crawlers:
|
|
141
|
+
llmsTxt: _chunkXLTV4VOGcjs.resolveFarmLlmsTxtConfig.call(void 0, _nullishCoalesce(_optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt]), () => ( (context.docs ? false : { full: false })))),
|
|
142
|
+
crawlers: _chunkXLTV4VOGcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _4 => _4.crawlers])),
|
|
142
143
|
apiCatalog: resolveFarmApiCatalogEnabled(_optionalChain([input, 'optionalAccess', _5 => _5.apiCatalog]))
|
|
143
144
|
};
|
|
144
145
|
}
|
|
@@ -687,9 +688,9 @@ async function resolveConfig(userConfig, mode) {
|
|
|
687
688
|
const routeRules = _chunkQ5B3KJBPcjs.normalizeRouteRules.call(void 0, userConfig.routeRules);
|
|
688
689
|
const routeRuleRedirects = _chunkQ5B3KJBPcjs.routeRulesToRedirects.call(void 0, routeRules);
|
|
689
690
|
const routeRuleHeaders = _chunkQ5B3KJBPcjs.routeRulesToHeaders.call(void 0, routeRules);
|
|
690
|
-
const security =
|
|
691
|
-
const securityHeader =
|
|
692
|
-
if (
|
|
691
|
+
const security = _chunkXLTV4VOGcjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
|
|
692
|
+
const securityHeader = _chunkXLTV4VOGcjs.getFarmSecurityHeader.call(void 0, security);
|
|
693
|
+
if (_chunkXLTV4VOGcjs.farmCspBlocksFrameworkInlineScripts.call(void 0, security)) {
|
|
693
694
|
_chunk5QIKR7RRcjs.logger.warn(
|
|
694
695
|
"security.csp blocks the inline scripts Farm injects for theming and hydration. Set security.csp.nonce to true for managed dynamic nonces and prerendered hashes, or make the governing script directive allow 'unsafe-inline' without a nonce, hash, or 'strict-dynamic' source."
|
|
695
696
|
);
|
|
@@ -697,20 +698,21 @@ async function resolveConfig(userConfig, mode) {
|
|
|
697
698
|
const deploy = resolveDeployConfig(userConfig);
|
|
698
699
|
const root = userConfig.root || process.cwd();
|
|
699
700
|
const srcDir = userConfig.srcDir || "src";
|
|
701
|
+
_chunk6MVFL3R5cjs.setFarmProjectSourceDir.call(void 0, root, srcDir);
|
|
700
702
|
const docs = await resolveDocsConfig(userConfig.docs, { root, srcDir });
|
|
701
|
-
const md =
|
|
703
|
+
const md = _chunk6CNX6Q3Kcjs.resolveMarkdownConfig.call(void 0, userConfig.md);
|
|
702
704
|
const mdx = _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, userConfig.mdx);
|
|
703
705
|
const env = _chunkVEKFLAQMcjs.resolveEnv.call(void 0, userConfig.env, process.env);
|
|
704
706
|
_chunkVEKFLAQMcjs.setEnv.call(void 0, env);
|
|
705
707
|
const api = await _chunkS3A45T7Fcjs.resolveFarmAPIConfig.call(void 0, userConfig.api, { root, mode, env });
|
|
706
|
-
const auth =
|
|
708
|
+
const auth = _chunk6MVFL3R5cjs.resolveFarmAuthConfig.call(void 0, userConfig.auth);
|
|
707
709
|
const mcp = resolveFarmMCPConfig(userConfig.mcp);
|
|
708
710
|
if (auth.enabled && _optionalChain([userConfig, 'access', _23 => _23.integrations, 'optionalAccess', _24 => _24.auth])) {
|
|
709
711
|
throw new Error(
|
|
710
712
|
"Choose either the top-level `auth` config or `integrations.auth`; they cannot both own the auth route."
|
|
711
713
|
);
|
|
712
714
|
}
|
|
713
|
-
const nativeAuthIntegration = await
|
|
715
|
+
const nativeAuthIntegration = await _chunk6MVFL3R5cjs.resolveFarmAuthIntegration.call(void 0, auth, {
|
|
714
716
|
root,
|
|
715
717
|
mode
|
|
716
718
|
});
|
|
@@ -789,7 +791,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
789
791
|
], "headers"),
|
|
790
792
|
routeRules,
|
|
791
793
|
images: _chunkYFPGHF5Fcjs.resolveFarmImageConfig.call(void 0, userConfig.images),
|
|
792
|
-
performance:
|
|
794
|
+
performance: _chunkXLTV4VOGcjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
|
|
793
795
|
theme: _chunkOI6CMLWXcjs.resolveFarmThemeConfig.call(void 0, userConfig.theme, basePath),
|
|
794
796
|
publicDir: userConfig.publicDir || "public",
|
|
795
797
|
i18n: _chunkHBTUGXHScjs.resolveFarmI18nConfig.call(void 0, userConfig.i18n, { root, mode, basePath }),
|
|
@@ -804,13 +806,13 @@ async function resolveConfig(userConfig, mode) {
|
|
|
804
806
|
distDir: userConfig.distDir || ".farm",
|
|
805
807
|
generateBuildId,
|
|
806
808
|
compress: _nullishCoalesce(userConfig.compress, () => ( true)),
|
|
807
|
-
devIndicators:
|
|
809
|
+
devIndicators: _chunk6MVFL3R5cjs.resolveFarmDevIndicatorsConfig.call(void 0, userConfig.devIndicators, mode),
|
|
808
810
|
serverRuntimeConfig: userConfig.serverRuntimeConfig || {},
|
|
809
811
|
publicRuntimeConfig: userConfig.publicRuntimeConfig || {},
|
|
810
812
|
env,
|
|
811
813
|
vite: typeof userConfig.vite === "function" ? userConfig.vite({}) : userConfig.vite || {}
|
|
812
814
|
};
|
|
813
|
-
|
|
815
|
+
_chunk6MVFL3R5cjs.assertPluginDependencies.call(void 0, resolved.plugins, resolved.integrations);
|
|
814
816
|
return resolved;
|
|
815
817
|
}
|
|
816
818
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveConfig, "resolveConfig");
|
|
@@ -894,4 +896,6 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, loadConfig, "loadConfig");
|
|
|
894
896
|
|
|
895
897
|
|
|
896
898
|
|
|
897
|
-
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
exports.resolveFarmMCPConfig = resolveFarmMCPConfig; exports.resolveFarmMCPPlugin = resolveFarmMCPPlugin; exports.hasCustomFarmRouteContext = hasCustomFarmRouteContext; exports.isResolvedFarmConfig = isResolvedFarmConfig; exports.normalizeDeployTarget = normalizeDeployTarget; exports.getPresetForDeployTarget = getPresetForDeployTarget; exports.getDeployTargetForPreset = getDeployTargetForPreset; exports.getDefaultDeployOutputDir = getDefaultDeployOutputDir; exports.resolveDeployOutputPath = resolveDeployOutputPath; exports.resolveDeployConfig = resolveDeployConfig; exports.resolveMigrationsConfig = resolveMigrationsConfig; exports.resolveDocsConfig = resolveDocsConfig; exports.resolveConfig = resolveConfig; exports.loadConfig = loadConfig;
|