@farm.js/core 0.2.0 → 0.2.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 (237) hide show
  1. package/dist/{agent-mcp.d-xPua9Zdz.d.ts → agent-mcp.d-DuZjglYX.d.ts} +1 -1
  2. package/dist/{agent-mcp.d-DhZf5-v0.d.mts → agent-mcp.d-gI3ahrF6.d.mts} +1 -1
  3. package/dist/agent-runtime.d.mts +4 -4
  4. package/dist/agent-runtime.d.ts +4 -4
  5. package/dist/analyzer-5RSMYPWD.cjs +17 -0
  6. package/dist/{analyzer-LQ4LVDCW.mjs → analyzer-7TNBOI3J.mjs} +2 -2
  7. package/dist/api/node.d.mts +6 -6
  8. package/dist/api/node.d.ts +6 -6
  9. package/dist/api/route-manager.cjs +5 -5
  10. package/dist/api/route-manager.d.mts +6 -6
  11. package/dist/api/route-manager.d.ts +6 -6
  12. package/dist/api/route-manager.mjs +4 -4
  13. package/dist/api/runtime.d.mts +5 -5
  14. package/dist/api/runtime.d.ts +5 -5
  15. package/dist/api.cjs +6 -6
  16. package/dist/api.d.mts +7 -7
  17. package/dist/api.d.ts +7 -7
  18. package/dist/api.mjs +5 -5
  19. package/dist/{app-manifest.d-D6l1Wkn6.d.ts → app-manifest.d-B3h89j6a.d.ts} +1 -1
  20. package/dist/{app-manifest.d-Bq9VWtpk.d.mts → app-manifest.d-bHK9EGPI.d.mts} +1 -1
  21. package/dist/app-markdown.d.mts +5 -5
  22. package/dist/app-markdown.d.ts +5 -5
  23. package/dist/{app.d-gnTrW72o.d.ts → app.d-C3uyET_L.d.ts} +4 -4
  24. package/dist/{app.d-Bn1bqBkf.d.mts → app.d-Cr7fXGvJ.d.mts} +4 -4
  25. package/dist/{chunk-MEIZIRMK.mjs → chunk-2FKGY2ZS.mjs} +1 -1
  26. package/dist/{chunk-YOVSWY2E.mjs → chunk-2XDRRAAD.mjs} +1 -1
  27. package/dist/{chunk-GAD63TH7.mjs → chunk-4WCEWA22.mjs} +4 -4
  28. package/dist/{chunk-YQXLBYY2.cjs → chunk-5B2Y4EVS.cjs} +32 -8
  29. package/dist/{chunk-QCVP22KW.cjs → chunk-5RYBQKBY.cjs} +3 -3
  30. package/dist/{chunk-VFZQXADS.cjs → chunk-6QWBZGGP.cjs} +139 -137
  31. package/dist/{chunk-DVL3UVYT.mjs → chunk-6XABTMXR.mjs} +2 -2
  32. package/dist/{chunk-RDT2LJES.mjs → chunk-6YOMQ4GX.mjs} +9 -9
  33. package/dist/chunk-7QGA6UX6.cjs +26 -0
  34. package/dist/{chunk-LGL5QKUJ.cjs → chunk-A4WDDASS.cjs} +2 -2
  35. package/dist/{chunk-V36K4TSU.mjs → chunk-ADKPJZPP.mjs} +1 -1
  36. package/dist/{chunk-LQZXCSYG.mjs → chunk-B6K2ZM3C.mjs} +5 -3
  37. package/dist/{chunk-Z7YIQ7AJ.cjs → chunk-C2J5LMH6.cjs} +1 -1
  38. package/dist/{chunk-D7KBMJ7L.mjs → chunk-CIRC2LRP.mjs} +1 -1
  39. package/dist/{chunk-RMLXUVR5.cjs → chunk-CS6GXE42.cjs} +91 -21
  40. package/dist/{chunk-DNERKYN4.cjs → chunk-CSCORWIQ.cjs} +15 -15
  41. package/dist/{chunk-GK2RCRT2.mjs → chunk-CTHQE7DO.mjs} +1 -1
  42. package/dist/{chunk-PRKFECGT.cjs → chunk-DZWX7FDX.cjs} +6 -4
  43. package/dist/{chunk-ZVEKOMZS.mjs → chunk-ERY4VYUH.mjs} +1 -1
  44. package/dist/{chunk-4ER5KYSC.cjs → chunk-F6JSVP5C.cjs} +3 -3
  45. package/dist/chunk-G7LNCHTS.mjs +21 -0
  46. package/dist/{chunk-ZCT6B5PQ.cjs → chunk-GWFNJLDN.cjs} +11 -11
  47. package/dist/{chunk-O47IT4CS.cjs → chunk-H7DAFRYR.cjs} +4 -4
  48. package/dist/{chunk-MX4G24YS.mjs → chunk-HOBCEE5J.mjs} +17 -15
  49. package/dist/{chunk-ZF7N222A.mjs → chunk-IPKL7L6B.mjs} +2 -2
  50. package/dist/{chunk-54INSSWI.mjs → chunk-IQQ3SWH6.mjs} +99 -56
  51. package/dist/{chunk-MUQP2APN.cjs → chunk-JJUHUPRB.cjs} +2 -2
  52. package/dist/{chunk-2LHO4HTP.cjs → chunk-K7RXZ77U.cjs} +2 -2
  53. package/dist/{chunk-SIHHYNX4.mjs → chunk-KJMRW3IP.mjs} +1 -1
  54. package/dist/{chunk-PYPHM7AS.cjs → chunk-LH7S7FI3.cjs} +5 -1
  55. package/dist/chunk-O77EKGAS.mjs +36 -0
  56. package/dist/{chunk-WXPY5FRF.cjs → chunk-P2PF5FUW.cjs} +2 -2
  57. package/dist/{chunk-WOPQQCP3.mjs → chunk-P3UT3OLV.mjs} +3 -3
  58. package/dist/{chunk-PZ5ZJAAO.mjs → chunk-POCWXRXW.mjs} +1 -1
  59. package/dist/{chunk-Z23OCU33.cjs → chunk-RF3VCNV7.cjs} +6 -6
  60. package/dist/{chunk-MLMDOIBY.mjs → chunk-RS4QZOFK.mjs} +3 -3
  61. package/dist/{chunk-MZG5M4JS.cjs → chunk-SO4USIKL.cjs} +4 -4
  62. package/dist/{chunk-HYYOVRED.mjs → chunk-SPVXL37B.mjs} +1 -1
  63. package/dist/{chunk-VWPGK6UV.cjs → chunk-TAXZQNFZ.cjs} +74 -74
  64. package/dist/{chunk-KKXGBQ2K.mjs → chunk-UKGAP2OK.mjs} +4 -4
  65. package/dist/{chunk-DZXD6CYJ.mjs → chunk-V2RXBDV6.mjs} +4 -0
  66. package/dist/{chunk-FFROR7QD.mjs → chunk-VZRY3CL5.mjs} +1 -1
  67. package/dist/{chunk-LO5BNR6Y.mjs → chunk-W5T3ZAFU.mjs} +25 -1
  68. package/dist/{chunk-ADCVSTFV.cjs → chunk-WAQIO2VD.cjs} +2 -2
  69. package/dist/{chunk-JKNQMGZE.cjs → chunk-WFL7CD5C.cjs} +12 -12
  70. package/dist/{chunk-KJW6KEOZ.mjs → chunk-WRT775N6.mjs} +92 -22
  71. package/dist/{chunk-RP55BUJM.mjs → chunk-XGBDRC5B.mjs} +2 -2
  72. package/dist/{chunk-J6JAUJPC.cjs → chunk-XLJ2REOI.cjs} +385 -342
  73. package/dist/{chunk-ZTNU4XCC.cjs → chunk-Y3MTKPLN.cjs} +7 -7
  74. package/dist/{chunk-MNBFSAWF.cjs → chunk-YCGOQKVC.cjs} +20 -1
  75. package/dist/{chunk-T4VF6BYV.cjs → chunk-YPPAYYSX.cjs} +6 -6
  76. package/dist/{chunk-PATIHHC7.cjs → chunk-ZQOHL6TX.cjs} +2 -2
  77. package/dist/{client-component.d-DT5OKBZu.d.ts → client-component.d-BavTzqsn.d.ts} +1 -1
  78. package/dist/{client-component.d-34DDMZcl.d.mts → client-component.d-X3j9FOZ2.d.mts} +1 -1
  79. package/dist/{client-plugins.d-D9CnUvZ5.d.ts → client-plugins.d-CqTr5IrQ.d.ts} +64 -4
  80. package/dist/{client-plugins.d-D7k9t9Ge.d.mts → client-plugins.d-DnnAopKG.d.mts} +64 -4
  81. package/dist/client-plugins.d.mts +4 -4
  82. package/dist/client-plugins.d.ts +4 -4
  83. package/dist/client.d.mts +10 -10
  84. package/dist/client.d.ts +10 -10
  85. package/dist/config.d.mts +4 -4
  86. package/dist/config.d.ts +4 -4
  87. package/dist/desktop.cjs +5 -1
  88. package/dist/desktop.d.mts +11 -7
  89. package/dist/desktop.d.ts +11 -7
  90. package/dist/desktop.mjs +4 -0
  91. package/dist/{dev-guard-M3ZCDWCK.cjs → dev-guard-5NUIX6IZ.cjs} +4 -3
  92. package/dist/{dev-guard-TFVWJNIB.mjs → dev-guard-L42ZZRCZ.mjs} +2 -1
  93. package/dist/{devtools-R77KAJA4.mjs → devtools-VPFBH6I2.mjs} +1 -1
  94. package/dist/{devtools-IUU4SWQL.cjs → devtools-YTND2OWT.cjs} +2 -2
  95. package/dist/docs.cjs +3 -3
  96. package/dist/docs.d.mts +6 -6
  97. package/dist/docs.d.ts +6 -6
  98. package/dist/docs.mjs +2 -2
  99. package/dist/environment/vite.cjs +4 -4
  100. package/dist/environment/vite.d.mts +1 -1
  101. package/dist/environment/vite.d.ts +1 -1
  102. package/dist/environment/vite.mjs +3 -3
  103. package/dist/{generate-route-types.d-BFOMM8Ef.d.mts → generate-route-types.d-CAiRw4N0.d.mts} +1 -1
  104. package/dist/{generate-route-types.d-C2m8myHb.d.ts → generate-route-types.d-Dz8MOQ3u.d.ts} +1 -1
  105. package/dist/{handler.d-fxTjv3Nn.d.mts → handler.d-BSlpYCDB.d.mts} +2 -2
  106. package/dist/{handler.d-DbZvbwNi.d.ts → handler.d-DgX7gPO6.d.ts} +2 -2
  107. package/dist/{headers.d-OBHpGTF_.d.mts → headers.d-Cf8l5LMo.d.mts} +1 -1
  108. package/dist/{headers.d-oeWybIk8.d.ts → headers.d-CmxW42R2.d.ts} +1 -1
  109. package/dist/index.cjs +29 -28
  110. package/dist/{index.d-CRrPQwlO.d.mts → index.d-7xoJqKRZ.d.mts} +1 -1
  111. package/dist/{index.d-BM-dKdzH.d.ts → index.d-BZZt7kxO.d.ts} +1 -1
  112. package/dist/index.d.mts +27 -27
  113. package/dist/index.d.ts +27 -27
  114. package/dist/index.mjs +24 -23
  115. package/dist/integrations/orm.d.mts +4 -4
  116. package/dist/integrations/orm.d.ts +4 -4
  117. package/dist/integrations.d.mts +4 -4
  118. package/dist/integrations.d.ts +4 -4
  119. package/dist/internal/app-markdown-runtime.d.mts +5 -5
  120. package/dist/internal/app-markdown-runtime.d.ts +5 -5
  121. package/dist/internal/build-runtime.cjs +24 -23
  122. package/dist/internal/build-runtime.d.mts +7 -7
  123. package/dist/internal/build-runtime.d.ts +7 -7
  124. package/dist/internal/build-runtime.mjs +23 -22
  125. package/dist/internal/cli-runtime.cjs +12 -9
  126. package/dist/internal/cli-runtime.d.mts +20 -12
  127. package/dist/internal/cli-runtime.d.ts +20 -12
  128. package/dist/internal/cli-runtime.mjs +11 -8
  129. package/dist/internal/client-error-overlay.cjs +4 -4
  130. package/dist/internal/client-error-overlay.mjs +1 -1
  131. package/dist/internal/client-runtime.d.mts +8 -8
  132. package/dist/internal/client-runtime.d.ts +8 -8
  133. package/dist/internal/compression-runtime.d.mts +4 -4
  134. package/dist/internal/compression-runtime.d.ts +4 -4
  135. package/dist/internal/config-runtime.cjs +5 -4
  136. package/dist/internal/config-runtime.d.mts +8 -8
  137. package/dist/internal/config-runtime.d.ts +8 -8
  138. package/dist/internal/config-runtime.mjs +4 -3
  139. package/dist/internal/infra-analytics-runtime.cjs +6 -6
  140. package/dist/internal/infra-analytics-runtime.mjs +4 -4
  141. package/dist/internal/native-server-fns.cjs +4 -4
  142. package/dist/internal/native-server-fns.mjs +3 -3
  143. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  144. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  145. package/dist/internal/production-runtime.cjs +4 -4
  146. package/dist/internal/production-runtime.d.mts +13 -13
  147. package/dist/internal/production-runtime.d.ts +13 -13
  148. package/dist/internal/production-runtime.mjs +3 -3
  149. package/dist/internal/spa-router.d.mts +6 -6
  150. package/dist/internal/spa-router.d.ts +6 -6
  151. package/dist/internal/start-manifest.d.mts +4 -4
  152. package/dist/internal/start-manifest.d.ts +4 -4
  153. package/dist/{layers.d-CH0bC4QL.d.mts → layers.d-dNBkiNE9.d.mts} +1 -1
  154. package/dist/{layers.d-CH0bC4QL.d.ts → layers.d-dNBkiNE9.d.ts} +1 -1
  155. package/dist/{manager-STAB5TVZ.cjs → manager-YRIENS63.cjs} +4 -4
  156. package/dist/{manager-EFPBRS3U.mjs → manager-YTJOAHII.mjs} +3 -3
  157. package/dist/markdown.d.mts +4 -4
  158. package/dist/markdown.d.ts +4 -4
  159. package/dist/middleware.d.mts +4 -4
  160. package/dist/middleware.d.ts +4 -4
  161. package/dist/mobile.d.mts +4 -4
  162. package/dist/mobile.d.ts +4 -4
  163. package/dist/{mount.d-TnD-Mebk.d.ts → mount.d-CD-xVBu7.d.ts} +1 -1
  164. package/dist/{mount.d-B7RiwjiO.d.mts → mount.d-Dd0xeRMl.d.mts} +1 -1
  165. package/dist/{navigation-delegate.d-VBCF0EeN.d.ts → navigation-delegate.d-Bses_F-y.d.ts} +1 -1
  166. package/dist/{navigation-delegate.d-Boz2511c.d.mts → navigation-delegate.d-dBNg976E.d.mts} +1 -1
  167. package/dist/navigation.d.mts +7 -7
  168. package/dist/navigation.d.ts +7 -7
  169. package/dist/plugin.cjs +19 -18
  170. package/dist/plugin.d.mts +8 -8
  171. package/dist/plugin.d.ts +8 -8
  172. package/dist/plugin.mjs +18 -17
  173. package/dist/{render-plan.d-BrumV_ZE.d.ts → render-plan.d-DaIwnRK2.d.ts} +1 -1
  174. package/dist/{render-plan.d-BwnmyfNk.d.mts → render-plan.d-vOdZHHLI.d.mts} +1 -1
  175. package/dist/renderer-client.d.mts +8 -8
  176. package/dist/renderer-client.d.ts +8 -8
  177. package/dist/{request.d-Dd5nRTO5.d.mts → request.d-B8U4pVFP.d.mts} +1 -1
  178. package/dist/{request.d-NUi01-5e.d.ts → request.d-CgXp3EEc.d.ts} +1 -1
  179. package/dist/request.d.mts +5 -5
  180. package/dist/request.d.ts +5 -5
  181. package/dist/{route-rendering.d-BK0Pf7_k.d.mts → route-rendering.d-BQvNYQqu.d.mts} +1 -1
  182. package/dist/{route-rendering.d-CJR5BPXV.d.ts → route-rendering.d-Di0AxFix.d.ts} +1 -1
  183. package/dist/{router.d-C-JSFCPU.d.ts → router.d-BJVGhSAJ.d.ts} +1 -1
  184. package/dist/{router.d-CNUS3x1j.d.mts → router.d-hNedVdoB.d.mts} +1 -1
  185. package/dist/routes.cjs +3 -3
  186. package/dist/{routes.d-D7RWvfqL.d.ts → routes.d-CYe98R_8.d.ts} +1 -1
  187. package/dist/{routes.d-BWvpUoYu.d.mts → routes.d-DBGnKaUQ.d.mts} +1 -1
  188. package/dist/routes.d.mts +4 -4
  189. package/dist/routes.d.ts +4 -4
  190. package/dist/routes.mjs +2 -2
  191. package/dist/{rsc-pipeline-DHISDFT7.mjs → rsc-pipeline-2JSNRVIL.mjs} +6 -5
  192. package/dist/{rsc-pipeline-UBWVU3NF.cjs → rsc-pipeline-WTKDMTE2.cjs} +7 -6
  193. package/dist/{runtime-XKRQW3YT.cjs → runtime-I4GV4CDP.cjs} +8 -8
  194. package/dist/{runtime-VUKMY44G.mjs → runtime-RNSTQY27.mjs} +5 -5
  195. package/dist/{runtime.d-B2T4bM5_.d.ts → runtime.d-0R8nHCM6.d.ts} +1 -1
  196. package/dist/{runtime.d-CsOpO6yQ.d.mts → runtime.d-DpeuF_T-.d.mts} +1 -1
  197. package/dist/{cli-runtime.d-LwIb0swO.d.mts → schema-dependencies.d-_Wyey4Wv.d.mts} +21 -13
  198. package/dist/{cli-runtime.d-Vvxf-Z8a.d.ts → schema-dependencies.d-tkUHREqz.d.ts} +21 -13
  199. package/dist/{schema.d-BM-uVGpx.d.mts → schema.d-HlGSe1on.d.mts} +1 -1
  200. package/dist/{schema.d-BM-uVGpx.d.ts → schema.d-HlGSe1on.d.ts} +1 -1
  201. package/dist/schema.d.mts +1 -1
  202. package/dist/schema.d.ts +1 -1
  203. package/dist/{server-components-status.d-DOYt4E_Q.d.ts → server-components-status.d-B2Z5WvO5.d.ts} +2 -2
  204. package/dist/{server-components-status.d-Cc5rir0l.d.mts → server-components-status.d-sN7ju-ie.d.mts} +2 -2
  205. package/dist/server-plugins.d.mts +6 -6
  206. package/dist/server-plugins.d.ts +6 -6
  207. package/dist/server.cjs +46 -45
  208. package/dist/server.d.mts +14 -14
  209. package/dist/server.d.ts +14 -14
  210. package/dist/server.mjs +20 -19
  211. package/dist/{spa-router.d-Cq5UFJvq.d.mts → spa-router.d-D3AtR2Bc.d.mts} +2 -2
  212. package/dist/{spa-router.d-C7FcpLxU.d.ts → spa-router.d-MjT6sGb9.d.ts} +2 -2
  213. package/dist/{ssg.d-BzNZemk7.d.mts → ssg.d-B32Cp_XW.d.mts} +3 -3
  214. package/dist/{ssg.d-DUhacIxj.d.ts → ssg.d-C1SNuPz5.d.ts} +3 -3
  215. package/dist/storage.d.mts +2 -2
  216. package/dist/storage.d.ts +2 -2
  217. package/dist/{store-core.d-BX3yXrxA.d.ts → store-core.d-BZ3YXs70.d.ts} +2 -2
  218. package/dist/{store-core.d-DbUAtSBK.d.mts → store-core.d-BbVdaoA0.d.mts} +2 -2
  219. package/dist/testing.cjs +6 -6
  220. package/dist/testing.d.mts +4 -4
  221. package/dist/testing.d.ts +4 -4
  222. package/dist/testing.mjs +5 -5
  223. package/dist/{types.d-C5hlNbHa.d.mts → types.d-CRiwa0jj.d.mts} +1 -1
  224. package/dist/{types.d-C5hlNbHa.d.ts → types.d-CRiwa0jj.d.ts} +1 -1
  225. package/dist/{utils.d-BhJJEXzo.d.ts → utils.d-Bjbm44fP.d.ts} +1 -1
  226. package/dist/{utils.d-NOMkLFpC.d.mts → utils.d-CoLozp7-.d.mts} +1 -1
  227. package/dist/version.cjs +2 -2
  228. package/dist/version.mjs +1 -1
  229. package/dist/vite.cjs +19 -18
  230. package/dist/vite.d.mts +9 -9
  231. package/dist/vite.d.ts +9 -9
  232. package/dist/vite.mjs +18 -17
  233. package/package.json +1 -1
  234. package/dist/analyzer-ZFC2L6NZ.cjs +0 -17
  235. package/dist/chunk-OZAVCLXY.mjs +0 -17
  236. /package/dist/{chunk-OAAVIFOJ.cjs → chunk-2LGM5WIK.cjs} +0 -0
  237. /package/dist/{chunk-ZRTBDHO2.mjs → chunk-MVNIAD6O.mjs} +0 -0
