@farm.js/core 0.2.2 → 0.2.4

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 (199) hide show
  1. package/dist/{agent-mcp.d-gI3ahrF6.d.mts → agent-mcp.d-CaJJsAVy.d.mts} +1 -1
  2. package/dist/{agent-mcp.d-DuZjglYX.d.ts → agent-mcp.d-klsG_XKS.d.ts} +1 -1
  3. package/dist/agent-runtime.d.mts +1 -1
  4. package/dist/agent-runtime.d.ts +1 -1
  5. package/dist/{analyzer-UXWYUTBK.mjs → analyzer-CY7BS4GB.mjs} +2 -2
  6. package/dist/analyzer-KHCOL6JF.cjs +17 -0
  7. package/dist/api/node.d.mts +3 -3
  8. package/dist/api/node.d.ts +3 -3
  9. package/dist/api/route-manager.cjs +4 -4
  10. package/dist/api/route-manager.d.mts +3 -3
  11. package/dist/api/route-manager.d.ts +3 -3
  12. package/dist/api/route-manager.mjs +3 -3
  13. package/dist/api/runtime.d.mts +2 -2
  14. package/dist/api/runtime.d.ts +2 -2
  15. package/dist/api.cjs +5 -5
  16. package/dist/api.d.mts +4 -4
  17. package/dist/api.d.ts +4 -4
  18. package/dist/api.mjs +4 -4
  19. package/dist/{app-manifest.d-bHK9EGPI.d.mts → app-manifest.d-BIdn8Whr.d.mts} +1 -1
  20. package/dist/{app-manifest.d-B3h89j6a.d.ts → app-manifest.d-DkIbmExG.d.ts} +1 -1
  21. package/dist/app-markdown.d.mts +2 -2
  22. package/dist/app-markdown.d.ts +2 -2
  23. package/dist/{app.d-C3uyET_L.d.ts → app.d-DhZ61V9X.d.ts} +8 -5
  24. package/dist/{app.d-Cr7fXGvJ.d.mts → app.d-DnqxbvCI.d.mts} +8 -5
  25. package/dist/{chunk-YOVSWY2E.mjs → chunk-2XDRRAAD.mjs} +1 -1
  26. package/dist/{chunk-2T4GGCQT.cjs → chunk-6UBGXEIH.cjs} +2 -2
  27. package/dist/{chunk-BEAQVRMQ.cjs → chunk-76ES7BCO.cjs} +80 -75
  28. package/dist/{chunk-TK2JJCP5.mjs → chunk-7FNKBP3J.mjs} +186 -29
  29. package/dist/{chunk-ST3U7XVO.mjs → chunk-7IM2MKRK.mjs} +1 -1
  30. package/dist/{chunk-GL4SPJTE.cjs → chunk-7Q6KUXH6.cjs} +58 -27
  31. package/dist/{chunk-5CG2UD6B.cjs → chunk-AMSX2U4D.cjs} +304 -7
  32. package/dist/{chunk-NPR6SCEV.mjs → chunk-AOSZIHL7.mjs} +1 -1
  33. package/dist/chunk-APVJJCMB.mjs +547 -0
  34. package/dist/{chunk-LQZXCSYG.mjs → chunk-B6K2ZM3C.mjs} +5 -3
  35. package/dist/{chunk-IEXZMDF4.mjs → chunk-BCIUG6EQ.mjs} +2 -2
  36. package/dist/{chunk-JCERO6YF.mjs → chunk-BUIZTM3Q.mjs} +1 -1
  37. package/dist/{chunk-SJQ24IB5.cjs → chunk-BY5VQ57W.cjs} +11 -11
  38. package/dist/{chunk-GKDOKES3.mjs → chunk-CQ5LVPBL.mjs} +1 -1
  39. package/dist/{chunk-Q4FHYBFT.cjs → chunk-CSCORWIQ.cjs} +11 -11
  40. package/dist/{chunk-6VMBLDWY.mjs → chunk-CV7C75LN.mjs} +1 -1
  41. package/dist/{chunk-CZMMU3FP.mjs → chunk-D4DAL7KK.mjs} +35 -4
  42. package/dist/{chunk-ZVT2F3JU.mjs → chunk-DR65XXXD.mjs} +2 -2
  43. package/dist/{chunk-PRKFECGT.cjs → chunk-DZWX7FDX.cjs} +6 -4
  44. package/dist/{chunk-A4AYTO2E.cjs → chunk-EZRB5N6S.cjs} +1 -1
  45. package/dist/{chunk-B7CZ7T2I.cjs → chunk-JEJXSTYR.cjs} +2 -2
  46. package/dist/{chunk-56F4CDKE.cjs → chunk-JRPCCBGL.cjs} +449 -291
  47. package/dist/{chunk-JM5VSEYC.cjs → chunk-KHTDVXXR.cjs} +2 -2
  48. package/dist/{chunk-PYPHM7AS.cjs → chunk-LH7S7FI3.cjs} +5 -1
  49. package/dist/{chunk-ZND5D4IC.cjs → chunk-LJZZDRD5.cjs} +363 -326
  50. package/dist/{chunk-WXPY5FRF.cjs → chunk-P2PF5FUW.cjs} +2 -2
  51. package/dist/{chunk-CPL7WIMP.mjs → chunk-P3UT3OLV.mjs} +2 -2
  52. package/dist/{chunk-PZ5ZJAAO.mjs → chunk-POCWXRXW.mjs} +1 -1
  53. package/dist/{chunk-L7Z6OAE2.cjs → chunk-PVR63WHW.cjs} +4 -4
  54. package/dist/{chunk-Z23OCU33.cjs → chunk-RF3VCNV7.cjs} +6 -6
  55. package/dist/{chunk-5AOARZJT.cjs → chunk-T2VXOAC3.cjs} +4 -4
  56. package/dist/{chunk-FEWGKBMM.mjs → chunk-UIBCPZFO.mjs} +85 -48
  57. package/dist/{chunk-MYJPW4XN.mjs → chunk-UKGAP2OK.mjs} +3 -3
  58. package/dist/{chunk-DZXD6CYJ.mjs → chunk-V2RXBDV6.mjs} +4 -0
  59. package/dist/{chunk-ALGAGXWB.mjs → chunk-XEOIZ4QC.mjs} +1 -1
  60. package/dist/{chunk-D2VLHRBN.cjs → chunk-Y3MTKPLN.cjs} +4 -4
  61. package/dist/{chunk-FDS6U2NT.cjs → chunk-Y7FLPQSL.cjs} +3 -3
  62. package/dist/{chunk-MEXGQE4T.mjs → chunk-YR7ZI57S.mjs} +17 -12
  63. package/dist/{client-component.d-BavTzqsn.d.ts → client-component.d-BHE9Ns8s.d.ts} +1 -1
  64. package/dist/{client-component.d-X3j9FOZ2.d.mts → client-component.d-uya-qDZu.d.mts} +1 -1
  65. package/dist/{client-plugins.d-DnnAopKG.d.mts → client-plugins.d-CqFAvu-W.d.mts} +38 -1
  66. package/dist/{client-plugins.d-CqTr5IrQ.d.ts → client-plugins.d-Dp89a9Gf.d.ts} +38 -1
  67. package/dist/client-plugins.d.mts +1 -1
  68. package/dist/client-plugins.d.ts +1 -1
  69. package/dist/client.d.mts +7 -7
  70. package/dist/client.d.ts +7 -7
  71. package/dist/config.d.mts +1 -1
  72. package/dist/config.d.ts +1 -1
  73. package/dist/desktop.d.mts +2 -2
  74. package/dist/desktop.d.ts +2 -2
  75. package/dist/{devtools-RFVGDHXH.mjs → devtools-CRZCFRRL.mjs} +1 -1
  76. package/dist/{devtools-4LMM3DDJ.cjs → devtools-ZHYYPMZ3.cjs} +2 -2
  77. package/dist/docs.cjs +3 -3
  78. package/dist/docs.d.mts +3 -3
  79. package/dist/docs.d.ts +3 -3
  80. package/dist/docs.mjs +2 -2
  81. package/dist/environment/vite.cjs +4 -4
  82. package/dist/environment/vite.mjs +3 -3
  83. package/dist/{handler.d-BSlpYCDB.d.mts → handler.d-BgJGywnq.d.mts} +1 -1
  84. package/dist/{handler.d-DgX7gPO6.d.ts → handler.d-DHxaRQr7.d.ts} +1 -1
  85. package/dist/{headers.d-CmxW42R2.d.ts → headers.d-DVm2BMtR.d.ts} +1 -1
  86. package/dist/{headers.d-Cf8l5LMo.d.mts → headers.d-QrzpChrN.d.mts} +1 -1
  87. package/dist/index.cjs +19 -19
  88. package/dist/{index.d-BZZt7kxO.d.ts → index.d-B8lXhfTs.d.ts} +1 -1
  89. package/dist/{index.d-7xoJqKRZ.d.mts → index.d-Bpu1TV0-.d.mts} +1 -1
  90. package/dist/index.d.mts +22 -22
  91. package/dist/index.d.ts +22 -22
  92. package/dist/index.mjs +18 -18
  93. package/dist/integrations/orm.d.mts +1 -1
  94. package/dist/integrations/orm.d.ts +1 -1
  95. package/dist/integrations.d.mts +1 -1
  96. package/dist/integrations.d.ts +1 -1
  97. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  98. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  99. package/dist/internal/build-runtime.cjs +18 -18
  100. package/dist/internal/build-runtime.d.mts +4 -4
  101. package/dist/internal/build-runtime.d.ts +4 -4
  102. package/dist/internal/build-runtime.mjs +17 -17
  103. package/dist/internal/cli-runtime.cjs +7 -7
  104. package/dist/internal/cli-runtime.d.mts +7 -7
  105. package/dist/internal/cli-runtime.d.ts +7 -7
  106. package/dist/internal/cli-runtime.mjs +6 -6
  107. package/dist/internal/client-error-overlay.cjs +4 -4
  108. package/dist/internal/client-error-overlay.mjs +1 -1
  109. package/dist/internal/client-runtime.d.mts +5 -5
  110. package/dist/internal/client-runtime.d.ts +5 -5
  111. package/dist/internal/compression-runtime.d.mts +1 -1
  112. package/dist/internal/compression-runtime.d.ts +1 -1
  113. package/dist/internal/config-runtime.cjs +3 -3
  114. package/dist/internal/config-runtime.d.mts +3 -3
  115. package/dist/internal/config-runtime.d.ts +3 -3
  116. package/dist/internal/config-runtime.mjs +2 -2
  117. package/dist/internal/infra-analytics-runtime.cjs +6 -6
  118. package/dist/internal/infra-analytics-runtime.mjs +4 -4
  119. package/dist/internal/native-server-fns.cjs +4 -4
  120. package/dist/internal/native-server-fns.mjs +3 -3
  121. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  122. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  123. package/dist/internal/production-runtime.cjs +4 -4
  124. package/dist/internal/production-runtime.d.mts +10 -10
  125. package/dist/internal/production-runtime.d.ts +10 -10
  126. package/dist/internal/production-runtime.mjs +3 -3
  127. package/dist/internal/spa-router.d.mts +3 -3
  128. package/dist/internal/spa-router.d.ts +3 -3
  129. package/dist/internal/start-manifest.d.mts +1 -1
  130. package/dist/internal/start-manifest.d.ts +1 -1
  131. package/dist/markdown.d.mts +1 -1
  132. package/dist/markdown.d.ts +1 -1
  133. package/dist/middleware.d.mts +1 -1
  134. package/dist/middleware.d.ts +1 -1
  135. package/dist/{mount.d-CD-xVBu7.d.ts → mount.d-Cw_75kb9.d.ts} +1 -1
  136. package/dist/{mount.d-Dd0xeRMl.d.mts → mount.d-CyfNKOHK.d.mts} +1 -1
  137. package/dist/{navigation-delegate.d-Bses_F-y.d.ts → navigation-delegate.d--imR0rY7.d.ts} +1 -1
  138. package/dist/{navigation-delegate.d-dBNg976E.d.mts → navigation-delegate.d-DVEtyGYw.d.mts} +1 -1
  139. package/dist/navigation.d.mts +4 -4
  140. package/dist/navigation.d.ts +4 -4
  141. package/dist/plugin.cjs +13 -13
  142. package/dist/plugin.d.mts +5 -5
  143. package/dist/plugin.d.ts +5 -5
  144. package/dist/plugin.mjs +12 -12
  145. package/dist/{render-plan.d-vOdZHHLI.d.mts → render-plan.d-CTehM6y8.d.mts} +1 -1
  146. package/dist/{render-plan.d-DaIwnRK2.d.ts → render-plan.d-DpxLd_1i.d.ts} +1 -1
  147. package/dist/renderer-client.d.mts +5 -5
  148. package/dist/renderer-client.d.ts +5 -5
  149. package/dist/{request.d-CgXp3EEc.d.ts → request.d-BFXzOr32.d.ts} +1 -1
  150. package/dist/{request.d-B8U4pVFP.d.mts → request.d-BmQzlKtT.d.mts} +1 -1
  151. package/dist/request.d.mts +2 -2
  152. package/dist/request.d.ts +2 -2
  153. package/dist/{route-rendering.d-Di0AxFix.d.ts → route-rendering.d-bEil1VkF.d.ts} +1 -1
  154. package/dist/{route-rendering.d-BQvNYQqu.d.mts → route-rendering.d-geg68qd0.d.mts} +1 -1
  155. package/dist/{router.d-BJVGhSAJ.d.ts → router.d-4OCT2ak5.d.ts} +1 -1
  156. package/dist/{router.d-hNedVdoB.d.mts → router.d-CQjEcNih.d.mts} +1 -1
  157. package/dist/routes.cjs +3 -3
  158. package/dist/routes.d.mts +1 -1
  159. package/dist/routes.d.ts +1 -1
  160. package/dist/routes.mjs +2 -2
  161. package/dist/{rsc-pipeline-NCJ3NIE5.mjs → rsc-pipeline-JISGZS6G.mjs} +2 -2
  162. package/dist/{rsc-pipeline-HT4G3QGT.cjs → rsc-pipeline-R5W3PAAL.cjs} +3 -3
  163. package/dist/{runtime-6UF5XKUP.cjs → runtime-HSTND4FF.cjs} +8 -8
  164. package/dist/{runtime-VHXIEXL7.mjs → runtime-I2SBIB2Q.mjs} +5 -5
  165. package/dist/{runtime.d-0R8nHCM6.d.ts → runtime.d-BKoa6J55.d.ts} +1 -1
  166. package/dist/{runtime.d-DpeuF_T-.d.mts → runtime.d-DjYo5E1n.d.mts} +1 -1
  167. package/dist/{schema-dependencies.d-_Wyey4Wv.d.mts → schema-dependencies.d-CGNgsyKS.d.mts} +1 -1
  168. package/dist/{schema-dependencies.d-tkUHREqz.d.ts → schema-dependencies.d-CRoN2Q9N.d.ts} +1 -1
  169. package/dist/{server-components-status.d-sN7ju-ie.d.mts → server-components-status.d-Crl3IonP.d.mts} +1 -1
  170. package/dist/{server-components-status.d-B2Z5WvO5.d.ts → server-components-status.d-CwfcQD6n.d.ts} +1 -1
  171. package/dist/server-plugins.d.mts +3 -3
  172. package/dist/server-plugins.d.ts +3 -3
  173. package/dist/server.cjs +34 -34
  174. package/dist/server.d.mts +11 -11
  175. package/dist/server.d.ts +11 -11
  176. package/dist/server.mjs +14 -14
  177. package/dist/{spa-router.d-MjT6sGb9.d.ts → spa-router.d-Bv-r3AAK.d.ts} +2 -2
  178. package/dist/{spa-router.d-D3AtR2Bc.d.mts → spa-router.d-DhO_PJHP.d.mts} +2 -2
  179. package/dist/{ssg.d-C1SNuPz5.d.ts → ssg.d-CzFOAkqy.d.mts} +13 -2
  180. package/dist/{ssg.d-B32Cp_XW.d.mts → ssg.d-SfEQfMsA.d.ts} +13 -2
  181. package/dist/{store-core.d-BZ3YXs70.d.ts → store-core.d-Ch0N8dni.d.ts} +2 -2
  182. package/dist/{store-core.d-BbVdaoA0.d.mts → store-core.d-pKJCUdTR.d.mts} +2 -2
  183. package/dist/testing.cjs +5 -5
  184. package/dist/testing.d.mts +1 -1
  185. package/dist/testing.d.ts +1 -1
  186. package/dist/testing.mjs +4 -4
  187. package/dist/{utils.d-Bjbm44fP.d.ts → utils.d-BaLODLrK.d.ts} +1 -1
  188. package/dist/{utils.d-CoLozp7-.d.mts → utils.d-TPjb_Q7w.d.mts} +1 -1
  189. package/dist/version.cjs +2 -2
  190. package/dist/version.mjs +1 -1
  191. package/dist/vite.cjs +13 -13
  192. package/dist/vite.d.mts +6 -6
  193. package/dist/vite.d.ts +6 -6
  194. package/dist/vite.mjs +12 -12
  195. package/package.json +2 -2
  196. package/dist/analyzer-ENHO4SA5.cjs +0 -17
  197. package/dist/chunk-Q4CPBKPT.mjs +0 -251
  198. /package/dist/{chunk-JL2HNLMC.mjs → chunk-3QC2XTCN.mjs} +0 -0
  199. /package/dist/{chunk-COXMHCIV.cjs → chunk-GDKJGL7D.cjs} +0 -0
