@farm.js/core 0.1.62 → 0.1.64

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 (194) hide show
  1. package/dist/{agent-mcp-handler-OV4WRFBL.cjs → agent-mcp-handler-OXT73ZBY.cjs} +5 -5
  2. package/dist/{agent-mcp-handler-7QMX2LUY.mjs → agent-mcp-handler-QLFDDTYN.mjs} +4 -4
  3. package/dist/{agent-mcp.d-BKZ3UNbt.d.mts → agent-mcp.d-CO_ABmNK.d.mts} +1 -1
  4. package/dist/{agent-mcp.d-C1zr_nGS.d.ts → agent-mcp.d-QD2WZ9BS.d.ts} +1 -1
  5. package/dist/agent-runtime.d.mts +1 -1
  6. package/dist/agent-runtime.d.ts +1 -1
  7. package/dist/analyzer-ODLF2Z6O.cjs +16 -0
  8. package/dist/{analyzer-YESYU3GK.mjs → analyzer-Q3QXC6PD.mjs} +3 -2
  9. package/dist/api/route-manager.d.mts +3 -3
  10. package/dist/api/route-manager.d.ts +3 -3
  11. package/dist/api/runtime.d.mts +2 -2
  12. package/dist/api/runtime.d.ts +2 -2
  13. package/dist/api.d.mts +3 -3
  14. package/dist/api.d.ts +3 -3
  15. package/dist/{app-manifest.d-ntch_bvA.d.ts → app-manifest.d-BpKxiU_E.d.mts} +9 -1
  16. package/dist/{app-manifest.d-BpvhfKRH.d.mts → app-manifest.d-DDmNkYQQ.d.ts} +9 -1
  17. package/dist/app-markdown.cjs +4 -4
  18. package/dist/app-markdown.d.mts +2 -2
  19. package/dist/app-markdown.d.ts +2 -2
  20. package/dist/app-markdown.mjs +3 -3
  21. package/dist/{app.d-CysWA_8v.d.mts → app.d-kuoVWhWM.d.mts} +4 -4
  22. package/dist/{app.d-AE8_v3Db.d.ts → app.d-x68Cwr0_.d.ts} +4 -4
  23. package/dist/{chunk-LT4VAF5Z.cjs → chunk-2C5L5RPM.cjs} +7 -6
  24. package/dist/{chunk-RMUD75WT.cjs → chunk-3EBHJET2.cjs} +355 -270
  25. package/dist/{chunk-RZNCMRD3.mjs → chunk-6NHSGVVA.mjs} +1 -1
  26. package/dist/{chunk-LVWGURLD.mjs → chunk-6NNYPY5W.mjs} +327 -13
  27. package/dist/{chunk-PRFNLQSP.cjs → chunk-7XGWBPQQ.cjs} +4 -4
  28. package/dist/{chunk-SG57PX7K.cjs → chunk-BTVDYS4B.cjs} +7 -2
  29. package/dist/{chunk-545WJ5UG.cjs → chunk-DUSHDZQL.cjs} +11 -11
  30. package/dist/{chunk-GVOMPU3Y.cjs → chunk-EL4364S2.cjs} +209 -32
  31. package/dist/{chunk-GGNJAGGE.cjs → chunk-FAP7CX7C.cjs} +1056 -529
  32. package/dist/{chunk-T46NNU4D.mjs → chunk-FH45OB37.mjs} +2 -2
  33. package/dist/{chunk-55U5QIXQ.mjs → chunk-FIR62CR3.mjs} +1 -1
  34. package/dist/{chunk-MEQN6DDA.cjs → chunk-FJWN7RV4.cjs} +5 -5
  35. package/dist/chunk-IOEXXZK3.mjs +88 -0
  36. package/dist/{chunk-EXXFSZOC.cjs → chunk-JCPSA4X5.cjs} +135 -134
  37. package/dist/{chunk-YSXTNSXS.mjs → chunk-K7OZAVOI.mjs} +7 -6
  38. package/dist/{chunk-KVW2M6PI.mjs → chunk-KL7SHLQB.mjs} +1 -1
  39. package/dist/{chunk-NT3QDN2E.mjs → chunk-LQDLEWPO.mjs} +1 -1
  40. package/dist/{chunk-UZZ6IEQP.mjs → chunk-MESQF2JC.mjs} +2 -2
  41. package/dist/{chunk-WKJQ2FJA.cjs → chunk-MG356ROI.cjs} +5 -5
  42. package/dist/{chunk-AJB3DHN6.cjs → chunk-N3Z3PLHC.cjs} +2 -2
  43. package/dist/{chunk-2CNKQC3G.mjs → chunk-NNLFW3P4.mjs} +2 -2
  44. package/dist/{chunk-XX32BOMM.cjs → chunk-NXFA7G3Y.cjs} +52 -26
  45. package/dist/{chunk-SM25ZC4S.cjs → chunk-O2XFIPNL.cjs} +1 -1
  46. package/dist/{chunk-VWW4Q3BJ.mjs → chunk-O4FWNLQK.mjs} +4 -4
  47. package/dist/{chunk-DZPR2W6U.cjs → chunk-O6L3YYPM.cjs} +5 -5
  48. package/dist/{chunk-UWI3SJAK.cjs → chunk-O7IEMY55.cjs} +3 -3
  49. package/dist/{chunk-6BJJYOFL.cjs → chunk-OLIGNTWU.cjs} +7 -7
  50. package/dist/{chunk-OUWRNHTV.mjs → chunk-OYF23QLG.mjs} +17 -16
  51. package/dist/{chunk-IQIKPKFP.mjs → chunk-RAH5MT53.mjs} +110 -25
  52. package/dist/{chunk-E72UD6ME.mjs → chunk-RVGSVQWT.mjs} +1 -1
  53. package/dist/{chunk-ZVIEFTUA.cjs → chunk-S25BQIFW.cjs} +16 -16
  54. package/dist/chunk-S7ZW72JH.cjs +254 -0
  55. package/dist/{chunk-VM7X5CKC.mjs → chunk-SLYDIHLW.mjs} +31 -5
  56. package/dist/chunk-SNFTMSHX.mjs +254 -0
  57. package/dist/{chunk-2WZTGPK6.mjs → chunk-SQ5O7I3L.mjs} +7 -2
  58. package/dist/{chunk-PCXIJKPM.mjs → chunk-TNBJ4LZG.mjs} +2 -2
  59. package/dist/{chunk-O27PLNQZ.cjs → chunk-UJ3R2AH2.cjs} +4 -4
  60. package/dist/{chunk-T4TBK5NY.mjs → chunk-VQ4NWOWO.mjs} +2 -2
  61. package/dist/{chunk-ZZ2QKCKW.mjs → chunk-WAY6LOQH.mjs} +1 -1
  62. package/dist/chunk-WBTHHTBO.cjs +88 -0
  63. package/dist/{chunk-ZBUAOGMY.mjs → chunk-WFNAOWH4.mjs} +1 -1
  64. package/dist/{chunk-IWRLV46X.cjs → chunk-WMTBBQHY.cjs} +4 -4
  65. package/dist/{chunk-2JYBLE63.mjs → chunk-WNYRYI4D.mjs} +770 -243
  66. package/dist/{chunk-CI4UNQHO.cjs → chunk-XBSKPLHF.cjs} +2 -2
  67. package/dist/{chunk-IOF4KXMP.mjs → chunk-XVWSDSUM.mjs} +201 -24
  68. package/dist/{chunk-JEJQGZI7.cjs → chunk-XZLZ6YPP.cjs} +346 -32
  69. package/dist/{chunk-QAS7KE7J.cjs → chunk-Y5TOT5F6.cjs} +5 -5
  70. package/dist/{chunk-DPE53XWL.mjs → chunk-ZEXE4TGY.mjs} +1 -1
  71. package/dist/{client-component.d-BoqC2MLC.d.mts → client-component.d-D74pqdea.d.mts} +14 -3
  72. package/dist/{client-component.d-Bgt3x5Fu.d.ts → client-component.d-D8VcypQA.d.ts} +14 -3
  73. package/dist/{client-plugins.d-BcqIy4au.d.ts → client-plugins.d-CXElzotB.d.ts} +18 -2
  74. package/dist/{client-plugins.d-CWyYBxXf.d.mts → client-plugins.d-D4-6hNx7.d.mts} +18 -2
  75. package/dist/client-plugins.d.mts +1 -1
  76. package/dist/client-plugins.d.ts +1 -1
  77. package/dist/client.d.mts +6 -6
  78. package/dist/client.d.ts +6 -6
  79. package/dist/config.d.mts +1 -1
  80. package/dist/config.d.ts +1 -1
  81. package/dist/desktop.d.mts +2 -2
  82. package/dist/desktop.d.ts +2 -2
  83. package/dist/{devtools-NUVXYG7I.mjs → devtools-MX3FE733.mjs} +5 -5
  84. package/dist/{devtools-SVRSGPNC.cjs → devtools-WET5NAKO.cjs} +6 -6
  85. package/dist/docs.cjs +8 -8
  86. package/dist/docs.d.mts +2 -2
  87. package/dist/docs.d.ts +2 -2
  88. package/dist/docs.mjs +7 -7
  89. package/dist/index.cjs +21 -20
  90. package/dist/{index.d-nAncqTXz.d.ts → index.d-A_x10zGS.d.ts} +1 -1
  91. package/dist/{index.d-BDaiu2i5.d.mts → index.d-SSgYDv4D.d.mts} +1 -1
  92. package/dist/index.d.mts +16 -16
  93. package/dist/index.d.ts +16 -16
  94. package/dist/index.mjs +20 -19
  95. package/dist/integrations.d.mts +1 -1
  96. package/dist/integrations.d.ts +1 -1
  97. package/dist/internal/app-markdown-runtime.cjs +3 -3
  98. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  99. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  100. package/dist/internal/app-markdown-runtime.mjs +2 -2
  101. package/dist/internal/build-runtime.cjs +22 -21
  102. package/dist/internal/build-runtime.d.mts +3 -3
  103. package/dist/internal/build-runtime.d.ts +3 -3
  104. package/dist/internal/build-runtime.mjs +21 -20
  105. package/dist/internal/cli-runtime.cjs +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 +4 -4
  110. package/dist/internal/client-runtime.d.ts +4 -4
  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 +7 -7
  114. package/dist/internal/config-runtime.d.mts +4 -4
  115. package/dist/internal/config-runtime.d.ts +4 -4
  116. package/dist/internal/config-runtime.mjs +6 -6
  117. package/dist/internal/infra-analytics-runtime.cjs +11 -9
  118. package/dist/internal/infra-analytics-runtime.mjs +9 -7
  119. package/dist/internal/native-server-fns.cjs +5 -4
  120. package/dist/internal/native-server-fns.mjs +4 -3
  121. package/dist/internal/product-telemetry-runtime.cjs +17 -211
  122. package/dist/internal/product-telemetry-runtime.mjs +10 -204
  123. package/dist/internal/production-runtime.cjs +13 -12
  124. package/dist/internal/production-runtime.d.mts +13 -12
  125. package/dist/internal/production-runtime.d.ts +13 -12
  126. package/dist/internal/production-runtime.mjs +14 -13
  127. package/dist/internal/react-cache.cjs +21 -1
  128. package/dist/internal/react-cache.d.mts +8 -1
  129. package/dist/internal/react-cache.d.ts +8 -1
  130. package/dist/internal/react-cache.mjs +21 -1
  131. package/dist/markdown.cjs +2 -2
  132. package/dist/markdown.d.mts +1 -1
  133. package/dist/markdown.d.ts +1 -1
  134. package/dist/markdown.mjs +1 -1
  135. package/dist/middleware.d.mts +3 -3
  136. package/dist/middleware.d.ts +3 -3
  137. package/dist/mobile.d.mts +2 -2
  138. package/dist/mobile.d.ts +2 -2
  139. package/dist/{native-tree-AS5L3ID3.mjs → native-tree-BPEE2LAL.mjs} +2 -2
  140. package/dist/{native-tree-Z2WYUJEV.cjs → native-tree-WOX3JMBG.cjs} +3 -3
  141. package/dist/{navigation-delegate.d-CSCm8ZxL.d.mts → navigation-delegate.d-DQVYKoaZ.d.mts} +1 -1
  142. package/dist/{navigation-delegate.d-BbUHRXxG.d.ts → navigation-delegate.d-GghbHJuK.d.ts} +1 -1
  143. package/dist/navigation.d.mts +4 -4
  144. package/dist/navigation.d.ts +4 -4
  145. package/dist/plugin.cjs +14 -14
  146. package/dist/plugin.d.mts +3 -3
  147. package/dist/plugin.d.ts +3 -3
  148. package/dist/plugin.mjs +13 -13
  149. package/dist/{production-runtime.d-DgT24A0f.d.ts → production-runtime.d-Bzns3NW9.d.ts} +1 -1
  150. package/dist/{production-runtime.d-CcQiDko5.d.mts → production-runtime.d-DiFa5vHW.d.mts} +1 -1
  151. package/dist/{render-plan.d-CyrX6MDs.d.ts → render-plan.d-CL_Ikfg_.d.ts} +1 -1
  152. package/dist/{render-plan.d-BH9WF-JZ.d.mts → render-plan.d-CcF0MeCf.d.mts} +1 -1
  153. package/dist/renderer-client.d.mts +4 -4
  154. package/dist/renderer-client.d.ts +4 -4
  155. package/dist/{request.d-BB8M8bcD.d.ts → request.d-B1RnTLri.d.ts} +1 -1
  156. package/dist/{request.d-CUrPnCW7.d.mts → request.d-DarDOCk9.d.mts} +1 -1
  157. package/dist/request.d.mts +2 -2
  158. package/dist/request.d.ts +2 -2
  159. package/dist/{route-rendering.d-DYqZMIf4.d.ts → route-rendering.d-BTUYCIj4.d.ts} +1 -1
  160. package/dist/{route-rendering.d-CYxlzaFm.d.mts → route-rendering.d-D_2Ual0-.d.mts} +1 -1
  161. package/dist/{router.d-DaKo507j.d.ts → router.d-CMANF6da.d.ts} +1 -1
  162. package/dist/{router.d-7o24CD8u.d.mts → router.d-Cuv1jntg.d.mts} +1 -1
  163. package/dist/{routes.d-BknKQcTu.d.ts → routes.d-B6yFe6jm.d.ts} +1 -1
  164. package/dist/{routes.d-D1IrO9KK.d.mts → routes.d-c2HKfrfL.d.mts} +1 -1
  165. package/dist/routes.d.mts +1 -1
  166. package/dist/routes.d.ts +1 -1
  167. package/dist/{rsc-pipeline-RFLHDAKD.mjs → rsc-pipeline-3LNVP2OO.mjs} +6 -6
  168. package/dist/{rsc-pipeline-OF2I7PCX.cjs → rsc-pipeline-G5WELVW3.cjs} +7 -7
  169. package/dist/{runtime-LBTK62AD.cjs → runtime-DMEULPE7.cjs} +22 -11
  170. package/dist/{runtime-M6UJCSLA.mjs → runtime-HQJ2LLQL.mjs} +20 -9
  171. package/dist/{runtime.d-CN73a-IL.d.ts → runtime.d-C3RQUj6_.d.ts} +1 -1
  172. package/dist/{runtime.d-CcNuzhX6.d.mts → runtime.d-wvh4ngU0.d.mts} +1 -1
  173. package/dist/server-plugins.d.mts +2 -2
  174. package/dist/server-plugins.d.ts +2 -2
  175. package/dist/server.cjs +31 -31
  176. package/dist/server.d.mts +9 -9
  177. package/dist/server.d.ts +9 -9
  178. package/dist/server.mjs +16 -16
  179. package/dist/{spa-router.d-CNi77LZm.d.mts → spa-router.d-WU_qS5gJ.d.mts} +2 -2
  180. package/dist/{spa-router.d-Cvgf5QP4.d.ts → spa-router.d-m8H_Kl_B.d.ts} +2 -2
  181. package/dist/testing.d.mts +1 -1
  182. package/dist/testing.d.ts +1 -1
  183. package/dist/{utils.d-C3H-14_Y.d.ts → utils.d-C9dQD5Zg.d.ts} +1 -1
  184. package/dist/{utils.d-D8VfzZYn.d.mts → utils.d-W9IiEqmW.d.mts} +1 -1
  185. package/dist/version.cjs +2 -2
  186. package/dist/version.mjs +1 -1
  187. package/dist/vite.cjs +18 -14
  188. package/dist/vite.d.mts +23 -5
  189. package/dist/vite.d.ts +23 -5
  190. package/dist/vite.mjs +17 -13
  191. package/package.json +1 -1
  192. package/dist/analyzer-2AHWJJR7.cjs +0 -15
  193. package/dist/chunk-CSLUBKGG.mjs +0 -44
  194. package/dist/chunk-SGBNF56S.cjs +0 -44
