@farm.js/core 0.1.17 → 0.1.19

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 (269) hide show
  1. package/dist/after.cjs +12 -225
  2. package/dist/agent-runtime.cjs +83 -2800
  3. package/dist/api/client.cjs +17 -4060
  4. package/dist/api/route-manager.cjs +34 -4354
  5. package/dist/api/runtime.cjs +29 -2696
  6. package/dist/api.cjs +88 -8434
  7. package/dist/app-markdown.cjs +39 -280
  8. package/dist/app-markdown.mjs +3 -3
  9. package/dist/cache.cjs +38 -1560
  10. package/dist/chunk-22GUSVNJ.cjs +351 -0
  11. package/dist/{chunk-EN7WTEAY.mjs → chunk-2ANEVVF7.mjs} +1 -1
  12. package/dist/chunk-2CQ74SP6.cjs +13 -0
  13. package/dist/{chunk-YD4J4XCI.mjs → chunk-2GNATDDE.mjs} +1 -1
  14. package/dist/chunk-2SJ4RQ6P.cjs +57 -0
  15. package/dist/chunk-3376ZTRC.cjs +1 -0
  16. package/dist/chunk-4PNUXIVU.cjs +472 -0
  17. package/dist/chunk-4PPEPOZZ.cjs +21 -0
  18. package/dist/chunk-4ZFL5GFN.cjs +520 -0
  19. package/dist/chunk-5OVTOKGH.cjs +65 -0
  20. package/dist/chunk-5QIKR7RR.cjs +224 -0
  21. package/dist/chunk-5ZSWG4UX.cjs +127 -0
  22. package/dist/chunk-62YJ2IEB.cjs +238 -0
  23. package/dist/chunk-6EODJYCX.cjs +183 -0
  24. package/dist/chunk-6EXBPJ24.cjs +434 -0
  25. package/dist/chunk-6QQDAAAZ.cjs +38 -0
  26. package/dist/chunk-6V4TDWEC.cjs +455 -0
  27. package/dist/chunk-72ADZ6GQ.cjs +19 -0
  28. package/dist/chunk-75BRBIFP.cjs +172 -0
  29. package/dist/{chunk-ZCNJKLA2.mjs → chunk-7BC6GAL7.mjs} +1 -1
  30. package/dist/chunk-7W3CPVXS.cjs +24 -0
  31. package/dist/chunk-A6WIQH5Z.cjs +31 -0
  32. package/dist/chunk-A777V5WU.cjs +725 -0
  33. package/dist/chunk-AFOD3LYZ.cjs +377 -0
  34. package/dist/chunk-AH7HOAQ3.cjs +151 -0
  35. package/dist/chunk-AMDMVWMI.cjs +39 -0
  36. package/dist/chunk-AORPIPNB.cjs +552 -0
  37. package/dist/chunk-ARJWXNQL.cjs +256 -0
  38. package/dist/chunk-AYJR42WX.cjs +711 -0
  39. package/dist/chunk-BBVSJVBZ.cjs +600 -0
  40. package/dist/chunk-BIDYX3SL.cjs +91 -0
  41. package/dist/chunk-BYODCJD6.cjs +663 -0
  42. package/dist/chunk-C3VRMB6H.cjs +85 -0
  43. package/dist/chunk-C5GUTBZK.cjs +173 -0
  44. package/dist/chunk-CIAGU2X4.cjs +337 -0
  45. package/dist/chunk-CMGMGHUZ.cjs +27 -0
  46. package/dist/chunk-CXP5U3RW.cjs +54 -0
  47. package/dist/chunk-D2ULAULS.cjs +166 -0
  48. package/dist/chunk-D7JTOLFK.cjs +285 -0
  49. package/dist/chunk-DVM4FKZL.cjs +169 -0
  50. package/dist/chunk-DYEJQTDN.cjs +49 -0
  51. package/dist/chunk-E2ROOWQC.cjs +2225 -0
  52. package/dist/chunk-E3UK5IIB.cjs +593 -0
  53. package/dist/chunk-EM6SBQKM.cjs +470 -0
  54. package/dist/chunk-FJSWYIR7.cjs +482 -0
  55. package/dist/chunk-FK6GO24V.cjs +54 -0
  56. package/dist/{chunk-MVIWBEJF.mjs → chunk-FVZGEVTO.mjs} +7 -7
  57. package/dist/chunk-FXUUWYAX.cjs +654 -0
  58. package/dist/chunk-G3HRIVEY.cjs +395 -0
  59. package/dist/chunk-G643DQCH.cjs +13 -0
  60. package/dist/chunk-G7HXGLEC.cjs +175 -0
  61. package/dist/chunk-GDSHDTJ4.cjs +152 -0
  62. package/dist/chunk-GPVTX3HT.cjs +1415 -0
  63. package/dist/chunk-H6G5INWM.cjs +1094 -0
  64. package/dist/{chunk-DHDVMXYK.mjs → chunk-HALDNTIV.mjs} +30 -4
  65. package/dist/chunk-HBTUGXHS.cjs +180 -0
  66. package/dist/chunk-HREOKQWT.cjs +45 -0
  67. package/dist/{chunk-5QOEPUYE.mjs → chunk-HSDL2AUR.mjs} +1 -1
  68. package/dist/chunk-I4J452B7.cjs +435 -0
  69. package/dist/chunk-I57LW5VZ.cjs +94 -0
  70. package/dist/chunk-I5YBCWQ6.cjs +40 -0
  71. package/dist/chunk-I7PUUDGY.cjs +389 -0
  72. package/dist/chunk-IAMRBF3Z.cjs +86 -0
  73. package/dist/chunk-IQXFRNY2.cjs +169 -0
  74. package/dist/chunk-ISTFC3MZ.cjs +1357 -0
  75. package/dist/chunk-IXTFU4PL.cjs +2355 -0
  76. package/dist/chunk-J3LOGE4T.cjs +42 -0
  77. package/dist/chunk-J7FSKED3.cjs +93 -0
  78. package/dist/chunk-JDNHKPTD.cjs +22 -0
  79. package/dist/chunk-JSROZYYO.cjs +164 -0
  80. package/dist/chunk-K6FNHVDR.cjs +696 -0
  81. package/dist/chunk-KGZIORNL.cjs +43 -0
  82. package/dist/chunk-KR6CKSXT.cjs +15 -0
  83. package/dist/chunk-KROWKCUH.cjs +185 -0
  84. package/dist/chunk-KVFPGF2M.cjs +46 -0
  85. package/dist/{chunk-TNBAYAWO.mjs → chunk-L4DVIHOC.mjs} +1 -1
  86. package/dist/chunk-LCCBO7PJ.cjs +46 -0
  87. package/dist/chunk-LIUGYUX3.cjs +22 -0
  88. package/dist/chunk-LTNGXMQ6.cjs +55 -0
  89. package/dist/chunk-M2L4MYDQ.cjs +14 -0
  90. package/dist/chunk-MCJLA63J.cjs +1 -0
  91. package/dist/chunk-MKB2EGIR.cjs +148 -0
  92. package/dist/chunk-MQ3H6LT5.cjs +202 -0
  93. package/dist/chunk-MT763TDW.cjs +43 -0
  94. package/dist/{chunk-XWAYMDLB.mjs → chunk-MVUREHPN.mjs} +1 -1
  95. package/dist/chunk-MWSK6C4J.cjs +18 -0
  96. package/dist/chunk-MWWVKDW3.cjs +169 -0
  97. package/dist/{chunk-6VQIKZZO.mjs → chunk-N255VYFP.mjs} +1 -1
  98. package/dist/chunk-NBAHDVOJ.cjs +2040 -0
  99. package/dist/chunk-NO3WWW3N.cjs +192 -0
  100. package/dist/chunk-NSFC3LHB.cjs +10244 -0
  101. package/dist/chunk-NZKJGRB3.cjs +230 -0
  102. package/dist/chunk-OAVTUMJP.cjs +1496 -0
  103. package/dist/{chunk-SXHV42UQ.mjs → chunk-OFEY6KHO.mjs} +88 -13
  104. package/dist/chunk-OHY2ZWUG.cjs +25 -0
  105. package/dist/chunk-OI6CMLWX.cjs +47 -0
  106. package/dist/chunk-OWOUTKIJ.cjs +558 -0
  107. package/dist/chunk-OX6O6WVA.cjs +74 -0
  108. package/dist/chunk-OXSIH4D6.cjs +476 -0
  109. package/dist/chunk-OYDRPBBV.cjs +453 -0
  110. package/dist/chunk-OYEUREB6.cjs +35 -0
  111. package/dist/chunk-PCOTGFSM.cjs +139 -0
  112. package/dist/{chunk-76DG3LF3.mjs → chunk-PGQBL5DN.mjs} +1 -1
  113. package/dist/chunk-PZYCPSCC.cjs +35 -0
  114. package/dist/chunk-QBK2AA4U.cjs +445 -0
  115. package/dist/{chunk-UTBVHYS3.mjs → chunk-QBPKKQTD.mjs} +2 -2
  116. package/dist/chunk-QBPXNZGV.cjs +487 -0
  117. package/dist/chunk-QNPEUFHQ.cjs +27 -0
  118. package/dist/chunk-QZRVZSPN.cjs +236 -0
  119. package/dist/chunk-R5A5KNVX.cjs +20 -0
  120. package/dist/chunk-R5JIFR6B.cjs +42 -0
  121. package/dist/chunk-R6AIILII.cjs +193 -0
  122. package/dist/chunk-RFYO7QUD.cjs +9 -0
  123. package/dist/chunk-RG3ZOTG5.cjs +34 -0
  124. package/dist/chunk-ROUTX2E5.cjs +390 -0
  125. package/dist/chunk-RTHIVJ2G.cjs +54 -0
  126. package/dist/chunk-S27FMYAM.cjs +644 -0
  127. package/dist/chunk-S3A45T7F.cjs +166 -0
  128. package/dist/chunk-S3JO3N4H.cjs +17 -0
  129. package/dist/chunk-SK35NQKK.cjs +27 -0
  130. package/dist/chunk-SU7MH53P.cjs +180 -0
  131. package/dist/chunk-SVRTJOUF.cjs +113 -0
  132. package/dist/chunk-SWN467MP.cjs +18 -0
  133. package/dist/chunk-SYQ3MOWW.cjs +73 -0
  134. package/dist/chunk-T5CERMEH.cjs +417 -0
  135. package/dist/chunk-TFAXUHWX.cjs +206 -0
  136. package/dist/chunk-TIWHTW3Q.cjs +24 -0
  137. package/dist/chunk-TKJZFIML.cjs +20 -0
  138. package/dist/chunk-TKNSDBBN.cjs +193 -0
  139. package/dist/chunk-U4KT7QP3.cjs +23 -0
  140. package/dist/chunk-U5BMPGS3.cjs +862 -0
  141. package/dist/chunk-UJ2C4ICS.cjs +277 -0
  142. package/dist/chunk-UQZ4AYTH.cjs +168 -0
  143. package/dist/chunk-US2QVW3E.cjs +36 -0
  144. package/dist/{chunk-QGVJVSNX.mjs → chunk-V4AICMQA.mjs} +2 -2
  145. package/dist/chunk-VB6UCX3V.cjs +421 -0
  146. package/dist/chunk-VEKFLAQM.cjs +300 -0
  147. package/dist/chunk-VQDBNVOO.cjs +14 -0
  148. package/dist/chunk-W4E7WMXE.cjs +71 -0
  149. package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
  150. package/dist/chunk-WMAPPDMM.cjs +28 -0
  151. package/dist/chunk-WMOGFOUJ.cjs +223 -0
  152. package/dist/chunk-WPYFSQKK.cjs +37 -0
  153. package/dist/{chunk-56DAX2BE.mjs → chunk-WZXN4R5Y.mjs} +24 -13
  154. package/dist/chunk-XDGMADQM.cjs +14225 -0
  155. package/dist/chunk-XGC343EY.cjs +443 -0
  156. package/dist/chunk-XSKZORAS.cjs +727 -0
  157. package/dist/chunk-XWAWFQFS.cjs +82 -0
  158. package/dist/chunk-Y4YMF2NQ.cjs +460 -0
  159. package/dist/chunk-Y4YWHNKU.cjs +250 -0
  160. package/dist/chunk-Y53ZSFN6.cjs +504 -0
  161. package/dist/chunk-YA6LLTIJ.cjs +411 -0
  162. package/dist/chunk-YFPGHF5F.cjs +202 -0
  163. package/dist/chunk-YJRZR7VU.cjs +28 -0
  164. package/dist/chunk-YTAABQEV.cjs +1 -0
  165. package/dist/chunk-YX3DBN4M.cjs +18 -0
  166. package/dist/chunk-YZTASLPQ.cjs +64 -0
  167. package/dist/chunk-Z5HIWVDP.cjs +2173 -0
  168. package/dist/chunk-ZEG3OPIB.cjs +93 -0
  169. package/dist/chunk-ZMN3H73H.cjs +155 -0
  170. package/dist/client/lifecycle.cjs +6 -35
  171. package/dist/client-plugins.cjs +7 -448
  172. package/dist/client.cjs +171 -9808
  173. package/dist/config.cjs +8 -36
  174. package/dist/cron.cjs +24 -491
  175. package/dist/deferred.cjs +26 -475
  176. package/dist/deployment.cjs +39 -210
  177. package/dist/devtools-5KGPDVKL.cjs +388 -0
  178. package/dist/{devtools-UFVTMQX5.mjs → devtools-FY5R7TQ4.mjs} +3 -3
  179. package/dist/devtools-client-4WAPJY5L.cjs +254 -0
  180. package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
  181. package/dist/docs.cjs +46 -5657
  182. package/dist/docs.mjs +5 -5
  183. package/dist/env-types.cjs +5 -226
  184. package/dist/env.cjs +21 -338
  185. package/dist/environment/vite.cjs +8 -372
  186. package/dist/environment.cjs +12 -94
  187. package/dist/font.cjs +13 -63
  188. package/dist/headers.cjs +7 -123
  189. package/dist/i18n/client.cjs +55 -294
  190. package/dist/i18n/index.cjs +22 -209
  191. package/dist/i18n/server.cjs +22 -745
  192. package/dist/image/server.cjs +13 -729
  193. package/dist/image/sharp.cjs +33 -171
  194. package/dist/image.cjs +41 -85
  195. package/dist/index.cjs +1151 -68080
  196. package/dist/index.mjs +14 -14
  197. package/dist/instrumentation.cjs +12 -138
  198. package/dist/integration-orm-55F7CII5.cjs +13 -0
  199. package/dist/integrations.cjs +55 -4090
  200. package/dist/internal/app-markdown-runtime.cjs +27 -224
  201. package/dist/internal/app-markdown-runtime.mjs +2 -2
  202. package/dist/internal/build-runtime.cjs +120 -52259
  203. package/dist/internal/build-runtime.mjs +13 -13
  204. package/dist/internal/cli-runtime.cjs +67 -13811
  205. package/dist/internal/cli-runtime.mjs +7 -7
  206. package/dist/internal/client-error-overlay.cjs +80 -733
  207. package/dist/internal/client-error-overlay.mjs +1 -1
  208. package/dist/internal/client-runtime.cjs +81 -913
  209. package/dist/internal/compression-runtime.cjs +8 -214
  210. package/dist/internal/config-runtime.cjs +42 -6547
  211. package/dist/internal/config-runtime.mjs +3 -3
  212. package/dist/internal/docs-precompiled-runtime.cjs +26 -46
  213. package/dist/internal/infra-analytics-runtime.cjs +10 -536
  214. package/dist/internal/isolated-boundary.cjs +14 -414
  215. package/dist/internal/metadata-image-runtime.cjs +7 -285
  216. package/dist/internal/product-telemetry-runtime.cjs +42 -97
  217. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  218. package/dist/internal/production-node-env.cjs +6 -63
  219. package/dist/internal/production-runtime.cjs +418 -7133
  220. package/dist/internal/production-runtime.mjs +3 -3
  221. package/dist/internal/request-cookies.cjs +6 -54
  222. package/dist/json-ld.cjs +24 -50
  223. package/dist/layers-E4WPJNY5.cjs +17 -0
  224. package/dist/manager-G4B2IPYE.cjs +14 -0
  225. package/dist/markdown.cjs +21 -547
  226. package/dist/markdown.mjs +1 -1
  227. package/dist/middleware.cjs +36 -2995
  228. package/dist/navigation.cjs +22 -2588
  229. package/dist/nitro-4I2MYLY2.cjs +652 -0
  230. package/dist/observability.cjs +22 -614
  231. package/dist/og.cjs +5 -28
  232. package/dist/plugin.cjs +106 -37442
  233. package/dist/plugin.mjs +9 -9
  234. package/dist/query/client.cjs +113 -449
  235. package/dist/query/index.cjs +26 -288
  236. package/dist/query/parsers.cjs +23 -247
  237. package/dist/query/server.cjs +36 -298
  238. package/dist/renderer/react/client.cjs +9 -43
  239. package/dist/renderer/react/server.cjs +40 -103
  240. package/dist/renderer/react/vite.cjs +7 -29
  241. package/dist/renderer-client.cjs +126 -4295
  242. package/dist/renderer.cjs +31 -249
  243. package/dist/request.cjs +5 -68
  244. package/dist/router.cjs +11 -474
  245. package/dist/routes.cjs +42 -2461
  246. package/dist/{schema-dev-notice-2IE2F2XI.mjs → schema-dev-notice-O67CPXJ6.mjs} +1 -1
  247. package/dist/schema-dev-notice-Y7MQEFGN.cjs +56 -0
  248. package/dist/schema.cjs +6 -33
  249. package/dist/search-client-G3RICOFU.cjs +13 -0
  250. package/dist/server-action-security.cjs +25 -541
  251. package/dist/server-fn-client.cjs +6 -337
  252. package/dist/server-fn.cjs +32 -1841
  253. package/dist/server-plugins.cjs +15 -884
  254. package/dist/server-query-client.cjs +15 -1883
  255. package/dist/server-query.cjs +16 -1838
  256. package/dist/server.cjs +296 -44681
  257. package/dist/server.mjs +11 -11
  258. package/dist/storage.cjs +57 -576
  259. package/dist/testing.cjs +89 -3186
  260. package/dist/theme/client.cjs +13 -108
  261. package/dist/theme/index.cjs +6 -68
  262. package/dist/theme/runtime.cjs +13 -78
  263. package/dist/theme/server.cjs +10 -179
  264. package/dist/version.cjs +4 -32
  265. package/dist/version.mjs +1 -1
  266. package/dist/vite.cjs +119 -37773
  267. package/dist/vite.mjs +9 -9
  268. package/dist/workflows.cjs +19 -1040
  269. package/package.json +1 -1
