@farm.js/core 0.1.28 → 0.1.30

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 (149) hide show
  1. package/dist/agent-runtime.d.mts +2 -2
  2. package/dist/agent-runtime.d.ts +2 -2
  3. package/dist/api/route-manager.d.mts +1 -1
  4. package/dist/api/route-manager.d.ts +1 -1
  5. package/dist/api/runtime.d.mts +2 -2
  6. package/dist/api/runtime.d.ts +2 -2
  7. package/dist/api.cjs +2 -2
  8. package/dist/api.d.mts +18 -4
  9. package/dist/api.d.ts +18 -4
  10. package/dist/api.mjs +1 -1
  11. package/dist/{app-DSSq6wiN.d.mts → app-DAuUTIZf.d.mts} +3 -3
  12. package/dist/app-markdown.cjs +5 -4
  13. package/dist/app-markdown.d.mts +3 -3
  14. package/dist/app-markdown.d.ts +3 -3
  15. package/dist/app-markdown.mjs +4 -3
  16. package/dist/{app-M8nVWvNU.d.ts → app-sUJ3jnTZ.d.ts} +3 -3
  17. package/dist/{chunk-N6UROPT7.mjs → chunk-2FQHH5SC.mjs} +12 -13
  18. package/dist/{chunk-2CNBR3EB.mjs → chunk-2UABTL3Y.mjs} +2 -2
  19. package/dist/{chunk-JUFRXDTK.cjs → chunk-3FCFQP5V.cjs} +17 -5
  20. package/dist/{chunk-XSPGWQWA.cjs → chunk-6CNX6Q3K.cjs} +96 -24
  21. package/dist/{chunk-NVBS5WSZ.mjs → chunk-6G3ZZ2IE.mjs} +1 -1
  22. package/dist/{chunk-QBPXNZGV.cjs → chunk-6MVFL3R5.cjs} +25 -6
  23. package/dist/{chunk-PZPDGOU5.mjs → chunk-7CXKSRKL.mjs} +11 -7
  24. package/dist/{chunk-K3YEZLSY.mjs → chunk-ATXI6LGT.mjs} +96 -24
  25. package/dist/{chunk-2DLN6HG4.mjs → chunk-BZ3CHOFX.mjs} +1 -1
  26. package/dist/{chunk-EWZ3XHKQ.cjs → chunk-BZAGKCKB.cjs} +2 -2
  27. package/dist/{chunk-FB3H4INL.mjs → chunk-D234YWNA.mjs} +1 -1
  28. package/dist/{chunk-KXGDXYUC.mjs → chunk-DGXN3L4D.mjs} +17 -5
  29. package/dist/chunk-FJ3M4CUX.cjs +46 -0
  30. package/dist/chunk-FXEF4PPL.mjs +47 -0
  31. package/dist/{chunk-ID6OVSLH.cjs → chunk-GIWC4CFJ.cjs} +175 -171
  32. package/dist/{chunk-F52CDFJM.cjs → chunk-HPQC2LHF.cjs} +435 -274
  33. package/dist/{chunk-FVCSLZWT.mjs → chunk-IVLUJUT4.mjs} +315 -154
  34. package/dist/{chunk-KOQ555NR.cjs → chunk-JFHKNFEO.cjs} +24 -20
  35. package/dist/{chunk-UX2DD2VK.mjs → chunk-K6V52QMI.mjs} +1 -1
  36. package/dist/{chunk-BYODCJD6.cjs → chunk-K7CELQLK.cjs} +12 -13
  37. package/dist/{chunk-A672WZEG.cjs → chunk-NPPL5YDT.cjs} +2 -2
  38. package/dist/{chunk-TII23GJC.cjs → chunk-NXG66MR7.cjs} +3 -3
  39. package/dist/{chunk-R6AIILII.cjs → chunk-OZVEHHMA.cjs} +15 -14
  40. package/dist/{chunk-T7HQ3I4C.mjs → chunk-PQD2AI3B.mjs} +1 -1
  41. package/dist/{chunk-VQXDC5UV.cjs → chunk-Q5JFU33Q.cjs} +4 -4
  42. package/dist/{chunk-FZC7EEPM.mjs → chunk-RSOJ7DRT.mjs} +26 -7
  43. package/dist/{chunk-ZRIE4KMG.mjs → chunk-S4K74WI4.mjs} +17 -13
  44. package/dist/{chunk-Y7GW7J46.cjs → chunk-X5TXZFMN.cjs} +1 -1
  45. package/dist/chunk-XD32KALF.cjs +47 -0
  46. package/dist/{chunk-RDV44SED.mjs → chunk-XJJVLDM6.mjs} +15 -14
  47. package/dist/{chunk-55ZY4ZA7.cjs → chunk-XLTV4VOG.cjs} +21 -16
  48. package/dist/{chunk-REGFZJEJ.mjs → chunk-YMUE7L3D.mjs} +18 -13
  49. package/dist/chunk-Z3HATSKO.mjs +46 -0
  50. package/dist/{chunk-MH24QDVJ.cjs → chunk-ZDILFMWN.cjs} +13 -13
  51. package/dist/{client-plugins-CgYNY7jF.d.mts → client-plugins-BX2ptm4H.d.mts} +7 -2
  52. package/dist/{client-plugins-Fl9Og3yB.d.ts → client-plugins-BmxM5KW_.d.ts} +7 -2
  53. package/dist/client-plugins.d.mts +2 -2
  54. package/dist/client-plugins.d.ts +2 -2
  55. package/dist/client.d.mts +5 -5
  56. package/dist/client.d.ts +5 -5
  57. package/dist/config.d.mts +2 -2
  58. package/dist/config.d.ts +2 -2
  59. package/dist/{devtools-5AREISIA.cjs → devtools-GGVPZHJX.cjs} +95 -20
  60. package/dist/{devtools-3E7ZANMZ.mjs → devtools-THVNPI2M.mjs} +79 -4
  61. package/dist/{devtools-client-4WAPJY5L.cjs → devtools-client-CXQ6PXI6.cjs} +1 -1
  62. package/dist/{devtools-client-LEUIHHAS.mjs → devtools-client-HJS2T34Y.mjs} +1 -1
  63. package/dist/docs.cjs +8 -7
  64. package/dist/docs.mjs +7 -6
  65. package/dist/index.cjs +18 -16
  66. package/dist/index.d.mts +24 -14
  67. package/dist/index.d.ts +24 -14
  68. package/dist/index.mjs +17 -15
  69. package/dist/integrations.d.mts +2 -2
  70. package/dist/integrations.d.ts +2 -2
  71. package/dist/internal/app-markdown-runtime.cjs +4 -3
  72. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  73. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  74. package/dist/internal/app-markdown-runtime.mjs +3 -2
  75. package/dist/internal/build-runtime.cjs +15 -13
  76. package/dist/internal/build-runtime.d.mts +4 -4
  77. package/dist/internal/build-runtime.d.ts +4 -4
  78. package/dist/internal/build-runtime.mjs +14 -12
  79. package/dist/internal/cli-runtime.cjs +7 -6
  80. package/dist/internal/cli-runtime.mjs +6 -5
  81. package/dist/internal/client-error-overlay.cjs +4 -4
  82. package/dist/internal/client-error-overlay.mjs +1 -1
  83. package/dist/internal/compression-runtime.cjs +3 -2
  84. package/dist/internal/compression-runtime.d.mts +5 -3
  85. package/dist/internal/compression-runtime.d.ts +5 -3
  86. package/dist/internal/compression-runtime.mjs +2 -1
  87. package/dist/internal/config-runtime.cjs +6 -5
  88. package/dist/internal/config-runtime.d.mts +3 -3
  89. package/dist/internal/config-runtime.d.ts +3 -3
  90. package/dist/internal/config-runtime.mjs +5 -4
  91. package/dist/internal/product-telemetry-runtime.cjs +10 -6
  92. package/dist/internal/product-telemetry-runtime.mjs +9 -5
  93. package/dist/internal/production-runtime.cjs +19 -5
  94. package/dist/internal/production-runtime.d.mts +35 -8
  95. package/dist/internal/production-runtime.d.ts +35 -8
  96. package/dist/internal/production-runtime.mjs +18 -4
  97. package/dist/markdown.cjs +3 -2
  98. package/dist/markdown.d.mts +2 -2
  99. package/dist/markdown.d.ts +2 -2
  100. package/dist/markdown.mjs +2 -1
  101. package/dist/{metadata-B0X-qtcQ.d.mts → metadata-DsEaK7mQ.d.mts} +1 -1
  102. package/dist/{metadata-BdDKgd7K.d.ts → metadata-fwZ3gfG6.d.ts} +1 -1
  103. package/dist/middleware.cjs +3 -2
  104. package/dist/middleware.d.mts +3 -3
  105. package/dist/middleware.d.ts +3 -3
  106. package/dist/middleware.mjs +2 -1
  107. package/dist/navigation.d.mts +4 -4
  108. package/dist/navigation.d.ts +4 -4
  109. package/dist/plugin.cjs +10 -9
  110. package/dist/plugin.d.mts +2 -2
  111. package/dist/plugin.d.ts +2 -2
  112. package/dist/plugin.mjs +9 -8
  113. package/dist/{production-runtime-BjgFgDIg.d.mts → production-runtime-Baqgwtvc.d.mts} +1 -1
  114. package/dist/{production-runtime-Dx_qMA3t.d.ts → production-runtime-DNkpFnmg.d.ts} +1 -1
  115. package/dist/{render-plan-_1TAWODt.d.mts → render-plan-DhwQnmmX.d.mts} +1 -1
  116. package/dist/{render-plan-B41EWmBb.d.ts → render-plan-rkIK9wd9.d.ts} +1 -1
  117. package/dist/renderer-client.d.mts +3 -3
  118. package/dist/renderer-client.d.ts +3 -3
  119. package/dist/{request-Dbf3G0zM.d.ts → request-BcY4RYPC.d.ts} +1 -1
  120. package/dist/{request-BhE4luLv.d.mts → request-CFy1BltJ.d.mts} +1 -1
  121. package/dist/request.d.mts +3 -3
  122. package/dist/request.d.ts +3 -3
  123. package/dist/{route-rendering-zzfx_GHf.d.mts → route-rendering-BkS0TBlB.d.mts} +1 -1
  124. package/dist/{route-rendering-Z7PveTZE.d.ts → route-rendering-D4XpMjam.d.ts} +1 -1
  125. package/dist/{router-BatNMsa1.d.mts → router-C4zPlC3V.d.mts} +1 -1
  126. package/dist/{router-DtNRhQl3.d.ts → router-Cq7BcZxg.d.ts} +1 -1
  127. package/dist/routes.d.mts +2 -2
  128. package/dist/routes.d.ts +2 -2
  129. package/dist/server-plugins.cjs +3 -2
  130. package/dist/server-plugins.d.mts +2 -2
  131. package/dist/server-plugins.d.ts +2 -2
  132. package/dist/server-plugins.mjs +2 -1
  133. package/dist/server.cjs +33 -28
  134. package/dist/server.d.mts +8 -8
  135. package/dist/server.d.ts +8 -8
  136. package/dist/server.mjs +16 -11
  137. package/dist/{spa-router-BE3bwU-J.d.ts → spa-router-B1HI3X9k.d.ts} +2 -2
  138. package/dist/{spa-router-DQOnHZVj.d.mts → spa-router-DzPZH-AO.d.mts} +2 -2
  139. package/dist/testing.d.mts +1 -1
  140. package/dist/testing.d.ts +1 -1
  141. package/dist/{utils-DLK1ERNl.d.mts → utils-CEBktlBG.d.mts} +1 -1
  142. package/dist/{utils-u7ZBSWAK.d.ts → utils-DMD1Hzta.d.ts} +1 -1
  143. package/dist/version.cjs +2 -2
  144. package/dist/version.mjs +1 -1
  145. package/dist/vite.cjs +10 -9
  146. package/dist/vite.d.mts +2 -2
  147. package/dist/vite.d.ts +2 -2
  148. package/dist/vite.mjs +9 -8
  149. package/package.json +1 -1