@@ -1,14 +1,20 @@
1
1
  import {
2
2
  FARM_DEFAULT_MCP_PATH,
3
3
  FARM_DEFAULT_MCP_TOOLS
4
- } from "./chunk-UZZ6IEQP.mjs";
4
+ } from "./chunk-MESQF2JC.mjs";
5
+ import {
6
+ normalizeFarmProductionSiteOrigin
7
+ } from "./chunk-SNFTMSHX.mjs";
5
8
  import {
6
9
  resolveFarmAppManifestConfig
7
- } from "./chunk-2WZTGPK6.mjs";
10
+ } from "./chunk-SQ5O7I3L.mjs";
8
11
  import {
9
12
  emitFarmAgentRead,
10
13
  getFarmMarkdownMirrorPath
11
- } from "./chunk-YSXTNSXS.mjs";
14
+ } from "./chunk-K7OZAVOI.mjs";
15
+ import {
16
+ readFarmEnvironmentValue
17
+ } from "./chunk-WXFY5JIY.mjs";
12
18
  import {
13
19
  _listFarmMCPCatalogs,
14
20
  _listFarmRegisteredMCPServers
@@ -23,7 +29,7 @@ import {
23
29
  } from "./chunk-QDWMCFTH.mjs";
24
30
  import {
25
31
  FARM_VERSION
26
- } from "./chunk-NT3QDN2E.mjs";
32
+ } from "./chunk-LQDLEWPO.mjs";
27
33
  import {
28
34
  applyFarmBasePath
29
35
  } from "./chunk-SF3JB56B.mjs";
