@farm.js/core 0.1.16 → 0.1.18

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 (390) hide show
  1. package/dist/after.cjs +12 -225
  2. package/dist/agent-runtime.cjs +83 -2800
  3. package/dist/agent-runtime.d.mts +3 -3
  4. package/dist/agent-runtime.d.ts +3 -3
  5. package/dist/api/client.cjs +17 -4026
  6. package/dist/api/client.d.mts +3 -3
  7. package/dist/api/client.d.ts +3 -3
  8. package/dist/api/client.mjs +3 -3
  9. package/dist/api/route-manager.cjs +34 -4317
  10. package/dist/api/route-manager.d.mts +3 -3
  11. package/dist/api/route-manager.d.ts +3 -3
  12. package/dist/api/route-manager.mjs +5 -5
  13. package/dist/api/runtime.cjs +29 -2660
  14. package/dist/api/runtime.d.mts +3 -3
  15. package/dist/api/runtime.d.ts +3 -3
  16. package/dist/api/runtime.mjs +6 -3
  17. package/dist/{api-client-B-n3pm_Q.d.mts → api-client-Cx54IR5g.d.mts} +2 -2
  18. package/dist/{api-client-C0_NZEBl.d.ts → api-client-DykpaKcY.d.ts} +2 -2
  19. package/dist/api.cjs +88 -8361
  20. package/dist/api.d.mts +5 -5
  21. package/dist/api.d.ts +5 -5
  22. package/dist/api.mjs +8 -8
  23. package/dist/{app-AyjEsCBq.d.ts → app-BHY_10Lm.d.ts} +3 -3
  24. package/dist/{app-CYPHeOo_.d.mts → app-BMk0do23.d.mts} +3 -3
  25. package/dist/app-markdown.cjs +39 -280
  26. package/dist/app-markdown.d.mts +4 -4
  27. package/dist/app-markdown.d.ts +4 -4
  28. package/dist/app-markdown.mjs +3 -3
  29. package/dist/cache.cjs +38 -1526
  30. package/dist/cache.d.mts +11 -1
  31. package/dist/cache.d.ts +11 -1
  32. package/dist/cache.mjs +1 -1
  33. package/dist/chunk-22GUSVNJ.cjs +351 -0
  34. package/dist/chunk-2CQ74SP6.cjs +13 -0
  35. package/dist/chunk-2SJ4RQ6P.cjs +57 -0
  36. package/dist/chunk-3376ZTRC.cjs +1 -0
  37. package/dist/{chunk-IL5RWYK7.mjs → chunk-3XG26Z3J.mjs} +1 -1
  38. package/dist/{chunk-7HDZYYS4.mjs → chunk-4OOBRCJX.mjs} +27 -5
  39. package/dist/chunk-4PNUXIVU.cjs +472 -0
  40. package/dist/chunk-4PPEPOZZ.cjs +21 -0
  41. package/dist/chunk-4ZFL5GFN.cjs +520 -0
  42. package/dist/{chunk-B76DT5Y6.mjs → chunk-57J3Y7Y3.mjs} +1 -1
  43. package/dist/chunk-5OVTOKGH.cjs +65 -0
  44. package/dist/chunk-5QIKR7RR.cjs +224 -0
  45. package/dist/{chunk-MOQNHLTS.mjs → chunk-5QOEPUYE.mjs} +5 -2
  46. package/dist/{chunk-HKLRP3BN.mjs → chunk-5SPPCN5J.mjs} +1 -1
  47. package/dist/chunk-5ZSWG4UX.cjs +127 -0
  48. package/dist/chunk-62YJ2IEB.cjs +238 -0
  49. package/dist/chunk-6EODJYCX.cjs +183 -0
  50. package/dist/chunk-6EXBPJ24.cjs +434 -0
  51. package/dist/chunk-6QQDAAAZ.cjs +38 -0
  52. package/dist/chunk-6V4TDWEC.cjs +455 -0
  53. package/dist/{chunk-LUC2FAGW.mjs → chunk-6VQIKZZO.mjs} +1 -1
  54. package/dist/chunk-72ADZ6GQ.cjs +19 -0
  55. package/dist/chunk-75BRBIFP.cjs +172 -0
  56. package/dist/{chunk-7ZWL7XOU.mjs → chunk-76DG3LF3.mjs} +1 -1
  57. package/dist/chunk-7W3CPVXS.cjs +24 -0
  58. package/dist/chunk-A6WIQH5Z.cjs +31 -0
  59. package/dist/{chunk-EWDK36MM.mjs → chunk-A72YEUZ3.mjs} +1 -1
  60. package/dist/chunk-AFOD3LYZ.cjs +377 -0
  61. package/dist/chunk-AMDMVWMI.cjs +39 -0
  62. package/dist/chunk-AORPIPNB.cjs +552 -0
  63. package/dist/chunk-ARJWXNQL.cjs +256 -0
  64. package/dist/{chunk-ZHOIQC6U.mjs → chunk-ATERBVHQ.mjs} +2 -2
  65. package/dist/chunk-AWRISO2H.cjs +2199 -0
  66. package/dist/chunk-AYJR42WX.cjs +711 -0
  67. package/dist/chunk-B4CH33IG.cjs +644 -0
  68. package/dist/chunk-BIDYX3SL.cjs +91 -0
  69. package/dist/chunk-BSTRERPP.cjs +40 -0
  70. package/dist/chunk-BYODCJD6.cjs +663 -0
  71. package/dist/chunk-C3VRMB6H.cjs +85 -0
  72. package/dist/chunk-C5GUTBZK.cjs +173 -0
  73. package/dist/chunk-CIAGU2X4.cjs +337 -0
  74. package/dist/chunk-CMGMGHUZ.cjs +27 -0
  75. package/dist/chunk-CXP5U3RW.cjs +54 -0
  76. package/dist/chunk-D2ULAULS.cjs +166 -0
  77. package/dist/chunk-D7JTOLFK.cjs +285 -0
  78. package/dist/chunk-DVM4FKZL.cjs +169 -0
  79. package/dist/chunk-DYEJQTDN.cjs +49 -0
  80. package/dist/chunk-E2BMSZ2W.cjs +151 -0
  81. package/dist/chunk-E3UK5IIB.cjs +593 -0
  82. package/dist/chunk-EM6SBQKM.cjs +470 -0
  83. package/dist/{chunk-27JNCYEK.mjs → chunk-EN7WTEAY.mjs} +2 -2
  84. package/dist/{chunk-IGO2HEV7.mjs → chunk-F6SJAKFJ.mjs} +62 -28
  85. package/dist/{chunk-GSDIZACQ.mjs → chunk-FG5H2VCJ.mjs} +2 -2
  86. package/dist/chunk-FJSWYIR7.cjs +482 -0
  87. package/dist/chunk-FK6GO24V.cjs +54 -0
  88. package/dist/chunk-FXUUWYAX.cjs +654 -0
  89. package/dist/chunk-G3HRIVEY.cjs +395 -0
  90. package/dist/chunk-G643DQCH.cjs +13 -0
  91. package/dist/chunk-G7HXGLEC.cjs +175 -0
  92. package/dist/chunk-GDSHDTJ4.cjs +152 -0
  93. package/dist/chunk-GNEO2XOF.cjs +2040 -0
  94. package/dist/{chunk-NHHKW2T6.mjs → chunk-GYKJCFTS.mjs} +170 -52
  95. package/dist/chunk-H6G5INWM.cjs +1094 -0
  96. package/dist/chunk-HBTUGXHS.cjs +180 -0
  97. package/dist/chunk-HREOKQWT.cjs +45 -0
  98. package/dist/chunk-I4J452B7.cjs +435 -0
  99. package/dist/chunk-I57LW5VZ.cjs +94 -0
  100. package/dist/chunk-I7PUUDGY.cjs +389 -0
  101. package/dist/chunk-IAMRBF3Z.cjs +86 -0
  102. package/dist/chunk-IKNRN4VS.cjs +14214 -0
  103. package/dist/chunk-IQXFRNY2.cjs +169 -0
  104. package/dist/chunk-IXTFU4PL.cjs +2355 -0
  105. package/dist/chunk-J2OP5GG3.cjs +725 -0
  106. package/dist/chunk-J3LOGE4T.cjs +42 -0
  107. package/dist/chunk-J7FSKED3.cjs +93 -0
  108. package/dist/chunk-JDNHKPTD.cjs +22 -0
  109. package/dist/chunk-JSROZYYO.cjs +164 -0
  110. package/dist/chunk-K6FNHVDR.cjs +696 -0
  111. package/dist/chunk-KGZIORNL.cjs +43 -0
  112. package/dist/{chunk-LZK5CXDW.mjs → chunk-KLSSO6YD.mjs} +2 -2
  113. package/dist/{chunk-TYVVIQ5M.mjs → chunk-KPNVGRBL.mjs} +32 -25
  114. package/dist/chunk-KR6CKSXT.cjs +15 -0
  115. package/dist/chunk-KROWKCUH.cjs +185 -0
  116. package/dist/chunk-KVFPGF2M.cjs +46 -0
  117. package/dist/{chunk-KUO3GBPK.mjs → chunk-L6V3P73N.mjs} +1 -1
  118. package/dist/chunk-LCCBO7PJ.cjs +46 -0
  119. package/dist/chunk-LIUGYUX3.cjs +22 -0
  120. package/dist/chunk-LTNGXMQ6.cjs +55 -0
  121. package/dist/chunk-M2L4MYDQ.cjs +14 -0
  122. package/dist/chunk-MCJLA63J.cjs +1 -0
  123. package/dist/chunk-MKB2EGIR.cjs +148 -0
  124. package/dist/chunk-MQ3H6LT5.cjs +202 -0
  125. package/dist/chunk-MT763TDW.cjs +43 -0
  126. package/dist/chunk-MWSK6C4J.cjs +18 -0
  127. package/dist/chunk-MWWVKDW3.cjs +169 -0
  128. package/dist/{chunk-KTGFMHET.mjs → chunk-N6UROPT7.mjs} +1 -1
  129. package/dist/chunk-NO3WWW3N.cjs +192 -0
  130. package/dist/{chunk-NDD2YVGU.mjs → chunk-NRVGEI5I.mjs} +10 -3
  131. package/dist/chunk-NV3A5DXM.cjs +862 -0
  132. package/dist/chunk-NWOD6NIT.cjs +9 -0
  133. package/dist/chunk-NZKJGRB3.cjs +230 -0
  134. package/dist/chunk-OAVTUMJP.cjs +1496 -0
  135. package/dist/chunk-OHY2ZWUG.cjs +25 -0
  136. package/dist/chunk-OI6CMLWX.cjs +47 -0
  137. package/dist/chunk-OIEOCXKG.cjs +453 -0
  138. package/dist/chunk-OWOUTKIJ.cjs +558 -0
  139. package/dist/chunk-OX6O6WVA.cjs +74 -0
  140. package/dist/chunk-OXSIH4D6.cjs +476 -0
  141. package/dist/chunk-OYEUREB6.cjs +35 -0
  142. package/dist/chunk-PCOTGFSM.cjs +139 -0
  143. package/dist/chunk-PZYCPSCC.cjs +35 -0
  144. package/dist/chunk-QBK2AA4U.cjs +445 -0
  145. package/dist/chunk-QBPXNZGV.cjs +487 -0
  146. package/dist/{chunk-IXTEENRS.mjs → chunk-QGVJVSNX.mjs} +5 -5
  147. package/dist/chunk-QNPEUFHQ.cjs +27 -0
  148. package/dist/chunk-QZRVZSPN.cjs +236 -0
  149. package/dist/chunk-R5A5KNVX.cjs +20 -0
  150. package/dist/chunk-R5JIFR6B.cjs +42 -0
  151. package/dist/chunk-R6AIILII.cjs +193 -0
  152. package/dist/chunk-RG3ZOTG5.cjs +34 -0
  153. package/dist/chunk-ROUTX2E5.cjs +390 -0
  154. package/dist/chunk-RTHIVJ2G.cjs +54 -0
  155. package/dist/chunk-S3A45T7F.cjs +166 -0
  156. package/dist/chunk-S3JO3N4H.cjs +17 -0
  157. package/dist/chunk-SK35NQKK.cjs +27 -0
  158. package/dist/chunk-SU7MH53P.cjs +180 -0
  159. package/dist/chunk-SVRTJOUF.cjs +113 -0
  160. package/dist/chunk-SWN467MP.cjs +18 -0
  161. package/dist/{chunk-6SCB2MXB.mjs → chunk-SXHV42UQ.mjs} +16 -1
  162. package/dist/{chunk-OWTIOHON.mjs → chunk-SYGGPS4A.mjs} +2 -2
  163. package/dist/chunk-SYQ3MOWW.cjs +73 -0
  164. package/dist/chunk-T5CERMEH.cjs +417 -0
  165. package/dist/chunk-TFAXUHWX.cjs +206 -0
  166. package/dist/chunk-TIWHTW3Q.cjs +24 -0
  167. package/dist/chunk-TKJZFIML.cjs +20 -0
  168. package/dist/chunk-TKNSDBBN.cjs +193 -0
  169. package/dist/{chunk-NC333MFA.mjs → chunk-TSWW5BVH.mjs} +7 -4
  170. package/dist/chunk-TWGMSEHX.cjs +525 -0
  171. package/dist/chunk-TYQUSXUG.cjs +1357 -0
  172. package/dist/chunk-U4KT7QP3.cjs +23 -0
  173. package/dist/{chunk-LK6FGAQR.mjs → chunk-UDBJCUPA.mjs} +7 -4
  174. package/dist/chunk-UJ2C4ICS.cjs +277 -0
  175. package/dist/chunk-UN5GHC5V.cjs +10244 -0
  176. package/dist/chunk-UQZ4AYTH.cjs +168 -0
  177. package/dist/chunk-US2QVW3E.cjs +36 -0
  178. package/dist/{chunk-NUD6XBMO.mjs → chunk-UTBVHYS3.mjs} +2 -2
  179. package/dist/{chunk-76MNRHTS.mjs → chunk-UUYF3CHN.mjs} +2 -2
  180. package/dist/chunk-VB6UCX3V.cjs +421 -0
  181. package/dist/chunk-VEKFLAQM.cjs +300 -0
  182. package/dist/chunk-VQDBNVOO.cjs +14 -0
  183. package/dist/chunk-W4E7WMXE.cjs +71 -0
  184. package/dist/{chunk-VVTREAG5.mjs → chunk-WD4YXVLV.mjs} +11 -3
  185. package/dist/{chunk-UQZPTIML.mjs → chunk-WD5PNSOB.mjs} +2 -2
  186. package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
  187. package/dist/chunk-WMAPPDMM.cjs +28 -0
  188. package/dist/chunk-WMOGFOUJ.cjs +223 -0
  189. package/dist/chunk-WPYFSQKK.cjs +37 -0
  190. package/dist/chunk-WZMNW2IW.cjs +1415 -0
  191. package/dist/chunk-XGC343EY.cjs +443 -0
  192. package/dist/{chunk-DPZUDPVJ.mjs → chunk-XP777LRD.mjs} +1 -1
  193. package/dist/chunk-XSKZORAS.cjs +727 -0
  194. package/dist/chunk-XWAWFQFS.cjs +82 -0
  195. package/dist/{chunk-KATQ6I56.mjs → chunk-XWAYMDLB.mjs} +1 -1
  196. package/dist/chunk-Y4YMF2NQ.cjs +460 -0
  197. package/dist/chunk-Y4YWHNKU.cjs +250 -0
  198. package/dist/chunk-Y53ZSFN6.cjs +504 -0
  199. package/dist/chunk-YA6LLTIJ.cjs +411 -0
  200. package/dist/chunk-YFPGHF5F.cjs +202 -0
  201. package/dist/chunk-YJRZR7VU.cjs +28 -0
  202. package/dist/chunk-YTAABQEV.cjs +1 -0
  203. package/dist/chunk-YX3DBN4M.cjs +18 -0
  204. package/dist/chunk-YZTASLPQ.cjs +64 -0
  205. package/dist/chunk-Z5HIWVDP.cjs +2173 -0
  206. package/dist/{chunk-Q3MDL7TM.mjs → chunk-ZCNJKLA2.mjs} +30 -11
  207. package/dist/chunk-ZEG3OPIB.cjs +93 -0
  208. package/dist/chunk-ZMN3H73H.cjs +155 -0
  209. package/dist/client/lifecycle.cjs +6 -35
  210. package/dist/{client-plugins-CqVtZi5X.d.ts → client-plugins-C089bQhN.d.ts} +2 -2
  211. package/dist/{client-plugins-CIPRtSsW.d.mts → client-plugins-JXXmZliS.d.mts} +2 -2
  212. package/dist/client-plugins.cjs +7 -448
  213. package/dist/client-plugins.d.mts +3 -3
  214. package/dist/client-plugins.d.ts +3 -3
  215. package/dist/client.cjs +171 -9774
  216. package/dist/client.d.mts +8 -8
  217. package/dist/client.d.ts +8 -8
  218. package/dist/client.mjs +6 -6
  219. package/dist/config.cjs +8 -36
  220. package/dist/config.d.mts +3 -3
  221. package/dist/config.d.ts +3 -3
  222. package/dist/cron.cjs +24 -491
  223. package/dist/cron.mjs +2 -2
  224. package/dist/deferred.cjs +26 -475
  225. package/dist/deployment.cjs +39 -210
  226. package/dist/devtools-OUIPHVV6.cjs +388 -0
  227. package/dist/{devtools-IU7LKZOH.mjs → devtools-UFVTMQX5.mjs} +7 -7
  228. package/dist/devtools-client-4WAPJY5L.cjs +254 -0
  229. package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
  230. package/dist/docs.cjs +46 -5649
  231. package/dist/docs.mjs +9 -9
  232. package/dist/{endpoint-kSAxE52R.d.ts → endpoint-1zA994xL.d.ts} +1 -1
  233. package/dist/{endpoint-Bu3XgeMK.d.mts → endpoint-DAc96i93.d.mts} +1 -1
  234. package/dist/env-types.cjs +5 -226
  235. package/dist/env.cjs +23 -306
  236. package/dist/env.d.mts +5 -3
  237. package/dist/env.d.ts +5 -3
  238. package/dist/env.mjs +2 -1
  239. package/dist/environment/vite.cjs +8 -372
  240. package/dist/environment.cjs +12 -94
  241. package/dist/font.cjs +13 -63
  242. package/dist/headers.cjs +7 -123
  243. package/dist/i18n/client.cjs +55 -294
  244. package/dist/i18n/index.cjs +22 -209
  245. package/dist/i18n/server.cjs +22 -745
  246. package/dist/image/server.cjs +13 -729
  247. package/dist/image/sharp.cjs +33 -171
  248. package/dist/image.cjs +41 -85
  249. package/dist/index.cjs +1151 -67862
  250. package/dist/index.d.mts +14 -14
  251. package/dist/index.d.ts +14 -14
  252. package/dist/index.mjs +34 -34
  253. package/dist/instrumentation.cjs +12 -138
  254. package/dist/integration-orm-55F7CII5.cjs +13 -0
  255. package/dist/integrations.cjs +55 -4090
  256. package/dist/integrations.d.mts +3 -3
  257. package/dist/integrations.d.ts +3 -3
  258. package/dist/internal/app-markdown-runtime.cjs +27 -224
  259. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  260. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  261. package/dist/internal/app-markdown-runtime.mjs +2 -2
  262. package/dist/internal/build-runtime.cjs +120 -52038
  263. package/dist/internal/build-runtime.d.mts +5 -5
  264. package/dist/internal/build-runtime.d.ts +5 -5
  265. package/dist/internal/build-runtime.mjs +23 -23
  266. package/dist/internal/cli-runtime.cjs +67 -13765
  267. package/dist/internal/cli-runtime.mjs +13 -13
  268. package/dist/internal/client-error-overlay.cjs +80 -733
  269. package/dist/internal/client-error-overlay.mjs +1 -1
  270. package/dist/internal/client-runtime.cjs +81 -913
  271. package/dist/internal/compression-runtime.cjs +8 -214
  272. package/dist/internal/compression-runtime.d.mts +3 -3
  273. package/dist/internal/compression-runtime.d.ts +3 -3
  274. package/dist/internal/config-runtime.cjs +42 -6535
  275. package/dist/internal/config-runtime.d.mts +4 -4
  276. package/dist/internal/config-runtime.d.ts +4 -4
  277. package/dist/internal/config-runtime.mjs +7 -7
  278. package/dist/internal/docs-precompiled-runtime.cjs +26 -46
  279. package/dist/internal/infra-analytics-runtime.cjs +10 -536
  280. package/dist/internal/isolated-boundary.cjs +14 -414
  281. package/dist/internal/metadata-image-runtime.cjs +7 -285
  282. package/dist/internal/product-telemetry-runtime.cjs +42 -97
  283. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  284. package/dist/internal/production-node-env.cjs +6 -63
  285. package/dist/internal/production-runtime.cjs +418 -7073
  286. package/dist/internal/production-runtime.d.mts +9 -9
  287. package/dist/internal/production-runtime.d.ts +9 -9
  288. package/dist/internal/production-runtime.mjs +6 -6
  289. package/dist/internal/request-cookies.cjs +6 -54
  290. package/dist/json-ld.cjs +24 -50
  291. package/dist/layers-E4WPJNY5.cjs +17 -0
  292. package/dist/manager-G4B2IPYE.cjs +14 -0
  293. package/dist/markdown.cjs +21 -532
  294. package/dist/markdown.mjs +1 -1
  295. package/dist/{metadata-8g__AMPM.d.ts → metadata-BcNJP4fq.d.ts} +1 -1
  296. package/dist/{metadata-OMX6wFNf.d.mts → metadata-C1Z9vLbb.d.mts} +1 -1
  297. package/dist/middleware.cjs +36 -2988
  298. package/dist/middleware.d.mts +5 -5
  299. package/dist/middleware.d.ts +5 -5
  300. package/dist/middleware.mjs +4 -4
  301. package/dist/navigation.cjs +22 -2588
  302. package/dist/nitro-4I2MYLY2.cjs +652 -0
  303. package/dist/{nitro-3N4ZXRYM.mjs → nitro-CVZ36JM5.mjs} +4 -4
  304. package/dist/observability.cjs +22 -614
  305. package/dist/og.cjs +5 -28
  306. package/dist/plugin.cjs +106 -37291
  307. package/dist/plugin.d.mts +3 -3
  308. package/dist/plugin.d.ts +3 -3
  309. package/dist/plugin.mjs +19 -19
  310. package/dist/{production-runtime-W3M0eNDV.d.mts → production-runtime-jcrTlRTb.d.mts} +1 -1
  311. package/dist/{production-runtime-BJh7o6Cr.d.ts → production-runtime-oKmC0WU-.d.ts} +1 -1
  312. package/dist/query/client.cjs +113 -449
  313. package/dist/query/index.cjs +26 -288
  314. package/dist/query/parsers.cjs +23 -247
  315. package/dist/query/server.cjs +36 -298
  316. package/dist/{render-plan-io7pvDNc.d.mts → render-plan-BLIfc4jt.d.mts} +1 -1
  317. package/dist/{render-plan-Be4ZGTJP.d.ts → render-plan-DOB9cV-h.d.ts} +1 -1
  318. package/dist/renderer/react/client.cjs +9 -43
  319. package/dist/renderer/react/server.cjs +40 -103
  320. package/dist/renderer/react/vite.cjs +7 -29
  321. package/dist/renderer-client.cjs +126 -4261
  322. package/dist/renderer-client.d.mts +5 -5
  323. package/dist/renderer-client.d.ts +5 -5
  324. package/dist/renderer-client.mjs +3 -3
  325. package/dist/renderer.cjs +31 -249
  326. package/dist/{request-DZkHYQ89.d.mts → request-Cr53NRHr.d.mts} +1 -1
  327. package/dist/{request-G8JhKr4F.d.ts → request-Dt2gNuQD.d.ts} +1 -1
  328. package/dist/request.cjs +5 -68
  329. package/dist/request.d.mts +4 -4
  330. package/dist/request.d.ts +4 -4
  331. package/dist/{route-C_eLaFTZ.d.mts → route-B0XrsrFk.d.mts} +1 -1
  332. package/dist/{route-BxNJT447.d.ts → route-DOEpbyWZ.d.ts} +1 -1
  333. package/dist/{route-rendering-BcLLPJgN.d.ts → route-rendering-CWYd8Mv1.d.ts} +1 -1
  334. package/dist/{route-rendering-CbAKr1TY.d.mts → route-rendering-CeFBEAoZ.d.mts} +1 -1
  335. package/dist/router.cjs +11 -474
  336. package/dist/routes.cjs +42 -2424
  337. package/dist/routes.d.mts +4 -4
  338. package/dist/routes.d.ts +4 -4
  339. package/dist/routes.mjs +2 -2
  340. package/dist/schema-dev-notice-MXSZMVDG.cjs +56 -0
  341. package/dist/schema.cjs +6 -33
  342. package/dist/search-client-G3RICOFU.cjs +13 -0
  343. package/dist/server-action-security.cjs +25 -541
  344. package/dist/server-fn-client.cjs +6 -337
  345. package/dist/server-fn-client.d.mts +3 -3
  346. package/dist/server-fn-client.d.ts +3 -3
  347. package/dist/server-fn.cjs +32 -1799
  348. package/dist/server-fn.d.mts +1 -1
  349. package/dist/server-fn.d.ts +1 -1
  350. package/dist/server-fn.mjs +2 -2
  351. package/dist/server-plugins.cjs +15 -884
  352. package/dist/server-plugins.d.mts +4 -4
  353. package/dist/server-plugins.d.ts +4 -4
  354. package/dist/server-query-client.cjs +15 -1849
  355. package/dist/server-query-client.d.mts +1 -1
  356. package/dist/server-query-client.d.ts +1 -1
  357. package/dist/server-query-client.mjs +4 -4
  358. package/dist/server-query.cjs +16 -1796
  359. package/dist/server-query.d.mts +1 -1
  360. package/dist/server-query.d.ts +1 -1
  361. package/dist/server-query.mjs +3 -3
  362. package/dist/server.cjs +296 -44522
  363. package/dist/server.d.mts +9 -9
  364. package/dist/server.d.ts +9 -9
  365. package/dist/server.mjs +22 -22
  366. package/dist/{spa-router-BcS_4nqm.d.mts → spa-router-CQWiYGxS.d.mts} +2 -2
  367. package/dist/{spa-router-BzFBUJkn.d.ts → spa-router-Wjiw-8hB.d.ts} +2 -2
  368. package/dist/storage.cjs +57 -576
  369. package/dist/testing.cjs +92 -3148
  370. package/dist/testing.d.mts +3 -3
  371. package/dist/testing.d.ts +3 -3
  372. package/dist/testing.mjs +11 -7
  373. package/dist/theme/client.cjs +13 -108
  374. package/dist/theme/index.cjs +6 -68
  375. package/dist/theme/runtime.cjs +13 -78
  376. package/dist/theme/server.cjs +10 -179
  377. package/dist/{utils-C4yrAhNc.d.ts → utils-B0XJmG_b.d.ts} +1 -1
  378. package/dist/{utils-5kQP1mFR.d.mts → utils-uUxF0K0P.d.mts} +1 -1
  379. package/dist/version.cjs +4 -32
  380. package/dist/version.mjs +1 -1
  381. package/dist/vite.cjs +119 -37622
  382. package/dist/vite.d.mts +3 -3
  383. package/dist/vite.d.ts +3 -3
  384. package/dist/vite.mjs +19 -19
  385. package/dist/workflows.cjs +19 -1040
  386. package/dist/workflows.mjs +2 -2
  387. package/package.json +2 -2
  388. package/dist/{chunk-VO5SCWF5.mjs → chunk-BNGS6KJ6.mjs} +0 -0
  389. package/dist/{chunk-MUUZJLCI.mjs → chunk-EGJDUF4Q.mjs} +3 -3
  390. package/dist/{chunk-4L7SZOHZ.mjs → chunk-YHOCRI4H.mjs} +3 -3