@@ -6,6 +6,9 @@ import {
6
6
  resolvePlatformBlock,
7
7
  resolvePlatformProfile
8
8
  } from "./chunk-UB7RVEMX.mjs";
9
+ import {
10
+ FARM_DESKTOP_PERMISSIONS
11
+ } from "./chunk-G7LNCHTS.mjs";
9
12
 
10
13
  // src/desktop/config.ts
11
14
  import { existsSync } from "fs";
@@ -21,8 +24,9 @@ function resolveFarmPlatform(env = process.env) {
21
24
  const value = env[FARM_PLATFORM_ENV];
22
25
  return value === "desktop" || value === "mobile" ? value : "web";
23
26
  }
24
- var DESKTOP_KEYS = /* @__PURE__ */ new Set(["name", "id", "version", "icon", "window", "shell"]);
27
+ var DESKTOP_KEYS = /* @__PURE__ */ new Set(["name", "id", "version", "icon", "window", "permissions", "shell"]);
25
28
  var WINDOW_KEYS = /* @__PURE__ */ new Set(["width", "height", "title", "hideOnClose"]);
29
+ var PERMISSION_KEYS = new Set(FARM_DESKTOP_PERMISSIONS);
26
30
  var APP_ID = /^[A-Za-z][A-Za-z0-9-]*(?:\.[A-Za-z0-9][A-Za-z0-9-]*)+$/;
