@farm.js/core 0.1.18 → 0.1.19

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.
Files changed (63) hide show
  1. package/dist/app-markdown.cjs +4 -4
  2. package/dist/app-markdown.mjs +3 -3
  3. package/dist/{chunk-EN7WTEAY.mjs → chunk-2ANEVVF7.mjs} +1 -1
  4. package/dist/{chunk-3XG26Z3J.mjs → chunk-2GNATDDE.mjs} +1 -1
  5. package/dist/{chunk-ZCNJKLA2.mjs → chunk-7BC6GAL7.mjs} +1 -1
  6. package/dist/{chunk-J2OP5GG3.cjs → chunk-A777V5WU.cjs} +28 -28
  7. package/dist/{chunk-E2BMSZ2W.cjs → chunk-AH7HOAQ3.cjs} +2 -2
  8. package/dist/{chunk-TWGMSEHX.cjs → chunk-BBVSJVBZ.cjs} +88 -13
  9. package/dist/{chunk-AWRISO2H.cjs → chunk-E2ROOWQC.cjs} +30 -4
  10. package/dist/{chunk-KPNVGRBL.mjs → chunk-FVZGEVTO.mjs} +7 -7
  11. package/dist/{chunk-WZMNW2IW.cjs → chunk-GPVTX3HT.cjs} +2 -2
  12. package/dist/{chunk-DHDVMXYK.mjs → chunk-HALDNTIV.mjs} +30 -4
  13. package/dist/{chunk-5QOEPUYE.mjs → chunk-HSDL2AUR.mjs} +1 -1
  14. package/dist/{chunk-BSTRERPP.cjs → chunk-I5YBCWQ6.cjs} +2 -2
  15. package/dist/{chunk-TYQUSXUG.cjs → chunk-ISTFC3MZ.cjs} +4 -4
  16. package/dist/{chunk-TNBAYAWO.mjs → chunk-L4DVIHOC.mjs} +1 -1
  17. package/dist/{chunk-XWAYMDLB.mjs → chunk-MVUREHPN.mjs} +1 -1
  18. package/dist/{chunk-6VQIKZZO.mjs → chunk-N255VYFP.mjs} +1 -1
  19. package/dist/{chunk-GNEO2XOF.cjs → chunk-NBAHDVOJ.cjs} +4 -4
  20. package/dist/{chunk-UN5GHC5V.cjs → chunk-NSFC3LHB.cjs} +68 -68
  21. package/dist/{chunk-SXHV42UQ.mjs → chunk-OFEY6KHO.mjs} +88 -13
  22. package/dist/{chunk-OIEOCXKG.cjs → chunk-OYDRPBBV.cjs} +2 -2
  23. package/dist/{chunk-76DG3LF3.mjs → chunk-PGQBL5DN.mjs} +1 -1
  24. package/dist/{chunk-UTBVHYS3.mjs → chunk-QBPKKQTD.mjs} +2 -2
  25. package/dist/{chunk-NWOD6NIT.cjs → chunk-RFYO7QUD.cjs} +1 -1
  26. package/dist/{chunk-B4CH33IG.cjs → chunk-S27FMYAM.cjs} +13 -13
  27. package/dist/{chunk-NV3A5DXM.cjs → chunk-U5BMPGS3.cjs} +10 -10
  28. package/dist/{chunk-QGVJVSNX.mjs → chunk-V4AICMQA.mjs} +2 -2
  29. package/dist/{chunk-GYKJCFTS.mjs → chunk-WZXN4R5Y.mjs} +24 -13
  30. package/dist/{chunk-IKNRN4VS.cjs → chunk-XDGMADQM.cjs} +100 -89
  31. package/dist/{devtools-OUIPHVV6.cjs → devtools-5KGPDVKL.cjs} +4 -4
  32. package/dist/{devtools-UFVTMQX5.mjs → devtools-FY5R7TQ4.mjs} +3 -3
  33. package/dist/docs.cjs +6 -6
  34. package/dist/docs.mjs +5 -5
  35. package/dist/index.cjs +15 -15
  36. package/dist/index.mjs +14 -14
  37. package/dist/internal/app-markdown-runtime.cjs +3 -3
  38. package/dist/internal/app-markdown-runtime.mjs +2 -2
  39. package/dist/internal/build-runtime.cjs +14 -14
  40. package/dist/internal/build-runtime.mjs +13 -13
  41. package/dist/internal/cli-runtime.cjs +8 -8
  42. package/dist/internal/cli-runtime.mjs +7 -7
  43. package/dist/internal/client-error-overlay.cjs +4 -4
  44. package/dist/internal/client-error-overlay.mjs +1 -1
  45. package/dist/internal/config-runtime.cjs +4 -4
  46. package/dist/internal/config-runtime.mjs +3 -3
  47. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  48. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  49. package/dist/internal/production-runtime.cjs +4 -4
  50. package/dist/internal/production-runtime.mjs +3 -3
  51. package/dist/markdown.cjs +2 -2
  52. package/dist/markdown.mjs +1 -1
  53. package/dist/plugin.cjs +10 -10
  54. package/dist/plugin.mjs +9 -9
  55. package/dist/{schema-dev-notice-2IE2F2XI.mjs → schema-dev-notice-O67CPXJ6.mjs} +1 -1
  56. package/dist/{schema-dev-notice-MXSZMVDG.cjs → schema-dev-notice-Y7MQEFGN.cjs} +3 -3
  57. package/dist/server.cjs +25 -25
  58. package/dist/server.mjs +11 -11
  59. package/dist/version.cjs +2 -2
  60. package/dist/version.mjs +1 -1
  61. package/dist/vite.cjs +10 -10
  62. package/dist/vite.mjs +9 -9
  63. package/package.json +1 -1