@@ -0,0 +1,411 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
+
3
+ var _chunkE3UK5IIBcjs = require('./chunk-E3UK5IIB.cjs');
4
+
5
+
6
+ var _chunk5ZSWG4UXcjs = require('./chunk-5ZSWG4UX.cjs');
7
+
8
+
9
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
10
+
11
+ // src/plugins/infra-analytics.ts
12
+ var FARM_PRERENDER_ENV = "FARM_PRERENDER";
13
+ var DEFAULT_URL = "https://app.farmjs.dev";
14
+ var EVENTS_PATH = "/api/telemetry/v1/events";
15
+ var INGESTION_KEY = /^fti_[A-Za-z0-9_-]{43}$/;
16
+ var API_KEY = /^farmjs_[A-Za-z0-9_-]{32}$/;
17
+ var PROJECT = /^proj_[0-9a-f-]{36}$/;
18
+ var ENVIRONMENTS = ["production", "staging", "development"];
19
+ var METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "QUERY"]);
20
+ var MAX_QUEUE = 500;
21
+ var MAX_AGE = 3e5;
22
+ var MAX_ATTEMPTS = 5;
23
+ var FLUSH_BUDGET = 5e3;
24
+ var TIMEOUT = 2e3;
25
+ var encoder = new TextEncoder();
26
+ var sleep = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep");
27
+ var uuid = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => globalThis.crypto.randomUUID(), "uuid");
28
+ function processEnv() {
29
+ return _nullishCoalesce(_optionalChain([globalThis, 'access', _ => _.process, 'optionalAccess', _2 => _2.env]), () => ( {}));
30
+ }
31
+ _chunkS3JO3N4Hcjs.__name.call(void 0, processEnv, "processEnv");
32
+ function defaultFarmInfraEnvironment(env = processEnv()) {
33
+ const explicit = env.FARMJS_ENVIRONMENT;
34
+ if (explicit && ENVIRONMENTS.includes(explicit)) return explicit;
35
+ if (env.VERCEL_ENV === "production") return "production";
36
+ if (env.VERCEL_ENV === "preview") return "staging";
37
+ if (env.VERCEL_ENV === "development") return "development";
38
+ return env.NODE_ENV === "production" ? "production" : "development";
39
+ }
40
+ _chunkS3JO3N4Hcjs.__name.call(void 0, defaultFarmInfraEnvironment, "defaultFarmInfraEnvironment");
41
+ function resolveFarmInfraAnalytics(env = processEnv()) {
42
+ const key = _optionalChain([env, 'access', _3 => _3.FARMJS_API_KEY, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
43
+ if (!key || env[FARM_PRERENDER_ENV] === "1") return { off: null };
44
+ const ingestionKey = INGESTION_KEY.test(key);
45
+ const projectId = _optionalChain([env, 'access', _6 => _6.FARMJS_PROJECT_ID, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]) || void 0;
46
+ if (!ingestionKey && !projectId) return { off: null };
47
+ if (!ingestionKey && !API_KEY.test(key)) {
48
+ return {
49
+ off: "FARMJS_API_KEY isn't a Farm Infra API key (farmjs_\u2026) or write-only key (fti_\u2026)"
50
+ };
51
+ }
52
+ if (!ingestionKey && !PROJECT.test(projectId)) {
53
+ return { off: "FARMJS_PROJECT_ID isn't a Farm Infra project ID (proj_\u2026)" };
54
+ }
55
+ if (env.FARMJS_ENVIRONMENT && !ENVIRONMENTS.includes(env.FARMJS_ENVIRONMENT)) {
56
+ return { off: "FARMJS_ENVIRONMENT must be production, staging or development" };
57
+ }
58
+ let endpoint;
59
+ try {
60
+ endpoint = new URL(EVENTS_PATH, _optionalChain([env, 'access', _9 => _9.FARMJS_API_URL, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]) || DEFAULT_URL);
61
+ } catch (e) {
62
+ return { off: "FARMJS_API_URL isn't a URL" };
63
+ }
64
+ const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(endpoint.hostname);
65
+ if (endpoint.protocol !== "https:" && !(endpoint.protocol === "http:" && loopback) || endpoint.username || endpoint.password) {
66
+ return { off: "FARMJS_API_URL must use HTTPS (HTTP only for localhost)" };
67
+ }
68
+ return {
69
+ options: {
70
+ endpoint: endpoint.href,
71
+ key,
72
+ ...ingestionKey ? {} : { projectId, environment: defaultFarmInfraEnvironment(env) }
73
+ }
74
+ };
75
+ }
76
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmInfraAnalytics, "resolveFarmInfraAnalytics");
77
+ var AGENT_TOKENS = [
78
+ ["ChatGPT-User", "openai", "agent"],
79
+ ["OAI-SearchBot", "openai", "crawler"],
80
+ ["GPTBot", "openai", "crawler"],
81
+ ["Claude-User", "anthropic", "agent"],
82
+ ["Claude-SearchBot", "anthropic", "crawler"],
83
+ ["ClaudeBot", "anthropic", "crawler"]
84
+ ];
85
+ var AGENT_PATTERNS = AGENT_TOKENS.map(([token, family, category]) => ({
86
+ pattern: new RegExp(`(?:^|[\\s;(])${token}(?=[/\\s;)]|$)`, "i"),
87
+ family,
88
+ category
89
+ }));
90
+ function classifyFarmInfraAgent(userAgent) {
91
+ const value = (_nullishCoalesce(userAgent, () => ( ""))).slice(0, 2048);
92
+ const matches = AGENT_PATTERNS.filter(({ pattern }) => pattern.test(value));
93
+ if (matches.length === 1) {
94
+ const { family, category } = matches[0];
95
+ return { family, category, identity: "self-reported" };
96
+ }
97
+ return { family: "unknown", category: "unknown", identity: "unknown" };
98
+ }
99
+ _chunkS3JO3N4Hcjs.__name.call(void 0, classifyFarmInfraAgent, "classifyFarmInfraAgent");
100
+ function routeTemplate(pattern) {
101
+ return typeof pattern === "string" && pattern.length <= 256 && /^\/(?!\/)[a-zA-Z0-9_./:[\]()*-]*$/.test(pattern) ? pattern : "/[unmatched]";
102
+ }
103
+ _chunkS3JO3N4Hcjs.__name.call(void 0, routeTemplate, "routeTemplate");
104
+ function duration(value) {
105
+ return Number.isFinite(value) ? Math.min(864e5, Math.max(0, value)) : 0;
106
+ }
107
+ _chunkS3JO3N4Hcjs.__name.call(void 0, duration, "duration");
108
+ function isToolEvent(value) {
109
+ if (!value || typeof value !== "object") return false;
110
+ const event = value;
111
+ return event.type === "mcp.tool.complete" && typeof event.tool === "string" && /^[a-zA-Z0-9_.:/-]{1,128}$/.test(event.tool) && (event.outcome === "success" || event.outcome === "error") && typeof event.durationMs === "number" && Number.isFinite(event.durationMs);
112
+ }
113
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isToolEvent, "isToolEvent");
114
+ function retryAt(value, now) {
115
+ if (!value) return now;
116
+ if (/^\d+$/.test(value.trim())) return now + Math.min(Number(value), 86400) * 1e3;
117
+ const date = Date.parse(value);
118
+ return Number.isFinite(date) ? Math.max(now, Math.min(date, now + 864e5)) : now;
119
+ }
120
+ _chunkS3JO3N4Hcjs.__name.call(void 0, retryAt, "retryAt");
121
+ function createFarmInfraAnalyticsExporter(options, send = (input, init) => fetch(input, init)) {
122
+ const requestHeaders = {
123
+ "content-type": "application/json",
124
+ authorization: `Bearer ${options.key}`
125
+ };
126
+ if (!INGESTION_KEY.test(options.key)) {
127
+ requestHeaders["x-farm-project"] = options.projectId;
128
+ requestHeaders["x-farm-environment"] = _nullishCoalesce(options.environment, () => ( defaultFarmInfraEnvironment()));
129
+ }
130
+ const queue = [];
131
+ let stopped = false;
132
+ let closing = false;
133
+ let pending;
134
+ let notBefore = 0;
135
+ let active;
136
+ let inFlight = /* @__PURE__ */ new Set();
137
+ const diagnostic = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (event) => {
138
+ try {
139
+ void Promise.resolve(_optionalChain([options, 'access', _12 => _12.onDiagnostic, 'optionalCall', _13 => _13(event)])).catch(() => {
140
+ });
141
+ } catch (e2) {
142
+ }
143
+ }, "diagnostic");
144
+ const expired = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (item, now) => !inFlight.has(item) && (now - item.enqueuedAt >= MAX_AGE || item.attempts >= MAX_ATTEMPTS), "expired");
145
+ function prune() {
146
+ const now = Date.now();
147
+ let count = 0;
148
+ for (let i = queue.length - 1; i >= 0; i--) {
149
+ if (expired(queue[i], now)) {
150
+ queue.splice(i, 1);
151
+ count++;
152
+ }
153
+ }
154
+ if (count) diagnostic({ code: "dropped", count });
155
+ }
156
+ _chunkS3JO3N4Hcjs.__name.call(void 0, prune, "prune");
157
+ function remove(batch) {
158
+ const sent = new Set(batch);
159
+ for (let i = queue.length - 1; i >= 0; i--) if (sent.has(queue[i])) queue.splice(i, 1);
160
+ }
161
+ _chunkS3JO3N4Hcjs.__name.call(void 0, remove, "remove");
162
+ function enqueue(event) {
163
+ if (stopped || closing) return;
164
+ prune();
165
+ if (queue.length >= MAX_QUEUE) {
166
+ diagnostic({ code: "dropped", count: 1 });
167
+ return;
168
+ }
169
+ queue.push({ event, enqueuedAt: Date.now(), attempts: 0 });
170
+ }
171
+ _chunkS3JO3N4Hcjs.__name.call(void 0, enqueue, "enqueue");
172
+ async function drain() {
173
+ const deadline = Date.now() + FLUSH_BUDGET;
174
+ await sleep(25);
175
+ while (!stopped && queue.length && Date.now() < deadline) {
176
+ prune();
177
+ if (!queue.length || notBefore >= deadline) break;
178
+ if (notBefore > Date.now()) await sleep(notBefore - Date.now());
179
+ if (stopped || Date.now() >= deadline) break;
180
+ const batch = queue.slice(0, 50);
181
+ const body = JSON.stringify({ schemaVersion: 1, events: batch.map(({ event }) => event) });
182
+ if (encoder.encode(body).length > 128 * 1024) {
183
+ queue.splice(0, batch.length);
184
+ diagnostic({ code: "dropped", count: batch.length });
185
+ continue;
186
+ }
187
+ for (const item of batch) item.attempts++;
188
+ inFlight = new Set(batch);
189
+ active = new AbortController();
190
+ const timeout = setTimeout(() => _optionalChain([active, 'optionalAccess', _14 => _14.abort, 'call', _15 => _15()]), Math.min(TIMEOUT, deadline - Date.now()));
191
+ let status;
192
+ try {
193
+ const response = await send(options.endpoint, {
194
+ method: "POST",
195
+ redirect: "error",
196
+ signal: active.signal,
197
+ headers: requestHeaders,
198
+ body
199
+ });
200
+ status = response.status;
201
+ void _optionalChain([response, 'access', _16 => _16.body, 'optionalAccess', _17 => _17.cancel, 'call', _18 => _18(), 'access', _19 => _19.catch, 'call', _20 => _20(() => {
202
+ })]);
203
+ if (response.ok) {
204
+ remove(batch);
205
+ continue;
206
+ }
207
+ if ([400, 401, 403, 404, 413, 415].includes(status) || status >= 300 && status < 400) {
208
+ stopped = true;
209
+ queue.length = 0;
210
+ diagnostic({ code: "disabled", status });
211
+ break;
212
+ }
213
+ if (status !== 408 && status !== 429 && status < 500) {
214
+ remove(batch);
215
+ diagnostic({ code: "dropped", count: batch.length, status });
216
+ continue;
217
+ }
218
+ notBefore = Math.max(notBefore, retryAt(response.headers.get("retry-after"), Date.now()));
219
+ } catch (e3) {
220
+ } finally {
221
+ clearTimeout(timeout);
222
+ active = void 0;
223
+ inFlight.clear();
224
+ }
225
+ notBefore = Math.max(
226
+ notBefore,
227
+ Date.now() + Math.min(3e4, 500 * 2 ** (batch[0].attempts - 1))
228
+ );
229
+ diagnostic({ code: "retry", ...status === void 0 ? {} : { status } });
230
+ }
231
+ }
232
+ _chunkS3JO3N4Hcjs.__name.call(void 0, drain, "drain");
233
+ function flush() {
234
+ if (stopped || !queue.length || notBefore > Date.now() + FLUSH_BUDGET)
235
+ return _nullishCoalesce(pending, () => ( Promise.resolve()));
236
+ _nullishCoalesce(pending, () => ( (pending = drain().catch(() => {
237
+ }).finally(() => {
238
+ pending = void 0;
239
+ }))));
240
+ return pending;
241
+ }
242
+ _chunkS3JO3N4Hcjs.__name.call(void 0, flush, "flush");
243
+ async function close() {
244
+ if (closing) {
245
+ await pending;
246
+ return;
247
+ }
248
+ closing = true;
249
+ await flush();
250
+ stopped = true;
251
+ _optionalChain([active, 'optionalAccess', _21 => _21.abort, 'call', _22 => _22()]);
252
+ if (queue.length) diagnostic({ code: "dropped", count: queue.length });
253
+ queue.length = 0;
254
+ }
255
+ _chunkS3JO3N4Hcjs.__name.call(void 0, close, "close");
256
+ return { enqueue, flush, close };
257
+ }
258
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmInfraAnalyticsExporter, "createFarmInfraAnalyticsExporter");
259
+ var CONTEXT_KEY = "farm.infra.analytics";
260
+ function beginRequest(request, pattern, waitUntil) {
261
+ return {
262
+ id: uuid(),
263
+ agent: classifyFarmInfraAgent(request.headers.get("user-agent")),
264
+ route: routeTemplate(pattern),
265
+ completed: false,
266
+ waitUntil
267
+ };
268
+ }
269
+ _chunkS3JO3N4Hcjs.__name.call(void 0, beginRequest, "beginRequest");
270
+ function requestEvent(metadata, method, status, durationMs) {
271
+ return {
272
+ id: uuid(),
273
+ requestId: metadata.id,
274
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
275
+ route: metadata.route,
276
+ agent: metadata.agent,
277
+ kind: "request",
278
+ method,
279
+ status,
280
+ durationMs: duration(durationMs)
281
+ };
282
+ }
283
+ _chunkS3JO3N4Hcjs.__name.call(void 0, requestEvent, "requestEvent");
284
+ function farmInfraAnalyticsPlugin(options, send) {
285
+ const contextKey = `${CONTEXT_KEY}.${uuid()}`;
286
+ return {
287
+ name: "farm:infra-analytics",
288
+ enforce: "post",
289
+ setup(context) {
290
+ const state = { exporter: createFarmInfraAnalyticsExporter(options, send) };
291
+ context.lifecycle.onShutdown(async () => {
292
+ _optionalChain([state, 'access', _23 => _23.unsubscribe, 'optionalCall', _24 => _24()]);
293
+ await state.exporter.close();
294
+ });
295
+ return state;
296
+ },
297
+ runtime: {
298
+ start(context) {
299
+ const { exporter } = context.state;
300
+ context.state.unsubscribe = _chunkE3UK5IIBcjs.onFarmEvent.call(void 0,
301
+ (event) => {
302
+ if (!isToolEvent(event)) return;
303
+ const request = _chunk5ZSWG4UXcjs.getCurrentRequestOrNull.call(void 0, );
304
+ if (!request) return;
305
+ const metadata = context.requestContext.get(request, contextKey);
306
+ if (!metadata) return;
307
+ exporter.enqueue({
308
+ id: uuid(),
309
+ requestId: metadata.id,
310
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
311
+ route: metadata.route,
312
+ agent: metadata.agent,
313
+ kind: "mcp.tool",
314
+ tool: event.tool,
315
+ outcome: event.outcome,
316
+ durationMs: duration(event.durationMs)
317
+ });
318
+ metadata.waitUntil(exporter.flush());
319
+ },
320
+ { unfiltered: true }
321
+ );
322
+ },
323
+ before(event) {
324
+ if (event.kind === "asset" || !event.state) return;
325
+ event.req.set(
326
+ contextKey,
327
+ beginRequest(event.request, _optionalChain([event, 'access', _25 => _25.route, 'optionalAccess', _26 => _26.pattern]), event.waitUntil)
328
+ );
329
+ },
330
+ after(event) {
331
+ const metadata = event.req.get(contextKey);
332
+ if (!metadata || metadata.completed || !event.state) return;
333
+ metadata.completed = true;
334
+ if (!METHODS.has(event.request.method)) return;
335
+ event.state.exporter.enqueue(
336
+ requestEvent(metadata, event.request.method, event.response.status, event.durationMs)
337
+ );
338
+ event.waitUntil(event.state.exporter.flush());
339
+ },
340
+ // Unhandled exceptions have no final HTTP status at this boundary. Do not fabricate a 500.
341
+ error(event) {
342
+ const metadata = event.req.get(contextKey);
343
+ if (metadata) metadata.completed = true;
344
+ if (event.state) event.waitUntil(event.state.exporter.flush());
345
+ }
346
+ }
347
+ };
348
+ }
349
+ _chunkS3JO3N4Hcjs.__name.call(void 0, farmInfraAnalyticsPlugin, "farmInfraAnalyticsPlugin");
350
+ function farmInfraAnalyticsRecorder(options, send) {
351
+ const exporter = createFarmInfraAnalyticsExporter(options, send);
352
+ return {
353
+ async record(request, runtime, waitUntil, handler) {
354
+ if (runtime.kind === "asset") return handler();
355
+ const background = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (promise) => waitUntil ? waitUntil(promise) : void promise.catch(() => {
356
+ }), "background");
357
+ const metadata = beginRequest(request, _optionalChain([runtime, 'access', _27 => _27.route, 'optionalAccess', _28 => _28.pattern]), background);
358
+ const startedAt = performance.now();
359
+ let response;
360
+ try {
361
+ response = await handler();
362
+ } catch (error) {
363
+ background(exporter.flush());
364
+ throw error;
365
+ }
366
+ if (METHODS.has(request.method)) {
367
+ exporter.enqueue(
368
+ requestEvent(metadata, request.method, response.status, performance.now() - startedAt)
369
+ );
370
+ }
371
+ background(exporter.flush());
372
+ return response;
373
+ },
374
+ close: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => exporter.close(), "close")
375
+ };
376
+ }
377
+ _chunkS3JO3N4Hcjs.__name.call(void 0, farmInfraAnalyticsRecorder, "farmInfraAnalyticsRecorder");
378
+ function linkedOptions(env, warn) {
379
+ const resolved = resolveFarmInfraAnalytics(env);
380
+ if ("off" in resolved) {
381
+ if (resolved.off) warn(`[Farm] Farm Infra analytics is off: ${resolved.off}.`);
382
+ return null;
383
+ }
384
+ return {
385
+ ...resolved.options,
386
+ onDiagnostic(event) {
387
+ if (event.code === "disabled") {
388
+ warn(
389
+ `[Farm] Farm Infra analytics stopped: Farm Infra answered ${event.status}. Check FARMJS_API_KEY and FARMJS_PROJECT_ID, then restart the server.`
390
+ );
391
+ }
392
+ }
393
+ };
394
+ }
395
+ _chunkS3JO3N4Hcjs.__name.call(void 0, linkedOptions, "linkedOptions");
396
+ function createFarmInfraAnalyticsPlugin(env = processEnv(), warn = console.warn) {
397
+ const options = linkedOptions(env, warn);
398
+ return options ? farmInfraAnalyticsPlugin(options) : null;
399
+ }
400
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmInfraAnalyticsPlugin, "createFarmInfraAnalyticsPlugin");
401
+ function createFarmInfraAnalyticsRecorder(env = processEnv(), warn = console.warn) {
402
+ const options = linkedOptions(env, warn);
403
+ return options ? farmInfraAnalyticsRecorder(options) : null;
404
+ }
405
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmInfraAnalyticsRecorder, "createFarmInfraAnalyticsRecorder");
406
+
407
+
408
+
409
+
410
+
411
+ exports.FARM_PRERENDER_ENV = FARM_PRERENDER_ENV; exports.createFarmInfraAnalyticsPlugin = createFarmInfraAnalyticsPlugin; exports.createFarmInfraAnalyticsRecorder = createFarmInfraAnalyticsRecorder;
@@ -0,0 +1,202 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/image-config.ts
6
+ var DEFAULT_FARM_IMAGE_PATH = "/_farm/image";
7
+ var DEFAULT_FARM_IMAGE_DEVICE_SIZES = [
8
+ 640,
9
+ 750,
10
+ 828,
11
+ 1080,
12
+ 1200,
13
+ 1920,
14
+ 2048,
15
+ 3840
16
+ ];
17
+ var DEFAULT_FARM_IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
18
+ var DEFAULT_FARM_IMAGE_QUALITIES = [75];
19
+ var DEFAULT_FARM_IMAGE_FORMATS = ["image/webp"];
20
+ var SIZE_UNITS = {
21
+ b: 1,
22
+ kb: 1e3,
23
+ mb: 1e6,
24
+ gb: 1e9,
25
+ kib: 1024,
26
+ mib: 1048576,
27
+ gib: 1073741824
28
+ };
29
+ function resolveFarmImageConfig(config) {
30
+ const path = normalizeImagePath(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.path]), () => ( DEFAULT_FARM_IMAGE_PATH)));
31
+ const deviceSizes = normalizeIntegerList(
32
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.deviceSizes]), () => ( DEFAULT_FARM_IMAGE_DEVICE_SIZES)),
33
+ "images.deviceSizes"
34
+ );
35
+ const imageSizes = normalizeIntegerList(
36
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _3 => _3.imageSizes]), () => ( DEFAULT_FARM_IMAGE_SIZES)),
37
+ "images.imageSizes"
38
+ );
39
+ const qualities = normalizeIntegerList(
40
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _4 => _4.qualities]), () => ( DEFAULT_FARM_IMAGE_QUALITIES)),
41
+ "images.qualities",
42
+ 100
43
+ );
44
+ const formats = [...new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _5 => _5.formats]), () => ( DEFAULT_FARM_IMAGE_FORMATS)))];
45
+ if (formats.some((format) => format !== "image/avif" && format !== "image/webp")) {
46
+ throw new TypeError('images.formats only supports "image/avif" and "image/webp"');
47
+ }
48
+ const minimumCacheTTL = normalizeNonNegativeInteger(
49
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _6 => _6.minimumCacheTTL]), () => ( 60)),
50
+ "images.minimumCacheTTL"
51
+ );
52
+ const maximumRedirects = normalizeNonNegativeInteger(
53
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _7 => _7.maximumRedirects]), () => ( 3)),
54
+ "images.maximumRedirects"
55
+ );
56
+ return Object.freeze({
57
+ provider: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _8 => _8.provider]), () => ( "auto")),
58
+ path,
59
+ domains: Object.freeze([
60
+ ...new Set(
61
+ (_nullishCoalesce(_optionalChain([config, 'optionalAccess', _9 => _9.domains]), () => ( []))).map((domain) => domain.trim().toLowerCase()).filter(Boolean)
62
+ )
63
+ ]),
64
+ remotePatterns: Object.freeze(
65
+ (_nullishCoalesce(_optionalChain([config, 'optionalAccess', _10 => _10.remotePatterns]), () => ( []))).map((pattern) => normalizeRemotePattern(pattern))
66
+ ),
67
+ localPatterns: Object.freeze(
68
+ (_nullishCoalesce(_optionalChain([config, 'optionalAccess', _11 => _11.localPatterns]), () => ( [{ pathname: "/**" }]))).map(
69
+ (pattern) => normalizeLocalPattern(pattern)
70
+ )
71
+ ),
72
+ deviceSizes: Object.freeze(deviceSizes),
73
+ imageSizes: Object.freeze(imageSizes),
74
+ qualities: Object.freeze(qualities),
75
+ formats: Object.freeze(formats),
76
+ minimumCacheTTL,
77
+ maximumResponseBody: parseSize(
78
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _12 => _12.maximumResponseBody]), () => ( "10mb")),
79
+ "images.maximumResponseBody"
80
+ ),
81
+ maximumRedirects,
82
+ dangerouslyAllowSVG: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _13 => _13.dangerouslyAllowSVG]), () => ( false)),
83
+ dangerouslyAllowLocalIP: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _14 => _14.dangerouslyAllowLocalIP]), () => ( false))
84
+ });
85
+ }
86
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmImageConfig, "resolveFarmImageConfig");
87
+ function getPublicFarmImageConfig(config) {
88
+ return {
89
+ provider: config.provider,
90
+ path: config.path,
91
+ deviceSizes: config.deviceSizes,
92
+ imageSizes: config.imageSizes,
93
+ qualities: config.qualities,
94
+ formats: config.formats
95
+ };
96
+ }
97
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getPublicFarmImageConfig, "getPublicFarmImageConfig");
98
+ function normalizeImagePath(value) {
99
+ const hasUnstableCharacters = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (candidate) => candidate.includes("\\") || Array.from(candidate).some((character) => {
100
+ const code = character.charCodeAt(0);
101
+ return code <= 31 || code >= 127 && code <= 159;
102
+ }), "hasUnstableCharacters");
103
+ if (hasUnstableCharacters(value)) {
104
+ throw new TypeError("images.path cannot contain backslashes or control characters");
105
+ }
106
+ const path = value.trim().replace(/\/+$/, "") || "/";
107
+ if (!path.startsWith("/") || path.startsWith("//") || path.includes("?") || path.includes("#")) {
108
+ throw new TypeError("images.path must be an absolute pathname without a query or hash");
109
+ }
110
+ for (const segment of path.split("/")) {
111
+ let decoded = segment;
112
+ try {
113
+ decoded = decodeURIComponent(segment);
114
+ } catch (e) {
115
+ }
116
+ if (hasUnstableCharacters(decoded)) {
117
+ throw new TypeError("images.path cannot contain backslashes or control characters");
118
+ }
119
+ if (decoded.includes("/")) {
120
+ throw new TypeError("images.path cannot contain percent-encoded path separators");
121
+ }
122
+ if (decoded === "." || decoded === "..") {
123
+ throw new TypeError('images.path cannot contain "." or ".." path segments');
124
+ }
125
+ }
126
+ return path;
127
+ }
128
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeImagePath, "normalizeImagePath");
129
+ function normalizeIntegerList(values, name, max) {
130
+ if (values.length === 0) {
131
+ throw new TypeError(`${name} must contain at least one value`);
132
+ }
133
+ const normalized = [...new Set(values)].sort((left, right) => left - right);
134
+ for (const value of normalized) {
135
+ if (!Number.isSafeInteger(value) || value <= 0 || max !== void 0 && value > max) {
136
+ throw new TypeError(
137
+ `${name} must contain positive integers${max ? ` no greater than ${max}` : ""}`
138
+ );
139
+ }
140
+ }
141
+ return normalized;
142
+ }
143
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegerList, "normalizeIntegerList");
144
+ function normalizeNonNegativeInteger(value, name) {
145
+ if (!Number.isSafeInteger(value) || value < 0) {
146
+ throw new TypeError(`${name} must be a non-negative safe integer`);
147
+ }
148
+ return value;
149
+ }
150
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeNonNegativeInteger, "normalizeNonNegativeInteger");
151
+ function parseSize(value, name) {
152
+ if (typeof value === "number") {
153
+ if (!Number.isSafeInteger(value) || value <= 0) {
154
+ throw new TypeError(`${name} must be a positive safe integer`);
155
+ }
156
+ return value;
157
+ }
158
+ const match = value.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|kib|mib|gib)$/);
159
+ if (!match) {
160
+ throw new TypeError(`${name} must be bytes or a size string such as "5mb"`);
161
+ }
162
+ const bytes = Number(match[1]) * SIZE_UNITS[match[2]];
163
+ if (!Number.isSafeInteger(bytes) || bytes <= 0) {
164
+ throw new TypeError(`${name} must resolve to a positive safe integer`);
165
+ }
166
+ return bytes;
167
+ }
168
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseSize, "parseSize");
169
+ function normalizeRemotePattern(pattern) {
170
+ const hostname = pattern.hostname.trim().toLowerCase();
171
+ if (!hostname || hostname.includes("/") || hostname.includes(":")) {
172
+ throw new TypeError("images.remotePatterns[].hostname must be a hostname or wildcard hostname");
173
+ }
174
+ if (pattern.pathname && !pattern.pathname.startsWith("/")) {
175
+ throw new TypeError("images.remotePatterns[].pathname must start with /");
176
+ }
177
+ if (pattern.search && !pattern.search.startsWith("?")) {
178
+ throw new TypeError("images.remotePatterns[].search must start with ?");
179
+ }
180
+ return Object.freeze({ ...pattern, hostname });
181
+ }
182
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeRemotePattern, "normalizeRemotePattern");
183
+ function normalizeLocalPattern(pattern) {
184
+ if (!pattern.pathname.startsWith("/")) {
185
+ throw new TypeError("images.localPatterns[].pathname must start with /");
186
+ }
187
+ if (pattern.search && !pattern.search.startsWith("?")) {
188
+ throw new TypeError("images.localPatterns[].search must start with ?");
189
+ }
190
+ return Object.freeze({ ...pattern });
191
+ }
192
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeLocalPattern, "normalizeLocalPattern");
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+ exports.DEFAULT_FARM_IMAGE_PATH = DEFAULT_FARM_IMAGE_PATH; exports.DEFAULT_FARM_IMAGE_DEVICE_SIZES = DEFAULT_FARM_IMAGE_DEVICE_SIZES; exports.DEFAULT_FARM_IMAGE_SIZES = DEFAULT_FARM_IMAGE_SIZES; exports.DEFAULT_FARM_IMAGE_QUALITIES = DEFAULT_FARM_IMAGE_QUALITIES; exports.DEFAULT_FARM_IMAGE_FORMATS = DEFAULT_FARM_IMAGE_FORMATS; exports.resolveFarmImageConfig = resolveFarmImageConfig; exports.getPublicFarmImageConfig = getPublicFarmImageConfig;
@@ -0,0 +1,28 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/devtools-config.ts
6
+ var DEFAULT_FARM_DEVTOOLS_SHORTCUT = "mod+shift+.";
7
+ var FARM_DEVTOOLS_PATH = "/__farm/devtools";
8
+ var FARM_DEVTOOLS_LAUNCH_PARAM = "__farm_devtools";
9
+ function resolveFarmDevtoolsConfig(config, mode = "development") {
10
+ if (mode !== "development" || config === false) {
11
+ return { enabled: false, shortcut: false };
12
+ }
13
+ const options = config === true || config === void 0 ? {} : config;
14
+ const enabled = _nullishCoalesce(options.enabled, () => ( true));
15
+ if (!enabled) {
16
+ return { enabled: false, shortcut: false };
17
+ }
18
+ const shortcut = typeof options.shortcut === "string" && options.shortcut.trim() ? options.shortcut.toLowerCase().split("+").map((part) => part.trim()).filter(Boolean).join("+") : options.shortcut === false ? false : DEFAULT_FARM_DEVTOOLS_SHORTCUT;
19
+ return { enabled: true, shortcut };
20
+ }
21
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmDevtoolsConfig, "resolveFarmDevtoolsConfig");
22
+
23
+
24
+
25
+
26
+
27
+
28
+ exports.DEFAULT_FARM_DEVTOOLS_SHORTCUT = DEFAULT_FARM_DEVTOOLS_SHORTCUT; exports.FARM_DEVTOOLS_PATH = FARM_DEVTOOLS_PATH; exports.FARM_DEVTOOLS_LAUNCH_PARAM = FARM_DEVTOOLS_LAUNCH_PARAM; exports.resolveFarmDevtoolsConfig = resolveFarmDevtoolsConfig;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,18 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/redirect-query.ts
6
+ function appendFarmRedirectQuery(destination, search) {
7
+ if (!search || search === "?") return destination;
8
+ const hashIndex = destination.indexOf("#");
9
+ const pathAndQuery = hashIndex === -1 ? destination : destination.slice(0, hashIndex);
10
+ if (pathAndQuery.includes("?")) return destination;
11
+ if (hashIndex === -1) return `${destination}${search}`;
12
+ return `${pathAndQuery}${search}${destination.slice(hashIndex)}`;
13
+ }
14
+ _chunkS3JO3N4Hcjs.__name.call(void 0, appendFarmRedirectQuery, "appendFarmRedirectQuery");
15
+
16
+
17
+
18
+ exports.appendFarmRedirectQuery = appendFarmRedirectQuery;