@@ -295,9 +301,29 @@ function createFarmAppManifest(input) {
295
301
  } : null,
296
302
  integrations: sections.integrations ? input.integrations : null,
297
303
  agent: sections.agent ? input.agent : null,
298
- plugins: sections.plugins ? input.plugins : null
304
+ plugins: sections.plugins ? input.plugins : null,
305
+ site: sections.site ? { url: resolveFarmSiteUrl() } : null
299
306
  };
300
307
  }
308
+ function asUrl(value) {
309
+ const trimmed = value?.trim();
310
+ if (!trimmed) return void 0;
311
+ return /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
312
+ }
313
+ function resolveFarmSiteUrl() {
314
+ const read = readFarmEnvironmentValue;
315
+ const explicit = read("FARM_SITE_URL");
316
+ const candidates = explicit?.trim() ? [explicit] : [
317
+ asUrl(read("VERCEL_PROJECT_PRODUCTION_URL")),
318
+ read("RENDER_EXTERNAL_URL"),
319
+ asUrl(read("RAILWAY_PUBLIC_DOMAIN"))
320
+ ];
321
+ for (const candidate of candidates) {
322
+ const origin = candidate ? normalizeFarmProductionSiteOrigin(candidate) : void 0;
323
+ if (origin) return origin;
324
+ }
325
+ return null;
326
+ }
301
327
  function listServers(input, mcp) {
302
328
  const servers = _listFarmMCPCatalogs().map(({ server, tools, details }) => {
303
329
  const open = details?.public === true && !input.guardCoversPath?.(server.path);
@@ -0,0 +1,254 @@
1
+ import {
2
+ FARM_VERSION
3
+ } from "./chunk-LQDLEWPO.mjs";
4
+
5
+ // src/deployment-environment.ts
6
+ function isFarmProductionDeploymentEnvironment(env = process.env) {
7
+ const environment = normalizeEnvironment(env.VERCEL_ENV);
8
+ const targetEnvironment = normalizeEnvironment(env.VERCEL_TARGET_ENV);
9
+ if (environment && environment !== "production") return false;
10
+ if (targetEnvironment && targetEnvironment !== "production") return false;
11
+ if (isTrue(env.NETLIFY)) {
12
+ const context = normalizeEnvironment(env.CONTEXT);
13
+ if (context && context !== "production") return false;
14
+ }
15
+ if (isTrue(env.IS_PULL_REQUEST)) return false;
16
+ return true;
17
+ }
18
+ function isFarmPreviewDeploymentEnvironment(env) {
19
+ return resolveFarmPreviewDeployment(env, false);
20
+ }
21
+ function resolveFarmPreviewDeployment(env, builtAsPreview) {
22
+ const explicit = env?.FARM_PREVIEW;
23
+ if (isTrue(explicit)) return true;
24
+ if (isFalse(explicit)) return false;
25
+ if (builtAsPreview || !env) return builtAsPreview;
26
+ if (normalizeEnvironment(env.VERCEL_ENV) === "preview") return true;
27
+ if (isTrue(env.NETLIFY)) {
28
+ const context = normalizeEnvironment(env.CONTEXT);
29
+ if (context === "deploy-preview" || context === "branch-deploy") return true;
30
+ }
31
+ return isTrue(env.IS_PULL_REQUEST);
32
+ }
33
+ function normalizeEnvironment(value) {
34
+ const normalized = value?.trim().toLowerCase();
35
+ return normalized || void 0;
36
+ }
37
+ function isTrue(value) {
38
+ return value !== void 0 && ["1", "true", "yes", "on"].includes(value.toLowerCase());
39
+ }
40
+ function isFalse(value) {
41
+ return value !== void 0 && ["0", "false", "no", "off"].includes(value.toLowerCase());
42
+ }
43
+
44
+ // src/product-telemetry.ts
45
+ var FARM_PRODUCTION_SITE_TELEMETRY_SCHEMA_VERSION = 1;
46
+ var FARM_PRODUCTION_SITE_TELEMETRY_EVENT_TYPE = "production_site_active";
47
+ var FARM_PRODUCTION_SITE_TELEMETRY_PACKAGE_NAME = "@farm.js/core";
48
+ var FARM_PRODUCTION_SITE_ATTESTATION_PATH = "/.well-known/farm-telemetry";
49
+ var FARM_PRODUCTION_SITE_ATTESTATION_EVENT_TYPE = "production_site_attestation";
50
+ var DEFAULT_SITE_TELEMETRY_ENDPOINT = "https://farmjs.dev/api/telemetry/v1/sites";
51
+ var REQUEST_TIMEOUT_MS = 3e3;
52
+ var REPORT_INTERVAL_MS = 24 * 60 * 60 * 1e3;
53
+ var RETRY_INTERVAL_MS = 5 * 60 * 1e3;
54
+ var MAX_ORIGINS_PER_INSTANCE = 32;
55
+ var SAFE_DETAIL_PATTERN = /^[0-9A-Za-z._-]{1,64}$/;
56
+ function detectFarmProductionSiteOrigin(value) {
57
+ try {
58
+ const url = value instanceof URL ? value : new URL(value);
59
+ return normalizeFarmProductionSiteOrigin(url.origin);
60
+ } catch {
61
+ return void 0;
62
+ }
63
+ }
64
+ function normalizeFarmProductionSiteOrigin(value) {
65
+ const candidate = value.trim();
66
+ if (!candidate || candidate.length > 2048) return void 0;
67
+ try {
68
+ const url = new URL(candidate);
69
+ const hostname = url.hostname.toLowerCase();
70
+ const isIpv4 = /^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname);
71
+ const isIpv6 = hostname.startsWith("[") && hostname.endsWith("]");
72
+ const isLocal = hostname === "localhost" || hostname.endsWith(".localhost") || hostname.endsWith(".local");
73
+ const isSingleLabel = !hostname.includes(".");
74
+ if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash || url.pathname !== "/" || isIpv4 || isIpv6 || isLocal || isSingleLabel || hostname.endsWith(".")) {
75
+ return void 0;
76
+ }
77
+ return url.origin;
78
+ } catch {
79
+ return void 0;
80
+ }
81
+ }
82
+ function createFarmProductionSiteReporter(options) {
83
+ const now = options.now ?? Date.now;
84
+ const reportIntervalMs = options.reportIntervalMs ?? REPORT_INTERVAL_MS;
85
+ const retryIntervalMs = options.retryIntervalMs ?? RETRY_INTERVAL_MS;
86
+ const send = options.fetch ?? globalThis.fetch;
87
+ const reportStates = /* @__PURE__ */ new Map();
88
+ let reportingSkipped;
89
+ const attestation = {
90
+ schemaVersion: FARM_PRODUCTION_SITE_TELEMETRY_SCHEMA_VERSION,
91
+ eventType: FARM_PRODUCTION_SITE_ATTESTATION_EVENT_TYPE,
92
+ packageName: FARM_PRODUCTION_SITE_TELEMETRY_PACKAGE_NAME,
93
+ packageVersion: sanitizeDetail(FARM_VERSION, "unknown"),
94
+ renderer: sanitizeDetail(options.renderer, "custom"),
95
+ deployTarget: sanitizeDetail(options.deployTarget, "custom")
96
+ };
97
+ return {
98
+ handleAttestation(request) {
99
+ if (!request.url.includes(FARM_PRODUCTION_SITE_ATTESTATION_PATH)) return null;
100
+ if (productionTelemetryDisabled()) return null;
101
+ let pathname;
102
+ try {
103
+ pathname = new URL(request.url).pathname;
104
+ } catch {
105
+ return null;
106
+ }
107
+ if (pathname !== FARM_PRODUCTION_SITE_ATTESTATION_PATH) return null;
108
+ if (request.method !== "GET" && request.method !== "HEAD") {
109
+ return new Response("Method Not Allowed", {
110
+ status: 405,
111
+ headers: {
112
+ allow: "GET, HEAD",
113
+ "cache-control": "no-store",
114
+ "content-type": "text/plain; charset=utf-8",
115
+ "x-content-type-options": "nosniff"
116
+ }
117
+ });
118
+ }
119
+ return new Response(request.method === "HEAD" ? null : JSON.stringify(attestation), {
120
+ status: 200,
121
+ headers: {
122
+ "cache-control": "no-store",
123
+ "content-type": "application/json; charset=utf-8",
124
+ "x-content-type-options": "nosniff"
125
+ }
126
+ });
127
+ },
128
+ report(requestUrl, waitUntil) {
129
+ if (reportingSkipped === void 0) {
130
+ reportingSkipped = productionTelemetryDisabled() ? "disabled" : isFarmProductionDeploymentEnvironment() ? false : "not-production";
131
+ if (reportingSkipped === "not-production") {
132
+ debug("production-site check-in skipped outside a production deployment");
133
+ }
134
+ }
135
+ if (reportingSkipped) return;
136
+ const siteUrl = detectFarmProductionSiteOrigin(requestUrl);
137
+ if (!siteUrl) return;
138
+ let state = reportStates.get(siteUrl);
139
+ if (!state) {
140
+ if (reportStates.size >= MAX_ORIGINS_PER_INSTANCE) return;
141
+ state = { nextReportAt: 0 };
142
+ reportStates.set(siteUrl, state);
143
+ }
144
+ const attemptedAt = now();
145
+ if (state.pending || attemptedAt < state.nextReportAt) return;
146
+ state.nextReportAt = attemptedAt + reportIntervalMs;
147
+ const payload = {
148
+ schemaVersion: FARM_PRODUCTION_SITE_TELEMETRY_SCHEMA_VERSION,
149
+ eventType: FARM_PRODUCTION_SITE_TELEMETRY_EVENT_TYPE,
150
+ siteUrl,
151
+ packageName: FARM_PRODUCTION_SITE_TELEMETRY_PACKAGE_NAME,
152
+ packageVersion: attestation.packageVersion,
153
+ renderer: attestation.renderer,
154
+ deployTarget: attestation.deployTarget
155
+ };
156
+ state.pending = deliver(send, resolveSiteTelemetryEndpoint(options.endpoint), payload).then((delivered) => {
157
+ if (!delivered) state.nextReportAt = now() + retryIntervalMs;
158
+ }).catch(() => {
159
+ state.nextReportAt = now() + retryIntervalMs;
160
+ }).finally(() => {
161
+ state.pending = void 0;
162
+ });
163
+ if (waitUntil) {
164
+ try {
165
+ waitUntil(state.pending);
166
+ } catch {
167
+ }
168
+ } else {
169
+ void state.pending;
170
+ }
171
+ }
172
+ };
173
+ }
174
+ async function deliver(send, endpoint, payload) {
175
+ if (!endpoint) {
176
+ debug("invalid or insecure production-site telemetry endpoint; check-in skipped");
177
+ return false;
178
+ }
179
+ const controller = new AbortController();
180
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
181
+ timeout.unref?.();
182
+ try {
183
+ const response = await send(endpoint, {
184
+ method: "POST",
185
+ headers: { "content-type": "application/json" },
186
+ body: JSON.stringify(payload),
187
+ signal: controller.signal
188
+ });
189
+ if (!response.ok) {
190
+ debug(`production-site check-in rejected with HTTP ${response.status}`);
191
+ return false;
192
+ }
193
+ try {
194
+ const result = await response.json();
195
+ if (result && result.stored === false) {
196
+ debug("production-site check-in was accepted but not stored");
197
+ return false;
198
+ }
199
+ } catch {
200
+ }
201
+ return true;
202
+ } catch {
203
+ debug("production-site check-in failed");
204
+ return false;
205
+ } finally {
206
+ clearTimeout(timeout);
207
+ }
208
+ }
209
+ function resolveSiteTelemetryEndpoint(explicit) {
210
+ const candidate = explicit || process.env.FARM_TELEMETRY_SITE_ENDPOINT;
211
+ if (!candidate) return DEFAULT_SITE_TELEMETRY_ENDPOINT;
212
+ try {
213
+ const url = new URL(candidate);
214
+ const hostname = url.hostname.toLowerCase().replace(/^\[|\]$/g, "");
215
+ const isLocal = ["localhost", "127.0.0.1", "::1"].includes(hostname);
216
+ if (url.protocol === "https:" || url.protocol === "http:" && isLocal) {
217
+ return url.toString();
218
+ }
219
+ } catch {
220
+ }
221
+ return void 0;
222
+ }
223
+ function productionTelemetryDisabled() {
224
+ if (process.env.DO_NOT_TRACK !== void 0 && !isFalse2(process.env.DO_NOT_TRACK)) return true;
225
+ if (isTrue2(process.env.FARM_TELEMETRY_DISABLED)) return true;
226
+ return isFalse2(process.env.FARM_TELEMETRY);
227
+ }
228
+ function sanitizeDetail(value, fallback) {
229
+ return value && SAFE_DETAIL_PATTERN.test(value) ? value : fallback;
230
+ }
231
+ function isTrue2(value) {
232
+ return value !== void 0 && ["1", "true", "yes", "on"].includes(value.toLowerCase());
233
+ }
234
+ function isFalse2(value) {
235
+ return value !== void 0 && ["0", "false", "no", "off"].includes(value.toLowerCase());
236
+ }
237
+ function debug(message) {
238
+ if (!isTrue2(process.env.FARM_TELEMETRY_DEBUG)) return;
239
+ process.stderr.write(`[farm.telemetry] ${message}
240
+ `);
241
+ }
242
+
243
+ export {
244
+ isFarmPreviewDeploymentEnvironment,
245
+ resolveFarmPreviewDeployment,
246
+ FARM_PRODUCTION_SITE_TELEMETRY_SCHEMA_VERSION,
247
+ FARM_PRODUCTION_SITE_TELEMETRY_EVENT_TYPE,
248
+ FARM_PRODUCTION_SITE_TELEMETRY_PACKAGE_NAME,
249
+ FARM_PRODUCTION_SITE_ATTESTATION_PATH,
250
+ FARM_PRODUCTION_SITE_ATTESTATION_EVENT_TYPE,
251
+ detectFarmProductionSiteOrigin,
252
+ normalizeFarmProductionSiteOrigin,
253
+ createFarmProductionSiteReporter
254
+ };
@@ -35,7 +35,11 @@ function resolveFarmAppManifestConfig(input) {
35
35
  throw new TypeError(`${NAME} must be true, false, or an options object.`);
36
36
  }
37
37
  const config = isObject(input) ? input : {};
38
- checkKeys(config, ["app", "packages", "mcp", "webmcp", "integrations", "agent", "plugins"], NAME);
38
+ checkKeys(
39
+ config,
40
+ ["app", "packages", "mcp", "webmcp", "integrations", "agent", "plugins", "site"],
41
+ NAME
42
+ );
39
43
  const packages = config.packages;
40
44
  if (packages !== void 0 && typeof packages !== "boolean" && packages !== "names") {
41
45
  throw new TypeError(`${NAME}.packages must be true, false, or "names".`);
@@ -56,7 +60,8 @@ function resolveFarmAppManifestConfig(input) {
56
60
  })),