@@ -145,9 +145,13 @@ var BLOCK_TAGS = /<\/?(ul|ol|main|section|article|header|footer|nav|aside|div|fo
145
145
  var BOX_TAGS = /<\/?(label|button|input|select|textarea|option|output|meter|progress|td|th)\b[^>]*>/gi;
146
146
  function htmlToMarkdown(html, options = {}) {
147
147
  const title = options.title ?? extractHtmlTitle(html);
148
+ const streamed = readStreamedBoundaryInstructions(html);
148
149
  let source = extractHtmlBody(
149
150
  removeHiddenElements(
150
- html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, "").replace(/<!--[\s\S]*?-->/g, "")
151
+ resolveStreamedBoundaries(
152
+ html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, ""),
153
+ streamed
154
+ ).replace(/<!--[\s\S]*?-->/g, "")
151
155
  )
152
156
  );
153
157
  const codeBlocks = [];
@@ -422,6 +426,7 @@ var VOID_TAGS = /* @__PURE__ */ new Set([
422
426
  ]);
423
427
  function removeHiddenElements(html) {
424
428
  const openingTag = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
429
+ let closingTags;
425
430
  let result = "";
426
431
  let cursor = 0;
427
432
  let match;
@@ -431,7 +436,8 @@ function removeHiddenElements(html) {
431
436
  const start = match.index;
432
437
  let end = start + tag.length;
433
438
  if (!VOID_TAGS.has(name.toLowerCase()) && !isSelfClosingTag(tag)) {
434
- const close = findClosingTagEnd(html, name, end);
439
+ closingTags ?? (closingTags = matchClosingTags(html));
440
+ const close = closingTags.get(start);
435
441
  if (close === void 0) continue;
436
442
  end = close;
437
443
  }
@@ -458,24 +464,93 @@ function isSelfClosingTag(tag) {
458
464
  return /(?:^<[a-zA-Z][\w:-]*|[\s"'])\/>$/.test(tag);
459
465
  }
460
466
  __name(isSelfClosingTag, "isSelfClosingTag");
461
- function findClosingTagEnd(html, name, from) {
467
+ function matchClosingTags(html) {
462
468
  const tags = /<(\/?)([a-zA-Z][\w:-]*)(?:[^>"']|"[^"]*"|'[^']*')*>/g;
463
- tags.lastIndex = from;
464
- const target = name.toLowerCase();
465
- let depth = 1;
469
+ const open = /* @__PURE__ */ new Map();
470
+ const closes = /* @__PURE__ */ new Map();
466
471
  let match;
467
472
  while (match = tags.exec(html)) {
468
- if (match[2].toLowerCase() !== target) continue;
473
+ const name = match[2].toLowerCase();
469
474
  if (match[1]) {
470
- depth -= 1;
471
- if (depth === 0) return match.index + match[0].length;
472
- } else if (!isSelfClosingTag(match[0])) {
473
- depth += 1;
475
+ const start = open.get(name)?.pop();
476
+ if (start !== void 0) closes.set(start, match.index + match[0].length);
477
+ } else if (!VOID_TAGS.has(name) && !isSelfClosingTag(match[0])) {
478
+ let starts = open.get(name);
479
+ if (!starts) open.set(name, starts = []);
480
+ starts.push(match.index);
474
481
  }
475
482
  }
476
- return void 0;
483
+ return closes;
484
+ }
485
+ __name(matchClosingTags, "matchClosingTags");
486
+ function readStreamedBoundaryInstructions(html) {
487
+ const boundaries = /* @__PURE__ */ new Map();
488
+ const placeholders = /* @__PURE__ */ new Map();
489
+ for (const [, script] of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)) {
490
+ for (const [, kind, first, second] of script.matchAll(
491
+ /\$R([CRS])\("([^"\\]+)","([^"\\]+)"/g
492
+ )) {
493
+ if (kind === "S") placeholders.set(second, first);
494
+ else boundaries.set(first, second);
495
+ }
496
+ }
497
+ return { boundaries, placeholders };
498
+ }
499
+ __name(readStreamedBoundaryInstructions, "readStreamedBoundaryInstructions");
500
+ function resolveStreamedBoundaries(html, { boundaries, placeholders }) {
501
+ if (boundaries.size === 0 && placeholders.size === 0) return html;
502
+ const wanted = /* @__PURE__ */ new Set([...boundaries.values(), ...placeholders.values()]);
503
+ const segments = /* @__PURE__ */ new Map();
504
+ const closingTags = matchClosingTags(html);
505
+ const openingTag = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
506
+ let page = "";
507
+ let cursor = 0;
508
+ let match;
509
+ while (match = openingTag.exec(html)) {
510
+ const id = /\sid="([^"]*)"/.exec(match[2])?.[1];
511
+ if (!id || !wanted.has(id) || segments.has(id)) continue;
512
+ const close = closingTags.get(match.index);
513
+ if (close === void 0) continue;
514
+ const contentStart = match.index + match[0].length;
515
+ segments.set(id, html.slice(contentStart, html.lastIndexOf("<", close - 1)));
516
+ page += html.slice(cursor, match.index);
517
+ cursor = close;
518
+ openingTag.lastIndex = close;
519
+ }
520
+ page += html.slice(cursor);
521
+ const used = /* @__PURE__ */ new Set();
522
+ const expand = /* @__PURE__ */ __name((fragment) => {
523
+ const template = /<template\b[^>]*\sid="([^"]+)"[^>]*>\s*<\/template>/gi;
524
+ let output = "";
525
+ let position = 0;
526
+ let found;
527
+ while (found = template.exec(fragment)) {
528
+ const id = found[1];
529
+ const segmentId = boundaries.get(id) ?? placeholders.get(id);
530
+ const segment = segmentId === void 0 ? void 0 : segments.get(segmentId);
531
+ if (segment === void 0 || used.has(segmentId)) continue;
532
+ used.add(segmentId);
533
+ output += fragment.slice(position, found.index) + expand(segment);
534
+ position = found.index + found[0].length;
535
+ if (boundaries.has(id)) {
536
+ const marker = /<!--(\/?)(?:\$[?!~]?|&)-->/g;
537
+ marker.lastIndex = position;
538
+ let depth = 0;
539
+ let end;
540
+ while (end = marker.exec(fragment)) {
541
+ if (!end[1]) depth += 1;
542
+ else if (depth === 0) break;
543
+ else depth -= 1;
544
+ }
545
+ if (end) position = end.index;
546
+ }
547
+ template.lastIndex = position;
548
+ }
549
+ return output + fragment.slice(position);
550
+ }, "expand");
551
+ return expand(page);
477
552
  }
478
- __name(findClosingTagEnd, "findClosingTagEnd");
553
+ __name(resolveStreamedBoundaries, "resolveStreamedBoundaries");
479
554
  function stripTags(input) {
480
555
  return input.replace(/<[^>]+>/g, "");
481
556
  }
@@ -3,7 +3,7 @@
3
3
  var _chunkOWOUTKIJcjs = require('./chunk-OWOUTKIJ.cjs');
4
4
 
5
5
 
6
- var _chunkTYQUSXUGcjs = require('./chunk-TYQUSXUG.cjs');
6
+ var _chunkISTFC3MZcjs = require('./chunk-ISTFC3MZ.cjs');
7
7
 
8
8
 
9
9
  var _chunkOI6CMLWXcjs = require('./chunk-OI6CMLWX.cjs');
@@ -197,7 +197,7 @@ function createFarmMetadataRouteResponse(kind, value, routeModule = {}, options
197
197
  if (isResponse(value)) {
198
198
  return method === "HEAD" ? _chunkTKJZFIMLcjs.omitFarmResponseBody.call(void 0, value) : value;
199
199
  }
200
- const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunkTYQUSXUGcjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
200
+ const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunkISTFC3MZcjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
201
201
  const contentType = kind === "sitemap" ? "application/xml; charset=utf-8" : kind === "robots" || kind === "llms" || kind === "llms-full" ? "text/plain; charset=utf-8" : "application/manifest+json; charset=utf-8";
202
202
  return new Response(method === "HEAD" ? null : body, {
203
203
  headers: {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-XAXTTBUT.mjs";
4
4
  import {
5
5
  serializeFarmLlmsTxt
6
- } from "./chunk-ZCNJKLA2.mjs";
6
+ } from "./chunk-7BC6GAL7.mjs";
7
7
  import {
8
8
  resolveFarmThemeConfig
9
9
  } from "./chunk-AELACLOB.mjs";
@@ -3,10 +3,10 @@ import {
3
3
  loadFarmDocsPage,
4
4
  resolveFarmDocsContentDir,
5
5
  toFarmDocsMarkdownPage
6
- } from "./chunk-5QOEPUYE.mjs";
6
+ } from "./chunk-HSDL2AUR.mjs";
7
7
  import {
8
8
  resolveDocsConfig
9
- } from "./chunk-QGVJVSNX.mjs";
9
+ } from "./chunk-V4AICMQA.mjs";
10
10
  import {
11
11
  __name
12
12
  } from "./chunk-LPEX4YW6.mjs";
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// package.json
2
- var version = "0.1.18";
2
+ var version = "0.1.19";
3
3
 
4
4
  // src/version.ts
5
5
  var FARM_VERSION = version;
@@ -3,10 +3,10 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkGNEO2XOFcjs = require('./chunk-GNEO2XOF.cjs');
6
+ var _chunkNBAHDVOJcjs = require('./chunk-NBAHDVOJ.cjs');
7
7
 
8
8
 
9
- var _chunkNV3A5DXMcjs = require('./chunk-NV3A5DXM.cjs');
9
+ var _chunkU5BMPGS3cjs = require('./chunk-U5BMPGS3.cjs');
10
10
 
11
11
 
12
12
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -24,7 +24,7 @@ function createFarmDocsAdapterRuntimeConfig(docs, options) {
24
24
  ...docs.config,
25
25
  entry: docs.config.entry || docs.entry.replace(/^\/+|\/+$/g, "") || "docs",
26
26
  docsPath: docs.entry,
27
- contentDir: _chunkGNEO2XOFcjs.resolveFarmDocsContentDir.call(void 0, docs, options)
27
+ contentDir: _chunkNBAHDVOJcjs.resolveFarmDocsContentDir.call(void 0, docs, options)
28
28
  };
29
29
  }
30
30
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmDocsAdapterRuntimeConfig, "createFarmDocsAdapterRuntimeConfig");
@@ -270,25 +270,25 @@ function getDocsDescription(docs) {
270
270
  }
271
271
  _chunkS3JO3N4Hcjs.__name.call(void 0, getDocsDescription, "getDocsDescription");
272
272
  function getLoadedDocsPages(context) {
273
- return _chunkGNEO2XOFcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs).map((page) => _chunkGNEO2XOFcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
273
+ return _chunkNBAHDVOJcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs).map((page) => _chunkNBAHDVOJcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
274
274
  }
275
275
  _chunkS3JO3N4Hcjs.__name.call(void 0, getLoadedDocsPages, "getLoadedDocsPages");
276
276
  function toDocsSourcePage(page) {
277
277
  return {
278
- ..._chunkGNEO2XOFcjs.toFarmDocsMarkdownPage.call(void 0, page),
278
+ ..._chunkNBAHDVOJcjs.toFarmDocsMarkdownPage.call(void 0, page),
279
279
  sourcePath: page.sourcePath
280
280
  };
281
281
  }
282
282
  _chunkS3JO3N4Hcjs.__name.call(void 0, toDocsSourcePage, "toDocsSourcePage");
283
283
  function toDocsSitemapPage(page) {
284
284
  return {
285
- ..._chunkGNEO2XOFcjs.toFarmDocsMarkdownPage.call(void 0, page),
285
+ ..._chunkNBAHDVOJcjs.toFarmDocsMarkdownPage.call(void 0, page),
286
286
  sourcePath: page.sourcePath
287
287
  };
288
288
  }
289
289
  _chunkS3JO3N4Hcjs.__name.call(void 0, toDocsSitemapPage, "toDocsSitemapPage");
290
290
  function toDocsLlmsPage(page) {
291
- return _chunkGNEO2XOFcjs.toFarmDocsMarkdownPage.call(void 0, page);
291
+ return _chunkNBAHDVOJcjs.toFarmDocsMarkdownPage.call(void 0, page);
292
292
  }
293
293
  _chunkS3JO3N4Hcjs.__name.call(void 0, toDocsLlmsPage, "toDocsLlmsPage");
294
294
  function getDocsLlmsOptions(context, request) {
@@ -382,7 +382,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, renderAgentsDocument, "renderAgentsDocumen
382
382
  function buildAgentSpec(context, request) {
383
383
  const url = new URL(request.url);
384
384
  const origin = url.origin;
385
- const pages = _chunkGNEO2XOFcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
385
+ const pages = _chunkNBAHDVOJcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
386
386
  const spec = _docs.buildDocsAgentDiscoverySpec.call(void 0, getDocsDiscoveryOptions(context, request));
387
387
  const title = getDocsTitle(context.docs);
388
388
  return {
@@ -424,7 +424,7 @@ function buildAgentSpec(context, request) {
424
424
  }
425
425
  _chunkS3JO3N4Hcjs.__name.call(void 0, buildAgentSpec, "buildAgentSpec");
426
426
  function buildDiagnostics(context) {
427
- const pages = _chunkGNEO2XOFcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
427
+ const pages = _chunkNBAHDVOJcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
428
428
  const diagnostics = _docs.buildDocsDiagnostics.call(void 0, context.docs.config, {
429
429
  entry: context.docs.entry,
430
430
  mcp: {
@@ -495,12 +495,12 @@ async function resolveAPIContext(options) {
495
495
  config: options.config,
496
496
  configPath: options.configPath
497
497
  }));
498
- const docs = isResolvedDocsConfig(docsInput) ? docsInput : await _chunkNV3A5DXMcjs.resolveDocsConfig.call(void 0, docsInput, { root, srcDir });
498
+ const docs = isResolvedDocsConfig(docsInput) ? docsInput : await _chunkU5BMPGS3cjs.resolveDocsConfig.call(void 0, docsInput, { root, srcDir });
499
499
  return {
500
500
  root,
501
501
  srcDir,
502
502
  docs,
503
- contentDir: _chunkGNEO2XOFcjs.resolveFarmDocsContentDir.call(void 0, docs, { root, srcDir })
503
+ contentDir: _chunkNBAHDVOJcjs.resolveFarmDocsContentDir.call(void 0, docs, { root, srcDir })
504
504
  };
505
505
  }
506
506
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveAPIContext, "resolveAPIContext");
@@ -563,10 +563,10 @@ async function handleDocsAPIGet(request, context) {
563
563
  if (format === "markdown" || url.pathname.endsWith(".md")) {
564
564
  const pathParam = url.searchParams.get("path") || url.searchParams.get("slug");
565
565
  const slug = normalizeDocsApiSlug(_nullishCoalesce(_nullishCoalesce(pathParam, () => ( pathTarget.slug)), () => ( "")), context.docs);
566
- const page = _chunkGNEO2XOFcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, slug);
566
+ const page = _chunkNBAHDVOJcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, slug);
567
567
  if (!page) return text("Docs page not found\n", "text/plain; charset=utf-8", { status: 404 });
568
568
  return text(
569
- _docs.renderDocsMarkdownDocument.call(void 0, _chunkGNEO2XOFcjs.toFarmDocsMarkdownPage.call(void 0, page), {
569
+ _docs.renderDocsMarkdownDocument.call(void 0, _chunkNBAHDVOJcjs.toFarmDocsMarkdownPage.call(void 0, page), {
570
570
  origin: new URL(request.url).origin,
571
571
  llms: getDocsLlmsOptions(context, request),
572
572
  sitemap: context.docs.config.sitemap
@@ -28,7 +28,7 @@ var _chunkTFAXUHWXcjs = require('./chunk-TFAXUHWX.cjs');
28
28
 
29
29
 
30
30
 
31
- var _chunkTYQUSXUGcjs = require('./chunk-TYQUSXUG.cjs');
31
+ var _chunkISTFC3MZcjs = require('./chunk-ISTFC3MZ.cjs');
32
32
 
33
33
 
34
34
  var _chunkYFPGHF5Fcjs = require('./chunk-YFPGHF5F.cjs');
@@ -47,7 +47,7 @@ var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
47
47
  var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
48
48
 
49
49
 
50
- var _chunkTWGMSEHXcjs = require('./chunk-TWGMSEHX.cjs');
50
+ var _chunkBBVSJVBZcjs = require('./chunk-BBVSJVBZ.cjs');
51
51
 
52
52
 
53
53
  var _chunkK6FNHVDRcjs = require('./chunk-K6FNHVDR.cjs');
@@ -130,9 +130,9 @@ function resolveFarmAgentConfig(input) {
130
130
  const jsonLd = _optionalChain([input, 'optionalAccess', _ => _.jsonLd]);
131
131
  return {
132
132
  jsonLd: !jsonLd ? false : jsonLd === true ? {} : jsonLd,
133
- noindexPreviews: _chunkTYQUSXUGcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
134
- llmsTxt: _chunkTYQUSXUGcjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt])),
135
- crawlers: _chunkTYQUSXUGcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _4 => _4.crawlers]))
133
+ noindexPreviews: _chunkISTFC3MZcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
134
+ llmsTxt: _chunkISTFC3MZcjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt])),
135
+ crawlers: _chunkISTFC3MZcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _4 => _4.crawlers]))
136
136
  };
