@farm.js/core 0.1.18 → 0.1.20

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 (189) hide show
  1. package/dist/agent-runtime.d.mts +2 -3
  2. package/dist/agent-runtime.d.ts +2 -3
  3. package/dist/api/route-manager.cjs +5 -5
  4. package/dist/api/route-manager.d.mts +2 -3
  5. package/dist/api/route-manager.d.ts +2 -3
  6. package/dist/api/route-manager.mjs +4 -4
  7. package/dist/api.cjs +6 -6
  8. package/dist/api.d.mts +3 -4
  9. package/dist/api.d.ts +3 -4
  10. package/dist/api.mjs +5 -5
  11. package/dist/{app-BHY_10Lm.d.ts → app-DAyPE-gr.d.ts} +11 -4
  12. package/dist/{app-BMk0do23.d.mts → app-D_6nTit-.d.mts} +11 -4
  13. package/dist/app-markdown.cjs +4 -4
  14. package/dist/app-markdown.d.mts +3 -4
  15. package/dist/app-markdown.d.ts +3 -4
  16. package/dist/app-markdown.mjs +3 -3
  17. package/dist/{chunk-FS7FLPOG.mjs → chunk-2J7W2WND.mjs} +3 -2
  18. package/dist/{chunk-YS3TRKCG.mjs → chunk-2M435BUE.mjs} +6 -1
  19. package/dist/{chunk-WJ3HK3LJ.cjs → chunk-2QLBIPFT.cjs} +4 -4
  20. package/dist/{chunk-FJSWYIR7.cjs → chunk-3IL5UC5I.cjs} +2 -2
  21. package/dist/chunk-43FMW62B.mjs +67 -0
  22. package/dist/{chunk-A7T6345N.mjs → chunk-5UX4C5QI.mjs} +10 -7
  23. package/dist/{chunk-KPNVGRBL.mjs → chunk-5V37LKBG.mjs} +105 -41
  24. package/dist/chunk-75WGQVQA.cjs +46 -0
  25. package/dist/{chunk-ZCNJKLA2.mjs → chunk-7BC6GAL7.mjs} +1 -1
  26. package/dist/{chunk-J2OP5GG3.cjs → chunk-A777V5WU.cjs} +28 -28
  27. package/dist/{chunk-NWOD6NIT.cjs → chunk-A7T6JZNI.cjs} +1 -1
  28. package/dist/{chunk-E2BMSZ2W.cjs → chunk-AH7HOAQ3.cjs} +2 -2
  29. package/dist/{chunk-AFOD3LYZ.cjs → chunk-B3WK4DTX.cjs} +10 -9
  30. package/dist/{chunk-TWGMSEHX.cjs → chunk-BBVSJVBZ.cjs} +88 -13
  31. package/dist/{chunk-AORPIPNB.cjs → chunk-BHJUZ64B.cjs} +18 -14
  32. package/dist/chunk-BMWDEBXO.cjs +67 -0
  33. package/dist/{chunk-ATERBVHQ.mjs → chunk-CQHFU55R.mjs} +5 -4
  34. package/dist/{chunk-XSKZORAS.cjs → chunk-DX4VKYAJ.cjs} +5 -5
  35. package/dist/{chunk-AWRISO2H.cjs → chunk-E2ROOWQC.cjs} +30 -4
  36. package/dist/{chunk-3XG26Z3J.mjs → chunk-F7E2AZKQ.mjs} +1 -1
  37. package/dist/{chunk-7WPA7GBZ.mjs → chunk-GHFS7RUB.mjs} +1 -1
  38. package/dist/{chunk-UN5GHC5V.cjs → chunk-GQFSCBKJ.cjs} +249 -185
  39. package/dist/{chunk-NZ2JVBT2.mjs → chunk-GZ3ZPTQV.mjs} +2 -2
  40. package/dist/{chunk-DHDVMXYK.mjs → chunk-HALDNTIV.mjs} +30 -4
  41. package/dist/{chunk-5QOEPUYE.mjs → chunk-HSDL2AUR.mjs} +1 -1
  42. package/dist/{chunk-BSTRERPP.cjs → chunk-I5YBCWQ6.cjs} +2 -2
  43. package/dist/{chunk-TYQUSXUG.cjs → chunk-ISTFC3MZ.cjs} +4 -4
  44. package/dist/{chunk-RKQVJN2O.mjs → chunk-JIKGGIOL.mjs} +1 -1
  45. package/dist/{chunk-GYKJCFTS.mjs → chunk-K6MG3SEG.mjs} +124 -82
  46. package/dist/{chunk-OXSIH4D6.cjs → chunk-KNPRCKXK.cjs} +6 -1
  47. package/dist/{chunk-TNBAYAWO.mjs → chunk-L4DVIHOC.mjs} +1 -1
  48. package/dist/{chunk-XWAYMDLB.mjs → chunk-MVUREHPN.mjs} +1 -1
  49. package/dist/{chunk-6VQIKZZO.mjs → chunk-N255VYFP.mjs} +1 -1
  50. package/dist/{chunk-GNEO2XOF.cjs → chunk-NBAHDVOJ.cjs} +4 -4
  51. package/dist/{chunk-EN7WTEAY.mjs → chunk-NRS46D4L.mjs} +2 -2
  52. package/dist/{chunk-A72YEUZ3.mjs → chunk-OCE65DDM.mjs} +1 -1
  53. package/dist/{chunk-SXHV42UQ.mjs → chunk-OFEY6KHO.mjs} +88 -13
  54. package/dist/{chunk-OIEOCXKG.cjs → chunk-OYDRPBBV.cjs} +2 -2
  55. package/dist/{chunk-76DG3LF3.mjs → chunk-PGQBL5DN.mjs} +1 -1
  56. package/dist/{chunk-UDBJCUPA.mjs → chunk-PUCUVI7K.mjs} +11 -7
  57. package/dist/{chunk-IKNRN4VS.cjs → chunk-PZX6I4JW.cjs} +462 -420
  58. package/dist/{chunk-GDSHDTJ4.cjs → chunk-Q5B3KJBP.cjs} +2 -2
  59. package/dist/{chunk-TSWW5BVH.mjs → chunk-QMV4QELL.mjs} +1 -1
  60. package/dist/{chunk-QGVJVSNX.mjs → chunk-RMIJFZU3.mjs} +28 -4
  61. package/dist/{chunk-MKB2EGIR.cjs → chunk-SOR334EB.cjs} +3 -2
  62. package/dist/{chunk-57J3Y7Y3.mjs → chunk-TIKNUAU7.mjs} +3 -2
  63. package/dist/chunk-VVBO3QH7.mjs +46 -0
  64. package/dist/{chunk-UTBVHYS3.mjs → chunk-W7MZXRXM.mjs} +20 -5
  65. package/dist/{chunk-Y53ZSFN6.cjs → chunk-WM6HL7E7.cjs} +4 -3
  66. package/dist/{chunk-WZMNW2IW.cjs → chunk-XFFQSD2F.cjs} +4 -4
  67. package/dist/{chunk-62YJ2IEB.cjs → chunk-XI3GWPUS.cjs} +23 -20
  68. package/dist/{chunk-KVFPGF2M.cjs → chunk-YJJLXIIS.cjs} +7 -7
  69. package/dist/{chunk-NV3A5DXM.cjs → chunk-YP5JZ4LF.cjs} +42 -18
  70. package/dist/{chunk-B4CH33IG.cjs → chunk-ZE6ONQ5R.cjs} +39 -24
  71. package/dist/{client-plugins-JXXmZliS.d.mts → client-plugins-CWrhb1ir.d.mts} +26 -3
  72. package/dist/{client-plugins-C089bQhN.d.ts → client-plugins-DPf0qZey.d.ts} +26 -3
  73. package/dist/client-plugins.d.mts +2 -3
  74. package/dist/client-plugins.d.ts +2 -3
  75. package/dist/client.cjs +4 -4
  76. package/dist/client.d.mts +9 -38
  77. package/dist/client.d.ts +9 -38
  78. package/dist/client.mjs +3 -3
  79. package/dist/config.d.mts +2 -3
  80. package/dist/config.d.ts +2 -3
  81. package/dist/{devtools-UFVTMQX5.mjs → devtools-MTB5SA2B.mjs} +5 -5
  82. package/dist/{devtools-OUIPHVV6.cjs → devtools-R6MDDAZK.cjs} +9 -9
  83. package/dist/docs.cjs +9 -8
  84. package/dist/docs.d.mts +2 -2
  85. package/dist/docs.d.ts +2 -2
  86. package/dist/docs.mjs +8 -7
  87. package/dist/index.cjs +29 -28
  88. package/dist/index.d.mts +14 -14
  89. package/dist/index.d.ts +14 -14
  90. package/dist/index.mjs +28 -27
  91. package/dist/integrations.d.mts +2 -3
  92. package/dist/integrations.d.ts +2 -3
  93. package/dist/internal/app-markdown-runtime.cjs +3 -3
  94. package/dist/internal/app-markdown-runtime.d.mts +2 -3
  95. package/dist/internal/app-markdown-runtime.d.ts +2 -3
  96. package/dist/internal/app-markdown-runtime.mjs +2 -2
  97. package/dist/internal/build-runtime.cjs +22 -21
  98. package/dist/internal/build-runtime.d.mts +4 -5
  99. package/dist/internal/build-runtime.d.ts +4 -5
  100. package/dist/internal/build-runtime.mjs +21 -20
  101. package/dist/internal/cli-runtime.cjs +12 -12
  102. package/dist/internal/cli-runtime.mjs +11 -11
  103. package/dist/internal/client-error-overlay.cjs +4 -4
  104. package/dist/internal/client-error-overlay.mjs +1 -1
  105. package/dist/internal/compression-runtime.d.mts +2 -3
  106. package/dist/internal/compression-runtime.d.ts +2 -3
  107. package/dist/internal/config-runtime.cjs +6 -6
  108. package/dist/internal/config-runtime.d.mts +3 -4
  109. package/dist/internal/config-runtime.d.ts +3 -4
  110. package/dist/internal/config-runtime.mjs +5 -5
  111. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  112. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  113. package/dist/internal/production-runtime.cjs +5 -5
  114. package/dist/internal/production-runtime.d.mts +8 -9
  115. package/dist/internal/production-runtime.d.ts +8 -9
  116. package/dist/internal/production-runtime.mjs +4 -4
  117. package/dist/markdown.cjs +2 -2
  118. package/dist/markdown.mjs +1 -1
  119. package/dist/{metadata-C1Z9vLbb.d.mts → metadata-CO9fRyyJ.d.mts} +1 -1
  120. package/dist/{metadata-BcNJP4fq.d.ts → metadata-zY9wltwH.d.ts} +1 -1
  121. package/dist/middleware.cjs +4 -4
  122. package/dist/middleware.d.mts +4 -11
  123. package/dist/middleware.d.ts +4 -11
  124. package/dist/middleware.mjs +3 -3
  125. package/dist/navigation.cjs +5 -5
  126. package/dist/navigation.d.mts +42 -3
  127. package/dist/navigation.d.ts +42 -3
  128. package/dist/navigation.mjs +4 -4
  129. package/dist/{nitro-CVZ36JM5.mjs → nitro-4LFVTT24.mjs} +2 -2
  130. package/dist/{nitro-4I2MYLY2.cjs → nitro-TSGDUJMN.cjs} +3 -3
  131. package/dist/plugin.cjs +23 -17
  132. package/dist/plugin.d.mts +3 -4
  133. package/dist/plugin.d.ts +3 -4
  134. package/dist/plugin.mjs +23 -17
  135. package/dist/{production-runtime-jcrTlRTb.d.mts → production-runtime-CywsHwnG.d.mts} +1 -1
  136. package/dist/{production-runtime-oKmC0WU-.d.ts → production-runtime-lkfwujwK.d.ts} +1 -1
  137. package/dist/query/client.cjs +6 -6
  138. package/dist/query/client.mjs +2 -2
  139. package/dist/{render-plan-DOB9cV-h.d.ts → render-plan-DHF0GeWo.d.ts} +1 -1
  140. package/dist/{render-plan-BLIfc4jt.d.mts → render-plan-LVy6sGQe.d.mts} +1 -1
  141. package/dist/renderer-client.cjs +5 -5
  142. package/dist/renderer-client.d.mts +4 -5
  143. package/dist/renderer-client.d.ts +4 -5
  144. package/dist/renderer-client.mjs +2 -2
  145. package/dist/renderer.d.mts +3 -0
  146. package/dist/renderer.d.ts +3 -0
  147. package/dist/{request-Cr53NRHr.d.mts → request-6AkmhEYE.d.mts} +1 -1
  148. package/dist/{request-Dt2gNuQD.d.ts → request-BYxlRqA9.d.ts} +1 -1
  149. package/dist/request.d.mts +3 -4
  150. package/dist/request.d.ts +3 -4
  151. package/dist/{route-rendering-CWYd8Mv1.d.ts → route-rendering-CWaKiUbS.d.ts} +1 -1
  152. package/dist/{route-rendering-CeFBEAoZ.d.mts → route-rendering-Dd8Jmml7.d.mts} +1 -1
  153. package/dist/router-B2m4fvve.d.ts +50 -0
  154. package/dist/router-xwEE112q.d.mts +50 -0
  155. package/dist/routes.cjs +3 -3
  156. package/dist/routes.d.mts +2 -3
  157. package/dist/routes.d.ts +2 -3
  158. package/dist/routes.mjs +2 -2
  159. package/dist/{schema-dev-notice-2IE2F2XI.mjs → schema-dev-notice-O67CPXJ6.mjs} +1 -1
  160. package/dist/{schema-dev-notice-MXSZMVDG.cjs → schema-dev-notice-Y7MQEFGN.cjs} +3 -3
  161. package/dist/server-plugins.d.mts +3 -4
  162. package/dist/server-plugins.d.ts +3 -4
  163. package/dist/server.cjs +33 -32
  164. package/dist/server.d.mts +8 -9
  165. package/dist/server.d.ts +8 -9
  166. package/dist/server.mjs +19 -18
  167. package/dist/{spa-router-CQWiYGxS.d.mts → spa-router-DVEHQnWo.d.mts} +3 -3
  168. package/dist/{spa-router-Wjiw-8hB.d.ts → spa-router-Y8rrXTVK.d.ts} +3 -3
  169. package/dist/testing.cjs +6 -6
  170. package/dist/testing.d.mts +2 -3
  171. package/dist/testing.d.ts +2 -3
  172. package/dist/testing.mjs +5 -5
  173. package/dist/{types-D-1WTE72.d.mts → types-DFbjpjXX.d.mts} +8 -0
  174. package/dist/{types-D-1WTE72.d.ts → types-DFbjpjXX.d.ts} +8 -0
  175. package/dist/{utils-uUxF0K0P.d.mts → utils-DSPx34-A.d.mts} +1 -1
  176. package/dist/{utils-B0XJmG_b.d.ts → utils-Dvuny_08.d.ts} +1 -1
  177. package/dist/version.cjs +2 -2
  178. package/dist/version.mjs +1 -1
  179. package/dist/vite.cjs +18 -17
  180. package/dist/vite.d.mts +2 -3
  181. package/dist/vite.d.ts +2 -3
  182. package/dist/vite.mjs +17 -16
  183. package/package.json +3 -3
  184. package/dist/chunk-7GNWGLWB.mjs +0 -14
  185. package/dist/chunk-VQDBNVOO.cjs +0 -14
  186. package/dist/navigation-errors-Dvwpzaer.d.mts +0 -13
  187. package/dist/navigation-errors-Dvwpzaer.d.ts +0 -13
  188. /package/dist/{chunk-IAMRBF3Z.cjs → chunk-N4RLRSWW.cjs} +0 -0
  189. /package/dist/{chunk-BNGS6KJ6.mjs → chunk-YOYF2E4U.mjs} +0 -0