57
61
  integrations: readBoolean(config.integrations, `${NAME}.integrations`),
58
62
  agent: readBoolean(config.agent, `${NAME}.agent`),
59
- plugins: readBoolean(config.plugins, `${NAME}.plugins`)
63
+ plugins: readBoolean(config.plugins, `${NAME}.plugins`),
64
+ site: readBoolean(config.site, `${NAME}.site`)
60
65
  };
61
66
  }
62
67
 
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-22W4FNTG.mjs";
7
7
  import {
8
8
  serializeFarmLlmsTxt
9
- } from "./chunk-KVW2M6PI.mjs";
9
+ } from "./chunk-KL7SHLQB.mjs";
10
10
  import {
11
11
  emitFarmAgentRead
12
- } from "./chunk-YSXTNSXS.mjs";
12
+ } from "./chunk-K7OZAVOI.mjs";
13
13
  import {
14
14
  resolveFarmThemeConfig
15
15
  } from "./chunk-YWPNIYUP.mjs";
@@ -6,10 +6,10 @@ var _chunkOWOUTKIJcjs = require('./chunk-OWOUTKIJ.cjs');
6
6
  var _chunk6JHZPB52cjs = require('./chunk-6JHZPB52.cjs');
7
7
 
8
8
 
9
- var _chunkMEQN6DDAcjs = require('./chunk-MEQN6DDA.cjs');
9
+ var _chunkFJWN7RV4cjs = require('./chunk-FJWN7RV4.cjs');
10
10
 
