@farm.js/core 0.1.51-beta.2 → 0.1.51-beta.3

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 (183) hide show
  1. package/dist/{agent-mcp-handler-WWCC4GLG.mjs → agent-mcp-handler-7JSKGSOW.mjs} +4 -4
  2. package/dist/{agent-mcp-handler-RT3COCEL.cjs → agent-mcp-handler-YE4AGWHN.cjs} +5 -5
  3. package/dist/{agent-mcp.d-CR5Ov83o.d.ts → agent-mcp.d-BAR9njbJ.d.ts} +1 -1
  4. package/dist/{agent-mcp.d-Z5DuwrqW.d.mts → agent-mcp.d-BJKChOrO.d.mts} +1 -1
  5. package/dist/agent-runtime.d.mts +2 -2
  6. package/dist/agent-runtime.d.ts +2 -2
  7. package/dist/{analyzer-Z6TNEAET.mjs → analyzer-OTPEWH5W.mjs} +14 -3
  8. package/dist/{analyzer-T76CN3S7.cjs → analyzer-TSQXZCZN.cjs} +14 -3
  9. package/dist/api/route-manager.d.mts +4 -4
  10. package/dist/api/route-manager.d.ts +4 -4
  11. package/dist/api/runtime.d.mts +3 -3
  12. package/dist/api/runtime.d.ts +3 -3
  13. package/dist/api.d.mts +4 -4
  14. package/dist/api.d.ts +4 -4
  15. package/dist/{app-manifest.d-DiWr_Jfx.d.ts → app-manifest.d-BLFbaqx8.d.ts} +1 -1
  16. package/dist/{app-manifest.d-CAHkOBFa.d.mts → app-manifest.d-DEQNnNhV.d.mts} +1 -1
  17. package/dist/app-markdown.cjs +4 -4
  18. package/dist/app-markdown.d.mts +3 -3
  19. package/dist/app-markdown.d.ts +3 -3
  20. package/dist/app-markdown.mjs +3 -3
  21. package/dist/{app.d-DmapqkbV.d.ts → app.d-CNPaUYaa.d.ts} +4 -4
  22. package/dist/{app.d-BfgJCsTQ.d.mts → app.d-CT7xDkj2.d.mts} +4 -4
  23. package/dist/{chunk-YVJV7Q2X.mjs → chunk-3BLEXUGE.mjs} +1 -1
  24. package/dist/chunk-3HLQTOVU.cjs +6 -0
  25. package/dist/{chunk-E6LTONL4.mjs → chunk-3SMXQNFD.mjs} +2 -2
  26. package/dist/{chunk-PMKUU273.mjs → chunk-3TLKUBXG.mjs} +411 -166
  27. package/dist/{chunk-74Z5KX4A.mjs → chunk-3WSIYBMG.mjs} +41 -19
  28. package/dist/{chunk-GNJIYJMS.cjs → chunk-3XQ57EFI.cjs} +16 -16
  29. package/dist/{chunk-GW4YUIHW.mjs → chunk-3Z63X45F.mjs} +1 -1
  30. package/dist/{chunk-IBSAYAWB.mjs → chunk-4353ZRE5.mjs} +1 -1
  31. package/dist/{chunk-SBABQKPT.cjs → chunk-46KXZBOG.cjs} +5 -5
  32. package/dist/{chunk-YU42A5MA.cjs → chunk-4CGOMZP3.cjs} +221 -199
  33. package/dist/{chunk-J3LBO2O4.cjs → chunk-4SEHMBL4.cjs} +10 -10
  34. package/dist/{chunk-E73PGHSR.mjs → chunk-4TKAIO2F.mjs} +3 -3
  35. package/dist/{chunk-NJLTQR5P.cjs → chunk-53SACYBY.cjs} +7 -7
  36. package/dist/{chunk-FM2UEKS2.mjs → chunk-5FXPJIOT.mjs} +2 -2
  37. package/dist/{chunk-QXPSWMUD.cjs → chunk-7MD37P5V.cjs} +5 -5
  38. package/dist/{chunk-JATTVAHA.cjs → chunk-B3GM5I6N.cjs} +4 -4
  39. package/dist/{chunk-WJFFPXCV.cjs → chunk-D7UQC4O6.cjs} +10 -8
  40. package/dist/{chunk-KRRZJ77U.mjs → chunk-E5DXF5GE.mjs} +2 -2
  41. package/dist/chunk-EFZGB7JC.cjs +114 -0
  42. package/dist/{chunk-NYQSC4DX.cjs → chunk-FFE2EMF7.cjs} +5 -5
  43. package/dist/{chunk-CTM4SPB3.mjs → chunk-GAO7MS5O.mjs} +4 -3
  44. package/dist/{chunk-HIFIG6HL.cjs → chunk-H33PJEXN.cjs} +5 -5
  45. package/dist/{chunk-NXBHYO7S.cjs → chunk-HLWOWZFX.cjs} +2 -2
  46. package/dist/chunk-JXEPLIXD.cjs +389 -0
  47. package/dist/{chunk-NPQLMP7M.cjs → chunk-KLNFJDFM.cjs} +10 -9
  48. package/dist/{chunk-KBRZAYI7.mjs → chunk-LDNSSHEG.mjs} +2 -2
  49. package/dist/chunk-LLZSYFOM.mjs +6 -0
  50. package/dist/{chunk-N77JBPLC.mjs → chunk-LPDKG6RA.mjs} +9 -7
  51. package/dist/chunk-MIGFX2FN.mjs +758 -0
  52. package/dist/{chunk-72D2NX77.mjs → chunk-MRNDAJEV.mjs} +1 -1
  53. package/dist/{chunk-4SSRBCBR.mjs → chunk-NOTSHVRN.mjs} +355 -218
  54. package/dist/{chunk-GUJTVM36.cjs → chunk-OAMUSC7H.cjs} +1 -1
  55. package/dist/chunk-P6MHI5O2.cjs +758 -0
  56. package/dist/{chunk-6CYQQQGR.mjs → chunk-R4PHCZ3G.mjs} +1 -1
  57. package/dist/{chunk-WZW6LEHM.cjs → chunk-TQMI6BYO.cjs} +675 -430
  58. package/dist/{chunk-76GHW3WI.cjs → chunk-TSFMFPRU.cjs} +4 -4
  59. package/dist/{chunk-5N7QAGEA.cjs → chunk-TWHXBMLJ.cjs} +37 -7
  60. package/dist/{chunk-BOVGCUDZ.cjs → chunk-UJL4JOXV.cjs} +2 -2
  61. package/dist/chunk-UQF3OJVE.mjs +389 -0
  62. package/dist/{chunk-DTU4PX7V.cjs → chunk-WGUHDWT5.cjs} +557 -420
  63. package/dist/{chunk-LAZK6UV7.mjs → chunk-YAJTD3ZG.mjs} +1 -1
  64. package/dist/{chunk-7UPCJDB5.mjs → chunk-YUEYBL35.mjs} +2 -2
  65. package/dist/{chunk-EIMK7D2D.mjs → chunk-ZD2VKAUI.mjs} +34 -4
  66. package/dist/chunk-ZNXTU4YH.mjs +114 -0
  67. package/dist/{client-plugins.d-Bx3FXpqm.d.mts → client-plugins.d-DllmH8eM.d.mts} +17 -4
  68. package/dist/{client-plugins.d-TiLbS5j4.d.ts → client-plugins.d-n3iWY1EJ.d.ts} +17 -4
  69. package/dist/client-plugins.d.mts +2 -2
  70. package/dist/client-plugins.d.ts +2 -2
  71. package/dist/client.d.mts +7 -7
  72. package/dist/client.d.ts +7 -7
  73. package/dist/{config.d-iRPI16ku.d.ts → config.d-DqKaCr1r.d.mts} +8 -1
  74. package/dist/{config.d-iRPI16ku.d.mts → config.d-DqKaCr1r.d.ts} +8 -1
  75. package/dist/config.d.mts +2 -2
  76. package/dist/config.d.ts +2 -2
  77. package/dist/desktop.d.mts +3 -3
  78. package/dist/desktop.d.ts +3 -3
  79. package/dist/{devtools-6XWCZIGO.cjs → devtools-TO6TAO32.cjs} +5 -5
  80. package/dist/{devtools-UQLDAOEI.mjs → devtools-UESYARTF.mjs} +4 -4
  81. package/dist/docs.cjs +7 -7
  82. package/dist/docs.d.mts +3 -3
  83. package/dist/docs.d.ts +3 -3
  84. package/dist/docs.mjs +6 -6
  85. package/dist/index.cjs +22 -18
  86. package/dist/{index.d-YxJ2AiDF.d.mts → index.d-BL7KKiwa.d.mts} +1 -1
  87. package/dist/{index.d-yueUNipJ.d.ts → index.d-BXsAXm1U.d.ts} +1 -1
  88. package/dist/index.d.mts +17 -17
  89. package/dist/index.d.ts +17 -17
  90. package/dist/index.mjs +22 -18
  91. package/dist/integrations.d.mts +2 -2
  92. package/dist/integrations.d.ts +2 -2
  93. package/dist/internal/app-markdown-runtime.cjs +3 -3
  94. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  95. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  96. package/dist/internal/app-markdown-runtime.mjs +2 -2
  97. package/dist/internal/build-runtime.cjs +20 -18
  98. package/dist/internal/build-runtime.d.mts +4 -4
  99. package/dist/internal/build-runtime.d.ts +4 -4
  100. package/dist/internal/build-runtime.mjs +19 -17
  101. package/dist/internal/cli-runtime.cjs +7 -7
  102. package/dist/internal/cli-runtime.mjs +6 -6
  103. package/dist/internal/client-error-overlay.cjs +4 -4
  104. package/dist/internal/client-error-overlay.mjs +1 -1
  105. package/dist/internal/client-runtime.d.mts +5 -5
  106. package/dist/internal/client-runtime.d.ts +5 -5
  107. package/dist/internal/compression-runtime.d.mts +2 -2
  108. package/dist/internal/compression-runtime.d.ts +2 -2
  109. package/dist/internal/config-runtime.cjs +6 -6
  110. package/dist/internal/config-runtime.d.mts +31 -7
  111. package/dist/internal/config-runtime.d.ts +31 -7
  112. package/dist/internal/config-runtime.mjs +5 -5
  113. package/dist/internal/infra-analytics-runtime.cjs +8 -8
  114. package/dist/internal/infra-analytics-runtime.mjs +6 -6
  115. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  116. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  117. package/dist/internal/production-runtime.cjs +87 -9
  118. package/dist/internal/production-runtime.d.mts +44 -12
  119. package/dist/internal/production-runtime.d.ts +44 -12
  120. package/dist/internal/production-runtime.mjs +86 -8
  121. package/dist/markdown.cjs +4 -2
  122. package/dist/markdown.d.mts +2 -2
  123. package/dist/markdown.d.ts +2 -2
  124. package/dist/markdown.mjs +3 -1
  125. package/dist/middleware.d.mts +4 -4
  126. package/dist/middleware.d.ts +4 -4
  127. package/dist/mobile.d.mts +21 -5
  128. package/dist/mobile.d.ts +21 -5
  129. package/dist/native-tree-EBPDFTRW.mjs +25 -0
  130. package/dist/native-tree-MMZS7S6W.cjs +25 -0
  131. package/dist/{navigation-delegate.d-HnDXhlyP.d.mts → navigation-delegate.d-C76gXTmO.d.mts} +1 -1
  132. package/dist/{navigation-delegate.d-BY1e_Xrh.d.ts → navigation-delegate.d-DIyDslxt.d.ts} +1 -1
  133. package/dist/navigation.d.mts +5 -5
  134. package/dist/navigation.d.ts +5 -5
  135. package/dist/plugin.cjs +14 -13
  136. package/dist/plugin.d.mts +5 -4
  137. package/dist/plugin.d.ts +5 -4
  138. package/dist/plugin.mjs +13 -12
  139. package/dist/{production-runtime.d-BpJUDzP8.d.mts → production-runtime.d-CDHztggO.d.mts} +1 -1
  140. package/dist/{production-runtime.d-lMjvE9cf.d.ts → production-runtime.d-tyaGdbk6.d.ts} +1 -1
  141. package/dist/{programmatic-routes-client.d-BlFp5hv4.d.ts → programmatic-routes-client.d-XfmIrCK1.d.ts} +2 -2
  142. package/dist/{programmatic-routes-client.d-6CGQ3TCk.d.mts → programmatic-routes-client.d-aAWiDd64.d.mts} +2 -2
  143. package/dist/{render-plan.d-BH9edqKs.d.mts → render-plan.d-Diwybxo8.d.mts} +1 -1
  144. package/dist/{render-plan.d-DhP0mTHF.d.ts → render-plan.d-Dr5WRjoV.d.ts} +1 -1
  145. package/dist/renderer-client.d.mts +5 -5
  146. package/dist/renderer-client.d.ts +5 -5
  147. package/dist/{request.d-BVZrsR1v.d.ts → request.d-D01fRn--.d.ts} +1 -1
  148. package/dist/{request.d-DJFRdKi8.d.mts → request.d-Dd3AFR79.d.mts} +1 -1
  149. package/dist/request.d.mts +3 -3
  150. package/dist/request.d.ts +3 -3
  151. package/dist/{route-rendering.d-Bpmw7PED.d.mts → route-rendering.d-BQ53lJ_D.d.mts} +1 -1
  152. package/dist/{route-rendering.d-B00JtK_-.d.ts → route-rendering.d-Bhx4QoJt.d.ts} +1 -1
  153. package/dist/{router.d-e0jQ3jQ-.d.mts → router.d-Bi23a6Xc.d.mts} +1 -1
  154. package/dist/{router.d-Bd1x9XxQ.d.ts → router.d-DQ3k7EYn.d.ts} +1 -1
  155. package/dist/{routes.d-Cmv8TgVq.d.mts → routes.d-BgTd7vI4.d.mts} +3 -3
  156. package/dist/{routes.d-D96Dq9lz.d.ts → routes.d-C7jMJFvP.d.ts} +3 -3
  157. package/dist/routes.d.mts +2 -2
  158. package/dist/routes.d.ts +2 -2
  159. package/dist/{rsc-pipeline-ZQ4CTVEG.mjs → rsc-pipeline-K3ER3Q4N.mjs} +5 -5
  160. package/dist/{rsc-pipeline-DX4OC5FN.cjs → rsc-pipeline-OCZIT5OF.cjs} +6 -6
  161. package/dist/{runtime-NQ3EDSA7.cjs → runtime-DKNSIH7V.cjs} +30 -23
  162. package/dist/{runtime-NPDRDV6R.mjs → runtime-MKYDEUZT.mjs} +20 -13
  163. package/dist/{runtime.d-CgB3IJDq.d.mts → runtime.d-B2Js6qZ2.d.mts} +1 -1
  164. package/dist/{runtime.d-D-td-RR3.d.ts → runtime.d-BL-CGwoi.d.ts} +1 -1
  165. package/dist/server-plugins.d.mts +3 -3
  166. package/dist/server-plugins.d.ts +3 -3
  167. package/dist/server.cjs +31 -30
  168. package/dist/server.d.mts +11 -10
  169. package/dist/server.d.ts +11 -10
  170. package/dist/server.mjs +16 -15
  171. package/dist/{spa-router.d-BWDhS0FK.d.mts → spa-router.d-B2rIFGs0.d.mts} +2 -2
  172. package/dist/{spa-router.d-CO01mVOM.d.ts → spa-router.d-DqZ6Lfs0.d.ts} +2 -2
  173. package/dist/testing.d.mts +2 -2
  174. package/dist/testing.d.ts +2 -2
  175. package/dist/{utils.d-B77__yh8.d.ts → utils.d-Bv2MPeLR.d.ts} +1 -1
  176. package/dist/{utils.d-DRDazhCA.d.mts → utils.d-fqXe8lNc.d.mts} +1 -1
  177. package/dist/version.cjs +2 -2
  178. package/dist/version.mjs +1 -1
  179. package/dist/vite.cjs +14 -13
  180. package/dist/vite.d.mts +12 -6
  181. package/dist/vite.d.ts +12 -6
  182. package/dist/vite.mjs +13 -12
  183. package/package.json +1 -1
