@farm.js/core 0.1.71 → 0.1.72

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 (222) hide show
  1. package/dist/agent-mcp-handler-KE4J3W7S.cjs +1 -1
  2. package/dist/agent-mcp-handler-VIT4GOSR.mjs +1 -1
  3. package/dist/{agent-mcp.d-BzNw6JI8.d.ts → agent-mcp.d-BO3rZXEM.d.ts} +2 -2
  4. package/dist/{agent-mcp.d-CgFen3EH.d.mts → agent-mcp.d-Cwff7lcA.d.mts} +2 -2
  5. package/dist/agent-runtime.d.mts +3 -3
  6. package/dist/agent-runtime.d.ts +3 -3
  7. package/dist/{analyzer-VK3BAOFI.mjs → analyzer-5Q75LTIL.mjs} +2 -2
  8. package/dist/analyzer-UJG4MIZW.cjs +16 -0
  9. package/dist/api/node.d.mts +5 -5
  10. package/dist/api/node.d.ts +5 -5
  11. package/dist/api/route-manager.cjs +7 -6
  12. package/dist/api/route-manager.d.mts +7 -7
  13. package/dist/api/route-manager.d.ts +7 -7
  14. package/dist/api/route-manager.mjs +6 -5
  15. package/dist/api/runtime.d.mts +4 -4
  16. package/dist/api/runtime.d.ts +4 -4
  17. package/dist/api.cjs +8 -7
  18. package/dist/api.d.mts +8 -8
  19. package/dist/api.d.ts +8 -8
  20. package/dist/api.mjs +7 -6
  21. package/dist/{app-manifest.d-DY4JfJxi.d.ts → app-manifest.d-DwjGkYlP.d.ts} +1 -1
  22. package/dist/{app-manifest.d-DpDK_B1k.d.mts → app-manifest.d-USD_IbFd.d.mts} +1 -1
  23. package/dist/app-markdown.d.mts +4 -4
  24. package/dist/app-markdown.d.ts +4 -4
  25. package/dist/{app.d-BeK6bb1c.d.ts → app.d-DAmF2MAk.d.ts} +48 -6
  26. package/dist/{app.d-D-5UNrFd.d.mts → app.d-fW06_h8h.d.mts} +48 -6
  27. package/dist/{chunk-7A3URI2F.mjs → chunk-2EVESLP3.mjs} +8 -1
  28. package/dist/{chunk-X7LGLF33.mjs → chunk-3JN5M3T5.mjs} +259 -61
  29. package/dist/{chunk-KEB7AGS6.cjs → chunk-3WG7GJQL.cjs} +7 -2
  30. package/dist/{chunk-K66JILV3.cjs → chunk-5LOARKDP.cjs} +2 -2
  31. package/dist/{chunk-UISZLYKY.cjs → chunk-5R4Q5FN7.cjs} +2 -2
  32. package/dist/{chunk-3BQ7QHUH.cjs → chunk-5X6OHJEE.cjs} +15 -3
  33. package/dist/{chunk-GUU3IZSM.mjs → chunk-5XFKWHZD.mjs} +234 -47
  34. package/dist/{chunk-MITIAOUQ.mjs → chunk-645ENY7W.mjs} +2 -2
  35. package/dist/{chunk-RJUCNO7R.mjs → chunk-77VNYVVX.mjs} +1 -1
  36. package/dist/{chunk-PLXD2MJV.cjs → chunk-7QCJDYZQ.cjs} +2 -2
  37. package/dist/{chunk-V25GSH43.mjs → chunk-AUAMXI6N.mjs} +1 -1
  38. package/dist/{chunk-2IFT2CSA.cjs → chunk-BE7AQXJB.cjs} +346 -148
  39. package/dist/{chunk-7BUE2GM6.mjs → chunk-BSXKZPFE.mjs} +70 -19
  40. package/dist/{chunk-2MR4MABG.cjs → chunk-C5AM2XDN.cjs} +54 -4
  41. package/dist/{chunk-KWST2O22.cjs → chunk-CBLRSZQL.cjs} +488 -301
  42. package/dist/{chunk-BBPDJGCU.cjs → chunk-CYOTNHDF.cjs} +2 -2
  43. package/dist/{chunk-W2T6NDNP.mjs → chunk-DGNMXL2O.mjs} +1 -1
  44. package/dist/{chunk-QUFENL7Q.mjs → chunk-DS7JGFW5.mjs} +13 -1
  45. package/dist/{chunk-IGXS54GC.mjs → chunk-E2V7RRFL.mjs} +1 -1
  46. package/dist/{chunk-CSQPMV3Q.cjs → chunk-E3LE6EZH.cjs} +4 -4
  47. package/dist/{chunk-JVA4PIYN.cjs → chunk-ET6WW3FY.cjs} +338 -171
  48. package/dist/{chunk-VXB5CMNC.cjs → chunk-EXN4DTVF.cjs} +2 -2
  49. package/dist/{chunk-SXMWVP2L.cjs → chunk-FSSONJRV.cjs} +4 -4
  50. package/dist/{chunk-Y2SZVIVH.cjs → chunk-GPICBTDV.cjs} +8 -1
  51. package/dist/{chunk-7OHJWFLB.cjs → chunk-HLMUWKAP.cjs} +333 -282
  52. package/dist/{chunk-ZPUAOKHV.cjs → chunk-IWCYRDRQ.cjs} +3 -3
  53. package/dist/{chunk-2AM26UGI.cjs → chunk-NLBK37HI.cjs} +5 -4
  54. package/dist/{chunk-NA77GEIU.mjs → chunk-NV26EGMC.mjs} +51 -1
  55. package/dist/{chunk-DPYBVVL3.cjs → chunk-OSEQL34Q.cjs} +2 -2
  56. package/dist/{chunk-IYDJNCR7.mjs → chunk-OSMUE5ST.mjs} +7 -2
  57. package/dist/{chunk-UQUOSNRN.mjs → chunk-QUYAGU65.mjs} +214 -47
  58. package/dist/{chunk-DPIGYXSV.mjs → chunk-RFWWXEIF.mjs} +1 -1
  59. package/dist/{chunk-E77IA5IF.mjs → chunk-RLFGKJQ6.mjs} +1 -1
  60. package/dist/{chunk-3AUINHFG.mjs → chunk-TNYC3TYP.mjs} +3 -2
  61. package/dist/{chunk-4OD2LXF2.mjs → chunk-VAWDGGW3.mjs} +1 -1
  62. package/dist/{chunk-MU5V7XHL.mjs → chunk-VJSXPN3W.mjs} +3 -0
  63. package/dist/{chunk-DU4VHHPJ.mjs → chunk-VO55MMBX.mjs} +1 -1
  64. package/dist/{chunk-LDVJIBGN.mjs → chunk-VT25ERQK.mjs} +1 -1
  65. package/dist/{chunk-2CQC5CMD.mjs → chunk-WIJF3PBM.mjs} +1 -1
  66. package/dist/{chunk-FILXOEWD.cjs → chunk-YXIQYWOK.cjs} +2 -2
  67. package/dist/{chunk-THG2TVDH.mjs → chunk-YZLEOMMA.mjs} +3 -3
  68. package/dist/{chunk-MEJCP2LX.cjs → chunk-ZDZUFD67.cjs} +1 -1
  69. package/dist/{chunk-Q5HMVGR5.cjs → chunk-ZFEJ2SF2.cjs} +13 -13
  70. package/dist/{chunk-LNVGXUL3.cjs → chunk-ZMSVKVI3.cjs} +3 -0
  71. package/dist/{client-component.d-fYupugbZ.d.ts → client-component.d-9J7CkTWW.d.ts} +2 -2
  72. package/dist/{client-component.d-DwpH251K.d.mts → client-component.d-ciHeCxr-.d.mts} +2 -2
  73. package/dist/{client-plugins.d-BxqFfHpM.d.ts → client-plugins.d-CUOhfapO.d.ts} +4 -3
  74. package/dist/{client-plugins.d-k3bOT5gz.d.mts → client-plugins.d-JnRz5a1o.d.mts} +4 -3
  75. package/dist/client-plugins.d.mts +3 -3
  76. package/dist/client-plugins.d.ts +3 -3
  77. package/dist/client.cjs +1 -1
  78. package/dist/client.d.mts +8 -8
  79. package/dist/client.d.ts +8 -8
  80. package/dist/client.mjs +1 -1
  81. package/dist/config.d.mts +3 -3
  82. package/dist/config.d.ts +3 -3
  83. package/dist/desktop.d.mts +4 -4
  84. package/dist/desktop.d.ts +4 -4
  85. package/dist/{devtools-6MXPFPNJ.mjs → devtools-7JPQMSTQ.mjs} +3 -3
  86. package/dist/{devtools-O5625KCK.cjs → devtools-IZFUYWPG.cjs} +4 -4
  87. package/dist/docs.cjs +5 -5
  88. package/dist/docs.d.mts +4 -4
  89. package/dist/docs.d.ts +4 -4
  90. package/dist/docs.mjs +4 -4
  91. package/dist/environment/vite.cjs +3 -3
  92. package/dist/environment/vite.mjs +2 -2
  93. package/dist/{headers.d-DalIGbVO.d.ts → headers.d-CqpTL_fZ.d.ts} +2 -2
  94. package/dist/{headers.d-sNT7ZQiU.d.mts → headers.d-rbbTKGaN.d.mts} +2 -2
  95. package/dist/i18n/client.cjs +3 -2
  96. package/dist/i18n/client.d.mts +2 -2
  97. package/dist/i18n/client.d.ts +2 -2
  98. package/dist/i18n/client.mjs +2 -1
  99. package/dist/i18n/index.cjs +3 -2
  100. package/dist/i18n/index.d.mts +3 -3
  101. package/dist/i18n/index.d.ts +3 -3
  102. package/dist/i18n/index.mjs +2 -1
  103. package/dist/i18n/server.cjs +6 -5
  104. package/dist/i18n/server.d.mts +5 -5
  105. package/dist/i18n/server.d.ts +5 -5
  106. package/dist/i18n/server.mjs +5 -4
  107. package/dist/index.cjs +22 -22
  108. package/dist/{index.d-BcA-secm.d.ts → index.d-CMKvzHLW.d.ts} +1 -1
  109. package/dist/{index.d-DDHHAv7j.d.mts → index.d-D_B2D9Il.d.mts} +1 -1
  110. package/dist/index.d.mts +23 -23
  111. package/dist/index.d.ts +23 -23
  112. package/dist/index.mjs +21 -21
  113. package/dist/integrations/orm.d.mts +3 -3
  114. package/dist/integrations/orm.d.ts +3 -3
  115. package/dist/integrations.d.mts +3 -3
  116. package/dist/integrations.d.ts +3 -3
  117. package/dist/internal/app-markdown-runtime.d.mts +4 -4
  118. package/dist/internal/app-markdown-runtime.d.ts +4 -4
  119. package/dist/internal/build-runtime.cjs +21 -21
  120. package/dist/internal/build-runtime.d.mts +5 -5
  121. package/dist/internal/build-runtime.d.ts +5 -5
  122. package/dist/internal/build-runtime.mjs +20 -20
  123. package/dist/internal/cli-runtime.cjs +6 -6
  124. package/dist/internal/cli-runtime.mjs +5 -5
  125. package/dist/internal/client-error-overlay.cjs +4 -4
  126. package/dist/internal/client-error-overlay.mjs +1 -1
  127. package/dist/internal/client-runtime.cjs +2 -2
  128. package/dist/internal/client-runtime.d.mts +6 -6
  129. package/dist/internal/client-runtime.d.ts +6 -6
  130. package/dist/internal/client-runtime.mjs +3 -3
  131. package/dist/internal/compression-runtime.d.mts +3 -3
  132. package/dist/internal/compression-runtime.d.ts +3 -3
  133. package/dist/internal/config-runtime.cjs +5 -5
  134. package/dist/internal/config-runtime.d.mts +6 -6
  135. package/dist/internal/config-runtime.d.ts +6 -6
  136. package/dist/internal/config-runtime.mjs +4 -4
  137. package/dist/internal/infra-analytics-runtime.cjs +7 -7
  138. package/dist/internal/infra-analytics-runtime.mjs +5 -5
  139. package/dist/internal/native-server-fns.cjs +4 -4
  140. package/dist/internal/native-server-fns.mjs +3 -3
  141. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  142. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  143. package/dist/internal/production-runtime.cjs +13 -13
  144. package/dist/internal/production-runtime.d.mts +36 -24
  145. package/dist/internal/production-runtime.d.ts +36 -24
  146. package/dist/internal/production-runtime.mjs +12 -12
  147. package/dist/internal/vercel-edge-middleware.d.mts +2 -2
  148. package/dist/internal/vercel-edge-middleware.d.ts +2 -2
  149. package/dist/markdown.d.mts +3 -3
  150. package/dist/markdown.d.ts +3 -3
  151. package/dist/middleware.cjs +3 -3
  152. package/dist/middleware.d.mts +4 -4
  153. package/dist/middleware.d.ts +4 -4
  154. package/dist/middleware.mjs +2 -2
  155. package/dist/mobile.d.mts +3 -3
  156. package/dist/mobile.d.ts +3 -3
  157. package/dist/{mount.d-D3JOux2V.d.ts → mount.d-B0XMxDRh.d.ts} +1 -1
  158. package/dist/{mount.d-C1PONsEe.d.mts → mount.d-ImEO7q8a.d.mts} +1 -1
  159. package/dist/{navigation-delegate.d-CJQQHboA.d.mts → navigation-delegate.d-83Q7ksf7.d.mts} +1 -1
  160. package/dist/{navigation-delegate.d-CQQPbdkE.d.ts → navigation-delegate.d-RRx1CSlb.d.ts} +1 -1
  161. package/dist/navigation.d.mts +6 -6
  162. package/dist/navigation.d.ts +6 -6
  163. package/dist/plugin.cjs +15 -15
  164. package/dist/plugin.d.mts +6 -6
  165. package/dist/plugin.d.ts +6 -6
  166. package/dist/plugin.mjs +14 -14
  167. package/dist/{production-runtime.d-B0IeWWyO.d.mts → production-runtime.d-Bcu37SCo.d.mts} +1 -1
  168. package/dist/{production-runtime.d-q3aHIv5Y.d.ts → production-runtime.d-qPj3XRET.d.ts} +1 -1
  169. package/dist/{render-plan.d-DHuJMJRP.d.ts → render-plan.d-Ds2sXJ5m.d.ts} +1 -1
  170. package/dist/{render-plan.d-CiUj0rq5.d.mts → render-plan.d-wP8nTeRV.d.mts} +1 -1
  171. package/dist/renderer-client.cjs +3 -2
  172. package/dist/renderer-client.d.mts +6 -6
  173. package/dist/renderer-client.d.ts +6 -6
  174. package/dist/renderer-client.mjs +2 -1
  175. package/dist/{request.d-D-F7o7tb.d.mts → request.d-F3h7K37m.d.mts} +1 -1
  176. package/dist/{request.d-DRUbOmYD.d.ts → request.d-zpSn6pu_.d.ts} +1 -1
  177. package/dist/request.d.mts +4 -4
  178. package/dist/request.d.ts +4 -4
  179. package/dist/{resolver.d-9iKC79CU.d.mts → resolver.d-DJgzbdsp.d.mts} +1 -1
  180. package/dist/{resolver.d-CY6mEa_F.d.ts → resolver.d-yaHcGCCG.d.ts} +1 -1
  181. package/dist/{route-rendering.d-KwqM_mlK.d.ts → route-rendering.d-BL0_AdKj.d.ts} +1 -1
  182. package/dist/{route-rendering.d-6smgwT2t.d.mts → route-rendering.d-Mw0ZKG2e.d.mts} +1 -1
  183. package/dist/{router.d-B6sesMRD.d.ts → router.d-BwXigemZ.d.ts} +1 -1
  184. package/dist/{router.d-BYmDeDlp.d.mts → router.d-NGVsU11T.d.mts} +1 -1
  185. package/dist/{routes.d-D3aJw1H5.d.mts → routes.d-CCccJRrp.d.mts} +1 -1
  186. package/dist/{routes.d-K-Qg79AA.d.ts → routes.d-b7khoRoU.d.ts} +1 -1
  187. package/dist/routes.d.mts +3 -3
  188. package/dist/routes.d.ts +3 -3
  189. package/dist/{routing.d-DwSUVZbF.d.mts → routing.d-BhPgtN_S.d.ts} +2 -1
  190. package/dist/{routing.d-BxOZ2YWc.d.ts → routing.d-D67HQmnv.d.mts} +2 -1
  191. package/dist/{rsc-pipeline-P4PCWDO2.cjs → rsc-pipeline-BNXYMG4G.cjs} +5 -5
  192. package/dist/{rsc-pipeline-R2GOKIMU.mjs → rsc-pipeline-DHYZLWSF.mjs} +4 -4
  193. package/dist/{runtime-WA2Q4SLG.cjs → runtime-IWOT6ZVC.cjs} +6 -6
  194. package/dist/{runtime-DP5DYGW5.mjs → runtime-XPYKUNL3.mjs} +4 -4
  195. package/dist/{runtime.d-BFSJf-ww.d.mts → runtime.d-BA3MzhXz.d.mts} +1 -1
  196. package/dist/{runtime.d-nUz0HAL4.d.mts → runtime.d-CTAXWZby.d.mts} +2 -2
  197. package/dist/{runtime.d-CbdMI0Oy.d.ts → runtime.d-OBIZWpx1.d.ts} +1 -1
  198. package/dist/{runtime.d-B_uPfMjA.d.ts → runtime.d-PUA5qBnd.d.ts} +2 -2
  199. package/dist/server-plugins.d.mts +5 -5
  200. package/dist/server-plugins.d.ts +5 -5
  201. package/dist/server.cjs +33 -33
  202. package/dist/server.d.mts +14 -14
  203. package/dist/server.d.ts +14 -14
  204. package/dist/server.mjs +17 -17
  205. package/dist/{spa-router.d-D4EDwR20.d.mts → spa-router.d-BG2XzE5p.d.mts} +3 -3
  206. package/dist/{spa-router.d-mC1D5cTN.d.ts → spa-router.d-DrYT944-.d.ts} +3 -3
  207. package/dist/testing.cjs +6 -5
  208. package/dist/testing.d.mts +3 -3
  209. package/dist/testing.d.ts +3 -3
  210. package/dist/testing.mjs +6 -5
  211. package/dist/{types.d-wVRlLtBf.d.ts → types.d-euATAbE4.d.mts} +4 -0
  212. package/dist/{types.d-wVRlLtBf.d.mts → types.d-euATAbE4.d.ts} +4 -0
  213. package/dist/{utils.d-DxMzteqE.d.mts → utils.d-C1k9BJeD.d.mts} +1 -1
  214. package/dist/{utils.d-A2X3a6z_.d.ts → utils.d-DcF4wxey.d.ts} +1 -1
  215. package/dist/version.cjs +2 -2
  216. package/dist/version.mjs +1 -1
  217. package/dist/vite.cjs +15 -15
  218. package/dist/vite.d.mts +7 -7
  219. package/dist/vite.d.ts +7 -7
  220. package/dist/vite.mjs +14 -14
  221. package/package.json +1 -1
  222. package/dist/analyzer-LPIVRSTJ.cjs +0 -16
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
3
 