27
31
  var SHELL_NAME = /^[a-z][a-z0-9-]*$/;
28
32
  var SHELL_PACKAGE = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)*$/;
@@ -70,6 +74,20 @@ function validateFarmDesktopConfig(input, context) {
70
74
  fail("window.hideOnClose must be true or false.");
71
75
  }
72
76
  }
77
+ if (input.permissions !== void 0) {
78
+ if (!isPlainObject(input.permissions)) {
79
+ fail('permissions must be an object, such as { microphone: "Notes records voice memos." }.');
80
+ }
81
+ checkKeys(input.permissions, PERMISSION_KEYS, "permissions.");
82
+ for (const key of PERMISSION_KEYS) {
83
+ const value = input.permissions[key];
84
+ if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
85
+ fail(
86
+ `permissions.${key} must be the sentence macOS shows when it asks for access, such as "Notes records voice memos.", or left out for no access.`
87
+ );
88
+ }
89
+ }
90
+ }
73
91
  const shell = optionalString(input.shell, "shell");
74
92
  if (shell !== void 0 && !SHELL_NAME.test(shell) && !shell.includes("/")) {
75
93
  fail(`shell must be an adapter name such as "electrobun" or a package name, got "${shell}".`);
@@ -94,6 +112,11 @@ function resolveFarmDesktopConfig(input, root, context) {
94
112
  const icon = config.icon ? path.resolve(root, config.icon.trim()) : void 0;
95
113
  if (icon && !existsSync(icon))
96
114
  desktopChecker(context).fail(`icon ${config.icon} was not found in ${root}.`);
115
+ const permissions = {};
116
+ for (const key of FARM_DESKTOP_PERMISSIONS) {
117
+ const sentence = config.permissions?.[key]?.trim();
118
+ if (sentence) permissions[key] = sentence;
119
+ }
97
120
  return {
98
121
  name,
99
122
  id: config.id?.trim() || `local.farm.${slug(name)}`,
@@ -105,6 +128,7 @@ function resolveFarmDesktopConfig(input, root, context) {
105
128
  title: config.window?.title?.trim() || name,
106
129
  hideOnClose: config.window?.hideOnClose === true
107
130
  },
131
+ ...Object.keys(permissions).length ? { permissions } : {},
108
132
  shell,
109
133
  shellPackage: resolveFarmDesktopShellPackage(shell)
110
134
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkYQXLBYY2cjs = require('./chunk-YQXLBYY2.cjs');
3
+ var _chunk5B2Y4EVScjs = require('./chunk-5B2Y4EVS.cjs');
4
4
 
5
5
 
6
6
  var _chunkN4AM7Q34cjs = require('./chunk-N4AM7Q34.cjs');
@@ -62,7 +62,7 @@ function resolveFarmClientPlugins(plugins, _root) {
62
62
  ];
63
63
  });
64
64
  }