@@ -0,0 +1,547 @@
1
+ import {
2
+ createFarmDevLoopbackPlugin
3
+ } from "./chunk-RLEAVG6G.mjs";
4
+ import {
5
+ resolveDeployOutputPath
6
+ } from "./chunk-3QC2XTCN.mjs";
7
+ import {
8
+ farmDesktopDevGuardPlugin,
9
+ loadFarmReactPlugin
10
+ } from "./chunk-6XABTMXR.mjs";
11
+ import {
12
+ generateFarmClientPluginEntryCode,
13
+ hasFarmServerRuntimePlugins,
14
+ loadTailwindVitePlugin
15
+ } from "./chunk-ADKPJZPP.mjs";
16
+ import {
17
+ resolveFarmPlatform
18
+ } from "./chunk-W5T3ZAFU.mjs";
19
+ import {
20
+ FARM_RSC_INSTALL_HINT,
21
+ findFarmAppPackageDir,
22
+ formatFarmRscBlockingMessage,
23
+ inspectFarmServerComponents,
24
+ resolveFarmRscCheckConfig
25
+ } from "./chunk-KQXYBJES.mjs";
26
+
27
+ // src/rsc-pipeline.ts
28
+ import { readFileSync as readFileSync2 } from "fs";
29
+ import path2 from "path";
30
+ import { pathToFileURL } from "url";
31
+
32
+ // src/package-imports.ts
33
+ import { existsSync, readFileSync, realpathSync, statSync } from "fs";
34
+ import path from "path";
35
+ var FARM_OPTIMIZED_PACKAGE_IMPORTS = [
36
+ "lucide-react",
37
+ "date-fns",
38
+ "lodash-es",
39
+ "ramda",
40
+ "antd",
41
+ "react-bootstrap",
42
+ "ahooks",
43
+ "@ant-design/icons",
44
+ "@headlessui/react",
45
+ "@headlessui-float/react",
46
+ "@heroicons/react/20/solid",
47
+ "@heroicons/react/24/solid",
48
+ "@heroicons/react/24/outline",
49
+ "@visx/visx",
50
+ "@tremor/react",
51
+ "rxjs",
52
+ "@mui/material",
53
+ "@mui/icons-material",
54
+ "recharts",
55
+ "react-use",
56
+ "effect",
57
+ "@effect/schema",
58
+ "@effect/platform",
59
+ "@effect/platform-node",
60
+ "@effect/platform-browser",
61
+ "@effect/platform-bun",
62
+ "@effect/sql",
63
+ "@effect/rpc",
64
+ "@effect/typeclass",
65
+ "@effect/experimental",
66
+ "@effect/opentelemetry",
67
+ "@material-ui/core",
68
+ "@material-ui/icons",
69
+ "@tabler/icons-react",
70
+ "mui-core",
71
+ ...[
72
+ "ai",
73
+ "bi",
74
+ "bs",
75
+ "cg",
76
+ "ci",
77
+ "di",
78
+ "fa",
79
+ "fa6",
80
+ "fc",
81
+ "fi",
82
+ "gi",
83
+ "go",
84
+ "gr",
85
+ "hi",
86
+ "hi2",
87
+ "im",
88
+ "io",
89
+ "io5",
90
+ "lia",
91
+ "lib",
92
+ "lu",
93
+ "md",
94
+ "pi",
95
+ "ri",
96
+ "rx",
97
+ "si",
98
+ "sl",
99
+ "tb",
100
+ "tfi",
101
+ "ti",
102
+ "vsc",
103
+ "wi"
104
+ ].map((set) => `react-icons/${set}`)
105
+ ];
106
+ var AMBIGUOUS_CONDITIONS = /* @__PURE__ */ new Set([
107
+ "node",
108
+ "browser",
109
+ "react-server",
110
+ "react-native",
111
+ "workerd",
112
+ "worker",
113
+ "edge-light",
114
+ "deno",
115
+ "bun"
116
+ ]);
117
+ var ENTRY_CONDITIONS = /* @__PURE__ */ new Set(["module", "import", "default"]);
118
+ var RESOLVE_EXTENSIONS = [".mjs", ".js", ".cjs"];
119
+ function pickEntry(value) {
120
+ if (typeof value === "string") return value;
121
+ if (Array.isArray(value)) return pickEntry(value[0]);
122
+ if (!value || typeof value !== "object") return void 0;
123
+ for (const [key, target] of Object.entries(value)) {
124
+ if (ENTRY_CONDITIONS.has(key)) return pickEntry(target);
125
+ if (AMBIGUOUS_CONDITIONS.has(key)) return null;
126
+ }
127
+ return void 0;
128
+ }
129
+ function resolveFarmPackageEntry(packageDir, manifest) {
130
+ let entry;
131
+ const { exports } = manifest;
132
+ if (exports !== void 0) {
133
+ const isSubpathMap = exports && typeof exports === "object" && !Array.isArray(exports) && Object.keys(exports).every((key) => key.startsWith("."));
134
+ entry = pickEntry(isSubpathMap ? exports["."] : exports);
135
+ }
136
+ if (entry === null) return null;
137
+ if (entry === void 0) {
138
+ entry = typeof manifest.module === "string" ? manifest.module : typeof manifest.main === "string" ? manifest.main : void 0;
139
+ }
140
+ if (!entry) return null;
141
+ const file = resolveRelative(path.resolve(packageDir, entry));
142
+ if (!file) return null;
143
+ const esm = file.endsWith(".mjs") || file.endsWith(".js") && (manifest.type === "module" || typeof manifest.module === "string");
144
+ return esm ? file : null;
145
+ }
146
+ function resolveRelative(target) {
147
+ const candidates = [
148
+ target,
149
+ ...RESOLVE_EXTENSIONS.map((ext) => target + ext),
150
+ ...RESOLVE_EXTENSIONS.map((ext) => path.join(target, `index${ext}`))
151
+ ];
152
+ for (const candidate of candidates) {
153
+ try {
154
+ if (statSync(candidate).isFile()) return candidate;
155
+ } catch {
156
+ }
157
+ }
158
+ return null;
159
+ }
160
+ var stripComments = (code) => code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^[ \t]*\/\/.*$/gm, "");
161
+ var IMPORT_RE = /\bimport\s+(?:(\*\s+as\s+(\w+))|(\w+)|\{([^}]*)\})?\s*(?:,\s*\{([^}]*)\})?\s*from\s*["']([^"']+)["']/g;
162
+ var EXPORT_FROM_RE = /\bexport\s+(?:(\*)(?:\s+as\s+(\w+))?|\{([^}]*)\})\s*from\s*["']([^"']+)["']/g;
163
+ var EXPORT_LOCAL_RE = /\bexport\s+\{([^}]*)\}\s*(?!from)/g;
164
+ var MODULE_DIRECTIVE_RE = /^\s*(["'])use (?:client|server)\1/;
165
+ var EXPORT_DECLARATION_RE = /\bexport\s+(?:default\b|(?:async\s+)?function\b|class\b|const\b|let\b|var\b|enum\b)/;
166
+ function specifiers(list) {
167
+ return list.split(",").map((s) => s.trim()).filter((s) => s && !s.startsWith("type ")).map((s) => {
168
+ const [imported, local] = s.split(/\s+as\s+/).map((p) => p.trim());
169
+ return { imported, local: local ?? imported };
170
+ });
171
+ }
172
+ function readFarmBarrel(file, depth = 0, seen = /* @__PURE__ */ new Set()) {
173
+ const map = /* @__PURE__ */ new Map();
174
+ let pure = true;
175
+ let directive = false;
176
+ if (seen.has(file) || depth > 4) return { map, pure, directive };
177
+ seen.add(file);
178
+ let code;
179
+ try {
180
+ code = stripComments(readFileSync(file, "utf8"));
181
+ } catch {
182
+ return { map, pure: false, directive };
183
+ }
184
+ if (MODULE_DIRECTIVE_RE.test(code)) directive = true;
185
+ const dir = path.dirname(file);
186
+ const resolve = (spec) => spec.startsWith(".") ? resolveRelative(path.resolve(dir, spec)) : null;
187
+ const locals = /* @__PURE__ */ new Map();
188
+ for (const m of code.matchAll(IMPORT_RE)) {
189
+ const target = resolve(m[6]);
190
+ if (!target) continue;
191
+ if (m[2]) locals.set(m[2], { file: target, name: "*" });
192
+ if (m[3]) locals.set(m[3], { file: target, name: "default" });
193
+ for (const list of [m[4], m[5]]) {
194
+ if (list)
195
+ for (const s of specifiers(list)) locals.set(s.local, { file: target, name: s.imported });
196
+ }
197
+ }
198
+ for (const m of code.matchAll(EXPORT_FROM_RE)) {
199
+ const target = resolve(m[4]);
200
+ if (!target) {
201
+ pure = false;
202
+ continue;
203
+ }
204
+ if (m[1] && m[2]) {
205
+ map.set(m[2], { file: target, name: "*" });
206
+ } else if (m[1]) {
207
+ const nested = readFarmBarrel(target, depth + 1, seen);
208
+ if (!nested.pure) pure = false;
209
+ if (nested.directive) directive = true;
210
+ for (const [name, binding] of nested.map) if (!map.has(name)) map.set(name, binding);
211
+ } else {
212
+ for (const s of specifiers(m[3])) map.set(s.local, { file: target, name: s.imported });
213
+ }
214
+ }
215
+ for (const m of code.matchAll(EXPORT_LOCAL_RE)) {
216
+ for (const s of specifiers(m[1])) {
217
+ const binding = locals.get(s.imported);
218
+ if (binding) map.set(s.local, binding);
219
+ else pure = false;
220
+ }
221
+ }
222
+ if (EXPORT_DECLARATION_RE.test(code)) pure = false;
223
+ return { map, pure, directive };
224
+ }
225
+ function findPackageDir(root, packageName) {
226
+ for (let dir = path.resolve(root); ; dir = path.dirname(dir)) {
227
+ const candidate = path.join(dir, "node_modules", packageName);
228
+ if (existsSync(path.join(candidate, "package.json"))) return realpathSync(candidate);
229
+ if (path.dirname(dir) === dir) return void 0;
230
+ }
231
+ }
232
+ function readFarmPackageBarrel(root, packageName) {
233
+ const dir = findPackageDir(root, packageName);
234
+ if (!dir) return null;
235
+ let manifest;
236
+ try {
237
+ manifest = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8"));
238
+ } catch {
239
+ return null;
240
+ }
241
+ const entry = resolveFarmPackageEntry(dir, manifest);
242
+ if (!entry) return null;
243
+ const { map, pure, directive } = readFarmBarrel(entry);
244
+ if (map.size === 0 || directive) return null;
245
+ if (!pure && manifest.sideEffects !== false) return null;
246
+ return map;
247
+ }
248
+ var NAMED_IMPORT_RE = /\bimport\s*\{([^}]*)\}\s*from\s*(["'])([^"']+)\2\s*;?/g;
249
+ var toImportPath = (file) => file.split(path.sep).join("/");
250
+ function importStatement(binding, local) {
251
+ const from = JSON.stringify(toImportPath(binding.file));
252
+ if (binding.name === "default") return `import ${local} from ${from};`;
253
+ if (binding.name === "*") return `import * as ${local} from ${from};`;
254
+ return `import { ${binding.name === local ? local : `${binding.name} as ${local}`} } from ${from};`;
255
+ }
256
+ function rewriteFarmPackageImports(code, packages, barrel) {
257
+ let changed = false;
258
+ const out = code.replace(
259
+ NAMED_IMPORT_RE,
260
+ (statement, list, _quote, specifier) => {
261
+ if (!packages.has(specifier)) return statement;
262
+ const map = barrel(specifier);
263
+ if (!map) return statement;
264
+ const kept = [];
265
+ const deep = [];
266
+ for (const s of specifiers(list)) {
267
+ const binding = map.get(s.imported);
268
+ if (binding) deep.push(importStatement(binding, s.local));
269
+ else kept.push(s.imported === s.local ? s.imported : `${s.imported} as ${s.local}`);
270
+ }
271
+ if (deep.length === 0) return statement;
272
+ changed = true;
273
+ return [
274
+ ...deep,
275
+ ...kept.length ? [`import { ${kept.join(", ")} } from ${JSON.stringify(specifier)};`] : []
276
+ ].join(" ");
277
+ }
278
+ );
279
+ return changed ? out : null;
280
+ }
281
+ function resolveFarmOptimizedPackageImports(option) {
282
+ if (option === false) return /* @__PURE__ */ new Set();
283
+ return /* @__PURE__ */ new Set([...FARM_OPTIMIZED_PACKAGE_IMPORTS, ...option ?? []]);
284
+ }
285
+ var SOURCE_RE = /\.(?:[cm]?[jt]sx?)$/;
286
+ function farmPackageImportsPlugin(options) {
287
+ const barrels = /* @__PURE__ */ new Map();
288
+ const barrel = (packageName) => {
289
+ let entry = barrels.get(packageName);
290
+ if (entry === void 0) {
291
+ entry = readFarmPackageBarrel(options.root, packageName);
292
+ barrels.set(packageName, entry);
293
+ }
294
+ return entry;
295
+ };
296
+ return {
297
+ name: "farm:package-imports",
298
+ transform(code, id) {
299
+ if (options.packages.size === 0) return;
300
+ if (this.environment?.name === "client") return;
301
+ const file = id.split("?")[0];
302
+ if (file.includes("/node_modules/") || !SOURCE_RE.test(file)) return;
303
+ if (!code.includes("import")) return;
304
+ let mentions = false;
305
+ for (const name of options.packages) {
306
+ if (code.includes(name)) {
307
+ mentions = true;
308
+ break;
309
+ }
310
+ }
311
+ if (!mentions) return;
312
+ const rewritten = rewriteFarmPackageImports(code, options.packages, barrel);
313
+ return rewritten === null ? void 0 : { code: rewritten, map: null };
314
+ }
315
+ };
316
+ }
317
+
318
+ // src/rsc-pipeline.ts
319
+ var FARM_RSC_ENTRIES = {
320
+ rsc: "./.farm/rsc-entries/entry.rsc.tsx",
321
+ ssr: "./.farm/rsc-entries/entry.ssr.tsx",
322
+ client: "./.farm/rsc-entries/entry.browser.tsx"
323
+ };
324
+ var FARM_RSC_CONFIG_KEYS = [
325
+ "srcDir",
326
+ "extends",
327
+ "basePath",
328
+ "trailingSlash",
329
+ "api",
330
+ "server",
331
+ "middleware",
332
+ "images",
333
+ "serverActions",
334
+ "deploymentId",
335
+ "generateBuildId",
336
+ "md",
337
+ "agent",
338
+ "mcp"
339
+ ];
340
+ var FARM_RSC_PASSTHROUGH_KEYS = [
341
+ "i18n",
342
+ "cache",
343
+ "redirects",
344
+ "rewrites",
345
+ "headers",
346
+ "compress"
347
+ ];
348
+ function pickImportTarget(entry) {
349
+ if (typeof entry === "string") return entry;
350
+ if (!entry || typeof entry !== "object") return void 0;
351
+ for (const condition of ["import", "node", "default"]) {
352
+ const target = pickImportTarget(entry[condition]);
353
+ if (target) return target;
354
+ }
355
+ return void 0;
356
+ }
357
+ async function importFromApp(root, packageName, subpath = ".") {
358
+ const packageDir = findFarmAppPackageDir(root, packageName);
359
+ if (!packageDir) return void 0;
360
+ const manifest = JSON.parse(readFileSync2(path2.join(packageDir, "package.json"), "utf8"));
361
+ const exportsMap = manifest.exports;
362
+ const entry = exportsMap && typeof exportsMap === "object" && !Array.isArray(exportsMap) && subpath in exportsMap ? exportsMap[subpath] : subpath === "." ? exportsMap ?? manifest.module ?? manifest.main ?? "index.js" : void 0;
363
+ const target = pickImportTarget(entry);
364
+ if (!target) return void 0;
365
+ return import(pathToFileURL(path2.join(packageDir, target)).href);
366
+ }
367
+ function hasPluginNamed(plugins, prefix) {
368
+ if (Array.isArray(plugins)) return plugins.some((plugin) => hasPluginNamed(plugin, prefix));
369
+ const name = plugins?.name;
370
+ return typeof name === "string" && name.startsWith(prefix);
371
+ }
372
+ async function createFarmRscViteConfig(userConfig, options) {
373
+ const root = path2.resolve(options.root);
374
+ const renderer = userConfig.renderer;
375
+ if (renderer && typeof renderer === "object" && renderer.name && renderer.name !== "react") {
376
+ throw new Error(
377
+ `[Farm.js] serverComponents needs the React renderer; this app uses "${renderer.name}".`
378
+ );
379
+ }
380
+ const [pluginRsc, viteRsc, viteReact] = await Promise.all([
381
+ importFromApp(root, "@farm.js/plugin", "./rsc"),
382
+ importFromApp(root, "@vitejs/plugin-rsc"),
383
+ importFromApp(root, "@vitejs/plugin-react")
384
+ ]);
385
+ if (!pluginRsc || !viteRsc || !findFarmAppPackageDir(root, "react-server-dom-webpack")) {
386
+ throw new Error(
387
+ `[Farm.js] serverComponents runs on @farm.js/plugin and the official @vitejs/plugin-rsc. Install them: ${FARM_RSC_INSTALL_HINT}`
388
+ );
389
+ }
390
+ const layered = await resolveFarmRscCheckConfig(
391
+ userConfig,
392
+ root,
393
+ options.command === "build" ? "production" : "development"
394
+ );
395
+ const config = await configureFarmRscPlugins(
396
+ {
397
+ ...userConfig,
398
+ vite: typeof userConfig.vite === "function" ? userConfig.vite({}) : userConfig.vite,
399
+ plugins: layered?.plugins ?? [],
400
+ publicRuntimeConfig: layered?.publicRuntimeConfig ?? {}
401
+ },
402
+ options.command
403
+ );
404
+ const blockingKeys = inspectFarmServerComponents(config, root).blockingKeys;
405
+ if (blockingKeys.length > 0) {
406
+ throw new Error(`[Farm.js] ${formatFarmRscBlockingMessage(blockingKeys)}`);
407
+ }
408
+ const { plugins: vitePlugins = [], ...viteOptions } = config.vite ?? {};
409
+ const rscConfig = {};
410
+ for (const key of FARM_RSC_CONFIG_KEYS) {
411
+ if (config[key] !== void 0) rscConfig[key] = config[key];
412
+ }
413
+ const createReactPlugin = hasPluginNamed(vitePlugins, "vite:react") ? void 0 : viteReact?.default ?? (options.command === "serve" ? (await loadFarmReactPlugin()).default : void 0);
414
+ const tailwind = hasPluginNamed(vitePlugins, "@tailwindcss/vite") ? void 0 : await loadTailwindVitePlugin();
415
+ const platform = resolveFarmPlatform();
416
+ const mobileClient = config.mobile === void 0 || platform === "desktop" ? void 0 : options.command === "build" ? "entry" : platform === "mobile" ? "inline" : void 0;
417
+ const clientPluginEntry = generateFarmClientPluginEntryCode(
418
+ config.plugins,
419
+ root,
420
+ typeof config.srcDir === "string" ? config.srcDir : "src",
421
+ config.publicRuntimeConfig ?? {},
422
+ // The RSC entry hands navigations to a mobile shell itself.
423
+ "web"
424
+ );
425
+ const serverPlugins = options.command === "build" ? await resolveFarmRscServerPlugins(userConfig, config, root) : void 0;
426
+ const farmConfig = pluginRsc.defineConfig({
427
+ ...rscConfig,
428
+ ...mobileClient ? { mobileClient } : {},
429
+ clientPlugins: {
430
+ empty: clientPluginEntry.empty,
431
+ imports: clientPluginEntry.imports,
432
+ registrations: clientPluginEntry.registrations
433
+ },
434
+ // Plugins with server hooks load in the production server, as in Farm's other servers, so
435
+ // factories such as `bot()` run there. Dev loaded them with the config already.
436
+ ...serverPlugins ? { serverPlugins } : {},
437
+ ...options.preset ? { preset: options.preset } : {},
438
+ experimental: { ...config.experimental, serverComponents: { mode: "rsc" } },
439
+ port: options.port ?? config.server?.port,
440
+ plugins: [
441
+ ...options.command === "serve" && platform === "desktop" ? [
442
+ farmDesktopDevGuardPlugin(
443
+ typeof config.basePath === "string" ? config.basePath : void 0
444
+ )
445
+ ] : [],
446
+ ...tailwind ? [tailwind] : [],
447
+ // Before the RSC plugin reads an app module. Only this pipeline has it: plugin-rsc runs every
448
+ // package that depends on React through Vite, so the deep module is the one the barrel would
449
+ // have loaded. Farm's own pipeline lets Node load such packages (lucide-react's `node`
450
+ // condition is CommonJS), where a deep ES module import would load a second copy.
451
+ farmPackageImportsPlugin({
452
+ root,
453
+ packages: resolveFarmOptimizedPackageImports(config.experimental?.optimizePackageImports)
454
+ }),
455
+ ...vitePlugins,
456
+ viteRsc.default({ serverHandler: false, entries: FARM_RSC_ENTRIES }),
457
+ ...typeof createReactPlugin === "function" ? [createReactPlugin()] : [],
458
+ pluginRsc.nitro({
459
+ server: { environmentName: "rsc" },
460
+ config: {
461
+ preset: options.preset,
462
+ outputDir: options.outputDir && resolveDeployOutputPath(root, options.outputDir)
463
+ }
464
+ })
465
+ ]
466
+ });
467
+ for (const key of FARM_RSC_PASSTHROUGH_KEYS) {
468
+ if (config[key] !== void 0) farmConfig[key] = config[key];
469
+ }
470
+ const { mergeConfig } = await import("vite");
471
+ return {
472
+ ...mergeConfig(farmConfig, viteOptions),
473
+ root,
474
+ // The Farm config is the app's config; a stray vite.config must not add a second pipeline.
475
+ configFile: false,
476
+ mode: options.command === "build" ? "production" : "development"
477
+ };
478
+ }
479
+ async function resolveFarmRscServerPlugins(userConfig, config, root) {
480
+ const kept = config.plugins ?? [];
481
+ const names = new Set(
482
+ kept.filter((plugin) => hasFarmServerRuntimePlugins([plugin])).map((plugin) => plugin.name)
483
+ );
484
+ if (names.size === 0) return void 0;
485
+ const loads = (plugin) => {
486
+ const candidate = plugin;
487
+ return !!candidate && names.has(candidate.name) && hasFarmServerRuntimePlugins([candidate]);
488
+ };
489
+ const { findFarmConfigFile, loadFarmConfigFile, resolveFarmLayers } = await import("./layers-O6GUR6LT.mjs");
490
+ const files = [];
491
+ if (userConfig.extends) {
492
+ const { layers } = await resolveFarmLayers(userConfig, { root, mode: "production" });
493
+ for (const layer of layers) {
494
+ if (!layer.configFile) continue;
495
+ const layerConfig = await loadFarmConfigFile(layer.configFile, {
496
+ root: layer.root,
497
+ cacheRoot: root
498
+ });
499
+ files.push([layer.configFile, layerConfig.plugins]);
500
+ }
501
+ }
502
+ const configFile = findFarmConfigFile(root);
503
+ if (configFile) files.push([configFile, userConfig.plugins]);
504
+ const selections = {};
505
+ for (const [file, plugins] of files) {
506
+ const entries = Array.isArray(plugins) ? plugins : [plugins];
507
+ const indexes = entries.flatMap(
508
+ (entry, index) => [entry].flat(Infinity).some(loads) ? [index] : []
509
+ );
510
+ if (indexes.length > 0) selections[path2.resolve(file)] = { indexes, count: entries.length };
511
+ }
512
+ return Object.keys(selections).length > 0 ? selections : void 0;
513
+ }
514
+ async function configureFarmRscPlugins(config, command) {
515
+ if (config.plugins.length === 0) return config;
516
+ const { PluginManager } = await import("./plugin-B7I5QVBE.mjs");
517
+ const manager = new PluginManager({
518
+ config,
519
+ isDev: command === "serve",
520
+ isProd: command === "build"
521
+ });
522
+ manager.addPlugins(config.plugins);
523
+ return await manager.runHookSerial("config", config);
524
+ }
525
+ async function createFarmRscDevServer(userConfig, options) {
526
+ const { createServer } = await import("vite");
527
+ const { host, ...configOptions } = options;
528
+ const config = await createFarmRscViteConfig(userConfig, { ...configOptions, command: "serve" });
529
+ return createServer({
530
+ ...config,
531
+ plugins: [...config.plugins ?? [], createFarmDevLoopbackPlugin()],
532
+ ...host === void 0 ? {} : { server: { ...config.server, host } }
533
+ });
534
+ }
535
+ async function buildFarmRsc(userConfig, options) {
536
+ const { createBuilder } = await import("vite");
537
+ const builder = await createBuilder(
538
+ await createFarmRscViteConfig(userConfig, { ...options, command: "build" })
539
+ );
540
+ await builder.buildApp();
541
+ }
542
+
543
+ export {
544
+ createFarmRscViteConfig,
545
+ createFarmRscDevServer,
546
+ buildFarmRsc
547
+ };
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  PROGRAMMATIC_ROUTE_FILE_NAMES,
3
+ isTestSourceFile,
3
4
  scanProgrammaticPagePaths
4
- } from "./chunk-DZXD6CYJ.mjs";
5
+ } from "./chunk-V2RXBDV6.mjs";
5
6
 
6
7
  // src/routes.server.ts
7
8
  import { existsSync, readFileSync } from "fs";
8
- import { join } from "path";
9
+ import { join, relative } from "path";
9
10
  async function loadProgrammaticRouteManifests(options) {
10
11
  const manifests = [];
11
12
  const routeFiles = findProgrammaticRouteFiles(options.root, options.srcDir);
@@ -53,7 +54,7 @@ async function findProgrammaticRouteSourceFiles(srcRoot) {
53
54
  }
54
55
  try {
55
56
  const { glob } = await import("tinyglobby");
56
- return await glob("**/*.{ts,tsx,js,jsx}", {
57
+ const files = await glob("**/*.{ts,tsx,js,jsx}", {
57
58
  cwd: srcRoot,
58
59
  absolute: true,
59
60
  expandDirectories: false,
@@ -66,6 +67,7 @@ async function findProgrammaticRouteSourceFiles(srcRoot) {
66
67
  "lib/api.generated.ts"
67
68
  ]
68
69
  });
70
+ return files.filter((file) => !isTestSourceFile(relative(srcRoot, file)));
69
71
  } catch {
70
72
  return [];
71
73
  }
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-WABOJXAA.mjs";
5
5
  import {
6
6
  normalizeFarmProductionSiteOrigin
7
- } from "./chunk-NPR6SCEV.mjs";
7
+ } from "./chunk-AOSZIHL7.mjs";
8
8
  import {
9
9
  resolveFarmAppManifestConfig
10
10
  } from "./chunk-SQ5O7I3L.mjs";
@@ -29,7 +29,7 @@ import {
29
29
  } from "./chunk-YT2ZMLXK.mjs";
30
30
  import {
31
31
  FARM_VERSION
32
- } from "./chunk-6VMBLDWY.mjs";
32
+ } from "./chunk-CV7C75LN.mjs";
33
33
  import {
34
34
  applyFarmBasePath
35
35
  } from "./chunk-SF3JB56B.mjs";
@@ -18,7 +18,7 @@ import {
18
18
  } from "./chunk-LRPPXKCX.mjs";
19
19
  import {
20
20
  resolveDocsConfig
21
- } from "./chunk-JL2HNLMC.mjs";
21
+ } from "./chunk-3QC2XTCN.mjs";
22
22
  import {
23
23
  getFarmDocsAdapterConfigModule,
24
24
  isSecretDocsConfigKey