11
11
 
12
- var _chunkLT4VAF5Zcjs = require('./chunk-LT4VAF5Z.cjs');
12
+ var _chunk2C5L5RPMcjs = require('./chunk-2C5L5RPM.cjs');
13
13
 
14
14
 
15
15
  var _chunkWT6RAN2Icjs = require('./chunk-WT6RAN2I.cjs');
@@ -603,12 +603,12 @@ function createFarmMetadataRouteResponse(kind, value, routeModule = {}, options
603
603
  return new Response(null, { status: 405, headers: { Allow: "GET, HEAD" } });
604
604
  }
605
605
  if ((kind === "llms" || kind === "llms-full") && options.request) {
606
- _chunkLT4VAF5Zcjs.emitFarmAgentRead.call(void 0, options.request, kind, isResponse(value) ? value.status : 200);
606
+ _chunk2C5L5RPMcjs.emitFarmAgentRead.call(void 0, options.request, kind, isResponse(value) ? value.status : 200);
607
607
  }
608
608
  if (isResponse(value)) {
609
609
  return method === "HEAD" ? _chunk4DCWVSL2cjs.omitFarmResponseBody.call(void 0, value) : value;
610
610
  }
611
- const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunkMEQN6DDAcjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
611
+ const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunkFJWN7RV4cjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
612
612
  const contentType = kind === "sitemap" ? "application/xml; charset=utf-8" : kind === "robots" || kind === "llms" || kind === "llms-full" ? "text/plain; charset=utf-8" : "application/manifest+json; charset=utf-8";