137
137
  }
138
138
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmAgentConfig, "resolveFarmAgentConfig");
@@ -653,9 +653,9 @@ async function resolveConfig(userConfig, mode) {
653
653
  const routeRules = _chunkGDSHDTJ4cjs.normalizeRouteRules.call(void 0, userConfig.routeRules);
654
654
  const routeRuleRedirects = _chunkGDSHDTJ4cjs.routeRulesToRedirects.call(void 0, routeRules);
655
655
  const routeRuleHeaders = _chunkGDSHDTJ4cjs.routeRulesToHeaders.call(void 0, routeRules);
656
- const security = _chunkTYQUSXUGcjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
657
- const securityHeader = _chunkTYQUSXUGcjs.getFarmSecurityHeader.call(void 0, security);
658
- if (_chunkTYQUSXUGcjs.farmCspBlocksFrameworkInlineScripts.call(void 0, security)) {
656
+ const security = _chunkISTFC3MZcjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
657
+ const securityHeader = _chunkISTFC3MZcjs.getFarmSecurityHeader.call(void 0, security);
658
+ if (_chunkISTFC3MZcjs.farmCspBlocksFrameworkInlineScripts.call(void 0, security)) {
659
659
  _chunk5QIKR7RRcjs.logger.warn(
660
660
  "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."
661
661
  );
@@ -664,7 +664,7 @@ async function resolveConfig(userConfig, mode) {
664
664
  const root = userConfig.root || process.cwd();
665
665
  const srcDir = userConfig.srcDir || "src";
666
666
  const docs = await resolveDocsConfig(userConfig.docs, { root, srcDir });
667
- const md = _chunkTWGMSEHXcjs.resolveMarkdownConfig.call(void 0, userConfig.md);
667
+ const md = _chunkBBVSJVBZcjs.resolveMarkdownConfig.call(void 0, userConfig.md);
668
668
  const mdx = _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, userConfig.mdx);
669
669
  const env = _chunkVEKFLAQMcjs.resolveEnv.call(void 0, userConfig.env, process.env);
670
670
  _chunkVEKFLAQMcjs.setEnv.call(void 0, env);
@@ -755,7 +755,7 @@ async function resolveConfig(userConfig, mode) {
755
755
  ], "headers"),
756
756
  routeRules,
757
757
  images: _chunkYFPGHF5Fcjs.resolveFarmImageConfig.call(void 0, userConfig.images),
758
- performance: _chunkTYQUSXUGcjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
758
+ performance: _chunkISTFC3MZcjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
759
759
  theme: _chunkOI6CMLWXcjs.resolveFarmThemeConfig.call(void 0, userConfig.theme, basePath),
760
760
  publicDir: userConfig.publicDir || "public",
761
761
  i18n: _chunkHBTUGXHScjs.resolveFarmI18nConfig.call(void 0, userConfig.i18n, { root, mode, basePath }),
@@ -28,7 +28,7 @@ import {
28
28
  resolveFarmNoindexPreviews,
29
29
  resolveFarmPerformanceConfig,
30
30
  resolveFarmSecurityConfig
31
- } from "./chunk-ZCNJKLA2.mjs";
31
+ } from "./chunk-7BC6GAL7.mjs";
32
32
  import {
33
33
  resolveFarmImageConfig
34
34
  } from "./chunk-G2KY33I6.mjs";
@@ -47,7 +47,7 @@ import {
47
47
  } from "./chunk-FA2W42OV.mjs";
48
48
  import {
49
49
  resolveMarkdownConfig
50
- } from "./chunk-SXHV42UQ.mjs";
50
+ } from "./chunk-OFEY6KHO.mjs";
51
51
  import {
52
52
  resolveWorkflowsConfig
53
53
  } from "./chunk-EGJDUF4Q.mjs";