@@ -21,7 +21,7 @@ import {
21
21
  readSchemaState,
22
22
  readSchemaTables,
23
23
  withoutRenameTargets
24
- } from "./chunk-DHDVMXYK.mjs";
24
+ } from "./chunk-HALDNTIV.mjs";
25
25
  import {
26
26
  resolveSchemaModels
27
27
  } from "./chunk-ZMSZZXOR.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createFarmMarkdownRouteModule
3
- } from "./chunk-6VQIKZZO.mjs";
3
+ } from "./chunk-N255VYFP.mjs";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-LPEX4YW6.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requestAcceptsMarkdown
3
- } from "./chunk-SXHV42UQ.mjs";
3
+ } from "./chunk-OFEY6KHO.mjs";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-LPEX4YW6.mjs";
@@ -11,7 +11,7 @@ var _chunkKGZIORNLcjs = require('./chunk-KGZIORNL.cjs');
11
11
  var _chunkHREOKQWTcjs = require('./chunk-HREOKQWT.cjs');
12
12
 
13
13
 
14
- var _chunkTWGMSEHXcjs = require('./chunk-TWGMSEHX.cjs');
14
+ var _chunkBBVSJVBZcjs = require('./chunk-BBVSJVBZ.cjs');
15
15
 
16
16
 