613
613
  return new Response(method === "HEAD" ? null : body, {
614
614
  headers: {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isFarmMetadataNoIndex
3
- } from "./chunk-KVW2M6PI.mjs";
3
+ } from "./chunk-KL7SHLQB.mjs";
4
4
  import {
5
5
  matchesFarmMarkdownRoutePattern
6
- } from "./chunk-YSXTNSXS.mjs";
6
+ } from "./chunk-K7OZAVOI.mjs";
7
7
  import {
8
8
  applyFarmBasePath
9
9
  } from "./chunk-SF3JB56B.mjs";
@@ -2,7 +2,7 @@ import {
2
2
  FARM_DEFAULT_MCP_DESCRIPTION,
3
3
  FARM_DEFAULT_MCP_PROTOCOL_VERSIONS,
4
4
  FARM_DEFAULT_MCP_TOOLS
5
- } from "./chunk-UZZ6IEQP.mjs";
5
+ } from "./chunk-MESQF2JC.mjs";
6
6
  import {
7
7
  stripFarmBasePath
8
8
  } from "./chunk-SF3JB56B.mjs";
@@ -0,0 +1,88 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/mobile/component-blocks.ts
2
+ function farmComponentKind(file) {
3
+ return file.endsWith(".vue") ? "vue" : file.endsWith(".svelte") ? "svelte" : void 0;
4
+ }
5
+ function readAttributes(text) {
6
+ const attributes = {};
7
+ for (const match of text.matchAll(
8
+ /([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g
9
+ )) {
10
+ attributes[match[1].toLowerCase()] = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(match[2], () => ( match[3])), () => ( match[4])), () => ( true));
11
+ }
12
+ return attributes;
13
+ }
14
+ function readFarmComponentBlocks(file, source) {
15
+ const kind = farmComponentKind(file);
16
+ if (!kind) throw new TypeError(`${file} is not a .vue or .svelte component`);
17
+ const scripts = [];
18
+ const styles = [];
19
+ const taken = [];
20
+ for (const name of ["script", "style"]) {
21
+ const open = new RegExp(`<${name}\\b((?:[^>"']|"[^"]*"|'[^']*')*)>`, "gi");
22
+ let match;
23
+ while (match = open.exec(source)) {
24
+ const start = match.index + match[0].length;
25
+ const close = source.toLowerCase().indexOf(`</${name}>`, start);
26
+ const end = close === -1 ? source.length : close;
27
+ (name === "script" ? scripts : styles).push({
28
+ start,
29
+ end,
30
+ attributes: readAttributes(_nullishCoalesce(match[1], () => ( "")))
31
+ });
32
+ taken.push({ start: match.index, end: close === -1 ? end : close + name.length + 3 });
33
+ open.lastIndex = end;
34
+ }
35
+ }
36
+ taken.sort((left, right) => left.start - right.start);
37
+ const markup = [];
38
+ if (kind === "svelte") {
39
+ let cursor = 0;
40
+ for (const range of taken) {
41
+ if (range.start > cursor) markup.push({ start: cursor, end: range.start });
42
+ cursor = Math.max(cursor, range.end);
43
+ }
44
+ if (cursor < source.length) markup.push({ start: cursor, end: source.length });
45
+ } else {
46
+ const tag = /<(\/?)template\b(?:[^>"']|"[^"]*"|'[^']*')*?(\/?)>/gi;
47
+ let depth = 0;
48
+ let start = -1;
49
+ let match;
50
+ while (match = tag.exec(source)) {
51
+ if (taken.some((range) => match.index >= range.start && match.index < range.end)) continue;
52
+ if (match[2]) continue;
53
+ if (!match[1]) {
54
+ if (depth === 0) start = match.index + match[0].length;
55
+ depth += 1;
56
+ } else if (depth > 0) {
57
+ depth -= 1;
58
+ if (depth === 0) {
59
+ markup.push({ start, end: match.index });
60
+ break;
61
+ }
62
+ }
63
+ }
64
+ }
65
+ return { kind, scripts, styles, markup };
66
+ }
67
+ function keepFarmComponentRanges(source, ranges) {
68
+ let out = "";
69
+ let cursor = 0;
70
+ const blank = (text) => text.replace(/[^\n]/g, " ");
71
+ for (const range of [...ranges].sort((left, right) => left.start - right.start)) {
72
+ out += blank(source.slice(cursor, range.start)) + source.slice(range.start, range.end);
73
+ cursor = range.end;
74
+ }
75
+ return out + blank(source.slice(cursor));
76
+ }
77
+ function farmComponentModuleScripts(blocks) {
78
+ return blocks.scripts.filter(
79
+ (script) => blocks.kind === "vue" ? script.attributes.setup === void 0 : script.attributes.module !== void 0 || script.attributes.context === "module"
80
+ );
81
+ }
82
+
83
+
84
+
85
+
86
+
87
+
88
+ exports.farmComponentKind = farmComponentKind; exports.readFarmComponentBlocks = readFarmComponentBlocks; exports.keepFarmComponentRanges = keepFarmComponentRanges; exports.farmComponentModuleScripts = farmComponentModuleScripts;
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-FN5UEC7I.mjs";
8
8
  import {
9
9
  resolveDeployOutputPath
10
- } from "./chunk-VWW4Q3BJ.mjs";
10
+ } from "./chunk-O4FWNLQK.mjs";
11
11
  import {
12
12
  farmDesktopDevGuardPlugin,
13
13
  loadFarmReactPlugin
@@ -18,7 +18,7 @@ var _chunkERMUL73Lcjs = require('./chunk-ERMUL73L.cjs');
18
18
  var _chunk6JHZPB52cjs = require('./chunk-6JHZPB52.cjs');
19
19
 
20
20
 
21
- var _chunkLT4VAF5Zcjs = require('./chunk-LT4VAF5Z.cjs');
21
+ var _chunk2C5L5RPMcjs = require('./chunk-2C5L5RPM.cjs');
22
22
 
23
23
 
24
24
  var _chunkCFG4QERRcjs = require('./chunk-CFG4QERR.cjs');
@@ -1179,11 +1179,11 @@ function shouldReturnMarkdown(request) {
1179
1179
  if (url.pathname.endsWith(".md")) return true;
1180
1180
  const accept = request.headers.get("accept");
1181
1181
  const markdown = Math.max(
1182
- _chunkLT4VAF5Zcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1183
- _chunkLT4VAF5Zcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1182
+ _chunk2C5L5RPMcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1183
+ _chunk2C5L5RPMcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1184
1184
  );
1185
1185
  if (markdown <= 0) return false;
1186
- return markdown >= _chunkLT4VAF5Zcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1186
+ return markdown >= _chunk2C5L5RPMcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1187
1187
  }
1188
1188
  function escapeAttribute(value) {
1189
1189
  return escapeHtml(value).replace(/'/g, "&#39;");