@@ -6,12 +6,12 @@ import {
6
6
  parseRouteSlotFile,
7
7
  resolveRouteRenderingConfig,
8
8
  resolveRouteRenderingConfigFromFile
9
- } from "./chunk-EN7WTEAY.mjs";
9
+ } from "./chunk-2ANEVVF7.mjs";
10
10
  import {
11
11
  collectSchemaExtensions,
12
12
  declareSchemaTables,
13
13
  readSchemaTables
14
- } from "./chunk-DHDVMXYK.mjs";
14
+ } from "./chunk-HALDNTIV.mjs";
15
15
  import {
16
16
  resolveSchemaModels
17
17
  } from "./chunk-ZMSZZXOR.mjs";
@@ -24,7 +24,7 @@ import {
24
24
  getDefaultErrorStatusText,
25
25
  renderFarmLocaleAlternateLinks,
26
26
  resolveDefaultErrorStatus
27
- } from "./chunk-76DG3LF3.mjs";
27
+ } from "./chunk-PGQBL5DN.mjs";
28
28
  import {
29
29
  isFarmPreviewDeploymentEnvironment
30
30
  } from "./chunk-BOYNDCZL.mjs";
@@ -99,7 +99,7 @@ import {
99
99
  resolveFarmLlmsTxtConfig,
100
100
  resolveFarmPerformanceConfig,
101
101
  resolveFarmSecurityConfig
102
- } from "./chunk-ZCNJKLA2.mjs";
102
+ } from "./chunk-7BC6GAL7.mjs";
103
103
  import {
104
104
  getPublicFarmImageConfig,
105
105
  resolveFarmImageConfig
@@ -117,12 +117,12 @@ import {
117
117
  import {
118
118
  createFarmMarkdownRouteModuleFromFile,
119
119
  loadFarmMdxComponents
120
- } from "./chunk-XWAYMDLB.mjs";
120
+ } from "./chunk-MVUREHPN.mjs";
121
121
  import {
122
122
  createFarmMarkdownSourceResponse,
123
123
  isFarmMarkdownPageFile,
124
124
  normalizeFarmMarkdownRoutePath
125
- } from "./chunk-6VQIKZZO.mjs";
125
+ } from "./chunk-N255VYFP.mjs";
126
126
  import {
127
127
  resolveFarmMdxComponentsModulePath,
128
128
  resolveMdxConfig
@@ -136,7 +136,7 @@ import {
136
136
  getFarmMarkdownMirrorPath,
137
137
  resolveMarkdownConfig,
138
138
  resolveMarkdownMirrorTarget
139
- } from "./chunk-SXHV42UQ.mjs";
139
+ } from "./chunk-OFEY6KHO.mjs";
140
140
  import {
141
141
  resolveWorkflowsConfig
142
142
  } from "./chunk-EGJDUF4Q.mjs";