@@ -3,7 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkQBPXNZGVcjs = require('./chunk-QBPXNZGV.cjs');
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 _chunk55ZY4ZA7cjs = require('./chunk-55ZY4ZA7.cjs');
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 _chunkXSPGWQWAcjs = require('./chunk-XSPGWQWA.cjs');
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: _chunk55ZY4ZA7cjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.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: _chunk55ZY4ZA7cjs.resolveFarmLlmsTxtConfig.call(void 0, _nullishCoalesce(_optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt]), () => ( (context.docs ? false : { full: false })))),
141
- crawlers: _chunk55ZY4ZA7cjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _4 => _4.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 = _chunk55ZY4ZA7cjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
691
- const securityHeader = _chunk55ZY4ZA7cjs.getFarmSecurityHeader.call(void 0, security);
692
- if (_chunk55ZY4ZA7cjs.farmCspBlocksFrameworkInlineScripts.call(void 0, security)) {
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 = _chunkXSPGWQWAcjs.resolveMarkdownConfig.call(void 0, userConfig.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 = _chunkQBPXNZGVcjs.resolveFarmAuthConfig.call(void 0, userConfig.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 _chunkQBPXNZGVcjs.resolveFarmAuthIntegration.call(void 0, auth, {
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: _chunk55ZY4ZA7cjs.resolveFarmPerformanceConfig.call(void 0, userConfig.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: _chunkQBPXNZGVcjs.resolveFarmDevIndicatorsConfig.call(void 0, userConfig.devIndicators, mode),
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
- _chunkQBPXNZGVcjs.assertPluginDependencies.call(void 0, resolved.plugins, resolved.integrations);
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
- 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;
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;
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.1.28";
2
+ var version = "0.1.30";
3
3
 
4
4
  // src/version.ts
5
5
  var FARM_VERSION = version;
@@ -13,6 +13,9 @@ var _chunkXGC343EYcjs = require('./chunk-XGC343EY.cjs');
13
13
  var _chunkE3UK5IIBcjs = require('./chunk-E3UK5IIB.cjs');
14
14
 
15
15
 
16
+ var _chunkFJ3M4CUXcjs = require('./chunk-FJ3M4CUX.cjs');
17
+
18
+
16
19
 
17
20
 
18
21
  var _chunkOX6O6WVAcjs = require('./chunk-OX6O6WVA.cjs');
@@ -637,21 +640,17 @@ function applyProductionMiddlewareHeaders(response, middlewareHeaders) {
637
640
  if (!middlewareHeaders || Array.from(middlewareHeaders.keys()).length === 0) {
638
641
  return response;
639
642
  }
640
- const headers = new Headers(response.headers);
641
643
  const getSetCookie = middlewareHeaders.getSetCookie;
642
644
  const setCookies = getSetCookie ? getSetCookie.call(middlewareHeaders) : middlewareHeaders.get("set-cookie") ? [middlewareHeaders.get("set-cookie")] : [];
643
- for (const [key, value] of middlewareHeaders) {
644
- if (key.toLowerCase() === "set-cookie") continue;
645
- if (headers.has(key)) continue;
646
- headers.set(key, value);
647
- }
648
- for (const cookie of setCookies) {
649
- headers.append("Set-Cookie", cookie);
650
- }
651
- return new Response(response.body, {
652
- status: response.status,
653
- statusText: response.statusText,
654
- headers
645
+ return _chunkFJ3M4CUXcjs._withFarmResponseHeaders.call(void 0, response, (headers) => {
646
+ for (const [key, value] of middlewareHeaders) {
647
+ if (key.toLowerCase() === "set-cookie") continue;
648
+ if (headers.has(key)) continue;
649
+ headers.set(key, value);
650
+ }
651
+ for (const cookie of setCookies) {
652
+ headers.append("Set-Cookie", cookie);
653
+ }
655
654
  });
656
655
  }
657
656
  _chunkS3JO3N4Hcjs.__name.call(void 0, applyProductionMiddlewareHeaders, "applyProductionMiddlewareHeaders");
@@ -3,7 +3,7 @@
3
3
  var _chunkOWOUTKIJcjs = require('./chunk-OWOUTKIJ.cjs');
4
4
 
5
5
 
6
- var _chunk55ZY4ZA7cjs = require('./chunk-55ZY4ZA7.cjs');
6
+ var _chunkXLTV4VOGcjs = require('./chunk-XLTV4VOG.cjs');
7
7
 
8
8
 
9
9
  var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
@@ -210,7 +210,7 @@ function createFarmMetadataRouteResponse(kind, value, routeModule = {}, options
210
210
  if (isResponse(value)) {
211
211
  return method === "HEAD" ? _chunkTKJZFIMLcjs.omitFarmResponseBody.call(void 0, value) : value;
212
212
  }
213
- const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunk55ZY4ZA7cjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
213
+ const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunkXLTV4VOGcjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
214
214
  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";
215
215
  return new Response(method === "HEAD" ? null : body, {
216
216
  headers: {
@@ -1,7 +1,7 @@
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
- var _chunkXSPGWQWAcjs = require('./chunk-XSPGWQWA.cjs');
4
+ var _chunk6CNX6Q3Kcjs = require('./chunk-6CNX6Q3K.cjs');
5
5
 
6
6
 
7
7
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -116,7 +116,7 @@ async function createFarmMarkdownSourceResponse(options) {
116
116
  }
117
117
  const url = new URL(options.request.url);
118
118
  const hasMarkdownExtension = url.pathname.toLowerCase().endsWith(".md");
119
- if (!hasMarkdownExtension && !_chunkXSPGWQWAcjs.requestAcceptsMarkdown.call(void 0, options.request.headers.get("accept"))) {
119
+ if (!hasMarkdownExtension && !_chunk6CNX6Q3Kcjs.requestAcceptsMarkdown.call(void 0, options.request.headers.get("accept"))) {
120
120
  return null;
121
121
  }
122
122
  const targetPathname = normalizeFarmMarkdownRoutePath(url.pathname);
@@ -134,7 +134,7 @@ async function createFarmMarkdownSourceResponse(options) {
134
134
  if (!hasMarkdownExtension) {
135
135
  headers.set("Vary", "Accept");
136
136
  }
137
- return _chunkXSPGWQWAcjs.createFarmMarkdownViewResponse.call(void 0, {
137
+ return _chunk6CNX6Q3Kcjs.createFarmMarkdownViewResponse.call(void 0, {
138
138
  request: options.request,
139
139
  requestUrl: url,
140
140
  markdown: source.source,
@@ -1,5 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
+ var _chunkFJ3M4CUXcjs = require('./chunk-FJ3M4CUX.cjs');
4
+
5
+
3
6
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
7
 
5
8
  // src/plugins/compression.ts
@@ -57,8 +60,12 @@ function isCompressibleMediaType(mediaType) {
57
60
  return COMPRESSIBLE_MEDIA_TYPE_SUFFIXES.some((suffix) => mediaType.endsWith(suffix));
58
61
  }
59
62
  _chunkS3JO3N4Hcjs.__name.call(void 0, isCompressibleMediaType, "isCompressibleMediaType");
60
- function isCompressionEligible(request, response) {
61
- if (request.method !== "HEAD" && !response.body || response.status === 204 || response.status === 205 || response.status === 304 || response.headers.has("content-encoding") || response.headers.has("content-range") || _optionalChain([response, 'access', _11 => _11.headers, 'access', _12 => _12.get, 'call', _13 => _13("cache-control"), 'optionalAccess', _14 => _14.toLowerCase, 'call', _15 => _15(), 'access', _16 => _16.includes, 'call', _17 => _17("no-transform")])) {
63
+ function isCompressionEligible(request, response, bufferedText) {
64
+ if (
65
+ // Known buffered text proves a body without reading response.body, which
66
+ // would create a lazy response's Web stream.
67
+ request.method !== "HEAD" && bufferedText === void 0 && !response.body || response.status === 204 || response.status === 205 || response.status === 304 || response.headers.has("content-encoding") || response.headers.has("content-range") || _optionalChain([response, 'access', _11 => _11.headers, 'access', _12 => _12.get, 'call', _13 => _13("cache-control"), 'optionalAccess', _14 => _14.toLowerCase, 'call', _15 => _15(), 'access', _16 => _16.includes, 'call', _17 => _17("no-transform")])
68
+ ) {
62
69
  return false;
63
70
  }
64
71
  const mediaType = _optionalChain([response, 'access', _18 => _18.headers, 'access', _19 => _19.get, 'call', _20 => _20("content-type"), 'optionalAccess', _21 => _21.split, 'call', _22 => _22(";", 1), 'access', _23 => _23[0], 'optionalAccess', _24 => _24.trim, 'call', _25 => _25(), 'access', _26 => _26.toLowerCase, 'call', _27 => _27()]);
@@ -88,9 +95,9 @@ function compressedHeaders(response, encoding) {
88
95
  return headers;
89
96
  }
90
97
  _chunkS3JO3N4Hcjs.__name.call(void 0, compressedHeaders, "compressedHeaders");
91
- function compressBufferedResponse(response, text, encoding) {
98
+ function compressBufferedResponse(response, text, encoding, lazyBody) {
92
99
  const headers = compressedHeaders(response, encoding);
93
- _optionalChain([response, 'access', _28 => _28.body, 'optionalAccess', _29 => _29.cancel, 'call', _30 => _30(), 'access', _31 => _31.catch, 'call', _32 => _32(() => {
100
+ if (!lazyBody) _optionalChain([response, 'access', _28 => _28.body, 'optionalAccess', _29 => _29.cancel, 'call', _30 => _30(), 'access', _31 => _31.catch, 'call', _32 => _32(() => {
94
101
  })]);
95
102
  const input = Buffer.from(text);
96
103
  let cancelled = false;
@@ -143,21 +150,15 @@ function compressResponse(response, encoding) {
143
150
  }
144
151
  _chunkS3JO3N4Hcjs.__name.call(void 0, compressResponse, "compressResponse");
145
152
  function varyIdentityResponse(response) {
146
- const headers = new Headers(response.headers);
147
- appendVary(headers, "Accept-Encoding");
148
- return new Response(response.body, {
149
- status: response.status,
150
- statusText: response.statusText,
151
- headers
152
- });
153
+ return _chunkFJ3M4CUXcjs._withFarmResponseHeaders.call(void 0, response, (headers) => appendVary(headers, "Accept-Encoding"));
153
154
  }
154
155
  _chunkS3JO3N4Hcjs.__name.call(void 0, varyIdentityResponse, "varyIdentityResponse");
155
- function compressFarmResponse(request, response, bufferedText) {
156
- if (!isCompressionEligible(request, response)) return response;
156
+ function compressFarmResponse(request, response, bufferedText, lazyBody = false) {
157
+ if (!isCompressionEligible(request, response, bufferedText)) return response;
157
158
  if (request.method === "HEAD") return varyIdentityResponse(response);
158
159
  const encoding = selectEncoding(_nullishCoalesce(request.headers.get("accept-encoding"), () => ( "")));
159
160
  if (!encoding) return varyIdentityResponse(response);
160
- return bufferedText === void 0 ? compressResponse(response, encoding) : compressBufferedResponse(response, bufferedText, encoding);
161
+ return bufferedText === void 0 ? compressResponse(response, encoding) : compressBufferedResponse(response, bufferedText, encoding, lazyBody);
161
162
  }
162
163
  _chunkS3JO3N4Hcjs.__name.call(void 0, compressFarmResponse, "compressFarmResponse");
163
164
  function createCompressionPlugin({
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-TVGP4BBZ.mjs";
16
16
  import {
17
17
  farmAcceptQuality
18
- } from "./chunk-K3YEZLSY.mjs";
18
+ } from "./chunk-ATXI6LGT.mjs";
19
19
  import {
20
20
  matchesFarmIfNoneMatch
21
21
  } from "./chunk-XF7Q24PF.mjs";
@@ -15,7 +15,7 @@ var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
15
15
  var _chunkHREOKQWTcjs = require('./chunk-HREOKQWT.cjs');
16
16
 
17
17
 
18
- var _chunkXSPGWQWAcjs = require('./chunk-XSPGWQWA.cjs');
18
+ var _chunk6CNX6Q3Kcjs = require('./chunk-6CNX6Q3K.cjs');
19
19
 
20
20
 
21
21
  var _chunkEM6SBQKMcjs = require('./chunk-EM6SBQKM.cjs');
@@ -1181,11 +1181,11 @@ function shouldReturnMarkdown(request) {
1181
1181
  if (url.pathname.endsWith(".md")) return true;
1182
1182
  const accept = request.headers.get("accept");
1183
1183
  const markdown = Math.max(
1184
- _chunkXSPGWQWAcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1185
- _chunkXSPGWQWAcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1184
+ _chunk6CNX6Q3Kcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1185
+ _chunk6CNX6Q3Kcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1186
1186
  );
1187
1187
  if (markdown <= 0) return false;
1188
- return markdown >= _chunkXSPGWQWAcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1188
+ return markdown >= _chunk6CNX6Q3Kcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1189
1189
  }
1190
1190
  _chunkS3JO3N4Hcjs.__name.call(void 0, shouldReturnMarkdown, "shouldReturnMarkdown");
1191
1191
  function escapeAttribute(value) {
@@ -336,32 +336,49 @@ function assertPluginDependencies(plugins, integrations) {
336
336
  }
337
337
  }
338
338
  const state = /* @__PURE__ */ new Map();
339
- const path2 = [];
339
+ const path3 = [];
340
340
  const visit = /* @__PURE__ */ __name((plugin) => {
341
341
  if (state.get(plugin) === "done") return;
342
342
  if (state.get(plugin) === "visiting") {
343
- const cycle = [...path2.slice(path2.indexOf(plugin)), plugin].map(
343
+ const cycle = [...path3.slice(path3.indexOf(plugin)), plugin].map(
344
344
  (entry) => pluginShortName(entry.name)
345
345
  );
346
346
  throw new Error(`Plugins depend on each other in a cycle: ${cycle.join(" \u2192 ")}.`);
347
347
  }
348
348
  state.set(plugin, "visiting");
349
- path2.push(plugin);
349
+ path3.push(plugin);
350
350
  for (const dependency of plugin.dependsOn ?? []) {
351
351
  for (const candidate of plugins) {
352
352
  if (candidate !== plugin && matches(candidate, dependency)) visit(candidate);
353
353
  }
354
354
  }
355
- path2.pop();
355
+ path3.pop();
356
356
  state.set(plugin, "done");
357
357
  }, "visit");
358
358
  for (const plugin of plugins) visit(plugin);
359
359
  }
360
360
  __name(assertPluginDependencies, "assertPluginDependencies");
361
361
 
362
+ // src/utils/source-dir.ts
363
+ import path from "path";
364
+ var FARM_PROJECT_SOURCE_DIRS = /* @__PURE__ */ Symbol.for("farm.projectSourceDirs");
365
+ function getProjectSourceDirs() {
366
+ const globalState = globalThis;
367
+ return globalState[FARM_PROJECT_SOURCE_DIRS] ?? (globalState[FARM_PROJECT_SOURCE_DIRS] = /* @__PURE__ */ new Map());
368
+ }
369
+ __name(getProjectSourceDirs, "getProjectSourceDirs");
370
+ function setFarmProjectSourceDir(root, srcDir) {
371
+ getProjectSourceDirs().set(path.resolve(root), srcDir);
372
+ }
373
+ __name(setFarmProjectSourceDir, "setFarmProjectSourceDir");
374
+ function getFarmProjectSourceDir(root) {
375
+ return getProjectSourceDirs().get(path.resolve(root)) ?? "src";
376
+ }
377
+ __name(getFarmProjectSourceDir, "getFarmProjectSourceDir");
378
+
362
379
  // src/auth-config.ts
363
380
  import { createRequire } from "module";
364
- import path from "path";
381
+ import path2 from "path";
365
382
  import { pathToFileURL } from "url";
366
383
  function resolveFarmAuthConfig(input) {
367
384
  const config = input === true ? {} : input && typeof input === "object" ? input : {};
@@ -392,10 +409,10 @@ function resolveFarmAuthConfig(input) {
392
409
  __name(resolveFarmAuthConfig, "resolveFarmAuthConfig");
393
410
  async function resolveFarmAuthIntegration(config, options) {
394
411
  if (!config.enabled) return void 0;
395
- const root = path.resolve(options.root);
412
+ const root = path2.resolve(options.root);
396
413
  let modulePath;
397
414
  try {
398
- const resolveFromApp = createRequire(path.join(root, "package.json"));
415
+ const resolveFromApp = createRequire(path2.join(root, "package.json"));
399
416
  modulePath = resolveFromApp.resolve("@farm.js/auth/internal");
400
417
  } catch {
401
418
  throw new Error(
@@ -478,6 +495,8 @@ function validateFarmAuthConfig(config) {
478
495
  __name(validateFarmAuthConfig, "validateFarmAuthConfig");
479
496
 
480
497
  export {
498
+ setFarmProjectSourceDir,
499
+ getFarmProjectSourceDir,
481
500
  resolveFarmDevIndicatorsConfig,
482
501
  generateFarmDevIndicatorsClientRuntime,
483
502
  resolveFarmAuthConfig,
@@ -27,7 +27,7 @@ import {
27
27
  renderFarmLocaleAlternateLinks,
28
28
  resolveDefaultErrorStatus,
29
29
  resolveFarmApiCatalogInput
30
- } from "./chunk-FB3H4INL.mjs";
30
+ } from "./chunk-D234YWNA.mjs";
31
31
  import {
32
32
  isFarmPreviewDeploymentEnvironment
33
33
  } from "./chunk-BOYNDCZL.mjs";
@@ -61,10 +61,11 @@ import {
61
61
  } from "./chunk-TVGP4BBZ.mjs";
62
62
  import {
63
63
  generateFarmDevIndicatorsClientRuntime,
64
+ getFarmProjectSourceDir,
64
65
  pluginShortName,
65
66
  resolveFarmAuthConfig,
66
67
  resolveFarmDevIndicatorsConfig
67
- } from "./chunk-FZC7EEPM.mjs";
68
+ } from "./chunk-RSOJ7DRT.mjs";
68
69
  import {
69
70
  FARM_DEVTOOLS_LAUNCH_PARAM,
70
71
  FARM_DEVTOOLS_PATH,
@@ -107,7 +108,7 @@ import {
107
108
  resolveFarmLlmsTxtConfig,
108
109
  resolveFarmPerformanceConfig,
109
110
  resolveFarmSecurityConfig
110
- } from "./chunk-REGFZJEJ.mjs";
111
+ } from "./chunk-YMUE7L3D.mjs";
111
112
  import {
112
113
  getPublicFarmImageConfig,
113
114
  resolveFarmImageConfig
@@ -125,12 +126,12 @@ import {
125
126
  import {
126
127
  createFarmMarkdownRouteModuleFromFile,
127
128
  loadFarmMdxComponents
128
- } from "./chunk-NVBS5WSZ.mjs";
129
+ } from "./chunk-6G3ZZ2IE.mjs";
129
130
  import {
130
131
  createFarmMarkdownSourceResponse,
131
132
  isFarmMarkdownPageFile,
132
133
  normalizeFarmMarkdownRoutePath
133
- } from "./chunk-2DLN6HG4.mjs";
134
+ } from "./chunk-BZ3CHOFX.mjs";
134
135
  import {
135
136
  resolveFarmMdxComponentsModulePath,
136
137
  resolveMdxConfig
@@ -144,7 +145,7 @@ import {
144
145
  getFarmMarkdownMirrorPath,
145
146
  resolveMarkdownConfig,
146
147
  resolveMarkdownMirrorTarget
147
- } from "./chunk-K3YEZLSY.mjs";
148
+ } from "./chunk-ATXI6LGT.mjs";
148
149
  import {
149
150
  resolveWorkflowsConfig
150
151
  } from "./chunk-3ATMYLLJ.mjs";
@@ -284,7 +285,7 @@ import {
284
285
  } from "./chunk-Z2RZJZIZ.mjs";
285
286
  import {
286
287
  FARM_VERSION
287
- } from "./chunk-UX2DD2VK.mjs";
288
+ } from "./chunk-K6V52QMI.mjs";
288
289
  import {
289
290
  resolveFarmTrailingSlashRedirect,
290
291
  setFarmTrailingSlashPreference
@@ -1503,8 +1504,10 @@ function getProjectImportAliases(projectRoot) {
1503
1504
  return "-";
1504
1505
  }
1505
1506
  }).join(":");
1507
+ const sourceDir = getFarmProjectSourceDir(projectRoot);
1508
+ const cacheStamp = `${stamp}:${sourceDir}`;
1506
1509
  const cached = projectImportAliasCache.get(projectRoot);
1507
- if (cached?.stamp === stamp) return cached.aliases;
1510
+ if (cached?.stamp === cacheStamp) return cached.aliases;
1508
1511
  const aliases = [
1509
1512
  ...readTsconfigPathAliases(projectRoot),
1510
1513
  ...readPackageImportAliases(projectRoot)
@@ -1514,10 +1517,10 @@ function getProjectImportAliases(projectRoot) {
1514
1517
  prefix: "@/",
1515
1518
  suffix: "",
1516
1519
  wildcard: true,
1517
- targets: [path.join(projectRoot, "src", "*")]
1520
+ targets: [path.join(projectRoot, sourceDir, "*")]
1518
1521
  });
1519
1522
  }
1520
- projectImportAliasCache.set(projectRoot, { stamp, aliases });
1523
+ projectImportAliasCache.set(projectRoot, { stamp: cacheStamp, aliases });
1521
1524
  return aliases;
1522
1525
  }
1523
1526
  __name(getProjectImportAliases, "getProjectImportAliases");
@@ -9547,7 +9550,7 @@ function loadFarmWorkflowsDevRuntime() {
9547
9550
  }
9548
9551
  __name(loadFarmWorkflowsDevRuntime, "loadFarmWorkflowsDevRuntime");
9549
9552
  function loadFarmDevtoolsSnapshotRuntime() {
9550
- return import("./devtools-3E7ZANMZ.mjs");
9553
+ return import("./devtools-THVNPI2M.mjs");
9551
9554
  }
9552
9555
  __name(loadFarmDevtoolsSnapshotRuntime, "loadFarmDevtoolsSnapshotRuntime");
9553
9556
  function loadFarmDevtoolsUIRuntime() {
@@ -9555,7 +9558,7 @@ function loadFarmDevtoolsUIRuntime() {
9555
9558
  }
9556
9559
  __name(loadFarmDevtoolsUIRuntime, "loadFarmDevtoolsUIRuntime");
9557
9560
  function loadFarmDevtoolsClientRuntime() {
9558
- return import("./devtools-client-LEUIHHAS.mjs");
9561
+ return import("./devtools-client-HJS2T34Y.mjs");
9559
9562
  }
9560
9563
  __name(loadFarmDevtoolsClientRuntime, "loadFarmDevtoolsClientRuntime");
9561
9564
  function farmI18nClientBridgePlugin() {
@@ -10786,7 +10789,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10786
10789
  ...currentConfig,
10787
10790
  openapi: options.openapi
10788
10791
  },
10789
- workflows: discoveredWorkflows
10792
+ workflows: discoveredWorkflows,
10793
+ plugins: pm?.getSortedPlugins()
10790
10794
  });
10791
10795
  res.statusCode = 200;
10792
10796
  res.setHeader(
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// package.json
2
- var version = "0.1.28";
2
+ var version = "0.1.30";
3
3
 
4
4
  // src/version.ts
5
5
  var FARM_VERSION = version;
@@ -0,0 +1,47 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/nitro/native-mcp-source.ts
6
+ function generateNativeMCPPluginSource(mcp) {
7
+ if (_optionalChain([mcp, 'optionalAccess', _ => _.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
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateNativeMCPPluginSource, "generateNativeMCPPluginSource");
44
+
45
+
46
+
47
+ exports.generateNativeMCPPluginSource = generateNativeMCPPluginSource;
@@ -1,3 +1,6 @@
1
+ import {
2
+ _withFarmResponseHeaders
3
+ } from "./chunk-Z3HATSKO.mjs";
1
4
  import {
2
5
  __name
3
6
  } from "./chunk-LPEX4YW6.mjs";
@@ -57,8 +60,12 @@ function isCompressibleMediaType(mediaType) {
57
60
  return COMPRESSIBLE_MEDIA_TYPE_SUFFIXES.some((suffix) => mediaType.endsWith(suffix));
58
61
  }
59
62
  __name(isCompressibleMediaType, "isCompressibleMediaType");
60
- function isCompressionEligible(request, response) {
61
- if (request.method !== "HEAD" && !response.body || response.status === 204 || response.status === 205 || response.status === 304 || response.headers.has("content-encoding") || response.headers.has("content-range") || response.headers.get("cache-control")?.toLowerCase().includes("no-transform")) {
63
+ function isCompressionEligible(request, response, bufferedText) {
64
+ if (
65
+ // Known buffered text proves a body without reading response.body, which
66
+ // would create a lazy response's Web stream.
67
+ request.method !== "HEAD" && bufferedText === void 0 && !response.body || response.status === 204 || response.status === 205 || response.status === 304 || response.headers.has("content-encoding") || response.headers.has("content-range") || response.headers.get("cache-control")?.toLowerCase().includes("no-transform")
68
+ ) {
62
69
  return false;
63
70
  }
64
71
  const mediaType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
@@ -88,9 +95,9 @@ function compressedHeaders(response, encoding) {
88
95
  return headers;
89
96
  }
90
97
  __name(compressedHeaders, "compressedHeaders");
91
- function compressBufferedResponse(response, text, encoding) {
98
+ function compressBufferedResponse(response, text, encoding, lazyBody) {
92
99
  const headers = compressedHeaders(response, encoding);
93
- response.body?.cancel().catch(() => {
100
+ if (!lazyBody) response.body?.cancel().catch(() => {
94
101
  });
95
102
  const input = Buffer.from(text);
96
103
  let cancelled = false;
@@ -143,21 +150,15 @@ function compressResponse(response, encoding) {
143
150
  }
144
151
  __name(compressResponse, "compressResponse");
145
152
  function varyIdentityResponse(response) {
146
- const headers = new Headers(response.headers);
147
- appendVary(headers, "Accept-Encoding");
148
- return new Response(response.body, {
149
- status: response.status,
150
- statusText: response.statusText,
151
- headers
152
- });
153
+ return _withFarmResponseHeaders(response, (headers) => appendVary(headers, "Accept-Encoding"));
153
154
  }
154
155
  __name(varyIdentityResponse, "varyIdentityResponse");
155
- function compressFarmResponse(request, response, bufferedText) {
156
- if (!isCompressionEligible(request, response)) return response;
156
+ function compressFarmResponse(request, response, bufferedText, lazyBody = false) {
157
+ if (!isCompressionEligible(request, response, bufferedText)) return response;
157
158
  if (request.method === "HEAD") return varyIdentityResponse(response);
158
159
  const encoding = selectEncoding(request.headers.get("accept-encoding") ?? "");
159
160
  if (!encoding) return varyIdentityResponse(response);
160
- return bufferedText === void 0 ? compressResponse(response, encoding) : compressBufferedResponse(response, bufferedText, encoding);
161
+ return bufferedText === void 0 ? compressResponse(response, encoding) : compressBufferedResponse(response, bufferedText, encoding, lazyBody);
161
162
  }
162
163
  __name(compressFarmResponse, "compressFarmResponse");
163
164
  function createCompressionPlugin({