17
17
  var _chunkEM6SBQKMcjs = require('./chunk-EM6SBQKM.cjs');
@@ -1194,11 +1194,11 @@ function shouldReturnMarkdown(request) {
1194
1194
  if (url.pathname.endsWith(".md")) return true;
1195
1195
  const accept = request.headers.get("accept");
1196
1196
  const markdown = Math.max(
1197
- _chunkTWGMSEHXcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1198
- _chunkTWGMSEHXcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1197
+ _chunkBBVSJVBZcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1198
+ _chunkBBVSJVBZcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1199
1199
  );
1200
1200
  if (markdown <= 0) return false;
1201
- return markdown >= _chunkTWGMSEHXcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1201
+ return markdown >= _chunkBBVSJVBZcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1202
1202
  }
1203
1203
  _chunkS3JO3N4Hcjs.__name.call(void 0, shouldReturnMarkdown, "shouldReturnMarkdown");
1204
1204
  function escapeAttribute(value) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readSchemaTables
3
- } from "./chunk-DHDVMXYK.mjs";
3
+ } from "./chunk-HALDNTIV.mjs";
4
4
  import {
5
5
  resolveSchemaModels
6
6
  } from "./chunk-ZMSZZXOR.mjs";
@@ -26,7 +26,7 @@ import {
26
26
  } from "./chunk-OLYK7EAK.mjs";