@@ -258,7 +258,7 @@ import {
258
258
  } from "./chunk-Z2RZJZIZ.mjs";
259
259
  import {
260
260
  FARM_VERSION
261
- } from "./chunk-3XG26Z3J.mjs";
261
+ } from "./chunk-2GNATDDE.mjs";
262
262
  import {
263
263
  resolveFarmTrailingSlashRedirect,
264
264
  setFarmTrailingSlashPreference
@@ -9324,7 +9324,7 @@ function loadFarmWorkflowsDevRuntime() {
9324
9324
  }
9325
9325
  __name(loadFarmWorkflowsDevRuntime, "loadFarmWorkflowsDevRuntime");
9326
9326
  function loadFarmDevtoolsSnapshotRuntime() {
9327
- return import("./devtools-UFVTMQX5.mjs");
9327
+ return import("./devtools-FY5R7TQ4.mjs");
9328
9328
  }
9329
9329
  __name(loadFarmDevtoolsSnapshotRuntime, "loadFarmDevtoolsSnapshotRuntime");
9330
9330
  function loadFarmDevtoolsUIRuntime() {
@@ -10069,10 +10069,16 @@ function farmPlugin(options = {}, initialPluginManager) {
10069
10069
  const layerConfigFiles = new Set(
10070
10070
  farmConfig.layers.map((layer) => layer.configFile?.replace(/\\/g, "/")).filter((file) => Boolean(file))
10071
10071
  );
10072
- const isPageFile = /* @__PURE__ */ __name((file) => {
10072
+ const routeModuleExtensions = /* @__PURE__ */ new Set([
10073
+ ...resolveFarmComponentExtensions(farmConfig.renderer.componentExtensions),
10074
+ ".md",
10075
+ ".mdx"
10076
+ ]);
10077
+ const isRouteModuleFile = /* @__PURE__ */ __name((file) => {
10073
10078
  const normalized = file.replace(/\\/g, "/");
10074
- return appDirSlugs.some((appDir) => normalized.startsWith(`${appDir}/`)) && /page\.(ts|tsx|js|jsx|md|mdx)$/.test(normalized);
10075
- }, "isPageFile");
10079
+ const match = /\/(?:page|layout|loading|error)(\.[^./]+)$/.exec(normalized);
10080
+ return appDirSlugs.some((appDir) => normalized.startsWith(`${appDir}/`)) && !!match && routeModuleExtensions.has(match[1].toLowerCase());
10081
+ }, "isRouteModuleFile");
10076
10082
  const isApiRouteFile = /* @__PURE__ */ __name((file) => {
10077
10083
  const normalized = file.replace(/\\/g, "/");
10078
10084
  return appDirSlugs.some((appDir) => normalized.startsWith(`${appDir}/api/`)) && /route\.(ts|tsx|js|jsx)$/.test(normalized);
@@ -10123,11 +10129,16 @@ function farmPlugin(options = {}, initialPluginManager) {
10123
10129
  }, "scheduleTypeArtifactGen");
10124
10130
  ["add", "change", "unlink"].forEach((ev) => {
10125
10131
  server.watcher.on(ev, (file) => {
10132
+ if (ev === "add") {
10133
+ for (const mod of server.moduleGraph.idToModuleMap.values()) {
10134
+ if (mod.ssrError) server.moduleGraph.invalidateModule(mod);
10135
+ }
10136
+ }
10126
10137
  const normalizedFile = file.replace(/\\/g, "/");
10127
10138
  const configChanged = isFarmConfigFile(file, farmConfig.root) || layerConfigFiles.has(normalizedFile);
10128
10139
  const programmaticRouteChanged = isProgrammaticRouteFile(file) || isProgrammaticRouteSourceFile(file) && (ev === "unlink" || fileContainsProgrammaticPageRoute(file));
10129
10140
  const typeArtifacts = configChanged ? ALL_TYPE_ARTIFACTS : {
10130
- routes: ev !== "change" && isPageFile(file) || programmaticRouteChanged,
10141
+ routes: ev !== "change" && isRouteModuleFile(file) || programmaticRouteChanged,
10131
10142
  api: isApiRouteFile(file) || programmaticRouteChanged,
10132
10143
  env: false,
10133
10144
  images: false,