@@ -1,733 +1,17 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
20
2
 
21
- // src/image-server.ts
22
- var image_server_exports = {};
23
- __export(image_server_exports, {
24
- FarmImageRequestError: () => FarmImageRequestError,
25
- createCloudflareImageTransformer: () => createCloudflareImageTransformer,
26
- createFarmImageHandler: () => createFarmImageHandler,
27
- isPrivateImageAddress: () => isPrivateImageAddress,
28
- selectOutputFormat: () => selectOutputFormat
29
- });
30
- module.exports = __toCommonJS(image_server_exports);
31
3
 
32
- // src/server-http.ts
33
- function matchesFarmIfNoneMatch(value, etag) {
34
- const expected = parseEntityTag(trimOptionalWhitespace(etag));
35
- if (!expected) return false;
36
- const values = Array.isArray(value) ? value : [value];
37
- const combined = values.filter((header) => typeof header === "string").join(",");
38
- const fieldValue = trimOptionalWhitespace(combined);
39
- if (!fieldValue) return false;
40
- if (fieldValue === "*") return true;
41
- let matched = false;
42
- let hasEntityTag = false;
43
- for (const candidate of splitEntityTags(fieldValue)) {
44
- const token = trimOptionalWhitespace(candidate);
45
- if (!token) continue;
46
- const parsed = parseEntityTag(token);
47
- if (!parsed) return false;
48
- hasEntityTag = true;
49
- if (parsed === expected) matched = true;
50
- }
51
- return hasEntityTag && matched;
52
- }
53
- __name(matchesFarmIfNoneMatch, "matchesFarmIfNoneMatch");
54
- function trimOptionalWhitespace(value) {
55
- return value.replace(/^[\t ]+|[\t ]+$/g, "");
56
- }
57
- __name(trimOptionalWhitespace, "trimOptionalWhitespace");
58
- function parseEntityTag(value) {
59
- const opaqueTag = value.startsWith("W/") ? value.slice(2) : value;
60
- if (opaqueTag.length < 2 || opaqueTag[0] !== '"' || opaqueTag.at(-1) !== '"') return null;
61
- for (let index = 1; index < opaqueTag.length - 1; index++) {
62
- const code = opaqueTag.charCodeAt(index);
63
- if (code === 33 || code >= 35 && code <= 126 || code >= 128) continue;
64
- return null;
65
- }
66
- return opaqueTag;
67
- }
68
- __name(parseEntityTag, "parseEntityTag");
69
- function splitEntityTags(value) {
70
- const tags = [];
71
- let start = 0;
72
- let quoted = false;
73
- for (let index = 0; index < value.length; index++) {
74
- const character = value[index];
75
- if (character === '"') {
76
- quoted = !quoted;
77
- } else if (character === "," && !quoted) {
78
- tags.push(value.slice(start, index));
79
- start = index + 1;
80
- }
81
- }
82
- tags.push(value.slice(start));
83
- return tags;
84
- }
85
- __name(splitEntityTags, "splitEntityTags");
86
4
 