27
27
  import {
28
28
  discoverProgrammaticRoutePaths
29
- } from "./chunk-BNGS6KJ6.mjs";
29
+ } from "./chunk-YOYF2E4U.mjs";
30
30
  import {
31
31
  readFarmI18nCatalogs
32
32
  } from "./chunk-FV45CKBC.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MiddlewareManager
3
- } from "./chunk-57J3Y7Y3.mjs";
3
+ } from "./chunk-TIKNUAU7.mjs";
4
4
  import {
5
5
  resolveFarmI18nConfig
6
6
  } from "./chunk-YMCXWPWK.mjs";
@@ -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";
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-IOEH4VWN.mjs";
7
7
  import {
8
8
  APIRouteConflictError
9
- } from "./chunk-ATERBVHQ.mjs";
9
+ } from "./chunk-CQHFU55R.mjs";
10
10
  import {
11
11
  findProgrammaticRouteFilesInDir
12
- } from "./chunk-BNGS6KJ6.mjs";
12
+ } from "./chunk-YOYF2E4U.mjs";
13
13
  import {
14
14
  isFarmAPIRouteFileName
15
15
  } from "./chunk-CU625VAY.mjs";
@@ -31,6 +31,9 @@ import {
31
31
  import {
32
32
  createCliColors
33
33
  } from "./chunk-I2BHUNBU.mjs";
34
+ import {
35
+ loadFarmDevModule
36
+ } from "./chunk-43FMW62B.mjs";
34
37
  import {
35
38
  toPosixPath,
36
39
  toViteModuleId
@@ -249,7 +252,7 @@ function farmApiPlugin(options = {}) {
249
252
  try {
250
253
  const relativePath = path.relative(apiDir, path.dirname(filePath));
251
254
  const routePath = "/api/" + (relativePath === "." ? "" : relativePath.replace(/\\/g, "/"));
252
- const routeModule = await server.ssrLoadModule(filePath);
255
+ const routeModule = await loadFarmDevModule(server, filePath);
253
256
  const endpoints = {};
254
257
  const availableMethods = [];
255
258
  for (const method of API_ROUTE_METHODS) {
@@ -281,7 +284,7 @@ function farmApiPlugin(options = {}) {
281
284
  for (const routesFile of routesFiles) {
282
285
  if (fs.existsSync(routesFile)) {
283
286
  try {
284
- const routesModule = await server.ssrLoadModule(routesFile);
287
+ const routesModule = await loadFarmDevModule(server, routesFile);
285
288
  for (const [exportName, exportValue] of Object.entries(routesModule)) {
286
289
  const endpoint = exportValue;
287
290
  if (endpoint && endpoint.__path) {
@@ -307,7 +310,8 @@ function farmApiPlugin(options = {}) {
307
310
  const { getProgrammaticRouteManifest } = await import("./routes.mjs");
308
311
  for (const routeFile of routeFiles) {
309
312
  try {
310
- const routesModule = await server.ssrLoadModule(
313
+ const routesModule = await loadFarmDevModule(
314
+ server,
311
315
  toViteModuleId(routeFile, server.config.root)
312
316
  );
313
317
  const manifest = getProgrammaticRouteManifest(routesModule);
@@ -471,7 +475,7 @@ function farmApiPlugin(options = {}) {
471
475
  if (await recoverFailedDiscovery?.()) return [];
472
476
  const previousState = snapshotRouteState();
473
477
  try {
474
- const routesModule = await server.ssrLoadModule(file);
478
+ const routesModule = await loadFarmDevModule(server, file);
475
479
  removeEndpointsFromFile(file);
476
480
  for (const [exportName, exportValue] of Object.entries(routesModule)) {
477
481
  const endpoint = exportValue;
@@ -524,7 +528,7 @@ function farmApiPlugin(options = {}) {
524
528
  log(`API route file removed: ${routePath}`);
525
529
  return [];
526
530
  }
527
- const routeModule = await server.ssrLoadModule(file);
531
+ const routeModule = await loadFarmDevModule(server, file);
528
532
  removeEndpointsFromFile(file);
529
533
  const availableMethods = [];
530
534
  for (const method of API_ROUTE_METHODS) {