@@ -30,10 +30,10 @@ import {
30
30
  renderFarmLocaleAlternateLinks,
31
31
  resolveDefaultErrorStatus,
32
32
  routeBoundaryCoversDirectory
33
- } from "./chunk-7UPCJDB5.mjs";
33
+ } from "./chunk-YUEYBL35.mjs";
34
34
  import {
35
35
  listFarmMCPLlmsTxtLinks
36
- } from "./chunk-E73PGHSR.mjs";
36
+ } from "./chunk-4TKAIO2F.mjs";
37
37
  import {
38
38
  FARM_DEFAULT_MCP_PATH,
39
39
  collectFarmDefaultMCPPages,
@@ -41,7 +41,7 @@ import {
41
41
  farmConfigMountsMCP,
42
42
  isFarmDefaultMCPPathname,
43
43
  resolveFarmDefaultMCPServer
44
- } from "./chunk-KRRZJ77U.mjs";
44
+ } from "./chunk-E5DXF5GE.mjs";
45
45
  import {
46
46
  createFarmMetadataImageResponse
47
47
  } from "./chunk-OZK2DS44.mjs";
@@ -64,10 +64,10 @@ import {
64
64
  import {
65
65
  createFarmMarkdownRouteModuleFromFile,
66
66
  loadFarmMdxComponents
67
- } from "./chunk-YVJV7Q2X.mjs";
67
+ } from "./chunk-3BLEXUGE.mjs";
68
68
  import {
69
69
  isFarmMarkdownPageFile
70
- } from "./chunk-GW4YUIHW.mjs";
70
+ } from "./chunk-3Z63X45F.mjs";
71
71
  import {
72
72
  _setDefaultFarmThemeConfig,
73
73
  getTheme
@@ -105,14 +105,14 @@ import {
105
105
  resolveFarmAgentCrawlers,
106
106
  resolveFarmAgentSitemap,
107
107
  resolveFarmPerformanceConfig
108
- } from "./chunk-KBRZAYI7.mjs";
108
+ } from "./chunk-LDNSSHEG.mjs";
109
109
  import {
110
110
  collectFarmLlmsTxtPages,
111
111
  createFarmDefaultLlmsTxt,
112
112
  createFarmLlmsMarkdownReader,
113
113
  renderFarmLlmsFullTxt,
114
114
  resolveFarmLlmsTxtConfig
115
- } from "./chunk-LAZK6UV7.mjs";
115
+ } from "./chunk-YAJTD3ZG.mjs";
116
116
  import {
117
117
  createFarmCspNonce,
118
118
  createFarmCspNonceRewriter,
@@ -152,7 +152,7 @@ import {
152
152
  farmRequestWantsMarkdown,
153
153
  getFarmMarkdownAlternatePath,
154
154
  resolveMarkdownConfig
155
- } from "./chunk-N77JBPLC.mjs";
155
+ } from "./chunk-LPDKG6RA.mjs";
156
156
  import {
157
157
  initStorage
158
158
  } from "./chunk-TJVUTGED.mjs";
@@ -254,7 +254,7 @@ import {
254
254
  } from "./chunk-LM2YOGDK.mjs";