87
- // src/image-pattern.ts
88
- var compiledPatterns = /* @__PURE__ */ new WeakMap();
89
- function matchesImagePathPattern(value, pattern) {
90
- const pathname = pattern.pathname ?? "/**";
91
- let compiled = compiledPatterns.get(pattern);
92
- if (!compiled || compiled.pathname !== pathname) {
93
- const escaped = pathname.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
94
- const source = escaped.replace(/\*\*/g, "\0").replace(/\*/g, "[^/]*").replace(/\0/g, ".*");
95
- compiled = { pathname, matcher: new RegExp(`^${source}$`) };
96
- compiledPatterns.set(pattern, compiled);
97
- }
98
- return compiled.matcher.test(value);
99
- }
100
- __name(matchesImagePathPattern, "matchesImagePathPattern");
101
5
 
102
- // src/image-server.ts
103
- var _FarmImageRequestError = class _FarmImageRequestError extends Error {
104
- constructor(code, status, message) {
105
- super(message);
106
- this.name = "FarmImageRequestError";
107
- this.code = code;
108
- this.status = status;
109
- }
110
- };
111
- __name(_FarmImageRequestError, "FarmImageRequestError");
112
- var FarmImageRequestError = _FarmImageRequestError;
113
- function createFarmImageHandler(config, options) {
114
- const fetcher = options.fetch ?? globalThis.fetch;
115
- const cache = new FarmImageMemoryCache(options.cacheEntries ?? 100);
116
- const inflight = /* @__PURE__ */ new Map();
117
- const allowedWidths = /* @__PURE__ */ new Set([...config.deviceSizes, ...config.imageSizes]);
118
- const allowedQualities = new Set(config.qualities);
119
- return /* @__PURE__ */ __name(async function handleFarmImage(request, context) {
120
- const requestUrl = new URL(request.url);
121
- if (requestUrl.pathname !== config.path) return null;
122
- try {
123
- const trustedLocalOrigin = resolveTrustedLocalOrigin(
124
- context?.trustedLocalOrigin ?? options.trustedLocalOrigin
125
- );
126
- if (config.provider === "none") {
127
- throw new FarmImageRequestError(
128
- "DISALLOWED_SOURCE",
129
- 404,
130
- "The Farm image optimizer is disabled"
131
- );
132
- }
133
- if (request.method !== "GET" && request.method !== "HEAD") {
134
- throw new FarmImageRequestError(
135
- "INVALID_METHOD",
136
- 405,
137
- "The Farm image optimizer only accepts GET and HEAD"
138
- );
139
- }
140
- const sourceUrl = await resolveImageSourceUrl(
141
- requestUrl,
142
- trustedLocalOrigin,
143
- config,
144
- options.validateRemoteUrl
145
- );
146
- const width = parseAllowedInteger(requestUrl.searchParams.get("w"), allowedWidths, "width");
147
- const quality = parseAllowedInteger(
148
- requestUrl.searchParams.get("q"),
149
- allowedQualities,
150
- "quality"
151
- );
152
- const accept = request.headers.get("accept") ?? "";
153
- const negotiatedFormat = selectOutputFormat(accept, config.formats) ?? "";
154
- const cacheKey = `${sourceUrl.href}
155
- ${width}
156
- ${quality}
157
- ${negotiatedFormat}`;
158
- let optimized = cache.get(cacheKey);
159
- if (!optimized) {
160
- optimized = await runCoalesced(inflight, cacheKey, request.signal, async (signal) => {
161
- const fetchedSource = await fetchImageSource(
162
- sourceUrl,
163
- requestUrl.origin,
164
- trustedLocalOrigin,
165
- config,
166
- fetcher,
167
- options.fetchRemote,
168
- options.validateRemoteUrl,
169
- signal
170
- );
171
- const source = await readResponseWithLimit(
172
- fetchedSource.response,
173
- config.maximumResponseBody
174
- );
175
- const sourceType = detectImageContentType(source);
176
- validateSourceType(sourceType, config);
177
- throwIfAborted(signal);
178
- const result = await options.transform({
179
- source,
180
- sourceUrl: fetchedSource.url,
181
- sourceType,
182
- width,
183
- quality,
184
- accept,
185
- formats: config.formats,
186
- signal,
187
- maximumResponseBody: config.maximumResponseBody
188
- });
189
- throwIfAborted(signal);
190
- validateTransformedResult(result, config);
191
- const entry = {
192
- ...result,
193
- etag: createImageEtag(result.body),
194
- cacheControl: `public, max-age=${config.minimumCacheTTL}, stale-while-revalidate=${Math.max(
195
- config.minimumCacheTTL,
196
- 60
197
- )}`,
198
- expiresAt: Date.now() + config.minimumCacheTTL * 1e3
199
- };
200
- cache.set(cacheKey, entry);
201
- return entry;
202
- });
203
- }
204
- return createOptimizedImageResponse(request, optimized, config);
205
- } catch (error) {
206
- if (!(error instanceof FarmImageRequestError) && !isAbortError(error)) {
207
- try {
208
- options.onError?.(error, request);
209
- } catch {
210
- }
211
- }
212
- return createFarmImageErrorResponse(error);
213
- }
214
- }, "handleFarmImage");
215
- }
216
- __name(createFarmImageHandler, "createFarmImageHandler");
217
- var DEFAULT_IMAGE_TRANSFORM_BODY_LIMIT = 10 * 1024 * 1024;
218
- function createCloudflareImageTransformer(fetcher = globalThis.fetch) {
219
- return async ({ sourceUrl, width, quality, accept, formats, signal, maximumResponseBody }) => {
220
- const format = selectOutputFormat(accept, formats);
221
- const response = await fetcher(sourceUrl, {
222
- signal,
223
- redirect: "manual",
224
- headers: { accept: "image/*" },
225
- cf: {
226
- image: {
227
- fit: "scale-down",
228
- width,
229
- quality,
230
- ...format ? { format: format === "image/avif" ? "avif" : "webp" } : {}
231
- }
232
- }
233
- });
234
- if (response.status >= 300 && response.status < 400) {
235
- void cancelResponseBody(response);
236
- throw new FarmImageRequestError(
237
- "UNSUPPORTED_IMAGE",
238
- 502,
239
- "Source image redirected after validation"
240
- );
241
- }
242
- if (!response.ok) {
243
- throw new FarmImageRequestError(
244
- "UNSUPPORTED_IMAGE",
245
- response.status === 404 ? 404 : 502,
246
- "Cloudflare could not transform the source image"
247
- );
248
- }
249
- const body = await readResponseWithLimit(
250
- response,
251
- maximumResponseBody ?? DEFAULT_IMAGE_TRANSFORM_BODY_LIMIT
252
- );
253
- return {
254
- body,
255
- contentType: normalizeImageContentType(response.headers.get("content-type")) || detectImageContentType(body)
256
- };
257
- };
258
- }
259
- __name(createCloudflareImageTransformer, "createCloudflareImageTransformer");
260
- function selectOutputFormat(accept, formats) {
261
- const qualityByFormat = /* @__PURE__ */ new Map();
262
- for (const range of accept.split(",")) {
263
- const [rawType, ...parameters] = range.split(";");
264
- const type = rawType.trim().toLowerCase();
265
- if (!type) continue;
266
- let quality = 1;
267
- for (const parameter of parameters) {
268
- const [rawName, rawValue] = parameter.split("=", 2);
269
- if (rawName.trim().toLowerCase() !== "q") continue;
270
- const parsed = Number(rawValue?.trim());
271
- quality = Number.isFinite(parsed) && parsed >= 0 && parsed <= 1 ? parsed : 0;
272
- break;
273
- }
274
- qualityByFormat.set(type, Math.max(qualityByFormat.get(type) ?? 0, quality));
275
- }
276
- let selected;
277
- let selectedQuality = 0;
278
- for (const format of formats) {
279
- const quality = qualityByFormat.get(format) ?? 0;
280
- if (quality > selectedQuality) {
281
- selected = format;
282
- selectedQuality = quality;
283
- }
284
- }
285
- return selected;
286
- }
287
- __name(selectOutputFormat, "selectOutputFormat");
288
- function parseIpv6Hextets(value) {
289
- let text = value.split("%", 1)[0] ?? "";
290
- if (!text.includes(":")) return null;
291
- let tail = [];
292
- const lastColon = text.lastIndexOf(":");
293
- const candidate = text.slice(lastColon + 1);
294
- if (candidate.includes(".")) {
295
- const octets = parseIpv4Octets(candidate);
296
- if (!octets) return null;
297
- tail = [octets[0] << 8 | octets[1], octets[2] << 8 | octets[3]];
298
- text = text.slice(0, lastColon);
299
- if (text === "") return null;
300
- }
301
- const compressionParts = text.split("::");
302
- if (compressionParts.length > 2) return null;
303
- const parseGroup = /* @__PURE__ */ __name((group) => {
304
- if (group === "") return [];
305
- const hextets = [];
306
- for (const part of group.split(":")) {
307
- if (!/^[0-9a-f]{1,4}$/.test(part)) return null;
308
- hextets.push(Number.parseInt(part, 16));
309
- }
310
- return hextets;
311
- }, "parseGroup");
312
- const head = parseGroup(compressionParts[0] ?? "");
313
- const rest = parseGroup(compressionParts[1] ?? "");
314
- if (!head || !rest) return null;
315
- const explicit = [...head, ...rest, ...tail];
316
- if (compressionParts.length === 1) {
317
- return explicit.length === 8 ? explicit : null;
318
- }
319
- if (explicit.length >= 8) return null;
320
- const zeros = Array.from({ length: 8 - explicit.length }, () => 0);
321
- return [...head, ...zeros, ...rest, ...tail];
322
- }
323
- __name(parseIpv6Hextets, "parseIpv6Hextets");
324
- function parseIpv4Octets(value) {
325
- const parts = value.split(".");
326
- if (parts.length !== 4 || parts.some((part) => !/^\d{1,3}$/.test(part))) return null;
327
- const octets = parts.map(Number);
328
- return octets.some((part) => part > 255) ? null : octets;
329
- }
330
- __name(parseIpv4Octets, "parseIpv4Octets");
331
- function isPrivateIpv4(octets) {
332
- const [a, b] = octets;
333
- return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && (b === 0 || b === 168) || a === 198 && (b === 18 || b === 19) || a >= 224;
334
- }
335
- __name(isPrivateIpv4, "isPrivateIpv4");
336
- function isPrivateImageAddress(address) {
337
- const value = address.trim().toLowerCase().replace(/^\[|\]$/g, "");
338
- const hextets = parseIpv6Hextets(value);
339
- if (hextets) {
340
- const [h0, h1, h2, h3, h4, h5, h6, h7] = hextets;
341
- const zeroPrefix = h0 === 0 && h1 === 0 && h2 === 0 && h3 === 0;
342
- const embedsIpv4 = zeroPrefix && (h4 === 0 && h5 === 65535 || h4 === 65535 && h5 === 0 || h4 === 0 && h5 === 0);
343
- if (embedsIpv4 && (h6 !== 0 || h7 !== 0)) {
344
- return isPrivateIpv4([h6 >> 8, h6 & 255, h7 >> 8, h7 & 255]);
345
- }
346
- if (zeroPrefix && h4 === 0 && h5 === 0 && h6 === 0 && (h7 === 0 || h7 === 1)) return true;
347
- if ((h0 & 65024) === 64512) return true;
348
- if ((h0 & 65472) === 65152) return true;
349
- if ((h0 & 65280) === 65280) return true;
350
- return false;
351
- }
352
- const octets = parseIpv4Octets(value);
353
- return octets ? isPrivateIpv4(octets) : false;
354
- }
355
- __name(isPrivateImageAddress, "isPrivateImageAddress");
356
- function parseAllowedInteger(raw, allowed, name) {
357
- if (!raw || !/^\d+$/.test(raw)) {
358
- throw new FarmImageRequestError(
359
- "INVALID_PARAMETER",
360
- 400,
361
- `Image ${name} must be an allowed integer`
362
- );
363
- }
364
- const value = Number(raw);
365
- if (!allowed.has(value)) {
366
- throw new FarmImageRequestError("INVALID_PARAMETER", 400, `Image ${name} is not configured`);
367
- }
368
- return value;
369
- }
370
- __name(parseAllowedInteger, "parseAllowedInteger");
371
- async function resolveImageSourceUrl(requestUrl, trustedLocalOrigin, config, validateRemoteUrl) {
372
- const raw = requestUrl.searchParams.get("url");
373
- if (!raw || raw.length > 4096 || raw.startsWith("//")) {
374
- throw new FarmImageRequestError("INVALID_PARAMETER", 400, "Invalid image source URL");
375
- }
376
- let sourceUrl;
377
- try {
378
- sourceUrl = raw.startsWith("/") ? new URL(raw, trustedLocalOrigin ?? requestUrl.origin) : new URL(raw);
379
- } catch {
380
- throw new FarmImageRequestError("INVALID_PARAMETER", 400, "Invalid image source URL");
381
- }
382
- await validateImageSourceUrl(
383
- sourceUrl,
384
- requestUrl.origin,
385
- trustedLocalOrigin,
386
- config,
387
- validateRemoteUrl
388
- );
389
- return sourceUrl;
390
- }
391
- __name(resolveImageSourceUrl, "resolveImageSourceUrl");
392
- async function validateImageSourceUrl(sourceUrl, requestOrigin, trustedLocalOrigin, config, validateRemoteUrl) {
393
- if (sourceUrl.protocol !== "http:" && sourceUrl.protocol !== "https:") {
394
- throw new FarmImageRequestError("DISALLOWED_SOURCE", 400, "Unsupported image protocol");
395
- }
396
- if (sourceUrl.username || sourceUrl.password || sourceUrl.hash) {
397
- throw new FarmImageRequestError("DISALLOWED_SOURCE", 400, "Unsafe image source URL");
398
- }
399
- const isLocalSource = sourceUrl.origin === requestOrigin || sourceUrl.origin === trustedLocalOrigin;
400
- if (isLocalSource) {
401
- if (sourceUrl.pathname === config.path || !matchesLocalPatterns(sourceUrl, config.localPatterns)) {
402
- throw new FarmImageRequestError(
403
- "DISALLOWED_SOURCE",
404
- 400,
405
- "Local image source is not allowed"
406
- );
407
- }
408
- if (sourceUrl.origin === trustedLocalOrigin) return;
409
- } else if (!matchesRemoteSource(sourceUrl, config)) {
410
- throw new FarmImageRequestError("DISALLOWED_SOURCE", 400, "Remote image source is not allowed");
411
- }
412
- if (!config.dangerouslyAllowLocalIP && isPrivateImageAddress(sourceUrl.hostname)) {
413
- throw new FarmImageRequestError("PRIVATE_SOURCE", 400, "Private image source is not allowed");
414
- }
415
- if (!config.dangerouslyAllowLocalIP) {
416
- await validateRemoteUrl?.(sourceUrl);
417
- }
418
- }
419
- __name(validateImageSourceUrl, "validateImageSourceUrl");
420
- async function fetchImageSource(initialUrl, requestOrigin, trustedLocalOrigin, config, fetcher, fetchRemote, validateRemoteUrl, signal) {
421
- let currentUrl = initialUrl;
422
- for (let redirectCount = 0; ; redirectCount += 1) {
423
- throwIfAborted(signal);
424
- const sourceFetcher = currentUrl.origin === trustedLocalOrigin ? fetcher : fetchRemote ?? fetcher;
425
- const response = await sourceFetcher(currentUrl, {
426
- method: "GET",
427
- redirect: "manual",
428
- signal,
429
- headers: {
430
- accept: "image/avif,image/webp,image/*,*/*;q=0.8",
431
- "user-agent": "Farm.js Image Optimizer"
432
- }
433
- });
434
- if (![301, 302, 303, 307, 308].includes(response.status)) {
435
- if (!response.ok) {
436
- await cancelResponseBody(response);
437
- throw new FarmImageRequestError(
438
- "UNSUPPORTED_IMAGE",
439
- response.status === 404 ? 404 : 502,
440
- "Could not fetch source image"
441
- );
442
- }
443
- return { response, url: currentUrl };
444
- }
445
- if (redirectCount >= config.maximumRedirects) {
446
- await cancelResponseBody(response);
447
- throw new FarmImageRequestError(
448
- "TOO_MANY_REDIRECTS",
449
- 400,
450
- "Source image exceeded the redirect limit"
451
- );
452
- }
453
- const location = response.headers.get("location");
454
- if (!location) {
455
- await cancelResponseBody(response);
456
- throw new FarmImageRequestError("UNSUPPORTED_IMAGE", 502, "Invalid image redirect");
457
- }
458
- await cancelResponseBody(response);
459
- currentUrl = new URL(location, currentUrl);
460
- await validateImageSourceUrl(
461
- currentUrl,
462
- requestOrigin,
463
- trustedLocalOrigin,
464
- config,
465
- validateRemoteUrl
466
- );
467
- }
468
- }
469
- __name(fetchImageSource, "fetchImageSource");
470
- function resolveTrustedLocalOrigin(configured) {
471
- const value = typeof configured === "function" ? configured() : configured;
472
- if (!value) return void 0;
473
- const url = new URL(value);
474
- if (url.protocol !== "http:" && url.protocol !== "https:") {
475
- throw new TypeError("trustedLocalOrigin must use http or https");
476
- }
477
- return url.origin;
478
- }
479
- __name(resolveTrustedLocalOrigin, "resolveTrustedLocalOrigin");
480
- async function runCoalesced(inflight, key, requestSignal, run) {
481
- let entry = inflight.get(key);
482
- if (!entry) {
483
- const controller = new AbortController();
484
- const created = {
485
- controller,
486
- waiters: 0,
487
- promise: void 0
488
- };
489
- created.promise = run(controller.signal).finally(() => {
490
- if (inflight.get(key) === created) inflight.delete(key);
491
- });
492
- created.promise.catch(() => {
493
- });
494
- inflight.set(key, created);
495
- entry = created;
496
- }
497
- const pending = entry;
498
- pending.waiters += 1;
499
- try {
500
- return await raceRequestAbort(pending.promise, requestSignal);
501
- } finally {
502
- pending.waiters -= 1;
503
- if (pending.waiters === 0 && inflight.get(key) === pending) {
504
- inflight.delete(key);
505
- pending.controller.abort();
506
- }
507
- }
508
- }
509
- __name(runCoalesced, "runCoalesced");
510
- function raceRequestAbort(promise, signal) {
511
- if (!signal) return promise;
512
- if (signal.aborted) return Promise.reject(signal.reason ?? new Error("Aborted"));
513
- return new Promise((resolve, reject) => {
514
- const onAbort = /* @__PURE__ */ __name(() => reject(signal.reason ?? new Error("Aborted")), "onAbort");
515
- signal.addEventListener("abort", onAbort, { once: true });
516
- promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
517
- });
518
- }
519
- __name(raceRequestAbort, "raceRequestAbort");
520
- async function readResponseWithLimit(response, limit) {
521
- const contentLength = response.headers.get("content-length");
522
- if (contentLength && Number(contentLength) > limit) {
523
- void cancelResponseBody(response);
524
- throw new FarmImageRequestError("BODY_TOO_LARGE", 413, "Source image is too large");
525
- }
526
- if (!response.body) return new Uint8Array();
527
- const reader = response.body.getReader();
528
- const chunks = [];
529
- let byteLength = 0;
530
- try {
531
- while (true) {
532
- const { done, value } = await reader.read();
533
- if (done) break;
534
- byteLength += value.byteLength;
535
- if (byteLength > limit) {
536
- const error = new FarmImageRequestError("BODY_TOO_LARGE", 413, "Source image is too large");
537
- void reader.cancel(error).catch(() => {
538
- });
539
- throw error;
540
- }
541
- chunks.push(value);
542
- }
543
- } finally {
544
- reader.releaseLock();
545
- }
546
- const result = new Uint8Array(byteLength);
547
- let offset = 0;
548
- for (const chunk of chunks) {
549
- result.set(chunk, offset);
550
- offset += chunk.byteLength;
551
- }
552
- return result;
553
- }
554
- __name(readResponseWithLimit, "readResponseWithLimit");
555
- async function cancelResponseBody(response) {
556
- try {
557
- await response.body?.cancel();
558
- } catch {
559
- }
560
- }
561
- __name(cancelResponseBody, "cancelResponseBody");
562
- function detectImageContentType(bytes) {
563
- if (bytes.length >= 8 && bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) {
564
- return "image/png";
565
- }
566
- if (bytes.length >= 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) {
567
- return "image/jpeg";
568
- }
569
- if (bytes.length >= 6) {
570
- const signature = new TextDecoder().decode(bytes.slice(0, 6));
571
- if (signature === "GIF87a" || signature === "GIF89a") return "image/gif";
572
- }
573
- if (bytes.length >= 12) {
574
- const riff = new TextDecoder().decode(bytes.slice(0, 4));
575
- const webp = new TextDecoder().decode(bytes.slice(8, 12));
576
- if (riff === "RIFF" && webp === "WEBP") return "image/webp";
577
- const box = new TextDecoder().decode(bytes.slice(4, 12));
578
- if (box.startsWith("ftypavif") || box.startsWith("ftypavis")) return "image/avif";
579
- }
580
- const prefix = new TextDecoder().decode(bytes.slice(0, 512)).trimStart().toLowerCase();
581
- if (prefix.startsWith("<svg") || prefix.startsWith("<?xml") && prefix.includes("<svg")) {
582
- return "image/svg+xml";
583
- }
584
- return "";
585
- }
586
- __name(detectImageContentType, "detectImageContentType");
587
- function validateSourceType(type, config) {
588
- if (!type || type === "image/svg+xml" && !config.dangerouslyAllowSVG) {
589
- throw new FarmImageRequestError("UNSUPPORTED_IMAGE", 415, "Unsupported source image");
590
- }
591
- }
592
- __name(validateSourceType, "validateSourceType");
593
- function validateTransformedResult(result, config) {
594
- if (!(result.body instanceof Uint8Array) || result.body.byteLength === 0) {
595
- throw new Error("The image transformer returned an empty response");
596
- }
597
- if (result.body.byteLength > config.maximumResponseBody) {
598
- throw new FarmImageRequestError("BODY_TOO_LARGE", 413, "Optimized image is too large");
599
- }
600
- const contentType = normalizeImageContentType(result.contentType);
601
- if (!contentType || contentType === "image/svg+xml" && !config.dangerouslyAllowSVG) {
602
- throw new Error("The image transformer returned an unsupported content type");
603
- }
604
- result.contentType = contentType;
605
- }
606
- __name(validateTransformedResult, "validateTransformedResult");
607
- function normalizeImageContentType(value) {
608
- const type = value?.split(";", 1)[0].trim().toLowerCase() ?? "";
609
- return type.startsWith("image/") ? type : "";
610
- }
611
- __name(normalizeImageContentType, "normalizeImageContentType");
612
- function matchesRemoteSource(url, config) {
613
- if (config.domains.includes(url.hostname.toLowerCase())) return true;
614
- return config.remotePatterns.some((pattern) => matchesRemotePattern(url, pattern));
615
- }
616
- __name(matchesRemoteSource, "matchesRemoteSource");
617
- function matchesRemotePattern(url, pattern) {
618
- return (!pattern.protocol || url.protocol === `${pattern.protocol}:`) && matchesHostname(url.hostname, pattern.hostname) && (pattern.port === void 0 || url.port === pattern.port) && matchesImagePathPattern(url.pathname, pattern) && (pattern.search === void 0 || url.search === pattern.search);
619
- }
620
- __name(matchesRemotePattern, "matchesRemotePattern");
621
- function matchesLocalPatterns(url, patterns) {
622
- return patterns.some(
623
- (pattern) => matchesImagePathPattern(url.pathname, pattern) && (pattern.search === void 0 || url.search === pattern.search)
624
- );
625
- }
626
- __name(matchesLocalPatterns, "matchesLocalPatterns");
627
- function matchesHostname(hostname, pattern) {
628
- const normalizedHostname = hostname.toLowerCase();
629
- const normalizedPattern = pattern.toLowerCase();
630
- if (normalizedPattern.startsWith("**.")) {
631
- const suffix = normalizedPattern.slice(3);
632
- return normalizedHostname === suffix || normalizedHostname.endsWith(`.${suffix}`);
633
- }
634
- if (normalizedPattern.startsWith("*.")) {
635
- const suffix = normalizedPattern.slice(2);
636
- const prefix = normalizedHostname.slice(0, -(suffix.length + 1));
637
- return normalizedHostname.endsWith(`.${suffix}`) && !!prefix && !prefix.includes(".");
638
- }
639
- return normalizedHostname === normalizedPattern;
640
- }
641
- __name(matchesHostname, "matchesHostname");
642
- function createOptimizedImageResponse(request, image, config) {
643
- const headers = new Headers({
644
- "cache-control": image.cacheControl,
645
- "content-type": image.contentType,
646
- "content-length": String(image.body.byteLength),
647
- "content-disposition": "inline",
648
- etag: image.etag,
649
- vary: "Accept",
650
- "x-content-type-options": "nosniff"
651
- });
652
- if (image.contentType === "image/svg+xml" && config.dangerouslyAllowSVG) {
653
- headers.set("content-security-policy", "default-src 'none'; sandbox");
654
- }
655
- if (matchesFarmIfNoneMatch(request.headers.get("if-none-match"), image.etag)) {
656
- headers.delete("content-length");
657
- return new Response(null, { status: 304, headers });
658
- }
659
- const body = request.method === "HEAD" ? null : image.body.buffer.slice(
660
- image.body.byteOffset,
661
- image.body.byteOffset + image.body.byteLength
662
- );
663
- return new Response(body, { status: 200, headers });
664
- }
665
- __name(createOptimizedImageResponse, "createOptimizedImageResponse");
666
- function createFarmImageErrorResponse(error) {
667
- const status = error instanceof FarmImageRequestError ? error.status : isAbortError(error) ? 499 : 500;
668
- const headers = new Headers({
669
- "cache-control": "no-store",
670
- "content-type": "text/plain; charset=utf-8",
671
- "x-content-type-options": "nosniff"
672
- });
673
- if (status === 405) headers.set("allow", "GET, HEAD");
674
- const message = status === 400 ? "Invalid image request" : status === 404 ? "Image not found" : status === 405 ? "Method not allowed" : status === 413 ? "Image is too large" : status === 415 ? "Unsupported image" : status === 499 ? "Image request cancelled" : "Image optimization failed";
675
- return new Response(message, { status, headers });
676
- }
677
- __name(createFarmImageErrorResponse, "createFarmImageErrorResponse");
678
- function createImageEtag(bytes) {
679
- let hash = 2166136261;
680
- for (const byte of bytes) {
681
- hash ^= byte;
682
- hash = Math.imul(hash, 16777619);
683
- }
684
- return `W/"farm-${bytes.byteLength.toString(16)}-${(hash >>> 0).toString(16)}"`;
685
- }
686
- __name(createImageEtag, "createImageEtag");
687
- function throwIfAborted(signal) {
688
- if (signal.aborted) {
689
- throw signal.reason instanceof Error ? signal.reason : new DOMException("The image request was aborted", "AbortError");
690
- }
691
- }
692
- __name(throwIfAborted, "throwIfAborted");
693
- function isAbortError(error) {
694
- return error instanceof Error && error.name === "AbortError";
695
- }
696
- __name(isAbortError, "isAbortError");
697
- var _FarmImageMemoryCache = class _FarmImageMemoryCache {
698
- constructor(capacity) {
699
- this.capacity = capacity;
700
- this.entries = /* @__PURE__ */ new Map();
701
- }
702
- get(key) {
703
- const value = this.entries.get(key);
704
- if (!value) return void 0;
705
- if (value.expiresAt <= Date.now()) {
706
- this.entries.delete(key);
707
- return void 0;
708
- }
709
- this.entries.delete(key);
710
- this.entries.set(key, value);
711
- return value;
712
- }
713
- set(key, value) {
714
- if (this.capacity <= 0) return;
715
- this.entries.delete(key);
716
- this.entries.set(key, value);
717
- while (this.entries.size > this.capacity) {
718
- const oldestKey = this.entries.keys().next().value;
719
- if (oldestKey === void 0) break;
720
- this.entries.delete(oldestKey);
721
- }
722
- }
723
- };
724
- __name(_FarmImageMemoryCache, "FarmImageMemoryCache");
725
- var FarmImageMemoryCache = _FarmImageMemoryCache;
726
- // Annotate the CommonJS export names for ESM import in node:
727
- 0 && (module.exports = {
728
- FarmImageRequestError,
729
- createCloudflareImageTransformer,
730
- createFarmImageHandler,
731
- isPrivateImageAddress,
732
- selectOutputFormat
733
- });
6
+
7
+ var _chunkFXUUWYAXcjs = require('../chunk-FXUUWYAX.cjs');
8
+ require('../chunk-EM6SBQKM.cjs');
9
+ require('../chunk-NO3WWW3N.cjs');
10
+ require('../chunk-S3JO3N4H.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+ exports.FarmImageRequestError = _chunkFXUUWYAXcjs.FarmImageRequestError; exports.createCloudflareImageTransformer = _chunkFXUUWYAXcjs.createCloudflareImageTransformer; exports.createFarmImageHandler = _chunkFXUUWYAXcjs.createFarmImageHandler; exports.isPrivateImageAddress = _chunkFXUUWYAXcjs.isPrivateImageAddress; exports.selectOutputFormat = _chunkFXUUWYAXcjs.selectOutputFormat;