65
- function generateFarmClientPluginEntryCode(plugins, root, srcDir = "src", appPublicData, platform = _chunkYQXLBYY2cjs.resolveFarmPlatform.call(void 0, )) {
65
+ function generateFarmClientPluginEntryCode(plugins, root, srcDir = "src", appPublicData, platform = _chunk5B2Y4EVScjs.resolveFarmPlatform.call(void 0, )) {
66
66
  const resolved = resolveFarmClientPlugins(plugins, root);
67
67
  const appClientEntry = root ? resolveFarmAppClientEntry(root, srcDir) : void 0;
68
68
  const appImport = appClientEntry ? `import farmAppClientDefinition from ${JSON.stringify(appClientEntry.replace(/\\/g, "/"))};` : "";
@@ -3,19 +3,19 @@
3
3
  var _chunkYV47TSSBcjs = require('./chunk-YV47TSSB.cjs');
4
4
 
5
5
 
6
- var _chunkOAAVIFOJcjs = require('./chunk-OAAVIFOJ.cjs');
6
+ var _chunk2LGM5WIKcjs = require('./chunk-2LGM5WIK.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkQCVP22KWcjs = require('./chunk-QCVP22KW.cjs');
10
+ var _chunk5RYBQKBYcjs = require('./chunk-5RYBQKBY.cjs');
11
11
 
12
12
 
13
13
 
14
14
 
15
- var _chunkADCVSTFVcjs = require('./chunk-ADCVSTFV.cjs');
15
+ var _chunkWAQIO2VDcjs = require('./chunk-WAQIO2VD.cjs');
16
16
 
17
17
 
18
- var _chunkYQXLBYY2cjs = require('./chunk-YQXLBYY2.cjs');
18
+ var _chunk5B2Y4EVScjs = require('./chunk-5B2Y4EVS.cjs');
19
19
 
20
20
 
21
21
 
@@ -126,11 +126,11 @@ async function createFarmRscViteConfig(userConfig, options) {
126
126
  for (const key of FARM_RSC_CONFIG_KEYS) {
127
127
  if (config[key] !== void 0) rscConfig[key] = config[key];
128
128
  }
129
- const createReactPlugin = hasPluginNamed(vitePlugins, "vite:react") ? void 0 : await _asyncNullishCoalesce(await _asyncOptionalChain([viteReact, 'optionalAccess', async _4 => _4.default]), async () => ( (options.command === "serve" ? (await _chunkQCVP22KWcjs.loadFarmReactPlugin.call(void 0, )).default : void 0)));
130
- const tailwind = hasPluginNamed(vitePlugins, "@tailwindcss/vite") ? void 0 : await _chunkADCVSTFVcjs.loadTailwindVitePlugin.call(void 0, );
131
- const platform = _chunkYQXLBYY2cjs.resolveFarmPlatform.call(void 0, );
129
+ const createReactPlugin = hasPluginNamed(vitePlugins, "vite:react") ? void 0 : await _asyncNullishCoalesce(await _asyncOptionalChain([viteReact, 'optionalAccess', async _4 => _4.default]), async () => ( (options.command === "serve" ? (await _chunk5RYBQKBYcjs.loadFarmReactPlugin.call(void 0, )).default : void 0)));
130
+ const tailwind = hasPluginNamed(vitePlugins, "@tailwindcss/vite") ? void 0 : await _chunkWAQIO2VDcjs.loadTailwindVitePlugin.call(void 0, );
131
+ const platform = _chunk5B2Y4EVScjs.resolveFarmPlatform.call(void 0, );
132
132
  const mobileClient = config.mobile === void 0 || platform === "desktop" ? void 0 : options.command === "build" ? "entry" : platform === "mobile" ? "inline" : void 0;
133
- const clientPluginEntry = _chunkADCVSTFVcjs.generateFarmClientPluginEntryCode.call(void 0,
133
+ const clientPluginEntry = _chunkWAQIO2VDcjs.generateFarmClientPluginEntryCode.call(void 0,
134
134
  config.plugins,
135
135
  root,
136
136
  typeof config.srcDir === "string" ? config.srcDir : "src",
@@ -155,7 +155,7 @@ async function createFarmRscViteConfig(userConfig, options) {
155
155
  port: _nullishCoalesce(options.port, () => ( _optionalChain([config, 'access', _5 => _5.server, 'optionalAccess', _6 => _6.port]))),
156
156
  plugins: [
157
157
  ...options.command === "serve" && platform === "desktop" ? [
158
- _chunkQCVP22KWcjs.farmDesktopDevGuardPlugin.call(void 0,
158
+ _chunk5RYBQKBYcjs.farmDesktopDevGuardPlugin.call(void 0,
159
159
  typeof config.basePath === "string" ? config.basePath : void 0
160
160
  )
161
161
  ] : [],
@@ -167,7 +167,7 @@ async function createFarmRscViteConfig(userConfig, options) {
167
167
  server: { environmentName: "rsc" },
168
168
  config: {
169
169
  preset: options.preset,
170
- outputDir: options.outputDir && _chunkOAAVIFOJcjs.resolveDeployOutputPath.call(void 0, root, options.outputDir)
170
+ outputDir: options.outputDir && _chunk2LGM5WIKcjs.resolveDeployOutputPath.call(void 0, root, options.outputDir)
171
171
  }
172
172
  })
173
173
  ]
@@ -187,12 +187,12 @@ async function createFarmRscViteConfig(userConfig, options) {
187
187
  async function resolveFarmRscServerPlugins(userConfig, config, root) {
188
188
  const kept = _nullishCoalesce(config.plugins, () => ( []));
189
189
  const names = new Set(
190
- kept.filter((plugin) => _chunkADCVSTFVcjs.hasFarmServerRuntimePlugins.call(void 0, [plugin])).map((plugin) => plugin.name)
190
+ kept.filter((plugin) => _chunkWAQIO2VDcjs.hasFarmServerRuntimePlugins.call(void 0, [plugin])).map((plugin) => plugin.name)
191
191
  );
192
192
  if (names.size === 0) return void 0;
193
193
  const loads = (plugin) => {
194
194
  const candidate = plugin;
195
- return !!candidate && names.has(candidate.name) && _chunkADCVSTFVcjs.hasFarmServerRuntimePlugins.call(void 0, [candidate]);
195
+ return !!candidate && names.has(candidate.name) && _chunkWAQIO2VDcjs.hasFarmServerRuntimePlugins.call(void 0, [candidate]);
196
196
  };
197
197
  const { findFarmConfigFile, loadFarmConfigFile, resolveFarmLayers } = await import("./layers-6R55QDT5.cjs");
198
198
  const files = [];
@@ -2,28 +2,59 @@ import {
2
2
  writeFileIfChanged
3
3
  } from "./chunk-YFTGIHNC.mjs";
4
4
  import {
5
- isFarmAPIRouteFileName
6
- } from "./chunk-OZAVCLXY.mjs";
5
+ getPolyrouteRouteDeclarationFileName,
6
+ isFarmAPIRouteFileName,
7
+ isPolyrouteRouteFileName
8
+ } from "./chunk-O77EKGAS.mjs";
7
9
  import {
8
10
  registerAPIRouteShape
9
11
  } from "./chunk-2LKUR5QJ.mjs";
10
12
 
11
13
  // src/type-generator.ts
12
- import { readFileSync, existsSync, readdirSync, mkdirSync } from "fs";
14
+ import { readFileSync, existsSync, readdirSync, mkdirSync, statSync } from "fs";
13
15
  import { createRequire } from "module";
14
- import { join, relative, dirname, extname } from "path";
16
+ import { basename, join, relative, dirname, extname } from "path";
15
17
  import { initSync, parse } from "es-module-lexer";
16
18
  var moduleLexerInitialized = false;
19
+ var HTTP_METHODS = ["GET", "HEAD", "QUERY", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
17
20
  var JSX_ROUTE_LANGS = { ".jsx": "jsx", ".tsx": "tsx" };
18
- var oxcTransformSync;
19
- function transformJSXRoute(content, lang, filePath) {
20
- oxcTransformSync ?? (oxcTransformSync = createRequire(typeof __filename === "string" ? __filename : import.meta.url)(
21
+ var oxcUtils;
22
+ function loadOxcUtils() {
23
+ return oxcUtils ?? (oxcUtils = createRequire(typeof __filename === "string" ? __filename : import.meta.url)(
21
24
  "rolldown/utils"
22
- ).transformSync);
23
- const result = oxcTransformSync(filePath, content, { lang, sourceType: "module" });
25
+ ));
26
+ }
27
+ function transformJSXRoute(content, lang, filePath) {
28
+ const result = loadOxcUtils().transformSync(filePath, content, { lang, sourceType: "module" });
24
29
  if (result.errors.length > 0) throw result.errors[0];
25
30
  return result.code;
26
31
  }
32
+ function extractDeclaredMethods(content, filePath) {
33
+ const { program, errors } = loadOxcUtils().parseSync(filePath, content, { lang: "dts" });
34
+ if (errors.length > 0) throw new Error(`${filePath}: ${errors[0].message}`);
35
+ const names = /* @__PURE__ */ new Set();
36
+ for (const statement of program.body) {
37
+ if (statement.type !== "ExportNamedDeclaration") continue;
38
+ const declaration = statement.declaration;
39
+ if (declaration?.type === "VariableDeclaration") {
40
+ for (const declarator of declaration.declarations) {
41
+ if (declarator.id.type === "Identifier") names.add(declarator.id.name);
42
+ }
43
+ } else if ((declaration?.type === "FunctionDeclaration" || declaration?.type === "TSDeclareFunction") && declaration.id) {
44
+ names.add(declaration.id.name);
45
+ } else if (!declaration && statement.exportKind !== "type") {
46
+ for (const specifier of statement.specifiers) {
47
+ if (specifier.exportKind === "type") continue;
48
+ const exported = specifier.exported;
49
+ names.add(exported.type === "Literal" ? String(exported.value) : exported.name);
50
+ }
51
+ }
52
+ }
53
+ return HTTP_METHODS.filter((method) => names.has(method));
54
+ }
55
+ function isFile(filePath) {
56
+ return statSync(filePath, { throwIfNoEntry: false })?.isFile() === true;
57
+ }
27
58
  var API_CLIENT_METHOD_SEGMENTS = /* @__PURE__ */ new Set([
28
59
  "get",
29
60
  "head",
@@ -35,8 +66,9 @@ var API_CLIENT_METHOD_SEGMENTS = /* @__PURE__ */ new Set([
35
66
  "options"
36
67
  ]);
37
68
  var APITypeGenerator = class {
38
- constructor(appDir) {
69
+ constructor(appDir, options = {}) {
39
70
  this.appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
71
+ this.polyroute = options.polyroute === true;
40
72
  }
41
73
  /**
42
74
  * Scan all API route files and extract route information
@@ -84,7 +116,7 @@ var APITypeGenerator = class {
84
116
  if (item.isDirectory()) {
85
117
  const newBasePath = basePath ? `${basePath}/${item.name}` : item.name;
86
118
  this.scanDirectory(fullPath, appDir, routes, newBasePath);
87
- } else if (isFarmAPIRouteFileName(item.name)) {
119
+ } else if (isFarmAPIRouteFileName(item.name, this.polyroute)) {
88
120
  const routeInfo = this.extractRouteInfo(fullPath, appDir, basePath);
89
121
  if (routeInfo) {
90
122
  routes.push(routeInfo);
@@ -93,14 +125,44 @@ var APITypeGenerator = class {
93
125
  }
94
126
  }
95
127
  extractRouteInfo(filePath, appDir, basePath) {
128
+ const relativePath = relative(appDir, filePath);
129
+ const apiPath = basePath ? `/api/${basePath}` : "/api";
130
+ const fileName = basename(filePath);
131
+ if (isPolyrouteRouteFileName(fileName)) {
132
+ const declarationPath = join(
133
+ dirname(filePath),
134
+ getPolyrouteRouteDeclarationFileName(fileName)
135
+ );
136
+ if (!isFile(declarationPath)) {
137
+ return { path: apiPath, methods: [...HTTP_METHODS], filePath, relativePath };
138
+ }
139
+ try {
140
+ const methods = extractDeclaredMethods(
141
+ readFileSync(declarationPath, "utf-8"),
142
+ declarationPath
143
+ );
144
+ if (methods.length === 0) return null;
145
+ return {
146
+ path: apiPath,
147
+ methods,
148
+ filePath,
149
+ relativePath,
150
+ declaration: {
151
+ filePath: declarationPath,
152
+ relativePath: relative(appDir, declarationPath)
153
+ }
154
+ };
155
+ } catch (error) {
156
+ console.warn(`Failed to read route declaration ${declarationPath}:`, error);
157
+ return null;
158
+ }
159
+ }
96
160
  try {
97
161
  const content = readFileSync(filePath, "utf-8");
98
162
  const methods = this.extractExportedMethods(content, filePath);
99
163
  if (methods.length === 0) {
100
164
  return null;
101
165
  }
102
- const relativePath = relative(appDir, filePath);
103
- const apiPath = basePath ? `/api/${basePath}` : "/api";
104
166
  return {
105
167
  path: apiPath,
106
168
  methods,
@@ -117,7 +179,7 @@ var APITypeGenerator = class {
117
179
  initSync();
118
180
  moduleLexerInitialized = true;
119
181
  }
120
- const httpMethods = ["GET", "HEAD", "QUERY", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
182
+ const httpMethods = HTTP_METHODS;
121
183
  const lang = JSX_ROUTE_LANGS[extname(filePath)];
122
184
  const source = lang ? transformJSXRoute(content, lang, filePath) : content;
123
185
  const [, exports] = parse(source);
@@ -154,9 +216,10 @@ var APITypeGenerator = class {
154
216
  */
155
217
  generateAPIRouter(routes, options = {}) {
156
218
  const imports = [];
219
+ const coreAPITypes = [];
157
220
  const pluginTypes = [];
158
221
  if (options.pluginConfigs?.length) {
159
- imports.push('import type { PluginAPIRouter } from "@farm.js/core/api";');
222
+ coreAPITypes.push("PluginAPIRouter");
160
223
  options.pluginConfigs.forEach((filePath, index) => {
161
224
  const importPath = this.getRouteImportPath({ filePath }, options.outFile);
162
225
  imports.push(`import type FarmPluginConfig${index} from ${JSON.stringify(importPath)};`);
@@ -197,18 +260,24 @@ var APITypeGenerator = class {
197
260
  for (const method of route.methods) methodSources.set(method, route);
198
261
  }
199
262
  const allMethods = [...methodSources.keys()];
263
+ const methodTypes = /* @__PURE__ */ new Map();
200
264
  for (const method of allMethods) {
201
- const importPath = this.getRouteImportPath(methodSources.get(method), options.outFile);
265
+ const source = methodSources.get(method);
266
+ if (!source.declaration && isPolyrouteRouteFileName(basename(source.filePath))) {
267
+ if (!coreAPITypes.includes("TypedEndpoint")) coreAPITypes.push("TypedEndpoint");
268
+ methodTypes.set(method, "TypedEndpoint<any, any>");
269
+ continue;
270
+ }
271
+ const importPath = this.getRouteImportPath(source.declaration ?? source, options.outFile);
202
272
  const importName = `${method}_${routeName}`;
203
273
  imports.push(
204
274
  `import type { ${method} as ${importName} } from ${JSON.stringify(importPath)};`
205
275
  );
276
+ methodTypes.set(method, `typeof ${importName}`);
206
277
  }
207
278
  if (parts.length === 0) {
208
279
  for (const method of allMethods) {
209
- const importName = `${method}_${routeName}`;
210
- const methodName = method.toLowerCase();
211
- nestedStructure[methodName] = `typeof ${importName}`;
280
+ nestedStructure[method.toLowerCase()] = methodTypes.get(method);
212
281
  }
213
282
  } else {
214
283
  const hasMethodCollision = parts.some((part, index) => {
@@ -224,9 +293,7 @@ var APITypeGenerator = class {
224
293
  if (i === typePath.length - 1) {
225
294
  current[part] = createRouteTreeNode();
226
295
  for (const method of allMethods) {
227
- const importName = `${method}_${routeName}`;
228
- const methodName = method.toLowerCase();
229
- current[part][methodName] = `typeof ${importName}`;
296
+ current[part][method.toLowerCase()] = methodTypes.get(method);
230
297
  }
231
298
  } else {
232
299
  if (!Object.prototype.hasOwnProperty.call(current, part)) {
@@ -263,6 +330,9 @@ ${routeManifest.map(
263
330
  },`
264
331
  ).join("\n")}
265
332
  ]` : "[]";
333
+ if (coreAPITypes.length) {
334
+ imports.unshift(`import type { ${coreAPITypes.join(", ")} } from "@farm.js/core/api";`);
335
+ }
266
336
  return `/**
267
337
  * Auto-generated API router types
268
338
  * This file is automatically generated - do not edit manually
@@ -25,13 +25,13 @@ import {
25
25
  PROGRAMMATIC_ROUTE_FILE_NAMES,
26
26
  getProgrammaticRouteDefinitionSource,
27
27
  parseProgrammaticRouteModuleId
28
- } from "./chunk-DZXD6CYJ.mjs";
28
+ } from "./chunk-V2RXBDV6.mjs";
29
29
  import {
30
30
  logger
31
31
  } from "./chunk-U6GMCDRS.mjs";
32
32
  import {
33
33
  FARM_VERSION
34
- } from "./chunk-MEIZIRMK.mjs";
34
+ } from "./chunk-2FKGY2ZS.mjs";
35
35
 
36
36
  // src/environment-vite.ts
37
37
  import { existsSync, readFileSync, realpathSync } from "fs";