255
255
  import {
256
256
  FARM_VERSION
257
- } from "./chunk-6CYQQQGR.mjs";
257
+ } from "./chunk-R4PHCZ3G.mjs";
258
258
  import {
259
259
  resolveFarmTrailingSlashRedirect,
260
260
  setFarmTrailingSlashPreference
@@ -326,15 +326,240 @@ import {
326
326
  } from "./chunk-AYP2YFVN.mjs";
327
327
 
328
328
  // src/utils/client-component.ts
329
+ import fs2 from "fs";
330
+ import path2 from "path";
331
+ import { fileURLToPath } from "url";
332
+
333
+ // src/utils/package-client-boundary-cache.ts
334
+ import { AsyncLocalStorage } from "async_hooks";
329
335
  import fs from "fs";
330
336
  import path from "path";
331
- import { fileURLToPath } from "url";
337
+ var SCHEMA_VERSION = 1;
338
+ var NODE_MODULES_SEGMENT = `${path.sep}node_modules${path.sep}`;
339
+ var PackageInspectionTrace = class {
340
+ constructor() {
341
+ this.files = /* @__PURE__ */ new Set();
342
+ this.stops = /* @__PURE__ */ new Set();
343
+ this.fileStamps = [];
344
+ this.directoryStamps = /* @__PURE__ */ new Map();
345
+ }
346
+ visit(file) {
347
+ this.files.add(file);
348
+ const directory = path.dirname(file);
349
+ if (!this.directoryStamps.has(directory)) {
350
+ this.directoryStamps.set(directory, stampPackagePath(directory, "directory"));
351
+ }
352
+ this.fileStamps.push(stampPackagePath(file, "file"));
353
+ }
354
+ /** The inspection reached `file` after it was already visited. */
355
+ stop(file) {
356
+ if (!this.files.has(file)) this.stops.add(file);
357
+ }
358
+ toEntry(result) {
359
+ const entry = {
360
+ result: { ...result },
361
+ files: Array.from(this.files),
362
+ stops: Array.from(this.stops)
363
+ };
364
+ const files = this.fileStamps.filter((stamp) => stamp !== void 0);
365
+ const directories = Array.from(this.directoryStamps.values()).filter(
366
+ (stamp) => stamp !== void 0
367
+ );
368
+ if (files.length === this.fileStamps.length && directories.length === this.directoryStamps.size) {
369
+ entry.stamps = { files, directories };
370
+ }
371
+ return entry;
372
+ }
373
+ };
374
+ function stampPackagePath(target, kind) {
375
+ if (!`${target}${path.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
376
+ try {
377
+ const stat = fs.statSync(target, { throwIfNoEntry: false });
378
+ if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
379
+ return [target, stat.size, stat.mtimeMs, stat.ctimeMs];
380
+ } catch {
381
+ return void 0;
382
+ }
383
+ }
384
+ var PackageClientBoundaryCache = class {
385
+ constructor() {
386
+ this.entries = /* @__PURE__ */ new Map();
387
+ this.stored = /* @__PURE__ */ new Map();
388
+ this.storedPaths = [];
389
+ this.unchangedPaths = /* @__PURE__ */ new Map();
390
+ this.dirty = false;
391
+ }
392
+ load(file) {
393
+ this.file = file;
394
+ const stored = readStoredCache(file);
395
+ if (!stored) {
396
+ this.dirty = true;
397
+ return;
398
+ }
399
+ this.storedPaths = stored.paths;
400
+ this.stored = new Map(Object.entries(stored.entries));
401
+ }
402
+ /** An inspection of `key` that applies to `visited`. */
403
+ find(key, visited) {
404
+ let entries = this.entries.get(key);
405
+ const stored = this.stored.get(key);
406
+ if (stored) {
407
+ this.stored.delete(key);
408
+ entries ?? (entries = []);
409
+ this.entries.set(key, entries);
410
+ for (const entry of stored) {
411
+ const restored = this.restore(entry);
412
+ if (restored) entries.push(restored);
413
+ else this.dirty = true;
414
+ }
415
+ }
416
+ return entries?.find(
417
+ (entry) => entry.stops.every((file) => visited.has(file)) && !entry.files.some((file) => visited.has(file))
418
+ );
419
+ }
420
+ add(key, entry) {
421
+ const entries = this.entries.get(key);
422
+ if (entries) entries.push(entry);
423
+ else this.entries.set(key, [entry]);
424
+ if (entry.stamps) this.dirty = true;
425
+ }
426
+ async persist() {
427
+ const file = this.file;
428
+ if (!file || !this.dirty && this.stored.size === 0) return;
429
+ const paths = [];
430
+ const pathIndexes = /* @__PURE__ */ new Map();
431
+ const indexOf = (stamp) => {
432
+ let index = pathIndexes.get(stamp[0]);
433
+ if (index === void 0) {
434
+ index = paths.push(stamp) - 1;
435
+ pathIndexes.set(stamp[0], index);
436
+ }
437
+ return index;
438
+ };
439
+ const entries = {};
440
+ for (const [key, variants] of this.entries) {
441
+ const persisted = variants.flatMap(
442
+ ({ result, stops, stamps }) => stamps ? [
443
+ {
444
+ result,
445
+ files: stamps.files.map(indexOf),
446
+ directories: stamps.directories.map(indexOf),
447
+ stops
448
+ }
449
+ ] : []
450
+ );
451
+ if (persisted.length > 0) entries[key] = persisted;
452
+ }
453
+ const contents = JSON.stringify({
454
+ schema: SCHEMA_VERSION,
455
+ farm: FARM_VERSION,
456
+ paths,
457
+ entries
458
+ });
459
+ const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
460
+ try {
461
+ await fs.promises.mkdir(path.dirname(file), { recursive: true });
462
+ await fs.promises.writeFile(temporary, contents);
463
+ await fs.promises.rename(temporary, file);
464
+ } catch {
465
+ await fs.promises.rm(temporary, { force: true }).catch(() => {
466
+ });
467
+ }
468
+ }
469
+ restore(entry) {
470
+ const files = this.restoreStamps(entry.files, "file");
471
+ const directories = this.restoreStamps(entry.directories, "directory");
472
+ if (!files || !directories) return void 0;
473
+ return {
474
+ result: entry.result,
475
+ files: files.map(([file]) => file),
476
+ stops: entry.stops,
477
+ stamps: { files, directories }
478
+ };
479
+ }
480
+ restoreStamps(indexes, kind) {
481
+ const stamps = [];
482
+ for (const index of indexes) {
483
+ const stamp = this.storedPaths[index];
484
+ let unchanged = this.unchangedPaths.get(index);
485
+ if (unchanged === void 0) {
486
+ const current = stampPackagePath(stamp[0], kind);
487
+ unchanged = current !== void 0 && current[1] === stamp[1] && current[2] === stamp[2] && current[3] === stamp[3];
488
+ this.unchangedPaths.set(index, unchanged);
489
+ }
490
+ if (!unchanged) return void 0;
491
+ stamps.push(stamp);
492
+ }
493
+ return stamps;
494
+ }
495
+ };
496
+ function readStoredCache(file) {
497
+ let value;
498
+ try {
499
+ value = JSON.parse(fs.readFileSync(file, "utf8"));
500
+ } catch {
501
+ return null;
502
+ }
503
+ if (!isRecord(value) || value.schema !== SCHEMA_VERSION || value.farm !== FARM_VERSION) {
504
+ return null;
505
+ }
506
+ const { paths, entries } = value;
507
+ if (!Array.isArray(paths) || !paths.every(isPathStamp) || !isRecord(entries)) return null;
508
+ const valid = {};
509
+ for (const [key, variants] of Object.entries(entries)) {
510
+ if (!Array.isArray(variants)) continue;
511
+ const usable = variants.filter((entry) => isStoredEntry(entry, paths.length));
512
+ if (usable.length > 0) valid[key] = usable;
513
+ }
514
+ return { schema: SCHEMA_VERSION, farm: FARM_VERSION, paths, entries: valid };
515
+ }
516
+ function isRecord(value) {
517
+ return typeof value === "object" && value !== null && !Array.isArray(value);
518
+ }
519
+ function isPathStamp(value) {
520
+ return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" && path.isAbsolute(value[0]) && value.slice(1).every((part) => typeof part === "number" && Number.isFinite(part));
521
+ }
522
+ function isPathIndexList(value, pathCount) {
523
+ return Array.isArray(value) && value.length > 0 && value.every((index) => Number.isSafeInteger(index) && index >= 0 && index < pathCount);
524
+ }
525
+ function isStoredEntry(value, pathCount) {
526
+ if (!isRecord(value) || !isRecord(value.result)) return false;
527
+ const { isClientComponent, shouldHydrate, islandStrategy } = value.result;
528
+ return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" && path.isAbsolute(file)) && typeof isClientComponent === "boolean" && typeof shouldHydrate === "boolean" && (islandStrategy === null || isFarmIslandStrategy(islandStrategy)) && Object.keys(value.result).length === 3;
529
+ }
530
+ var STORAGE_KEY = /* @__PURE__ */ Symbol.for("@farm.js/core/package-client-boundary-cache");
531
+ function getStorage() {
532
+ const runtime = globalThis;
533
+ const existing = runtime[STORAGE_KEY];
534
+ if (existing instanceof AsyncLocalStorage) {
535
+ return existing;
536
+ }
537
+ const storage = new AsyncLocalStorage();
538
+ runtime[STORAGE_KEY] = storage;
539
+ return storage;
540
+ }
541
+ function getPackageClientBoundaryCache() {
542
+ return getStorage().getStore();
543
+ }
544
+ async function withPackageClientBoundaryCache(operation) {
545
+ const cache2 = new PackageClientBoundaryCache();
546
+ try {
547
+ return await getStorage().run(cache2, operation);
548
+ } finally {
549
+ await cache2.persist();
550
+ }
551
+ }
552
+ function usePackageClientBoundaryCacheFile(file) {
553
+ getPackageClientBoundaryCache()?.load(file);
554
+ }
555
+
556
+ // src/utils/client-component.ts
332
557
  function readIfExists(filePath) {
333
558
  try {
334
- if (!filePath || !fs.existsSync(filePath)) {
559
+ if (!filePath || !fs2.existsSync(filePath)) {
335
560
  return null;
336
561
  }
337
- return fs.readFileSync(filePath, "utf-8");
562
+ return fs2.readFileSync(filePath, "utf-8");
338
563
  } catch {
339
564
  return null;
340
565
  }
@@ -353,21 +578,21 @@ function resolveModuleSourcePath(modulePath, root) {
353
578
  }
354
579
  if (modulePath.startsWith("/@fs/")) {
355
580
  const fsPath = withoutQuery.slice("/@fs/".length);
356
- candidates.add(path.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
581
+ candidates.add(path2.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
357
582
  }
358
583
  }
359
584
  if (root && modulePath) {
360
585
  const normalized = withoutQuery.replace(/^\/+/, "");
361
- candidates.add(path.join(root, normalized));
362
- candidates.add(path.resolve(root, normalized));
586
+ candidates.add(path2.join(root, normalized));
587
+ candidates.add(path2.resolve(root, normalized));
363
588
  }
364
589
  if (withoutQuery?.startsWith("/src/")) {
365
590
  const normalized = withoutQuery.replace(/^\/+/, "");
366
- candidates.add(path.join(process.cwd(), normalized));
367
- candidates.add(path.resolve(process.cwd(), normalized));
591
+ candidates.add(path2.join(process.cwd(), normalized));
592
+ candidates.add(path2.resolve(process.cwd(), normalized));
368
593
  }
369
594
  for (const candidate of candidates) {
370
- if (fs.existsSync(candidate)) {
595
+ if (fs2.existsSync(candidate)) {
371
596
  return candidate;
372
597
  }
373
598
  }
@@ -384,8 +609,8 @@ var FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES = 4;
384
609
  function isolatedHydrationBoundaryLimit() {
385
610
  const benchmarkRoot = process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_ROOT;
386
611
  const benchmarkLimit = Number(process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_LIMIT);
387
- const resolvedBenchmarkRoot = benchmarkRoot ? path.resolve(benchmarkRoot) : null;
388
- const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path.sep}`));
612
+ const resolvedBenchmarkRoot = benchmarkRoot ? path2.resolve(benchmarkRoot) : null;
613
+ const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path2.sep}`));
389
614
  return isBenchmarkFixture && Number.isSafeInteger(benchmarkLimit) && benchmarkLimit > FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES ? benchmarkLimit : FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES;
390
615
  }
391
616
  var RESOLVABLE_SOURCE_EXTENSIONS = [
@@ -1225,7 +1450,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
1225
1450
  let fallbackReason;
1226
1451
  let fallbackHint;
1227
1452
  let costGuardExceeded = false;
1228
- const projectRoot = root ? path.resolve(root) : void 0;
1453
+ const projectRoot = root ? path2.resolve(root) : void 0;
1229
1454
  const visit = (moduleSourcePath) => {
1230
1455
  if (fallbackReason) return 0;
1231
1456
  const cached = estimates.get(moduleSourcePath);
@@ -1235,7 +1460,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
1235
1460
  const content = readIfExists(moduleSourcePath);
1236
1461
  const parsed = parseClientModuleMetadata(content, false);
1237
1462
  if (parsed.isClientComponent) {
1238
- if (projectRoot && !path.resolve(moduleSourcePath).startsWith(`${projectRoot}${path.sep}`)) {
1463
+ if (projectRoot && !path2.resolve(moduleSourcePath).startsWith(`${projectRoot}${path2.sep}`)) {
1239
1464
  fallbackReason = `client boundary ${moduleSourcePath} is outside the application root`;
1240
1465
  fallbackHint = "Move the component into the application, or publish it as a package (package client components render as static HTML)";
1241
1466
  return 0;
@@ -1368,7 +1593,24 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
1368
1593
  };
1369
1594
  }
1370
1595
  function inspectPackageClientBoundary(resolvedPath, root, visited) {
1596
+ const cache2 = getPackageClientBoundaryCache();
1597
+ if (!cache2 || !resolvedPath || visited.has(resolvedPath)) {
1598
+ return traversePackageClientBoundary(resolvedPath, root, visited);
1599
+ }
1600
+ const key = `${root ?? ""}\0${resolvedPath}`;
1601
+ const cached = cache2.find(key, visited);
1602
+ if (cached) {
1603
+ for (const file of cached.files) visited.add(file);
1604
+ return { ...cached.result };
1605
+ }
1606
+ const trace = new PackageInspectionTrace();
1607
+ const result = traversePackageClientBoundary(resolvedPath, root, visited, trace);
1608
+ cache2.add(key, trace.toEntry(result));
1609
+ return result;
1610
+ }
1611
+ function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
1371
1612
  if (!resolvedPath || visited.has(resolvedPath)) {
1613
+ if (resolvedPath) trace?.stop(resolvedPath);
1372
1614
  return {
1373
1615
  isClientComponent: false,
1374
1616
  shouldHydrate: false,
@@ -1376,6 +1618,7 @@ function inspectPackageClientBoundary(resolvedPath, root, visited) {
1376
1618
  };
1377
1619
  }
1378
1620
  visited.add(resolvedPath);
1621
+ trace?.visit(resolvedPath);
1379
1622
  const content = readIfExists(resolvedPath);
1380
1623
  const parsed = parseClientModuleMetadata(content, false);
1381
1624
  let importsClientBoundary = false;
@@ -1383,7 +1626,7 @@ function inspectPackageClientBoundary(resolvedPath, root, visited) {
1383
1626
  for (const specifier of getImportSpecifiers(content)) {
1384
1627
  if (!specifier.startsWith(".") && !specifier.startsWith("/")) continue;
1385
1628
  const importedPath = resolveImportedModuleSourcePath(resolvedPath, specifier, root);
1386
- const importedMetadata = inspectPackageClientBoundary(importedPath, root, visited);
1629
+ const importedMetadata = traversePackageClientBoundary(importedPath, root, visited, trace);
1387
1630
  if (!importedMetadata.shouldHydrate) continue;
1388
1631
  importsClientBoundary = true;
1389
1632
  if (importedIslandStrategy === null) {
@@ -1482,7 +1725,7 @@ var ALIAS_IMPORT = /^(?:@\/|~\/|#)/;
1482
1725
  function warnUnresolvedAliasImport(importerPath, specifier, root) {
1483
1726
  if (!ALIAS_IMPORT.test(specifier) || warnedUnresolvedAliasImports.has(specifier)) return;
1484
1727
  warnedUnresolvedAliasImports.add(specifier);
1485
- const importer = root ? path.relative(root, importerPath) : importerPath;
1728
+ const importer = root ? path2.relative(root, importerPath) : importerPath;
1486
1729
  logger.warn(
1487
1730
  `Could not resolve "${specifier}" (imported by ${importer}) while checking which pages need client JavaScript. If it holds client components, they will not hydrate. Map the alias in tsconfig.json "paths" or package.json "imports".`
1488
1731
  );
@@ -1491,7 +1734,7 @@ var projectImportAliasCache = /* @__PURE__ */ new Map();
1491
1734
  var PROJECT_ALIAS_FILES = ["tsconfig.json", "jsconfig.json", "package.json"];
1492
1735
  function resolveProjectAliasSourcePath(specifier, root) {
1493
1736
  if (!root) return void 0;
1494
- const projectRoot = path.resolve(root);
1737
+ const projectRoot = path2.resolve(root);
1495
1738
  let match;
1496
1739
  for (const alias of getProjectImportAliases(projectRoot)) {
1497
1740
  const captured = matchProjectImportAlias(alias, specifier);
@@ -1501,7 +1744,7 @@ function resolveProjectAliasSourcePath(specifier, root) {
1501
1744
  if (!match) return void 0;
1502
1745
  const resolved = resolveSourceCandidate(
1503
1746
  match.alias.targets.map(
1504
- (target) => path.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
1747
+ (target) => path2.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
1505
1748
  )
1506
1749
  );
1507
1750
  return resolved && /\.d\.[cm]?ts$/.test(resolved) ? null : resolved;
@@ -1516,7 +1759,7 @@ function matchProjectImportAlias(alias, specifier) {
1516
1759
  function getProjectImportAliases(projectRoot) {
1517
1760
  const stamp = PROJECT_ALIAS_FILES.map((file) => {
1518
1761
  try {
1519
- return String(fs.statSync(path.join(projectRoot, file)).mtimeMs);
1762
+ return String(fs2.statSync(path2.join(projectRoot, file)).mtimeMs);
1520
1763
  } catch {
1521
1764
  return "-";
1522
1765
  }
@@ -1534,7 +1777,7 @@ function getProjectImportAliases(projectRoot) {
1534
1777
  prefix: "@/",
1535
1778
  suffix: "",
1536
1779
  wildcard: true,
1537
- targets: [path.join(projectRoot, sourceDir, "*")]
1780
+ targets: [path2.join(projectRoot, sourceDir, "*")]
1538
1781
  });
1539
1782
  }
1540
1783
  projectImportAliasCache.set(projectRoot, { stamp: cacheStamp, aliases });
@@ -1542,8 +1785,8 @@ function getProjectImportAliases(projectRoot) {
1542
1785
  }
1543
1786
  function readTsconfigPathAliases(projectRoot) {
1544
1787
  for (const name of ["tsconfig.json", "jsconfig.json"]) {
1545
- const configPath = path.join(projectRoot, name);
1546
- if (!fs.existsSync(configPath)) continue;
1788
+ const configPath = path2.join(projectRoot, name);
1789
+ if (!fs2.existsSync(configPath)) continue;
1547
1790
  const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
1548
1791
  if (!resolved?.paths) return [];
1549
1792
  const base = resolved.baseUrl ?? resolved.pathsDirectory;
@@ -1555,7 +1798,7 @@ function readTsconfigPathAliases(projectRoot) {
1555
1798
  prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
1556
1799
  suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
1557
1800
  wildcard: wildcardIndex !== -1,
1558
- targets: targets.filter((target) => typeof target === "string").map((target) => path.resolve(base, target))
1801
+ targets: targets.filter((target) => typeof target === "string").map((target) => path2.resolve(base, target))
1559
1802
  }
1560
1803
  ];
1561
1804
  });
@@ -1567,27 +1810,27 @@ function readTsconfigPaths(configPath, visited) {
1567
1810
  visited.add(configPath);
1568
1811
  const config = readJsonWithComments(configPath);
1569
1812
  if (!config) return null;
1570
- const directory = path.dirname(configPath);
1813
+ const directory = path2.dirname(configPath);
1571
1814
  const parents = (Array.isArray(config.extends) ? config.extends : [config.extends]).filter(
1572
1815
  (parent) => typeof parent === "string" && parent.startsWith(".")
1573
1816
  );
1574
1817
  let inherited = null;
1575
1818
  for (const parent of parents) {
1576
- const parentPath = path.resolve(
1819
+ const parentPath = path2.resolve(
1577
1820
  directory,
1578
1821
  parent.endsWith(".json") ? parent : `${parent}.json`
1579
1822
  );
1580
1823
  inherited = readTsconfigPaths(parentPath, visited) ?? inherited;
1581
1824
  }
1582
1825
  const options = config.compilerOptions ?? {};
1583
- const baseUrl = typeof options.baseUrl === "string" ? path.resolve(directory, options.baseUrl) : inherited?.baseUrl;
1826
+ const baseUrl = typeof options.baseUrl === "string" ? path2.resolve(directory, options.baseUrl) : inherited?.baseUrl;
1584
1827
  if (options.paths && typeof options.paths === "object") {
1585
1828
  return { paths: options.paths, pathsDirectory: directory, baseUrl };
1586
1829
  }
1587
1830
  return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
1588
1831
  }
1589
1832
  function readPackageImportAliases(projectRoot) {
1590
- const imports = readPackageJson(path.join(projectRoot, "package.json"))?.imports;
1833
+ const imports = readPackageJson(path2.join(projectRoot, "package.json"))?.imports;
1591
1834
  if (!imports || typeof imports !== "object") return [];
1592
1835
  return Object.entries(imports).flatMap(([pattern, value]) => {
1593
1836
  const target = resolveConditionalExportTarget(value);
@@ -1598,7 +1841,7 @@ function readPackageImportAliases(projectRoot) {
1598
1841
  prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
1599
1842
  suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
1600
1843
  wildcard: wildcardIndex !== -1,
1601
- targets: [path.resolve(projectRoot, target)]
1844
+ targets: [path2.resolve(projectRoot, target)]
1602
1845
  }
1603
1846
  ];
1604
1847
  });
@@ -1606,7 +1849,7 @@ function readPackageImportAliases(projectRoot) {
1606
1849
  function readJsonWithComments(filePath) {
1607
1850
  let source;
1608
1851
  try {
1609
- source = fs.readFileSync(filePath, "utf8");
1852
+ source = fs2.readFileSync(filePath, "utf8");
1610
1853
  } catch {
1611
1854
  return null;
1612
1855
  }
@@ -1644,7 +1887,7 @@ function resolveImportedModuleSourcePath(importerPath, specifier, root) {
1644
1887
  return resolvePackageModuleSourcePath(importerPath, specifier, root);
1645
1888
  }
1646
1889
  const candidates = /* @__PURE__ */ new Set();
1647
- const basePath = specifier.startsWith(".") ? path.resolve(path.dirname(importerPath), specifier) : root ? path.resolve(root, specifier.replace(/^\/+/, "")) : path.resolve(specifier);
1890
+ const basePath = specifier.startsWith(".") ? path2.resolve(path2.dirname(importerPath), specifier) : root ? path2.resolve(root, specifier.replace(/^\/+/, "")) : path2.resolve(specifier);
1648
1891
  candidates.add(basePath);
1649
1892
  return resolveSourceCandidate(candidates);
1650
1893
  }
@@ -1654,45 +1897,45 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
1654
1897
  const packageSubpath = packageParts.slice(packageName.startsWith("@") ? 2 : 1).join("/");
1655
1898
  const packageDirectory = findPackageDirectory(importerPath, packageName, root);
1656
1899
  if (!packageDirectory) return null;
1657
- const packageJsonPath = path.join(packageDirectory, "package.json");
1900
+ const packageJsonPath = path2.join(packageDirectory, "package.json");
1658
1901
  const packageJson = readPackageJson(packageJsonPath);
1659
1902
  const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
1660
1903
  const exportTarget = resolvePackageExport(packageJson?.exports, exportKey);
1661
1904
  const candidates = /* @__PURE__ */ new Set();
1662
1905
  if (exportTarget?.startsWith("./")) {
1663
- candidates.add(path.resolve(packageDirectory, exportTarget));
1906
+ candidates.add(path2.resolve(packageDirectory, exportTarget));
1664
1907
  }
1665
1908
  if (packageSubpath) {
1666
- candidates.add(path.join(packageDirectory, packageSubpath));
1909
+ candidates.add(path2.join(packageDirectory, packageSubpath));
1667
1910
  } else {
1668
1911
  for (const entry of [packageJson?.browser, packageJson?.module, packageJson?.main]) {
1669
- if (typeof entry === "string") candidates.add(path.resolve(packageDirectory, entry));
1912
+ if (typeof entry === "string") candidates.add(path2.resolve(packageDirectory, entry));
1670
1913
  }
1671
- candidates.add(path.join(packageDirectory, "index"));
1914
+ candidates.add(path2.join(packageDirectory, "index"));
1672
1915
  }
1673
1916
  return resolveSourceCandidate(candidates);
1674
1917
  }
1675
1918
  function findPackageDirectory(importerPath, packageName, root) {
1676
1919
  const searchRoots = /* @__PURE__ */ new Set();
1677
- let current = path.dirname(importerPath);
1920
+ let current = path2.dirname(importerPath);
1678
1921
  while (true) {
1679
1922
  searchRoots.add(current);
1680
- const parent = path.dirname(current);
1923
+ const parent = path2.dirname(current);
1681
1924
  if (parent === current) break;
1682
1925
  current = parent;
1683
1926
  }
1684
1927
  if (root) {
1685
- current = path.resolve(root);
1928
+ current = path2.resolve(root);
1686
1929
  while (true) {
1687
1930
  searchRoots.add(current);
1688
- const parent = path.dirname(current);
1931
+ const parent = path2.dirname(current);
1689
1932
  if (parent === current) break;
1690
1933
  current = parent;
1691
1934
  }
1692
1935
  }
1693
1936
  for (const searchRoot of searchRoots) {
1694
- const packageDirectory = path.join(searchRoot, "node_modules", packageName);
1695
- if (fs.existsSync(path.join(packageDirectory, "package.json"))) {
1937
+ const packageDirectory = path2.join(searchRoot, "node_modules", packageName);
1938
+ if (fs2.existsSync(path2.join(packageDirectory, "package.json"))) {
1696
1939
  return packageDirectory;
1697
1940
  }
1698
1941
  }
@@ -1700,7 +1943,7 @@ function findPackageDirectory(importerPath, packageName, root) {
1700
1943
  }
1701
1944
  function readPackageJson(packageJsonPath) {
1702
1945
  try {
1703
- return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
1946
+ return JSON.parse(fs2.readFileSync(packageJsonPath, "utf8"));
1704
1947
  } catch {
1705
1948
  return null;
1706
1949
  }
@@ -1758,11 +2001,11 @@ function resolveSourceCandidate(candidates) {
1758
2001
  for (const candidate of candidates) {
1759
2002
  const paths = [candidate];
1760
2003
  for (const extension of RESOLVABLE_SOURCE_EXTENSIONS) {
1761
- paths.push(`${candidate}${extension}`, path.join(candidate, `index${extension}`));
2004
+ paths.push(`${candidate}${extension}`, path2.join(candidate, `index${extension}`));
1762
2005
  }
1763
2006
  for (const sourcePath of paths) {
1764
2007
  try {
1765
- if (fs.statSync(sourcePath).isFile()) return sourcePath;
2008
+ if (fs2.statSync(sourcePath).isFile()) return sourcePath;
1766
2009
  } catch {
1767
2010
  }
1768
2011
  }
@@ -1772,12 +2015,12 @@ function resolveSourceCandidate(candidates) {
1772
2015
 
1773
2016
  // src/routing/route-manager.ts
1774
2017
  import { realpathSync } from "fs";
1775
- import path3 from "path";
2018
+ import path4 from "path";
1776
2019
 
1777
2020
  // src/static-metadata-image.ts
1778
2021
  import { createHash } from "crypto";
1779
2022
  import { readFile } from "fs/promises";
1780
- import path2 from "path";
2023
+ import path3 from "path";
1781
2024
  import { imageSize } from "image-size";
1782
2025
  var STATIC_METADATA_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp"];
1783
2026
  var CONTENT_TYPES = {
@@ -1818,13 +2061,13 @@ async function inspectStaticMetadataImage(filePath) {
1818
2061
  };
1819
2062
  }
1820
2063
  function getStaticMetadataImageAltPath(filePath) {
1821
- return path2.join(
1822
- path2.dirname(filePath),
1823
- `${path2.basename(filePath, path2.extname(filePath))}.alt.txt`
2064
+ return path3.join(
2065
+ path3.dirname(filePath),
2066
+ `${path3.basename(filePath, path3.extname(filePath))}.alt.txt`
1824
2067
  );
1825
2068
  }
1826
2069
  function getStaticMetadataImageExtension(filePath) {
1827
- const extension = path2.extname(filePath).slice(1).toLowerCase();
2070
+ const extension = path3.extname(filePath).slice(1).toLowerCase();
1828
2071
  return STATIC_METADATA_IMAGE_EXTENSIONS.includes(extension) ? extension : null;
1829
2072
  }
1830
2073
  async function readAltText(filePath) {
@@ -2152,14 +2395,14 @@ var RouteManager = class {
2152
2395
  * Requests still fetch route data, but never inspect component source.
2153
2396
  */
2154
2397
  generateClientManifest(projectRoot = this.config.root) {
2155
- const normalizedProjectRoot = path3.resolve(projectRoot);
2398
+ const normalizedProjectRoot = path4.resolve(projectRoot);
2156
2399
  if (this.clientManifestCache?.projectRoot === normalizedProjectRoot) {
2157
2400
  return this.clientManifestCache.manifest;
2158
2401
  }
2159
2402
  const toUrlPath = (absolutePath) => {
2160
2403
  const rootRelative = toRootRelativeUrlPath(absolutePath, normalizedProjectRoot);
2161
2404
  if (rootRelative !== void 0) return rootRelative;
2162
- if (path3.isAbsolute(absolutePath)) {
2405
+ if (path4.isAbsolute(absolutePath)) {
2163
2406
  const normalized = absolutePath.replace(/\\/g, "/");
2164
2407
  return normalized.startsWith("/") ? `/@fs${normalized}` : `/@fs/${normalized}`;
2165
2408
  }
@@ -2338,7 +2581,7 @@ var RouteManager = class {
2338
2581
  for (const { metadata } of [...layoutEntries, ...routeEntries]) {
2339
2582
  if (!metadata.hasIsolatedClientBoundaries && !metadata.serverTreeLayout) continue;
2340
2583
  for (const boundary of metadata.isolatedBoundaries) {
2341
- isolatedClientBoundaryModules.add(path3.resolve(boundary.modulePath));
2584
+ isolatedClientBoundaryModules.add(path4.resolve(boundary.modulePath));
2342
2585
  }
2343
2586
  }
2344
2587
  const islandsErrors = [
@@ -2389,7 +2632,7 @@ var RouteManager = class {
2389
2632
  }
2390
2633
  /** @internal Client modules selected by the compiled hydration ownership plan. */
2391
2634
  getIsolatedClientBoundaryModules(projectRoot = this.config.root) {
2392
- const normalizedProjectRoot = path3.resolve(projectRoot);
2635
+ const normalizedProjectRoot = path4.resolve(projectRoot);
2393
2636
  this.generateClientManifest(normalizedProjectRoot);
2394
2637
  return this.clientManifestCache?.isolatedClientBoundaryModules ?? /* @__PURE__ */ new Set();
2395
2638
  }
@@ -2398,7 +2641,7 @@ var RouteManager = class {
2398
2641
  * such a page whole would ship its server code to the browser, so it stays static instead.
2399
2642
  */
2400
2643
  getIslandsErrors(projectRoot = this.config.root) {
2401
- this.generateClientManifest(path3.resolve(projectRoot));
2644
+ this.generateClientManifest(path4.resolve(projectRoot));
2402
2645
  return this.clientManifestCache?.islandsErrors ?? [];
2403
2646
  }
2404
2647
  /**
@@ -2529,19 +2772,19 @@ var RouteManager = class {
2529
2772
  const markdownFiles = group.files.filter(isFarmMarkdownPageFile);
2530
2773
  if (componentFiles.length > 1) {
2531
2774
  throw new Error(
2532
- `Duplicate page route "${pattern}". Found ${componentFiles.map((file) => path3.join(appDir, file)).join(" and ")}.`
2775
+ `Duplicate page route "${pattern}". Found ${componentFiles.map((file) => path4.join(appDir, file)).join(" and ")}.`
2533
2776
  );
2534
2777
  }
2535
2778
  if (markdownFiles.length > 1) {
2536
2779
  throw new Error(
2537
- `Duplicate markdown representation for page route "${pattern}". Found ${markdownFiles.map((file) => path3.join(appDir, file)).join(" and ")}.`
2780
+ `Duplicate markdown representation for page route "${pattern}". Found ${markdownFiles.map((file) => path4.join(appDir, file)).join(" and ")}.`
2538
2781
  );
2539
2782
  }
2540
2783
  const componentFile = componentFiles[0];
2541
2784
  const markdownFile = markdownFiles[0];
2542
2785
  const primaryFile = componentFile || markdownFile;
2543
2786
  if (!primaryFile) continue;
2544
- const modulePath = path3.join(appDir, primaryFile);
2787
+ const modulePath = path4.join(appDir, primaryFile);
2545
2788
  const existing = this.routes.get(pattern);
2546
2789
  if (existing?.sourceRoot === source.root) {
2547
2790
  throw new Error(
@@ -2552,7 +2795,7 @@ var RouteManager = class {
2552
2795
  route: group.route,
2553
2796
  modulePath,
2554
2797
  ...markdownFile ? {
2555
- markdownSourcePath: path3.join(appDir, markdownFile)
2798
+ markdownSourcePath: path4.join(appDir, markdownFile)
2556
2799
  } : {},
2557
2800
  pattern,
2558
2801
  ...getPageDirectoryField(group.route, pattern),
@@ -2567,7 +2810,7 @@ var RouteManager = class {
2567
2810
  ]) {
2568
2811
  for (const file of files) {
2569
2812
  const route = parseRoutePath(file);
2570
- const modulePath = path3.join(appDir, file);
2813
+ const modulePath = path4.join(appDir, file);
2571
2814
  const pattern = createRouteDirectoryPattern(route);
2572
2815
  const existing = target.get(pattern);
2573
2816
  if (existing?.sourceRoot === source.root) {
@@ -2587,7 +2830,7 @@ var RouteManager = class {
2587
2830
  for (const file of [...pageFiles, ...slotDefaultFiles]) {
2588
2831
  const slot = parseRouteSlotFile(file);
2589
2832
  if (!slot) continue;
2590
- const modulePath = path3.join(appDir, file);
2833
+ const modulePath = path4.join(appDir, file);
2591
2834
  const pattern = this.createRoutePattern(slot.route);
2592
2835
  const ownerPattern = this.createRoutePattern(slot.ownerRoute);
2593
2836
  const ownerDirectory = createRouteDirectoryPattern(slot.ownerRoute);
@@ -2613,11 +2856,11 @@ var RouteManager = class {
2613
2856
  });
2614
2857
  }
2615
2858
  for (const file of metadataImageFiles) {
2616
- const fileBase = path3.basename(file, path3.extname(file));
2859
+ const fileBase = path4.basename(file, path4.extname(file));
2617
2860
  const kind = fileBase === "twitter-image" ? "twitter" : "opengraph";
2618
2861
  const fileName = kind === "twitter" ? "twitter-image" : "opengraph-image";
2619
2862
  const route = parseRoutePath(file);
2620
- const modulePath = path3.join(appDir, file);
2863
+ const modulePath = path4.join(appDir, file);
2621
2864
  const pattern = this.createRoutePattern(route);
2622
2865
  const key = `${kind}:${pattern}`;
2623
2866
  const existing = this.metadataImages.get(key);
@@ -2642,11 +2885,11 @@ var RouteManager = class {
2642
2885
  }
2643
2886
  for (const file of metadataRouteFiles) {
2644
2887
  const descriptor = getApplicationMetadataRouteDescriptor(
2645
- path3.basename(file, path3.extname(file))
2888
+ path4.basename(file, path4.extname(file))
2646
2889
  );
2647
2890
  if (!descriptor) continue;
2648
2891
  const route = parseRoutePath(file);
2649
- const modulePath = path3.join(appDir, file);
2892
+ const modulePath = path4.join(appDir, file);
2650
2893
  const pattern = this.createRoutePattern(route);
2651
2894
  const key = `${descriptor.kind}:${pattern}`;
2652
2895
  const existing = this.metadataRoutes.get(key);
@@ -3057,12 +3300,12 @@ function toRealPath(filePath) {
3057
3300
  }
3058
3301
 
3059
3302
  // src/server/dev-styles.ts
3060
- import * as fs2 from "fs";
3061
- import * as path4 from "path";
3303
+ import * as fs3 from "fs";
3304
+ import * as path5 from "path";
3062
3305
  function resolveDevGlobalStylesheetHref(root, srcDir = "src") {
3063
- const file = path4.join(root, srcDir, "app", "globals.css");
3064
- if (!fs2.existsSync(file)) return void 0;
3065
- return `/${path4.relative(root, file).split(path4.sep).join("/")}`;
3306
+ const file = path5.join(root, srcDir, "app", "globals.css");
3307
+ if (!fs3.existsSync(file)) return void 0;
3308
+ return `/${path5.relative(root, file).split(path5.sep).join("/")}`;
3066
3309
  }
3067
3310
  var STYLE_EXTENSIONS = /\.(css|scss|sass|less|styl|stylus)(?:$|\?)/;
3068
3311
  var ALREADY_LINKED = "/src/app/globals.css";
@@ -3085,7 +3328,7 @@ function collectDevStylesheetUrls(modules, alreadyLinked = ALREADY_LINKED) {
3085
3328
  import { createHash as createHash2, timingSafeEqual } from "crypto";
3086
3329
  import { existsSync as existsSync2 } from "fs";
3087
3330
  import { readFile as readFile2 } from "fs/promises";
3088
- import path5 from "path";
3331
+ import path6 from "path";
3089
3332
  import { createRequire } from "module";
3090
3333
  import { pathToFileURL } from "url";
3091
3334
  var FONT_IMPORTS = /* @__PURE__ */ new Set(["@farm.js/core", "@farm.js/core/font"]);
@@ -3442,7 +3685,7 @@ ${FONT_SECTION_END}
3442
3685
  return resource;
3443
3686
  }
3444
3687
  const bytes2 = await fetchRemoteFont(url, input.integrity);
3445
- return this.createSelfHostedResource(bytes2, extension, path5.basename(url.pathname));
3688
+ return this.createSelfHostedResource(bytes2, extension, path6.basename(url.pathname));
3446
3689
  }
3447
3690
  if (input.source.startsWith("/")) {
3448
3691
  return this.createPublicResource(input.moduleId, input.source);
@@ -3465,8 +3708,8 @@ ${FONT_SECTION_END}
3465
3708
  }
3466
3709
  return this.createSelfHostedResource(
3467
3710
  bytes,
3468
- path5.extname(resolvedPath),
3469
- path5.basename(resolvedPath)
3711
+ path6.extname(resolvedPath),
3712
+ path6.basename(resolvedPath)
3470
3713
  );
3471
3714
  }
3472
3715
  async createPublicResource(moduleId, source) {
@@ -3477,7 +3720,7 @@ ${FONT_SECTION_END}
3477
3720
  );
3478
3721
  }
3479
3722
  const publicPath = normalizePublicFontPath(source, moduleId);
3480
- const resolvedPath = path5.resolve(this.publicDir, `.${publicPath}`);
3723
+ const resolvedPath = path6.resolve(this.publicDir, `.${publicPath}`);
3481
3724
  if (!isPathInside(this.publicDir, resolvedPath)) {
3482
3725
  throw fontError(moduleId, `public font path must stay inside publicDir`);
3483
3726
  }
@@ -3493,7 +3736,7 @@ ${FONT_SECTION_END}
3493
3736
  `could not read ${JSON.stringify(source)} from publicDir: ${error.message}`
3494
3737
  );
3495
3738
  }
3496
- const extension = path5.extname(resolvedPath).toLowerCase();
3739
+ const extension = path6.extname(resolvedPath).toLowerCase();
3497
3740
  const hash = createHash2("sha256").update(bytes).digest("hex").slice(0, 12);
3498
3741
  const resource = {
3499
3742
  extension,
@@ -3508,7 +3751,7 @@ ${FONT_SECTION_END}
3508
3751
  createSelfHostedResource(bytes, extension, fileName) {
3509
3752
  const normalizedExtension = extension.toLowerCase();
3510
3753
  const hash = createHash2("sha256").update(bytes).digest("hex").slice(0, 12);
3511
- const baseName = sanitizeFileName(path5.basename(fileName, extension)) || "font";
3754
+ const baseName = sanitizeFileName(path6.basename(fileName, extension)) || "font";
3512
3755
  const outputFileName = `assets/fonts/${baseName}-h${hash}${normalizedExtension}`;
3513
3756
  const key = `${hash}${normalizedExtension}`;
3514
3757
  const existing = this.resources.get(key);
@@ -3861,24 +4104,24 @@ function verifyIntegrity(bytes, integrity) {
3861
4104
  if (!matches) throw new Error("downloaded font did not match its integrity value");
3862
4105
  }
3863
4106
  function resolveLocalFontPath(source, importer, root) {
3864
- if (source.startsWith(".")) return path5.resolve(path5.dirname(importer), source);
3865
- if (path5.isAbsolute(source)) {
4107
+ if (source.startsWith(".")) return path6.resolve(path6.dirname(importer), source);
4108
+ if (path6.isAbsolute(source)) {
3866
4109
  return source;
3867
4110
  }
3868
4111
  try {
3869
4112
  return createRequire(pathToFileURL(importer)).resolve(source);
3870
4113
  } catch {
3871
4114
  const segments = source.replace(/\\/g, "/").split("/");
3872
- if (segments.includes("..")) return path5.resolve(root, source);
3873
- let current = path5.dirname(importer);
3874
- const filesystemRoot = path5.parse(current).root;
4115
+ if (segments.includes("..")) return path6.resolve(root, source);
4116
+ let current = path6.dirname(importer);
4117
+ const filesystemRoot = path6.parse(current).root;
3875
4118
  while (true) {
3876
- const candidate = path5.join(current, "node_modules", ...segments);
4119
+ const candidate = path6.join(current, "node_modules", ...segments);
3877
4120
  if (existsSync2(candidate)) return candidate;
3878
4121
  if (current === filesystemRoot) break;
3879
- current = path5.dirname(current);
4122
+ current = path6.dirname(current);
3880
4123
  }
3881
- return path5.resolve(root, "node_modules", ...segments);
4124
+ return path6.resolve(root, "node_modules", ...segments);
3882
4125
  }
3883
4126
  }
3884
4127
  function replaceFontSection(css, section) {
@@ -3911,11 +4154,11 @@ function getGlobalMap(key) {
3911
4154
  return created;
3912
4155
  }
3913
4156
  function normalizeRoot(root) {
3914
- return path5.resolve(root).replace(/\\/g, "/");
4157
+ return path6.resolve(root).replace(/\\/g, "/");
3915
4158
  }
3916
4159
  function normalizePublicDir(root, publicDir) {
3917
4160
  if (publicDir === false || publicDir === "") return false;
3918
- return path5.resolve(root, publicDir || "public");
4161
+ return path6.resolve(root, publicDir || "public");
3919
4162
  }
3920
4163
  function normalizePublicFontPath(source, moduleId) {
3921
4164
  if (source.includes("?") || source.includes("#")) {
@@ -3924,8 +4167,8 @@ function normalizePublicFontPath(source, moduleId) {
3924
4167
  return `/${source.replace(/\\/g, "/").replace(/^\/+/, "")}`;
3925
4168
  }
3926
4169
  function isPathInside(parent, child) {
3927
- const relative3 = path5.relative(parent, child);
3928
- return relative3 === "" || !relative3.startsWith("..") && !path5.isAbsolute(relative3);
4170
+ const relative3 = path6.relative(parent, child);
4171
+ return relative3 === "" || !relative3.startsWith("..") && !path6.isAbsolute(relative3);
3929
4172
  }
3930
4173
  function normalizeBasePath(value) {
3931
4174
  if (!value || value === "/") return "/";
@@ -3935,7 +4178,7 @@ function joinBasePath(basePath, value) {
3935
4178
  return basePath === "/" ? value : `${basePath.replace(/\/$/, "")}${value}`;
3936
4179
  }
3937
4180
  function extensionFromPath(pathname) {
3938
- const extension = path5.extname(pathname).toLowerCase();
4181
+ const extension = path6.extname(pathname).toLowerCase();
3939
4182
  if (!FONT_EXTENSION_RE.test(extension)) {
3940
4183
  throw new Error(`[Farm fonts] Remote font URL must end in .woff2, .woff, .ttf, or .otf`);
3941
4184
  }
@@ -4075,7 +4318,7 @@ function fontError(id, message) {
4075
4318
  }
4076
4319
 
4077
4320
  // src/integration-provider-build.ts
4078
- import path6 from "path";
4321
+ import path7 from "path";
4079
4322
  function isRendererCompiledComponent(moduleId, rendererComponentExtensions) {
4080
4323
  const lowered = moduleId.toLowerCase();
4081
4324
  return rendererComponentExtensions.some((extension) => lowered.endsWith(extension.toLowerCase()));
@@ -4177,31 +4420,31 @@ function generateFarmIntegrationProviderServerModules(providers, root, rendererC
4177
4420
  }
4178
4421
  function resolveProviderModule(moduleId, root) {
4179
4422
  if (!moduleId.startsWith(".")) return moduleId;
4180
- return toViteModuleId(path6.resolve(root, moduleId), root);
4423
+ return toViteModuleId(path7.resolve(root, moduleId), root);
4181
4424
  }
4182
4425
 
4183
4426
  // src/server/renderer.ts
4184
- import * as fs5 from "fs";
4427
+ import * as fs6 from "fs";
4185
4428
  import * as https from "https";
4186
4429
  import { isIP } from "net";
4187
- import * as path9 from "path";
4430
+ import * as path10 from "path";
4188
4431
  import * as tls from "tls";
4189
4432
  import { Readable, Writable } from "stream";
4190
4433
 
4191
4434
  // src/not-found.ts
4192
- import fs3 from "fs";
4193
- import path7 from "path";
4435
+ import fs4 from "fs";
4436
+ import path8 from "path";
4194
4437
  function resolveFarmNotFoundComponentPath(config, appDirs) {
4195
4438
  const extensions = getFarmRendererComponentExtensions(config.renderer);
4196
4439
  const configuredPath = config.notFound?.component?.trim();
4197
4440
  if (configuredPath) {
4198
- const componentPath = path7.isAbsolute(configuredPath) ? path7.normalize(configuredPath) : path7.resolve(config.root, configuredPath);
4441
+ const componentPath = path8.isAbsolute(configuredPath) ? path8.normalize(configuredPath) : path8.resolve(config.root, configuredPath);
4199
4442
  if (!extensions.some((extension) => componentPath.endsWith(extension))) {
4200
4443
  throw new Error(
4201
4444
  `notFound.component must use one of the configured renderer extensions: ${extensions.join(", ")}`
4202
4445
  );
4203
4446
  }
4204
- if (!fs3.existsSync(componentPath) || !fs3.statSync(componentPath).isFile()) {
4447
+ if (!fs4.existsSync(componentPath) || !fs4.statSync(componentPath).isFile()) {
4205
4448
  throw new Error(`notFound.component was not found: ${componentPath}`);
4206
4449
  }
4207
4450
  return componentPath;
@@ -4209,8 +4452,8 @@ function resolveFarmNotFoundComponentPath(config, appDirs) {
4209
4452
  let discoveredPath = null;
4210
4453
  for (const appDir of appDirs) {
4211
4454
  for (const extension of extensions) {
4212
- const candidate = path7.join(appDir, `not-found${extension}`);
4213
- if (fs3.existsSync(candidate) && fs3.statSync(candidate).isFile()) {
4455
+ const candidate = path8.join(appDir, `not-found${extension}`);
4456
+ if (fs4.existsSync(candidate) && fs4.statSync(candidate).isFile()) {
4214
4457
  discoveredPath = candidate;
4215
4458
  break;
4216
4459
  }
@@ -4377,8 +4620,8 @@ body {
4377
4620
  import { pathToFileURL as pathToFileURL2 } from "url";
4378
4621
 
4379
4622
  // src/server/error-diagnostics.ts
4380
- import * as fs4 from "fs";
4381
- import * as path8 from "path";
4623
+ import * as fs5 from "fs";
4624
+ import * as path9 from "path";
4382
4625
  import { fileURLToPath as fileURLToPath2 } from "url";
4383
4626
  var SECRET_VALUE_PATTERN = /\b(api[_-]?key|access[_-]?token|auth[_-]?token|client[_-]?secret|secret[_-]?key|token|password|secret)\s*[:=]\s*([^\s,;]+)/gi;
4384
4627
  var BEARER_PATTERN = /\b(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi;
@@ -4386,8 +4629,8 @@ function redactErrorText(value) {
4386
4629
  return value.replace(BEARER_PATTERN, "$1[REDACTED]").replace(SECRET_VALUE_PATTERN, "$1=[REDACTED]");
4387
4630
  }
4388
4631
  function isPathInsideRoot(root, filePath) {
4389
- const relative3 = path8.relative(root, filePath);
4390
- return relative3 === "" || !relative3.startsWith("..") && !path8.isAbsolute(relative3);
4632
+ const relative3 = path9.relative(root, filePath);
4633
+ return relative3 === "" || !relative3.startsWith("..") && !path9.isAbsolute(relative3);
4391
4634
  }
4392
4635
  function normalizeStackPath(value) {
4393
4636
  const withoutQuery = value.replace(/[?#].*$/, "");
@@ -4404,13 +4647,13 @@ function findStackLocation(stack, root) {
4404
4647
  );
4405
4648
  if (!match) continue;
4406
4649
  const candidate = normalizeStackPath(match[1]);
4407
- if (!candidate || candidate.includes(`${path8.sep}node_modules${path8.sep}`)) continue;
4408
- const absolutePath = path8.resolve(candidate);
4409
- if (!isPathInsideRoot(root, absolutePath) || !fs4.existsSync(absolutePath)) continue;
4410
- const relativePath = path8.relative(root, absolutePath).split(path8.sep).join("/");
4650
+ if (!candidate || candidate.includes(`${path9.sep}node_modules${path9.sep}`)) continue;
4651
+ const absolutePath = path9.resolve(candidate);
4652
+ if (!isPathInsideRoot(root, absolutePath) || !fs5.existsSync(absolutePath)) continue;
4653
+ const relativePath = path9.relative(root, absolutePath).split(path9.sep).join("/");
4411
4654
  return {
4412
4655
  absolutePath,
4413
- displayPath: relativePath || path8.basename(absolutePath),
4656
+ displayPath: relativePath || path9.basename(absolutePath),
4414
4657
  line: Number(match[2]),
4415
4658
  column: Number(match[3])
4416
4659
  };
@@ -4419,7 +4662,7 @@ function findStackLocation(stack, root) {
4419
4662
  }
4420
4663
  function createSourceFrame(location) {
4421
4664
  try {
4422
- const sourceLines = fs4.readFileSync(location.absolutePath, "utf8").split(/\r?\n/);
4665
+ const sourceLines = fs5.readFileSync(location.absolutePath, "utf8").split(/\r?\n/);
4423
4666
  if (location.line < 1 || location.line > sourceLines.length) return void 0;
4424
4667
  const start = Math.max(1, location.line - 2);
4425
4668
  const end = Math.min(sourceLines.length, location.line + 2);
@@ -4442,13 +4685,13 @@ function createSourceFrame(location) {
4442
4685
  }
4443
4686
  }
4444
4687
  function sanitizeStack(stack, root) {
4445
- const normalizedRoot = path8.resolve(root);
4688
+ const normalizedRoot = path9.resolve(root);
4446
4689
  return redactErrorText(stack).split(normalizedRoot).join("<project>").replace(/<project>[^\s)]*/g, (segment) => segment.split("\\").join("/")).split("\n").filter((line, index) => index === 0 || !line.includes("node:internal")).slice(0, 14).join("\n");
4447
4690
  }
4448
4691
  function createDefaultErrorDiagnostics(error, root) {
4449
4692
  const normalizedError = error instanceof Error ? error : new Error(typeof error === "string" ? error : "Unknown server rendering error");
4450
4693
  const rawStack = normalizedError.stack || `${normalizedError.name}: ${normalizedError.message}`;
4451
- const location = findStackLocation(rawStack, path8.resolve(root));
4694
+ const location = findStackLocation(rawStack, path9.resolve(root));
4452
4695
  return {
4453
4696
  name: redactErrorText(normalizedError.name || "Error"),
4454
4697
  message: redactErrorText(normalizedError.message || "Unknown server rendering error"),
@@ -4702,7 +4945,7 @@ function createRouteStateProps(input) {
4702
4945
  function readAppPackageIdentity(root) {
4703
4946
  try {
4704
4947
  return JSON.parse(
4705
- fs5.readFileSync(path9.join(root || process.cwd(), "package.json"), "utf8")
4948
+ fs6.readFileSync(path10.join(root || process.cwd(), "package.json"), "utf8")
4706
4949
  );
4707
4950
  } catch {
4708
4951
  return {};
@@ -5001,10 +5244,10 @@ var ServerRenderer = class {
5001
5244
  * Load SSG manifest from build output
5002
5245
  */
5003
5246
  loadSSGManifest() {
5004
- const manifestPath = path9.join(this.config.root, this.config.outDir, "__ssg_manifest.json");
5247
+ const manifestPath = path10.join(this.config.root, this.config.outDir, "__ssg_manifest.json");
5005
5248
  let content;
5006
5249
  try {
5007
- content = fs5.readFileSync(manifestPath, "utf-8");
5250
+ content = fs6.readFileSync(manifestPath, "utf-8");
5008
5251
  } catch (error) {
5009
5252
  if (error.code === "ENOENT") {
5010
5253
  return;
@@ -5223,10 +5466,10 @@ var ServerRenderer = class {
5223
5466
  return true;
5224
5467
  }
5225
5468
  try {
5226
- const htmlPath = page.urlPath === "/" ? path9.join(this.config.root, this.config.outDir, "client", "index.html") : path9.join(this.config.root, this.config.outDir, "client", page.urlPath + ".html");
5227
- if (fs5.existsSync(htmlPath)) {
5228
- const stat = fs5.statSync(htmlPath);
5229
- const html = fs5.readFileSync(htmlPath, "utf-8");
5469
+ const htmlPath = page.urlPath === "/" ? path10.join(this.config.root, this.config.outDir, "client", "index.html") : path10.join(this.config.root, this.config.outDir, "client", page.urlPath + ".html");
5470
+ if (fs6.existsSync(htmlPath)) {
5471
+ const stat = fs6.statSync(htmlPath);
5472
+ const html = fs6.readFileSync(htmlPath, "utf-8");
5230
5473
  await this.cacheSSGPage(page, html, {
5231
5474
  document: true,
5232
5475
  createdAt: stat.mtimeMs
@@ -5961,11 +6204,11 @@ var ServerRenderer = class {
5961
6204
  if (isFarmIntegrationProviderComponentReference(provider.component)) {
5962
6205
  providerSourceModule = provider.component.module;
5963
6206
  const providerModuleId = provider.component.module.startsWith(".") ? toViteModuleId(
5964
- path9.resolve(this.config.root, provider.component.module),
6207
+ path10.resolve(this.config.root, provider.component.module),
5965
6208
  this.config.root
5966
6209
  ) : provider.component.module;
5967
6210
  const providerModule = this.viteServer ? await loadFarmDevModule(this.viteServer, providerModuleId) : await importRuntimeModule(
5968
- provider.component.module.startsWith(".") ? pathToFileURL2(path9.resolve(this.config.root, provider.component.module)).href : provider.component.module
6211
+ provider.component.module.startsWith(".") ? pathToFileURL2(path10.resolve(this.config.root, provider.component.module)).href : provider.component.module
5969
6212
  );
5970
6213
  ProviderComponent = providerModule[provider.component.export || "default"];
5971
6214
  } else if (typeof provider.component === "function") {
@@ -6232,7 +6475,7 @@ var ServerRenderer = class {
6232
6475
  logger.warn(`Could not read metadata for ${pattern} in sitemap.xml: ${error}`);
6233
6476
  return void 0;
6234
6477
  }),
6235
- fs5.promises.stat(route.modulePath).catch(() => void 0)
6478
+ fs6.promises.stat(route.modulePath).catch(() => void 0)
6236
6479
  ]);
6237
6480
  return { pattern, module, lastModified: stat?.mtime.toISOString() };
6238
6481
  })
@@ -6298,7 +6541,7 @@ var ServerRenderer = class {
6298
6541
  const server = this.getDefaultMCPServer();
6299
6542
  const request2 = getCurrentRequestOrNull() ?? createWebRequestFromFarmRequest(req, { trustProxy: this.config.server?.trustProxy });
6300
6543
  try {
6301
- const { handleFarmDefaultMCPRequest } = await import("./agent-mcp-handler-WWCC4GLG.mjs");
6544
+ const { handleFarmDefaultMCPRequest } = await import("./agent-mcp-handler-7JSKGSOW.mjs");
6302
6545
  const origin = new URL(request2.url).origin;
6303
6546
  const response = await handleFarmDefaultMCPRequest(request2, {
6304
6547
  server,
@@ -6483,7 +6726,7 @@ var ServerRenderer = class {
6483
6726
  res.end();
6484
6727
  return;
6485
6728
  }
6486
- res.write(await fs5.promises.readFile(image.modulePath));
6729
+ res.write(await fs6.promises.readFile(image.modulePath));
6487
6730
  res.end();
6488
6731
  }
6489
6732
  async renderRouteErrorBoundary(req, res, options) {
@@ -7278,13 +7521,13 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7278
7521
  res.end(createFarmMarkdownErrorBody(404, pathname, this.config.basePath || "/"));
7279
7522
  return;
7280
7523
  }
7281
- const appDir = path9.join(this.config.root, this.config.srcDir, "app");
7524
+ const appDir = path10.join(this.config.root, this.config.srcDir, "app");
7282
7525
  const notFoundExtensions = getFarmRendererComponentExtensions(this.config.renderer);
7283
7526
  let layoutModule = null;
7284
7527
  try {
7285
7528
  for (const ext of notFoundExtensions) {
7286
- const layoutPath = path9.join(appDir, `layout${ext}`);
7287
- if (fs5.existsSync(layoutPath)) {
7529
+ const layoutPath = path10.join(appDir, `layout${ext}`);
7530
+ if (fs6.existsSync(layoutPath)) {
7288
7531
  layoutModule = await this.routeManager.loadLayoutModule(layoutPath);
7289
7532
  break;
7290
7533
  }
@@ -7497,7 +7740,7 @@ ${clientScript}
7497
7740
  };
7498
7741
 
7499
7742
  // src/app.ts
7500
- import path10 from "path";
7743
+ import path11 from "path";
7501
7744
  var defaultDocsConfig = {
7502
7745
  enabled: false,
7503
7746
  entry: "/docs",
@@ -7637,7 +7880,7 @@ var FarmApp = class {
7637
7880
  }
7638
7881
  const componentExtensions = getFarmRendererComponentExtensions(this.config.renderer);
7639
7882
  const rootLayoutPaths = appDirs.flatMap(
7640
- (appDir) => componentExtensions.map((extension) => path10.join(appDir, `layout${extension}`))
7883
+ (appDir) => componentExtensions.map((extension) => path11.join(appDir, `layout${extension}`))
7641
7884
  );
7642
7885
  const hasRootLayout = await Promise.all(rootLayoutPaths.map((p) => fileExists(p))).then(
7643
7886
  (results) => results.some(Boolean)
@@ -7701,13 +7944,13 @@ function resolveFarmImageServerRuntime(images, preset) {
7701
7944
  }
7702
7945
 
7703
7946
  // src/app-manifest-packages.ts
7704
- import fs6 from "fs";
7705
- import path11 from "path";
7947
+ import fs7 from "fs";
7948
+ import path12 from "path";
7706
7949
  var FARM_PACKAGE = /^@(?:farm\.js|farming-labs)\/[a-z0-9._-]+$/;
7707
7950
  function resolveFarmAppPackages(root) {
7708
7951
  let manifest;
7709
7952
  try {
7710
- manifest = JSON.parse(fs6.readFileSync(path11.join(root, "package.json"), "utf8"));
7953
+ manifest = JSON.parse(fs7.readFileSync(path12.join(root, "package.json"), "utf8"));
7711
7954
  } catch {
7712
7955
  return {};
7713
7956
  }
@@ -7722,13 +7965,13 @@ function resolveFarmAppPackages(root) {
7722
7965
  for (let dir = root; ; ) {
7723
7966
  try {
7724
7967
  const { version } = JSON.parse(
7725
- fs6.readFileSync(path11.join(dir, "node_modules", name, "package.json"), "utf8")
7968
+ fs7.readFileSync(path12.join(dir, "node_modules", name, "package.json"), "utf8")
7726
7969
  );
7727
7970
  if (typeof version === "string" && /^[0-9A-Za-z.+-]{1,64}$/.test(version))
7728
7971
  versions[name] = version;
7729
7972
  break;
7730
7973
  } catch {
7731
- const parent = path11.dirname(dir);
7974
+ const parent = path12.dirname(dir);
7732
7975
  if (parent === dir) break;
7733
7976
  dir = parent;
7734
7977
  }
@@ -7738,9 +7981,9 @@ function resolveFarmAppPackages(root) {
7738
7981
  }
7739
7982
 
7740
7983
  // src/app-manifest-webmcp.ts
7741
- import fs7 from "fs";
7984
+ import fs8 from "fs";
7742
7985
  import { createRequire as createRequire2 } from "module";
7743
- import path12 from "path";
7986
+ import path13 from "path";
7744
7987
  import { globSync } from "tinyglobby";
7745
7988
  var WEBMCP_CLIENT = "@farm.js/webmcp/client";
7746
7989
  var DEFINERS = /* @__PURE__ */ new Set(["defineWebMCPTool", "registerWebMCPTool", "registerWebMCPTools"]);
@@ -7835,7 +8078,7 @@ function toolFromObject(object) {
7835
8078
  }
7836
8079
  function findFarmWebMCPTools(code, filename = "module.tsx") {
7837
8080
  if (!code.includes(WEBMCP_CLIENT)) return [];
7838
- const lang = LANGS[path12.extname(filename).slice(1)] ?? "tsx";
8081
+ const lang = LANGS[path13.extname(filename).slice(1)] ?? "tsx";
7839
8082
  parseAst ?? (parseAst = createRequire2(typeof __filename === "string" ? __filename : import.meta.url)(
7840
8083
  "rolldown/parseAst"
7841
8084
  ).parseAst);
@@ -7882,7 +8125,7 @@ function findFarmWebMCPTools(code, filename = "module.tsx") {
7882
8125
  }
7883
8126
  var cache = /* @__PURE__ */ new Map();
7884
8127
  function collectFarmWebMCPTools(root, srcDir = "src") {
7885
- const base = path12.resolve(root, srcDir);
8128
+ const base = path13.resolve(root, srcDir);
7886
8129
  let files;
7887
8130
  try {
7888
8131
  files = globSync("**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}", {
@@ -7899,7 +8142,7 @@ function collectFarmWebMCPTools(root, srcDir = "src") {
7899
8142
  for (const file of files.sort()) {
7900
8143
  let mtimeMs;
7901
8144
  try {
7902
- mtimeMs = fs7.statSync(file).mtimeMs;
8145
+ mtimeMs = fs8.statSync(file).mtimeMs;
7903
8146
  } catch {
7904
8147
  continue;
7905
8148
  }
@@ -7907,7 +8150,7 @@ function collectFarmWebMCPTools(root, srcDir = "src") {
7907
8150
  if (!entry || entry.mtimeMs !== mtimeMs) {
7908
8151
  let code = "";
7909
8152
  try {
7910
- code = fs7.readFileSync(file, "utf8");
8153
+ code = fs8.readFileSync(file, "utf8");
7911
8154
  } catch {
7912
8155
  }
7913
8156
  entry = { mtimeMs, tools: findFarmWebMCPTools(code, file) };
@@ -7923,8 +8166,8 @@ function collectFarmWebMCPTools(root, srcDir = "src") {
7923
8166
  }
7924
8167
 
7925
8168
  // src/client-plugin-build.ts
7926
- import fs8 from "fs";
7927
- import path13 from "path";
8169
+ import fs9 from "fs";
8170
+ import path14 from "path";
7928
8171
  var CLIENT_KEYS = [
7929
8172
  "public",
7930
8173
  "setup",
@@ -7944,10 +8187,10 @@ var MOBILE_SHELL_CLIENT_REGISTRATION = ` {
7944
8187
  }`;
7945
8188
  var APP_CLIENT_EXTENSIONS = ["ts", "tsx", "js", "jsx", "mts", "mjs"];
7946
8189
  function resolveFarmAppClientEntry(root = process.cwd(), srcDir = "src") {
7947
- const sourceRoot = path13.resolve(root, srcDir);
8190
+ const sourceRoot = path14.resolve(root, srcDir);
7948
8191
  for (const extension of APP_CLIENT_EXTENSIONS) {
7949
- const candidate = path13.join(sourceRoot, `client.${extension}`);
7950
- if (fs8.existsSync(candidate) && fs8.statSync(candidate).isFile()) return candidate;
8192
+ const candidate = path14.join(sourceRoot, `client.${extension}`);
8193
+ if (fs9.existsSync(candidate) && fs9.statSync(candidate).isFile()) return candidate;
7951
8194
  }
7952
8195
  return void 0;
7953
8196
  }
@@ -7968,11 +8211,11 @@ function resolveFarmClientPlugins(plugins, _root) {
7968
8211
  ];
7969
8212
  });
7970
8213
  }
7971
- function generateFarmClientPluginEntryCode(plugins, root, srcDir = "src", appPublicData) {
8214
+ function generateFarmClientPluginEntryCode(plugins, root, srcDir = "src", appPublicData, platform = resolveFarmPlatform()) {
7972
8215
  const resolved = resolveFarmClientPlugins(plugins, root);
7973
8216
  const appClientEntry = root ? resolveFarmAppClientEntry(root, srcDir) : void 0;
7974
8217
  const appImport = appClientEntry ? `import farmAppClientDefinition from ${JSON.stringify(appClientEntry.replace(/\\/g, "/"))};` : "";
7975
- const mobileShell = resolveFarmPlatform() === "mobile";
8218
+ const mobileShell = platform === "mobile";
7976
8219
  const imports = mobileShell ? [MOBILE_SHELL_CLIENT_IMPORT, appImport].filter(Boolean).join("\n") : appImport;
7977
8220
  const serializedPlugins = mobileShell ? [MOBILE_SHELL_CLIENT_REGISTRATION] : [];
7978
8221
  serializedPlugins.push(
@@ -8189,8 +8432,8 @@ function isArrayIndex(key) {
8189
8432
  }
8190
8433
 
8191
8434
  // src/client-cache-persistence-build.ts
8192
- import fs9 from "fs";
8193
- import path14 from "path";
8435
+ import fs10 from "fs";
8436
+ import path15 from "path";
8194
8437
  var ADAPTER_EXTENSIONS = ["ts", "tsx", "js", "jsx", "mts", "mjs"];
8195
8438
  function resolveFarmClientCacheAdapterEntry(root, cache2) {
8196
8439
  const client = cache2?.client;
@@ -8201,7 +8444,7 @@ function resolveFarmClientCacheAdapterEntry(root, cache2) {
8201
8444
  'cache.client.adapter must be a module path string, for example "./src/cache-adapter".'
8202
8445
  );
8203
8446
  }
8204
- const resolved = path14.resolve(root, adapter);
8447
+ const resolved = path15.resolve(root, adapter);
8205
8448
  const found = resolveAdapterFile(resolved);
8206
8449
  if (!found) {
8207
8450
  throw new Error(
@@ -8214,10 +8457,10 @@ function resolveFarmClientCacheAdapterEntry(root, cache2) {
8214
8457
  return { importPath: found.replace(/\\/g, "/"), options };
8215
8458
  }
8216
8459
  function resolveAdapterFile(resolved) {
8217
- if (fs9.existsSync(resolved) && fs9.statSync(resolved).isFile()) return resolved;
8460
+ if (fs10.existsSync(resolved) && fs10.statSync(resolved).isFile()) return resolved;
8218
8461
  for (const extension of ADAPTER_EXTENSIONS) {
8219
8462
  const candidate = `${resolved}.${extension}`;
8220
- if (fs9.existsSync(candidate) && fs9.statSync(candidate).isFile()) return candidate;
8463
+ if (fs10.existsSync(candidate) && fs10.statSync(candidate).isFile()) return candidate;
8221
8464
  }
8222
8465
  return void 0;
8223
8466
  }
@@ -8383,7 +8626,7 @@ async function buildFarmTreeLayouts(layouts, params, source, options) {
8383
8626
  // src/docs/client-config.ts
8384
8627
  import { realpathSync as realpathSync2 } from "fs";
8385
8628
  import { createRequire as createRequire3 } from "module";
8386
- import path15 from "path";
8629
+ import path16 from "path";
8387
8630
  var parseAst2;
8388
8631
  function propertyKeyName(property2) {
8389
8632
  if (property2.computed) return void 0;
@@ -8396,7 +8639,7 @@ function redactFarmDocsClientConfig(code, filename) {
8396
8639
  parseAst2 ?? (parseAst2 = createRequire3(typeof __filename === "string" ? __filename : import.meta.url)(
8397
8640
  "rolldown/parseAst"
8398
8641
  ).parseAst);
8399
- const extension = path15.extname(filename);
8642
+ const extension = path16.extname(filename);
8400
8643
  const program = parseAst2(code, {
8401
8644
  lang: extension === ".tsx" || extension === ".jsx" ? "tsx" : "ts"
8402
8645
  });
@@ -8458,7 +8701,7 @@ function farmDocsClientConfigPlugin(configModule) {
8458
8701
  }
8459
8702
 
8460
8703
  // src/server/vite-config.ts
8461
- import path16 from "path";
8704
+ import path17 from "path";
8462
8705
  var FARM_CLIENT_ENTRY_PATTERN = "**/{page,layout,loading,error,not-found,default}.{js,jsx,ts,tsx}";
8463
8706
  var FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE = [
8464
8707
  "react",
@@ -8485,9 +8728,9 @@ function getFarmClientOptimizeDepsInclude(renderer) {
8485
8728
  );
8486
8729
  }
8487
8730
  function createFarmClientOptimizeDepsEntries(projectRoot, appDirectories) {
8488
- const resolvedProjectRoot = path16.resolve(projectRoot);
8731
+ const resolvedProjectRoot = path17.resolve(projectRoot);
8489
8732
  return appDirectories.map((appDirectory) => {
8490
- const relativeAppDirectory = path16.relative(resolvedProjectRoot, path16.resolve(appDirectory)).replace(/\\/g, "/");
8733
+ const relativeAppDirectory = path17.relative(resolvedProjectRoot, path17.resolve(appDirectory)).replace(/\\/g, "/");
8491
8734
  const prefix = relativeAppDirectory || ".";
8492
8735
  return `${prefix}/${FARM_CLIENT_ENTRY_PATTERN}`;
8493
8736
  });
@@ -8509,7 +8752,7 @@ function createFarmClientOptimizeDepsConfig(entries, renderer) {
8509
8752
  }
8510
8753
  function createFarmSourceAlias(projectRoot, srcDir = "src") {
8511
8754
  return {
8512
- "@": path16.resolve(projectRoot, srcDir)
8755
+ "@": path17.resolve(projectRoot, srcDir)
8513
8756
  };
8514
8757
  }
8515
8758
  function mergeNoExternal(farmValue, userValue) {
@@ -8657,6 +8900,8 @@ ${FARM_DARK_VARIANT}
8657
8900
  }
8658
8901
 
8659
8902
  export {
8903
+ withPackageClientBoundaryCache,
8904
+ usePackageClientBoundaryCacheFile,
8660
8905
  resolveModuleSourcePath,
8661
8906
  getFarmClientHydrationPlanOptions,
8662
8907
  describeSuppressedAsyncHydration,