4
- var _chunkVXB5CMNCcjs = require('./chunk-VXB5CMNC.cjs');
4
+ var _chunkEXN4DTVFcjs = require('./chunk-EXN4DTVF.cjs');
5
5
 
6
6
 
7
7
  var _chunkPIUTGRDIcjs = require('./chunk-PIUTGRDI.cjs');
@@ -64,7 +64,7 @@ function findFarmNativeScreenFiles(appDirs) {
64
64
  }
65
65
  function collectFarmNativeServerFns(options) {
66
66
  const { root, srcDir } = options;
67
- const aliases = _chunkVXB5CMNCcjs.readAliases.call(void 0, root, srcDir);
67
+ const aliases = _chunkEXN4DTVFcjs.readAliases.call(void 0, root, srcDir);
68
68
  const seen = /* @__PURE__ */ new Set();
69
69
  const found = /* @__PURE__ */ new Map();
70
70
  const queue = [...options.entries];
@@ -98,7 +98,7 @@ function collectFarmNativeServerFns(options) {
98
98
  }
99
99
  }
100
100
  for (const candidate of _nullishCoalesce(candidates, () => ( []))) {
101
- const resolved = _chunkVXB5CMNCcjs.resolveFile.call(void 0, candidate);
101
+ const resolved = _chunkEXN4DTVFcjs.resolveFile.call(void 0, candidate);
102
102
  if (resolved && SCRIPT.test(resolved) && !resolved.includes(`${_path2.default.sep}node_modules${_path2.default.sep}`)) {
103
103
  queue.push(resolved);
104
104
  break;
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkBBPDJGCUcjs = require('./chunk-BBPDJGCU.cjs');
3
+ var _chunkCYOTNHDFcjs = require('./chunk-CYOTNHDF.cjs');
4
4
 
5
5
 
6
- var _chunkY2SZVIVHcjs = require('./chunk-Y2SZVIVH.cjs');
6
+ var _chunkGPICBTDVcjs = require('./chunk-GPICBTDV.cjs');
7
7
 
8
8
 
9
9
  var _chunkAOKXITZ6cjs = require('./chunk-AOKXITZ6.cjs');
@@ -25,7 +25,7 @@ var FarmI18nRuntime = class {
25
25
  }
26
26
  async initialize() {
27
27
  if (!this.config.enabled) return;
28
- const bundle = await _chunkBBPDJGCUcjs.readFarmI18nCatalogs.call(void 0, this.config);
28
+ const bundle = await _chunkCYOTNHDFcjs.readFarmI18nCatalogs.call(void 0, this.config);
29
29
  this.replaceCatalogs(bundle.catalogs);
30
30
  }
31
31
  async reload() {
@@ -42,7 +42,7 @@ var FarmI18nRuntime = class {
42
42
  );
43
43
  }
44
44
  resolveRequest(request, options = {}) {
45
- return _chunkY2SZVIVHcjs.resolveFarmLocaleRequest.call(void 0, request, this.config, options);
45
+ return _chunkGPICBTDVcjs.resolveFarmLocaleRequest.call(void 0, request, this.config, options);
46
46
  }
47
47
  translate(locale, key, values) {
48
48
  const result = this.formatMessage(locale, key, values);
@@ -69,6 +69,7 @@ var FarmI18nRuntime = class {
69
69
  defaultLocale: this.config.defaultLocale,
70
70
  routing: this.config.routing,
71
71
  basePath: this.config.basePath,
72
+ trailingSlash: this.config.trailingSlash,
72
73
  cookie: this.config.cookie,
73
74
  direction: _chunkOWQV6MLMcjs.getFarmLocaleDirection.call(void 0, resolution.locale, this.config.direction),
74
75
  messages: {
@@ -33,6 +33,9 @@ import {
33
33
  parseRoutePattern,
34
34
  splitNormalizedPathname
35
35
  } from "./chunk-MFQGU5CC.mjs";
36
+ import {
37
+ normalizeFarmTrailingSlashPathname
38
+ } from "./chunk-4O26BPUY.mjs";
36
39
  import {
37
40
  localizeFarmPathname
38
41
  } from "./chunk-7S7AAK2D.mjs";
@@ -237,6 +240,32 @@ function classifyFarmDocumentPrefix(markup) {
237
240
  if (/^<!doctype/i.test(inner) || /^<html[\s>]/i.test(inner)) return "document";
238
241
  return inner === "" ? "pending" : "fragment";
239
242
  }
243
+ function takeFarmHoistedHead(markup, complete) {
244
+ const kind = classifyFarmDocumentPrefix(markup);
245
+ if (kind === "document") return { head: "", body: markup };
246
+ if (kind === "pending" && !complete) return null;
247
+ let head = "";
248
+ let body = markup;
249
+ let match;
250
+ while (match = HOISTED_HEAD_ELEMENT.exec(body.replace(/^\s+/, ""))) {
251
+ head += match[0];
252
+ body = body.replace(/^\s+/, "").slice(match[0].length);
253
+ }
254
+ if (!complete && endsInsideHoistable(body)) return null;
255
+ return { head, body };
256
+ }
257
+ function endsInsideHoistable(body) {
258
+ const open = /^\s*<(meta|link|base|title|script|style)\b/i.exec(body);
259
+ if (!open) return false;
260
+ const tag = open[1].toLowerCase();
261
+ if (!body.includes(">")) return true;
262
+ return (tag === "title" || tag === "script" || tag === "style") && !new RegExp(`</${tag}>`, "i").test(body);
263
+ }
264
+ function appendFarmHead(document, head) {
265
+ if (!head) return document;
266
+ return document.replace(/<\/head>/i, () => `${head}
267
+ </head>`);
268
+ }
240
269
  function ensureFarmDocumentHead(markup) {
241
270
  if (/<head[\s>]/i.test(markup)) return markup;
242
271
  return markup.replace(/<html([^>]*)>/i, (_match, attributes) => {
@@ -423,10 +452,21 @@ function pathSpecificConfigMiddlewareCovers(config, pathname) {
423
452
  return matchesCompiledMiddlewareConfig(pathname, compiled, {}).matched;
424
453
  });
425
454
  }
455
+ function middlewareRouteConfig(route) {
456
+ if (route.config !== void 0) return route.config === "unknown" ? void 0 : route.config;
457
+ return route.module?.config;
458
+ }
426
459
  function farmPathGuardCoversPage(options, pathname) {
427
460
  return appMiddlewareMayHandlePath(
428
461
  options.middlewareRoutes.filter((route) => route.path !== "/"),
429
462
  pathname
463
+ ) || // The root file runs for every path unless its own matcher narrows it, which is how a
464
+ // Next.js-style `middleware.ts` guards `/dashboard/:path*`.
465
+ options.middlewareRoutes.some(
466
+ (route) => route.path === "/" && pathSpecificConfigMiddlewareCovers(
467
+ middlewareRouteConfig(route),
468
+ pathname
469
+ )
430
470
  ) || pathSpecificConfigMiddlewareCovers(options.config.middleware, pathname) || integrationMiddlewareMayHandlePath(options.config.integrations, pathname, CATCH_ALL_PROBE);
431
471
  }
432
472
  function farmPathGuardCoversEndpoint(options, path, apiServerBasePath) {
@@ -440,7 +480,15 @@ function renderFarmLocaleAlternateLinks(pathname, config, options = {}) {
440
480
  if (config.routing === "none") return "";
441
481
  const base = resolveAlternateBase(options);
442
482
  const link = (hreflang, locale) => `<link rel="alternate" hreflang="${escapeHtmlAttribute(hreflang)}" href="${escapeHtmlAttribute(
443
- resolveAlternateHref(localizeFarmPathname(pathname, locale, config), base)
483
+ resolveAlternateHref(
484
+ // Each alternate is the page's canonical URL in that locale, so it carries the app's
485
+ // trailingSlash: an alternate the server redirects reads as an error to search engines.
486
+ normalizeFarmTrailingSlashPathname(
487
+ localizeFarmPathname(pathname, locale, config),
488
+ config.trailingSlash === true
489
+ ),
490
+ base
491
+ )
444
492
  )}">`;
445
493
  const links = config.locales.map((locale) => link(locale, locale));
446
494
  links.push(link("x-default", config.defaultLocale));
@@ -856,6 +904,8 @@ export {
856
904
  HOISTED_HEAD_ELEMENT,
857
905
  extractFarmFullDocument,
858
906
  classifyFarmDocumentPrefix,
907
+ takeFarmHoistedHead,
908
+ appendFarmHead,
859
909
  removeFarmDocumentTitles,
860
910
  ensureFarmDocumentMeta,
861
911
  composeFarmFullDocument,
@@ -1,6 +1,6 @@
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 _chunkMEJCP2LXcjs = require('./chunk-MEJCP2LX.cjs');
3
+ var _chunkZDZUFD67cjs = require('./chunk-ZDZUFD67.cjs');
4
4
 
5
5
  // src/deployment-environment.ts
6
6
  function isFarmProductionDeploymentEnvironment(env = process.env) {
@@ -90,7 +90,7 @@ function createFarmProductionSiteReporter(options) {
90
90
  schemaVersion: FARM_PRODUCTION_SITE_TELEMETRY_SCHEMA_VERSION,
91
91
  eventType: FARM_PRODUCTION_SITE_ATTESTATION_EVENT_TYPE,
92
92
  packageName: FARM_PRODUCTION_SITE_TELEMETRY_PACKAGE_NAME,
93
- packageVersion: sanitizeDetail(_chunkMEJCP2LXcjs.FARM_VERSION, "unknown"),
93
+ packageVersion: sanitizeDetail(_chunkZDZUFD67cjs.FARM_VERSION, "unknown"),
94
94
  renderer: sanitizeDetail(options.renderer, "custom"),
95
95
  deployTarget: sanitizeDetail(options.deployTarget, "custom")
96
96
  };
@@ -82,7 +82,7 @@ import {
82
82
  } from "./chunk-EDPENAVO.mjs";
83
83
  import {
84
84
  resolveFarmI18nConfig
85
- } from "./chunk-MU5V7XHL.mjs";
85
+ } from "./chunk-VJSXPN3W.mjs";
86
86
  import {
87
87
  logger
88
88
  } from "./chunk-JSDV2NUN.mjs";
@@ -1208,7 +1208,12 @@ async function resolveConfig(userConfig, mode) {
1208
1208
  performance: resolveFarmPerformanceConfig(userConfig.performance),
1209
1209
  theme: resolveFarmThemeConfig(userConfig.theme, basePath),
1210
1210
  publicDir: userConfig.publicDir || "public",
1211
- i18n: resolveFarmI18nConfig(userConfig.i18n, { root, mode, basePath }),
1211
+ i18n: resolveFarmI18nConfig(userConfig.i18n, {
1212
+ root,
1213
+ mode,
1214
+ basePath,
1215
+ trailingSlash: userConfig.trailingSlash ?? false
1216
+ }),
1212
1217
  openapi,
1213
1218
  middleware: validateMiddlewareConfig(userConfig.middleware) || {},
1214
1219
  notFound: userConfig.notFound || {},
@@ -26,7 +26,7 @@ import {
26
26
  import {
27
27
  collectFarmNativeServerFns,
28
28
  findFarmNativeScreenFiles
29
- } from "./chunk-2CQC5CMD.mjs";
29
+ } from "./chunk-WIJF3PBM.mjs";
30
30
  import {
31
31
  generateNativeMCPPluginSource
32
32
  } from "./chunk-KQH2COEJ.mjs";
@@ -41,7 +41,7 @@ import {
41
41
  hasFarmDocsRuntimeAdapter,
42
42
  listFarmDocsAdapterPages,
43
43
  listFarmDocsPagePaths
44
- } from "./chunk-4OD2LXF2.mjs";
44
+ } from "./chunk-VAWDGGW3.mjs";
45
45
  import {
46
46
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
47
47
  createFarmDocsHandler,
@@ -65,7 +65,7 @@ import {
65
65
  } from "./chunk-OAEDVXVE.mjs";
66
66
  import {
67
67
  FARM_PRERENDER_ENV
68
- } from "./chunk-QUFENL7Q.mjs";
68
+ } from "./chunk-DS7JGFW5.mjs";
69
69
  import {
70
70
  loadFarmDocsEngine
71
71
  } from "./chunk-VE3FWJBO.mjs";
@@ -74,7 +74,7 @@ import {
74
74
  getDeployTargetForPreset,
75
75
  hasCustomFarmRouteContext,
76
76
  resolveDeployOutputPath
77
- } from "./chunk-IYDJNCR7.mjs";
77
+ } from "./chunk-OSMUE5ST.mjs";
78
78
  import {
79
79
  resolveFarmInstrumentationFile
80
80
  } from "./chunk-57QAQU4F.mjs";
@@ -110,7 +110,7 @@ import {
110
110
  resolveFarmImageServerRuntime,
111
111
  resolveFarmNotFoundComponentPath,
112
112
  resolveFarmRouteRootStrategy
113
- } from "./chunk-GUU3IZSM.mjs";
113
+ } from "./chunk-5XFKWHZD.mjs";
114
114
  import {
115
115
  generateFarmClientPluginEntryCode,
116
116
  hasFarmServerRuntimePlugins,
@@ -123,7 +123,7 @@ import {
123
123
  generateFarmTypeArtifacts,
124
124
  readRouteRenderingDirectiveFromFile,
125
125
  resolveRouteRenderingConfigFromFile
126
- } from "./chunk-W2T6NDNP.mjs";
126
+ } from "./chunk-DGNMXL2O.mjs";
127
127
  import {
128
128
  HOISTED_HEAD_ELEMENT,
129
129
  appMiddlewareMayHandlePath,
@@ -136,7 +136,7 @@ import {
136
136
  layoutsCanCoverSamePage,
137
137
  routeBoundaryCoversDirectory,
138
138
  stripRouteGroups
139
- } from "./chunk-NA77GEIU.mjs";
139
+ } from "./chunk-NV26EGMC.mjs";
140
140
  import {
141
141
  FARM_NATIVE_TREE_CONTENT_TYPE
142
142
  } from "./chunk-LLZSYFOM.mjs";
@@ -150,7 +150,7 @@ import {
150
150
  listFarmBuiltInRoutePaths,
151
151
  resolveFarmApiCatalogInput,
152
152
  resolveFarmAppManifestInput
153
- } from "./chunk-MITIAOUQ.mjs";
153
+ } from "./chunk-645ENY7W.mjs";
154
154
  import {
155
155
  FARM_DEFAULT_MCP_PATH,
156
156
  createFarmDefaultMCPServer,
@@ -158,7 +158,7 @@ import {
158
158
  } from "./chunk-JMFTKNBA.mjs";
159
159
  import {
160
160
  isFarmPreviewDeploymentEnvironment
161
- } from "./chunk-V25GSH43.mjs";
161
+ } from "./chunk-AUAMXI6N.mjs";
162
162
  import {
163
163
  FARM_NATIVE_SERVER_FN_PLUGIN
164
164
  } from "./chunk-L4RTTTVE.mjs";
@@ -176,7 +176,7 @@ import {
176
176
  usePackageClientBoundaryCacheFile,
177
177
  usesFarmServerTree,
178
178
  withPackageClientBoundaryCache
179
- } from "./chunk-X7LGLF33.mjs";
179
+ } from "./chunk-3JN5M3T5.mjs";
180
180
  import {
181
181
  generateFarmDocsAdapterClientRuntime,
182
182
  getFarmDocsAdapterConfigModule
@@ -255,10 +255,10 @@ import {
255
255
  } from "./chunk-MMK4MZUN.mjs";
256
256
  import {
257
257
  APIRouteManager
258
- } from "./chunk-E77IA5IF.mjs";
258
+ } from "./chunk-RLFGKJQ6.mjs";
259
259
  import {
260
260
  readFarmI18nCatalogs
261
- } from "./chunk-DU4VHHPJ.mjs";
261
+ } from "./chunk-VO55MMBX.mjs";
262
262
  import {
263
263
  VERCEL_OG_INSTALL_HINT
264
264
  } from "./chunk-NR63PD3P.mjs";
@@ -283,14 +283,14 @@ import {
283
283
  } from "./chunk-2I6PUKWJ.mjs";
284
284
  import {
285
285
  FARM_VERSION
286
- } from "./chunk-RJUCNO7R.mjs";
287
- import {
288
- normalizeFarmTrailingSlashPathname
289
- } from "./chunk-4O26BPUY.mjs";
286
+ } from "./chunk-77VNYVVX.mjs";
290
287
  import {
291
288
  getFarmPresetRuntime,
292
289
  resolveCloudflareProcessEnvFlags
293
290
  } from "./chunk-IWJONXPF.mjs";
291
+ import {
292
+ normalizeFarmTrailingSlashPathname
293
+ } from "./chunk-4O26BPUY.mjs";
294
294
  import {
295
295
  _runWithFarmCspNonce
296
296
  } from "./chunk-5OFNUETM.mjs";
@@ -1041,14 +1041,40 @@ function buildFarmVercelRoutes(options) {
1041
1041
  function escapeRegExp2(value) {
1042
1042
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1043
1043
  }
1044
+ var FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH = 4096;
1045
+ function groupFarmVercelRouteAlternatives(items, alternative) {
1046
+ const groups = [];
1047
+ let current = null;
1048
+ const frame = 6;
1049
+ for (const item of items) {
1050
+ const part = alternative(item);
1051
+ if (part.length + frame > FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH) {
1052
+ throw new Error(
1053
+ `Farm cannot route ${JSON.stringify(part.slice(0, 80))}\u2026 on Vercel: its pattern is longer than Vercel's ${FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH}-character limit for a route. Shorten the page's path.`
1054
+ );
1055
+ }
1056
+ if (current && current.length + 1 + part.length > FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH) {
1057
+ groups.push({ src: `^(?:${current.parts.join("|")})$`, items: current.items });
1058
+ current = null;
1059
+ }
1060
+ if (!current) current = { parts: [], items: [], length: frame - 1 };
1061
+ current.parts.push(part);
1062
+ current.items.push(item);
1063
+ current.length += 1 + part.length;
1064
+ }
1065
+ if (current) groups.push({ src: `^(?:${current.parts.join("|")})$`, items: current.items });
1066
+ return groups;
1067
+ }
1044
1068
  function createFarmVercelCanonicalSlashRoutes(publicPaths) {
1045
1069
  const otherSpellings = [
1046
1070
  ...new Set(
1047
1071
  publicPaths.filter((pathname) => pathname !== "/").map((pathname) => pathname.endsWith("/") ? pathname.replace(/\/+$/, "") : `${pathname}/`).filter((pathname) => pathname !== "")
1048
1072
  )
1049
1073
  ];
1050
- if (otherSpellings.length === 0) return [];
1051
- return [{ src: `^(?:${otherSpellings.map(escapeRegExp2).join("|")})$`, dest: "/__nitro" }];
1074
+ return groupFarmVercelRouteAlternatives(otherSpellings, escapeRegExp2).map((group) => ({
1075
+ src: group.src,
1076
+ dest: "/__nitro"
1077
+ }));
1052
1078
  }
1053
1079
 
1054
1080
  // src/nitro/ssr-public-assets.ts
@@ -1459,18 +1485,17 @@ function toFarmVercelEdgeGuardedUrls(pathnames, basePath) {
1459
1485
  ...new Set(pathnames.flatMap((pathname) => [pathname, applyFarmBasePath(pathname, basePath)]))
1460
1486
  ];
1461
1487
  }
1462
- function createFarmVercelEdgeMiddlewareRoute(pathnames, basePath = "/") {
1488
+ function createFarmVercelEdgeMiddlewareRoutes(pathnames, basePath = "/") {
1463
1489
  const publicPaths = toFarmVercelEdgeGuardedUrls(pathnames, basePath);
1464
- const alternatives = publicPaths.map((pathname) => {
1490
+ return groupFarmVercelRouteAlternatives(publicPaths, (pathname) => {
1465
1491
  const trimmed = pathname.replace(/\/+$/, "");
1466
1492
  return trimmed ? `${escapeRegExp3(trimmed)}(?:/|/index\\.html|\\.html)?` : "/(?:index\\.html)?";
1467
- });
1468
- return {
1469
- src: `^(?:${alternatives.join("|")})$`,
1493
+ }).map((group) => ({
1494
+ src: group.src,
1470
1495
  middlewarePath: FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION,
1471
- middlewareRawSrc: publicPaths,
1496
+ middlewareRawSrc: group.items,
1472
1497
  continue: true
1473
- };
1498
+ }));
1474
1499
  }
1475
1500
  function generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages) {
1476
1501
  const imports = routes.map(
@@ -4426,7 +4451,8 @@ ${generateUniversalRouterStateProperties()}
4426
4451
  this.currentHistoryState = options.popState;
4427
4452
  }
4428
4453
 
4429
- this.saveScrollPosition(window.location.pathname + window.location.search);
4454
+ // Save under the page still on screen: on Back/Forward the URL already names the destination.
4455
+ this.saveScrollPosition(from);
4430
4456
  const navigation = this.startNavigation(from, url, action);
4431
4457
  let clientNavigation;
4432
4458
  try {
@@ -5636,7 +5662,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5636
5662
  // A route transition invalidates any trigger waiting on the previous DOM boundary.
5637
5663
  cancelPendingPageHydration();
5638
5664
  this.stopNavigationStream();
5639
- this.saveScrollPosition(window.location.pathname + window.location.search);
5665
+ // Save under the page still on screen: on Back/Forward the URL already names the destination.
5666
+ this.saveScrollPosition(from);
5640
5667
  const navigation = this.startNavigation(from, url, action);
5641
5668
  // A refresh keeps the islands still on the page (islands mode).
5642
5669
  navigation.refresh = options.refresh === true;
@@ -6203,13 +6230,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6203
6230
  specRoute: config.openapi.specRoute || null
6204
6231
  };
6205
6232
  }
6206
- const discoveredMiddlewareRoutes = await discoverMiddlewareRoutes(appDirs);
6207
- const middlewareRoutes = farmTargetRunsEdgeMiddleware(preset) ? await Promise.all(
6208
- discoveredMiddlewareRoutes.map(async (route) => ({
6233
+ const middlewareRoutes = await Promise.all(
6234
+ (await discoverMiddlewareRoutes(appDirs)).map(async (route) => ({
6209
6235
  ...route,
6210
6236
  config: await readMiddlewareFileConfig(route.filePath)
6211
6237
  }))
6212
- ) : discoveredMiddlewareRoutes;
6238
+ );
6213
6239
  const instrumentationPath = resolveFarmInstrumentationFile(root, config.srcDir || "src");
6214
6240
  const notFoundPath = resolveFarmNotFoundComponentPath(config, appDirs);
6215
6241
  if (notFoundPath) logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
@@ -7135,11 +7161,12 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7135
7161
  const varName = `pageRoute${index}`;
7136
7162
  if (isFarmMarkdownPageFile(route.modulePath)) {
7137
7163
  const renderingDirective2 = readRouteRenderingDirectiveFromFile(route.modulePath);
7164
+ const markdownServerTree = pageHydrationPlanOptions.serverOwners && usesFarmServerTree(pageHydrationPlans.get(route.modulePath));
7138
7165
  pageRegistrations.push(`
7139
7166
  {
7140
7167
  pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
7141
7168
  directory: ${JSON.stringify(route.directory)},` : ""}${renderingDirective2 ? `
7142
- rendering: ${JSON.stringify(renderingDirective2)},` : ""}
7169
+ rendering: ${JSON.stringify(renderingDirective2)},` : ""}${markdownServerTree ? "\n serverTree: true," : ""}
7143
7170
  module: createFarmMarkdownRouteModule({
7144
7171
  source: ${JSON.stringify(route.source ?? "")},
7145
7172
  filePath: ${JSON.stringify(toBakedMarkdownSourcePath(config.root, route.modulePath))},
@@ -8590,12 +8617,98 @@ async function renderFarmElement(ReactDOMServer, element, routeKey, flushToken =
8590
8617
  return { html, head: "", shellHtml: html, streamErrors };
8591
8618
  }
8592
8619
 
8593
- async function renderFarmElementToString(ReactDOMServer, element) {
8594
- const rendered = await renderFarmElement(ReactDOMServer, element);
8595
- if (rendered.html !== undefined) return rendered.html;
8596
- const html = await new Response(rendered.stream).text();
8597
- if (rendered.streamErrors.length > 0) throw rendered.streamErrors[0];
8598
- return html;
8620
+ // The not-found and error documents go out whole, with their status, so they never stream.
8621
+ // renderToString renders a tree that does not suspend in one synchronous pass, but throws "A
8622
+ // component suspended while responding to synchronous input" when a lazy component or a use()
8623
+ // read suspends outside a Suspense boundary, and leaves a boundary that suspends inside one to
8624
+ // the client (<!--$!-->). Such a document renders with the streaming renderer instead, which
8625
+ // sends nothing until every boundary is done, so the output is the resolved markup without
8626
+ // fallbacks or reveal scripts. A document that suspended once keeps that renderer for the rest
8627
+ // of this server process, as a page route that suspends keeps streaming. As for pages, a
8628
+ // response with a CSP nonce or a posted form state renders with the stream, which takes them.
8629
+ // Renderers other than React wait for their own async content in renderToString.
8630
+ const farmSuspendingDocuments = new Set();
8631
+
8632
+ async function renderFarmCompleteDocument(ReactDOMServer, element, documentKey) {
8633
+ if (!farmReactSyncRender || !canRenderFarmElementWhenAllReady(ReactDOMServer)) {
8634
+ return await ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
8635
+ }
8636
+ if (!farmSuspendingDocuments.has(documentKey) &&
8637
+ !_resolveCurrentCspNonce() &&
8638
+ farmFormState() === undefined) {
8639
+ let html;
8640
+ try {
8641
+ html = ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
8642
+ } catch {
8643
+ // A real render error fails the streaming render the same way.
8644
+ }
8645
+ if (typeof html === "string" && !html.includes("<!--$!-->")) return html;
8646
+ farmSuspendingDocuments.add(documentKey);
8647
+ }
8648
+ return await renderFarmElementWhenAllReady(ReactDOMServer, element);
8649
+ }
8650
+
8651
+ function canRenderFarmElementWhenAllReady(ReactDOMServer) {
8652
+ return (farmRendererStreamingCapabilities.web &&
8653
+ typeof ReactDOMServer.renderToReadableStream === "function") ||
8654
+ (farmRendererStreamingCapabilities.node &&
8655
+ typeof ReactDOMServer.renderToPipeableStream === "function");
8656
+ }
8657
+
8658
+ async function renderFarmElementWhenAllReady(ReactDOMServer, element) {
8659
+ const onError = function(error) {
8660
+ // After the shell, a failed boundary is rendered by the client, as on a page.
8661
+ if (isFarmRedirectError(error) || isFarmNotFoundError(error)) return;
8662
+ console.error("[Farm SSR stream]", error);
8663
+ };
8664
+ // Completed boundaries larger than this would stream behind their fallback: keep them inline.
8665
+ const progressiveChunkSize = Number.MAX_SAFE_INTEGER;
8666
+ if (farmRendererStreamingCapabilities.web &&
8667
+ typeof ReactDOMServer.renderToReadableStream === "function") {
8668
+ const stream = await ReactDOMServer.renderToReadableStream(element, {
8669
+ nonce: _resolveCurrentCspNonce(),
8670
+ formState: farmFormState(),
8671
+ progressiveChunkSize,
8672
+ onError,
8673
+ });
8674
+ await stream.allReady;
8675
+ return await new Response(stream).text();
8676
+ }
8677
+ return await new Promise(function(resolve, reject) {
8678
+ const chunks = [];
8679
+ const decoder = new TextDecoder();
8680
+ const destination = {
8681
+ write(chunk) {
8682
+ chunks.push(typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }));
8683
+ return true;
8684
+ },
8685
+ flush() {},
8686
+ end() {
8687
+ chunks.push(decoder.decode());
8688
+ resolve(chunks.join(""));
8689
+ },
8690
+ on() {
8691
+ return destination;
8692
+ },
8693
+ destroy(error) {
8694
+ reject(error || new Error("React server render stream was destroyed"));
8695
+ },
8696
+ };
8697
+ const pipeableStream = ReactDOMServer.renderToPipeableStream(element, {
8698
+ nonce: _resolveCurrentCspNonce(),
8699
+ formState: farmFormState(),
8700
+ progressiveChunkSize,
8701
+ onAllReady() {
8702
+ try {
8703
+ pipeableStream.pipe(destination);
8704
+ } catch (error) {
8705
+ reject(error);
8706
+ }
8707
+ },
8708
+ onShellError: reject,
8709
+ onError,
8710
+ });
8711
+ });
8599
8712
  }
8600
8713
 
8601
8714
  // Most pages render without suspending. React's renderToString renders them in
@@ -8777,6 +8890,50 @@ function opensFarmFullDocument(markup) {
8777
8890
  return /^<!doctype/i.test(inner) || /^<html[\\s>]/i.test(inner);
8778
8891
  }
8779
8892
 
8893
+ // The head elements a component renders (<meta>, <title>, preloads), which React writes ahead of
8894
+ // a render whose root is not <html>, split off for the document's head. A full document keeps
8895
+ // them: its own head takes them. Matches the dev renderer's takeFarmHoistedHead.
8896
+ function takeFarmHoistedHead(markup) {
8897
+ if (opensFarmFullDocument(markup)) return { head: "", body: markup };
8898
+ const hoistable = /${HOISTED_HEAD_ELEMENT.source}/i;
8899
+ let head = "";
8900
+ let body = markup;
8901
+ let match;
8902
+ while ((match = hoistable.exec(body.replace(/^\\s+/, "")))) {
8903
+ head += match[0];
8904
+ body = body.replace(/^\\s+/, "").slice(match[0].length);
8905
+ }
8906
+ return { head: head, body: body };
8907
+ }
8908
+
8909
+ // A rendered page with the head elements React wrote first moved to its head field, for Farm's shell to
8910
+ // put in the document's head. A streamed page's first chunk is its shellHtml: those bytes are
8911
+ // dropped from the stream.
8912
+ function takeFarmRenderedHead(rendered) {
8913
+ if (rendered.head) return rendered;
8914
+ if (rendered.html !== undefined) {
8915
+ const split = takeFarmHoistedHead(rendered.html);
8916
+ if (!split.head) return rendered;
8917
+ return Object.assign({}, rendered, { html: split.body, shellHtml: split.body, head: split.head });
8918
+ }
8919
+ const shell = rendered.shellHtml || "";
8920
+ const split = takeFarmHoistedHead(shell);
8921
+ if (!split.head) return rendered;
8922
+ let left = new TextEncoder().encode(shell.slice(0, shell.length - split.body.length)).byteLength;
8923
+ const stream = rendered.stream.pipeThrough(new TransformStream({
8924
+ transform(chunk, controller) {
8925
+ if (left > 0) {
8926
+ const dropped = Math.min(left, chunk.byteLength);
8927
+ left -= dropped;
8928
+ chunk = chunk.subarray(dropped);
8929
+ if (chunk.byteLength === 0) return;
8930
+ }
8931
+ controller.enqueue(chunk);
8932
+ },
8933
+ }));
8934
+ return Object.assign({}, rendered, { stream: stream, shellHtml: split.body, head: split.head });
8935
+ }
8936
+
8780
8937
  function extractFarmFullDocument(markup) {
8781
8938
  if (!opensFarmFullDocument(markup)) return null;
8782
8939
  const hoisted = peelFarmDocumentPrefix(markup).hoisted;
@@ -11152,9 +11309,10 @@ ${hasServerRuntimeIntegrations ? `
11152
11309
  wrappedElement = wrapWithFarmIntegrationProviders(wrappedElement);
11153
11310
  return renderFarmElement(ReactDOMServer, wrappedElement, route.pattern, farmFlushToken);
11154
11311
  };
11155
- const renderedPage = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
11312
+ // The head elements a component rendered go to the document's head (takeFarmRenderedHead).
11313
+ const renderedPage = takeFarmRenderedHead(${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
11156
11314
  _runWithMiddlewareContext(middlewareContext, renderPageElement)
11157
- )` : "await renderPageElement()"};
11315
+ )` : "await renderPageElement()"});
11158
11316
 
11159
11317
  // A completed document is not a reusable PPR shell: it already contains
11160
11318
  // the request's resolved Suspense content. Until the production runtime
@@ -11394,7 +11552,8 @@ ${hasServerRuntimeIntegrations ? `
11394
11552
  ' <meta charset="utf-8">\\n' +
11395
11553
  ' ' + viewportTags + '\\n' +
11396
11554
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
11397
- ' <title>' + title + '</title>' + metaTags + '\\n' +
11555
+ (suppressDefaultTitle ? '' : ' <title>' + title + '</title>') + metaTags +
11556
+ (rendererHead ? '\\n ' + rendererHead : '') + '\\n' +
11398
11557
  ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
11399
11558
  ' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
11400
11559
  renderFarmRendererHydrationScript() + '\\n' +
@@ -11421,9 +11580,10 @@ ${hasServerRuntimeIntegrations ? `
11421
11580
  }
11422
11581
  try {
11423
11582
  return createLateNotFoundRecovery(
11424
- await ReactDOMServer.renderToString(
11583
+ await renderFarmCompleteDocument(
11584
+ ReactDOMServer,
11425
11585
  wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname)),
11426
- getFarmRendererRenderOptions()
11586
+ "not-found-recovery"
11427
11587
  )
11428
11588
  );
11429
11589
  } catch (error) {
@@ -11581,7 +11741,9 @@ ${hasServerRuntimeIntegrations ? `
11581
11741
  pprCacheKey,
11582
11742
  { html: fullHtml },
11583
11743
  {
11584
- paths: [pathname],
11744
+ // revalidatePath() takes the route path ("/pricing"), as the docs show, while the
11745
+ // shell answers the public one ("/console/fr/pricing"): either clears it.
11746
+ paths: [...new Set([pathname, getFarmRoutePathname(pathname)])],
11585
11747
  tags: ["ppr"],
11586
11748
  revalidate: pprConfig.revalidate ?? false,
11587
11749
  }
@@ -11712,7 +11874,12 @@ ${servesDefaultMCP ? `
11712
11874
  errorElement = wrapWithFarmIntegrationProviders(errorElement);
11713
11875
 
11714
11876
  const renderErrorElement = () =>
11715
- renderFarmElementToString(ReactDOMServer, errorElement);
11877
+ renderFarmCompleteDocument(
11878
+ ReactDOMServer,
11879
+ // Islands mode: the error document writes its islands' values, as a page does.
11880
+ typeof farmIslandsRender === "function" ? farmIslandsRender(errorElement) : errorElement,
11881
+ "error:" + errorBoundaryMatch.route.pattern
11882
+ );
11716
11883
  const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
11717
11884
  _runWithMiddlewareContext(middlewareContext, renderErrorElement)
11718
11885
  )` : "await renderErrorElement()"};
@@ -11853,7 +12020,7 @@ ${farmRendererDisabled ? `
11853
12020
  }
11854
12021
  notFoundElement = wrapWithFarmIntegrationProviders(notFoundElement);
11855
12022
 
11856
- const html = await ReactDOMServer.renderToString(notFoundElement, getFarmRendererRenderOptions());
12023
+ const html = await renderFarmCompleteDocument(ReactDOMServer, notFoundElement, "not-found");
11857
12024
  // The layouts' and the not-found page's metadata, as the development renderer uses it.
11858
12025
  const notFoundMetadata = renderMetadataHead(
11859
12026
  await resolveFarmNotFoundMetadata(
@@ -13360,7 +13527,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
13360
13527
  vercelConfig.routes = buildFarmVercelRoutes({
13361
13528
  presetRoutes: Array.isArray(vercelConfig.routes) ? vercelConfig.routes : [],
13362
13529
  runtimeRoutes,
13363
- middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? [createFarmVercelEdgeMiddlewareRoute(edgeMiddleware.guardedPages, config.basePath)] : [],
13530
+ middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? createFarmVercelEdgeMiddlewareRoutes(edgeMiddleware.guardedPages, config.basePath) : [],
13364
13531
  canonicalSlashRoutes: createFarmVercelCanonicalSlashRoutes(prerenderedPages)
13365
13532
  });
13366
13533
  const vercelConfigWithWorkflowCrons = applyFarmWorkflowVercelCrons(