@farm.js/core 0.1.17 → 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 (249) 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/cache.cjs +38 -1560
  9. package/dist/chunk-22GUSVNJ.cjs +351 -0
  10. package/dist/chunk-2CQ74SP6.cjs +13 -0
  11. package/dist/chunk-2SJ4RQ6P.cjs +57 -0
  12. package/dist/chunk-3376ZTRC.cjs +1 -0
  13. package/dist/{chunk-YD4J4XCI.mjs → chunk-3XG26Z3J.mjs} +1 -1
  14. package/dist/chunk-4PNUXIVU.cjs +472 -0
  15. package/dist/chunk-4PPEPOZZ.cjs +21 -0
  16. package/dist/chunk-4ZFL5GFN.cjs +520 -0
  17. package/dist/chunk-5OVTOKGH.cjs +65 -0
  18. package/dist/chunk-5QIKR7RR.cjs +224 -0
  19. package/dist/chunk-5ZSWG4UX.cjs +127 -0
  20. package/dist/chunk-62YJ2IEB.cjs +238 -0
  21. package/dist/chunk-6EODJYCX.cjs +183 -0
  22. package/dist/chunk-6EXBPJ24.cjs +434 -0
  23. package/dist/chunk-6QQDAAAZ.cjs +38 -0
  24. package/dist/chunk-6V4TDWEC.cjs +455 -0
  25. package/dist/chunk-72ADZ6GQ.cjs +19 -0
  26. package/dist/chunk-75BRBIFP.cjs +172 -0
  27. package/dist/chunk-7W3CPVXS.cjs +24 -0
  28. package/dist/chunk-A6WIQH5Z.cjs +31 -0
  29. package/dist/chunk-AFOD3LYZ.cjs +377 -0
  30. package/dist/chunk-AMDMVWMI.cjs +39 -0
  31. package/dist/chunk-AORPIPNB.cjs +552 -0
  32. package/dist/chunk-ARJWXNQL.cjs +256 -0
  33. package/dist/chunk-AWRISO2H.cjs +2199 -0
  34. package/dist/chunk-AYJR42WX.cjs +711 -0
  35. package/dist/chunk-B4CH33IG.cjs +644 -0
  36. package/dist/chunk-BIDYX3SL.cjs +91 -0
  37. package/dist/chunk-BSTRERPP.cjs +40 -0
  38. package/dist/chunk-BYODCJD6.cjs +663 -0
  39. package/dist/chunk-C3VRMB6H.cjs +85 -0
  40. package/dist/chunk-C5GUTBZK.cjs +173 -0
  41. package/dist/chunk-CIAGU2X4.cjs +337 -0
  42. package/dist/chunk-CMGMGHUZ.cjs +27 -0
  43. package/dist/chunk-CXP5U3RW.cjs +54 -0
  44. package/dist/chunk-D2ULAULS.cjs +166 -0
  45. package/dist/chunk-D7JTOLFK.cjs +285 -0
  46. package/dist/chunk-DVM4FKZL.cjs +169 -0
  47. package/dist/chunk-DYEJQTDN.cjs +49 -0
  48. package/dist/chunk-E2BMSZ2W.cjs +151 -0
  49. package/dist/chunk-E3UK5IIB.cjs +593 -0
  50. package/dist/chunk-EM6SBQKM.cjs +470 -0
  51. package/dist/chunk-FJSWYIR7.cjs +482 -0
  52. package/dist/chunk-FK6GO24V.cjs +54 -0
  53. package/dist/chunk-FXUUWYAX.cjs +654 -0
  54. package/dist/chunk-G3HRIVEY.cjs +395 -0
  55. package/dist/chunk-G643DQCH.cjs +13 -0
  56. package/dist/chunk-G7HXGLEC.cjs +175 -0
  57. package/dist/chunk-GDSHDTJ4.cjs +152 -0
  58. package/dist/chunk-GNEO2XOF.cjs +2040 -0
  59. package/dist/{chunk-56DAX2BE.mjs → chunk-GYKJCFTS.mjs} +1 -1
  60. package/dist/chunk-H6G5INWM.cjs +1094 -0
  61. package/dist/chunk-HBTUGXHS.cjs +180 -0
  62. package/dist/chunk-HREOKQWT.cjs +45 -0
  63. package/dist/chunk-I4J452B7.cjs +435 -0
  64. package/dist/chunk-I57LW5VZ.cjs +94 -0
  65. package/dist/chunk-I7PUUDGY.cjs +389 -0
  66. package/dist/chunk-IAMRBF3Z.cjs +86 -0
  67. package/dist/chunk-IKNRN4VS.cjs +14214 -0
  68. package/dist/chunk-IQXFRNY2.cjs +169 -0
  69. package/dist/chunk-IXTFU4PL.cjs +2355 -0
  70. package/dist/chunk-J2OP5GG3.cjs +725 -0
  71. package/dist/chunk-J3LOGE4T.cjs +42 -0
  72. package/dist/chunk-J7FSKED3.cjs +93 -0
  73. package/dist/chunk-JDNHKPTD.cjs +22 -0
  74. package/dist/chunk-JSROZYYO.cjs +164 -0
  75. package/dist/chunk-K6FNHVDR.cjs +696 -0
  76. package/dist/chunk-KGZIORNL.cjs +43 -0
  77. package/dist/{chunk-MVIWBEJF.mjs → chunk-KPNVGRBL.mjs} +1 -1
  78. package/dist/chunk-KR6CKSXT.cjs +15 -0
  79. package/dist/chunk-KROWKCUH.cjs +185 -0
  80. package/dist/chunk-KVFPGF2M.cjs +46 -0
  81. package/dist/chunk-LCCBO7PJ.cjs +46 -0
  82. package/dist/chunk-LIUGYUX3.cjs +22 -0
  83. package/dist/chunk-LTNGXMQ6.cjs +55 -0
  84. package/dist/chunk-M2L4MYDQ.cjs +14 -0
  85. package/dist/chunk-MCJLA63J.cjs +1 -0
  86. package/dist/chunk-MKB2EGIR.cjs +148 -0
  87. package/dist/chunk-MQ3H6LT5.cjs +202 -0
  88. package/dist/chunk-MT763TDW.cjs +43 -0
  89. package/dist/chunk-MWSK6C4J.cjs +18 -0
  90. package/dist/chunk-MWWVKDW3.cjs +169 -0
  91. package/dist/chunk-NO3WWW3N.cjs +192 -0
  92. package/dist/chunk-NV3A5DXM.cjs +862 -0
  93. package/dist/chunk-NWOD6NIT.cjs +9 -0
  94. package/dist/chunk-NZKJGRB3.cjs +230 -0
  95. package/dist/chunk-OAVTUMJP.cjs +1496 -0
  96. package/dist/chunk-OHY2ZWUG.cjs +25 -0
  97. package/dist/chunk-OI6CMLWX.cjs +47 -0
  98. package/dist/chunk-OIEOCXKG.cjs +453 -0
  99. package/dist/chunk-OWOUTKIJ.cjs +558 -0
  100. package/dist/chunk-OX6O6WVA.cjs +74 -0
  101. package/dist/chunk-OXSIH4D6.cjs +476 -0
  102. package/dist/chunk-OYEUREB6.cjs +35 -0
  103. package/dist/chunk-PCOTGFSM.cjs +139 -0
  104. package/dist/chunk-PZYCPSCC.cjs +35 -0
  105. package/dist/chunk-QBK2AA4U.cjs +445 -0
  106. package/dist/chunk-QBPXNZGV.cjs +487 -0
  107. package/dist/chunk-QNPEUFHQ.cjs +27 -0
  108. package/dist/chunk-QZRVZSPN.cjs +236 -0
  109. package/dist/chunk-R5A5KNVX.cjs +20 -0
  110. package/dist/chunk-R5JIFR6B.cjs +42 -0
  111. package/dist/chunk-R6AIILII.cjs +193 -0
  112. package/dist/chunk-RG3ZOTG5.cjs +34 -0
  113. package/dist/chunk-ROUTX2E5.cjs +390 -0
  114. package/dist/chunk-RTHIVJ2G.cjs +54 -0
  115. package/dist/chunk-S3A45T7F.cjs +166 -0
  116. package/dist/chunk-S3JO3N4H.cjs +17 -0
  117. package/dist/chunk-SK35NQKK.cjs +27 -0
  118. package/dist/chunk-SU7MH53P.cjs +180 -0
  119. package/dist/chunk-SVRTJOUF.cjs +113 -0
  120. package/dist/chunk-SWN467MP.cjs +18 -0
  121. package/dist/chunk-SYQ3MOWW.cjs +73 -0
  122. package/dist/chunk-T5CERMEH.cjs +417 -0
  123. package/dist/chunk-TFAXUHWX.cjs +206 -0
  124. package/dist/chunk-TIWHTW3Q.cjs +24 -0
  125. package/dist/chunk-TKJZFIML.cjs +20 -0
  126. package/dist/chunk-TKNSDBBN.cjs +193 -0
  127. package/dist/chunk-TWGMSEHX.cjs +525 -0
  128. package/dist/chunk-TYQUSXUG.cjs +1357 -0
  129. package/dist/chunk-U4KT7QP3.cjs +23 -0
  130. package/dist/chunk-UJ2C4ICS.cjs +277 -0
  131. package/dist/chunk-UN5GHC5V.cjs +10244 -0
  132. package/dist/chunk-UQZ4AYTH.cjs +168 -0
  133. package/dist/chunk-US2QVW3E.cjs +36 -0
  134. package/dist/chunk-VB6UCX3V.cjs +421 -0
  135. package/dist/chunk-VEKFLAQM.cjs +300 -0
  136. package/dist/chunk-VQDBNVOO.cjs +14 -0
  137. package/dist/chunk-W4E7WMXE.cjs +71 -0
  138. package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
  139. package/dist/chunk-WMAPPDMM.cjs +28 -0
  140. package/dist/chunk-WMOGFOUJ.cjs +223 -0
  141. package/dist/chunk-WPYFSQKK.cjs +37 -0
  142. package/dist/chunk-WZMNW2IW.cjs +1415 -0
  143. package/dist/chunk-XGC343EY.cjs +443 -0
  144. package/dist/chunk-XSKZORAS.cjs +727 -0
  145. package/dist/chunk-XWAWFQFS.cjs +82 -0
  146. package/dist/chunk-Y4YMF2NQ.cjs +460 -0
  147. package/dist/chunk-Y4YWHNKU.cjs +250 -0
  148. package/dist/chunk-Y53ZSFN6.cjs +504 -0
  149. package/dist/chunk-YA6LLTIJ.cjs +411 -0
  150. package/dist/chunk-YFPGHF5F.cjs +202 -0
  151. package/dist/chunk-YJRZR7VU.cjs +28 -0
  152. package/dist/chunk-YTAABQEV.cjs +1 -0
  153. package/dist/chunk-YX3DBN4M.cjs +18 -0
  154. package/dist/chunk-YZTASLPQ.cjs +64 -0
  155. package/dist/chunk-Z5HIWVDP.cjs +2173 -0
  156. package/dist/chunk-ZEG3OPIB.cjs +93 -0
  157. package/dist/chunk-ZMN3H73H.cjs +155 -0
  158. package/dist/client/lifecycle.cjs +6 -35
  159. package/dist/client-plugins.cjs +7 -448
  160. package/dist/client.cjs +171 -9808
  161. package/dist/config.cjs +8 -36
  162. package/dist/cron.cjs +24 -491
  163. package/dist/deferred.cjs +26 -475
  164. package/dist/deployment.cjs +39 -210
  165. package/dist/devtools-OUIPHVV6.cjs +388 -0
  166. package/dist/devtools-client-4WAPJY5L.cjs +254 -0
  167. package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
  168. package/dist/docs.cjs +46 -5657
  169. package/dist/env-types.cjs +5 -226
  170. package/dist/env.cjs +21 -338
  171. package/dist/environment/vite.cjs +8 -372
  172. package/dist/environment.cjs +12 -94
  173. package/dist/font.cjs +13 -63
  174. package/dist/headers.cjs +7 -123
  175. package/dist/i18n/client.cjs +55 -294
  176. package/dist/i18n/index.cjs +22 -209
  177. package/dist/i18n/server.cjs +22 -745
  178. package/dist/image/server.cjs +13 -729
  179. package/dist/image/sharp.cjs +33 -171
  180. package/dist/image.cjs +41 -85
  181. package/dist/index.cjs +1151 -68080
  182. package/dist/index.mjs +3 -3
  183. package/dist/instrumentation.cjs +12 -138
  184. package/dist/integration-orm-55F7CII5.cjs +13 -0
  185. package/dist/integrations.cjs +55 -4090
  186. package/dist/internal/app-markdown-runtime.cjs +27 -224
  187. package/dist/internal/build-runtime.cjs +120 -52259
  188. package/dist/internal/build-runtime.mjs +3 -3
  189. package/dist/internal/cli-runtime.cjs +67 -13811
  190. package/dist/internal/client-error-overlay.cjs +80 -733
  191. package/dist/internal/client-error-overlay.mjs +1 -1
  192. package/dist/internal/client-runtime.cjs +81 -913
  193. package/dist/internal/compression-runtime.cjs +8 -214
  194. package/dist/internal/config-runtime.cjs +42 -6547
  195. package/dist/internal/docs-precompiled-runtime.cjs +26 -46
  196. package/dist/internal/infra-analytics-runtime.cjs +10 -536
  197. package/dist/internal/isolated-boundary.cjs +14 -414
  198. package/dist/internal/metadata-image-runtime.cjs +7 -285
  199. package/dist/internal/product-telemetry-runtime.cjs +42 -97
  200. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  201. package/dist/internal/production-node-env.cjs +6 -63
  202. package/dist/internal/production-runtime.cjs +418 -7133
  203. package/dist/internal/request-cookies.cjs +6 -54
  204. package/dist/json-ld.cjs +24 -50
  205. package/dist/layers-E4WPJNY5.cjs +17 -0
  206. package/dist/manager-G4B2IPYE.cjs +14 -0
  207. package/dist/markdown.cjs +21 -547
  208. package/dist/middleware.cjs +36 -2995
  209. package/dist/navigation.cjs +22 -2588
  210. package/dist/nitro-4I2MYLY2.cjs +652 -0
  211. package/dist/observability.cjs +22 -614
  212. package/dist/og.cjs +5 -28
  213. package/dist/plugin.cjs +106 -37442
  214. package/dist/plugin.mjs +2 -2
  215. package/dist/query/client.cjs +113 -449
  216. package/dist/query/index.cjs +26 -288
  217. package/dist/query/parsers.cjs +23 -247
  218. package/dist/query/server.cjs +36 -298
  219. package/dist/renderer/react/client.cjs +9 -43
  220. package/dist/renderer/react/server.cjs +40 -103
  221. package/dist/renderer/react/vite.cjs +7 -29
  222. package/dist/renderer-client.cjs +126 -4295
  223. package/dist/renderer.cjs +31 -249
  224. package/dist/request.cjs +5 -68
  225. package/dist/router.cjs +11 -474
  226. package/dist/routes.cjs +42 -2461
  227. package/dist/schema-dev-notice-MXSZMVDG.cjs +56 -0
  228. package/dist/schema.cjs +6 -33
  229. package/dist/search-client-G3RICOFU.cjs +13 -0
  230. package/dist/server-action-security.cjs +25 -541
  231. package/dist/server-fn-client.cjs +6 -337
  232. package/dist/server-fn.cjs +32 -1841
  233. package/dist/server-plugins.cjs +15 -884
  234. package/dist/server-query-client.cjs +15 -1883
  235. package/dist/server-query.cjs +16 -1838
  236. package/dist/server.cjs +296 -44681
  237. package/dist/server.mjs +2 -2
  238. package/dist/storage.cjs +57 -576
  239. package/dist/testing.cjs +89 -3186
  240. package/dist/theme/client.cjs +13 -108
  241. package/dist/theme/index.cjs +6 -68
  242. package/dist/theme/runtime.cjs +13 -78
  243. package/dist/theme/server.cjs +10 -179
  244. package/dist/version.cjs +4 -32
  245. package/dist/version.mjs +1 -1
  246. package/dist/vite.cjs +119 -37773
  247. package/dist/vite.mjs +2 -2
  248. package/dist/workflows.cjs +19 -1040
  249. package/package.json +1 -1
@@ -0,0 +1,417 @@
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
+
4
+
5
+
6
+ var _chunkSVRTJOUFcjs = require('./chunk-SVRTJOUF.cjs');
7
+
8
+
9
+ var _chunkEM6SBQKMcjs = require('./chunk-EM6SBQKM.cjs');
10
+
11
+
12
+
13
+ var _chunkZEG3OPIBcjs = require('./chunk-ZEG3OPIB.cjs');
14
+
15
+
16
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
17
+
18
+ // src/server-action-security.ts
19
+ var _async_hooks = require('async_hooks');
20
+
21
+ // src/server-fn-error.ts
22
+ var FARM_SERVER_FN_FAILURE_SYMBOL = /* @__PURE__ */ Symbol.for("farm.server-fn.failure");
23
+ var _ServerFnFailure = class _ServerFnFailure extends Error {
24
+ constructor(code, data, options) {
25
+ super(options.message);
26
+ this.name = "ServerFnFailure";
27
+ this.code = code;
28
+ this.data = data;
29
+ this.status = options.status;
30
+ Object.defineProperty(this, FARM_SERVER_FN_FAILURE_SYMBOL, {
31
+ value: true,
32
+ enumerable: false
33
+ });
34
+ }
35
+ };
36
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _ServerFnFailure, "ServerFnFailure");
37
+ var ServerFnFailure = _ServerFnFailure;
38
+ var _ServerActionError = class _ServerActionError extends Error {
39
+ constructor(message = "Server function failed") {
40
+ super(message);
41
+ this.name = "ServerActionError";
42
+ }
43
+ };
44
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _ServerActionError, "ServerActionError");
45
+ var ServerActionError = _ServerActionError;
46
+ function isServerFnFailure(value) {
47
+ if (!value || typeof value !== "object") return false;
48
+ const candidate = value;
49
+ return candidate[FARM_SERVER_FN_FAILURE_SYMBOL] === true && candidate.name === "ServerFnFailure" && typeof candidate.code === "string" && Number.isInteger(candidate.status) && (_nullishCoalesce(candidate.status, () => ( 0))) >= 400 && (_nullishCoalesce(candidate.status, () => ( 0))) <= 599;
50
+ }
51
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isServerFnFailure, "isServerFnFailure");
52
+ function serializeServerFnFailure(value) {
53
+ if (!isServerFnFailure(value)) return null;
54
+ return {
55
+ name: "ServerFnFailure",
56
+ message: value.message,
57
+ code: value.code,
58
+ status: value.status,
59
+ data: value.data
60
+ };
61
+ }
62
+ _chunkS3JO3N4Hcjs.__name.call(void 0, serializeServerFnFailure, "serializeServerFnFailure");
63
+ function createServerFnTransportError(value) {
64
+ if (isSerializedServerFnFailure(value)) {
65
+ return new ServerFnFailure(value.code, value.data, {
66
+ status: value.status,
67
+ message: value.message
68
+ });
69
+ }
70
+ const message = value && typeof value === "object" && "message" in value && typeof value.message === "string" ? value.message : "Server function failed";
71
+ return new ServerActionError(message);
72
+ }
73
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createServerFnTransportError, "createServerFnTransportError");
74
+ function isSerializedServerFnFailure(value) {
75
+ if (!value || typeof value !== "object") return false;
76
+ const candidate = value;
77
+ return candidate.name === "ServerFnFailure" && typeof candidate.message === "string" && typeof candidate.code === "string" && Number.isInteger(candidate.status) && (_nullishCoalesce(candidate.status, () => ( 0))) >= 400 && (_nullishCoalesce(candidate.status, () => ( 0))) <= 599 && "data" in candidate;
78
+ }
79
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isSerializedServerFnFailure, "isSerializedServerFnFailure");
80
+
81
+ // src/server-action-security.ts
82
+ var SERVER_ACTION_ALLOWED_ORIGINS_LABEL = "serverActions.allowedOrigins";
83
+ var DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1e6;
84
+ var _ServerActionRequestError = class _ServerActionRequestError extends Error {
85
+ constructor(code, status, message) {
86
+ super(message);
87
+ this.name = "ServerActionRequestError";
88
+ this.code = code;
89
+ this.status = status;
90
+ }
91
+ };
92
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _ServerActionRequestError, "ServerActionRequestError");
93
+ var ServerActionRequestError = _ServerActionRequestError;
94
+ var SERVER_ACTION_STORAGE_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionStorage");
95
+ var FALLBACK_ABORT_CONTROLLER_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionFallbackAbortController");
96
+ var FORM_ACTION_CONTENT_TYPES = /* @__PURE__ */ new Set([
97
+ "application/x-www-form-urlencoded",
98
+ "multipart/form-data"
99
+ ]);
100
+ var JAVASCRIPT_ACTION_CONTENT_TYPES = /* @__PURE__ */ new Set([
101
+ "application/octet-stream",
102
+ "application/x-www-form-urlencoded",
103
+ "multipart/form-data",
104
+ "text/plain"
105
+ ]);
106
+ function resolveServerActionsConfig(config) {
107
+ const allowedOrigins = (_nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.allowedOrigins]), () => ( []))).map(
108
+ (value) => _chunkSVRTJOUFcjs.normalizeAllowedOriginPattern.call(void 0, value, SERVER_ACTION_ALLOWED_ORIGINS_LABEL)
109
+ );
110
+ const bodySizeLimit = _chunkEM6SBQKMcjs.parseBodySizeLimit.call(void 0,
111
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.bodySizeLimit]), () => ( DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT)),
112
+ "serverActions.bodySizeLimit"
113
+ );
114
+ return Object.freeze({
115
+ allowedOrigins: Object.freeze(allowedOrigins),
116
+ bodySizeLimit
117
+ });
118
+ }
119
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveServerActionsConfig, "resolveServerActionsConfig");
120
+ function validateServerActionRequest(request, config) {
121
+ if (request.method.toUpperCase() !== "POST") {
122
+ throw new ServerActionRequestError(
123
+ "INVALID_METHOD",
124
+ 405,
125
+ "Server actions only accept POST requests"
126
+ );
127
+ }
128
+ const requestUrl = new URL(request.url);
129
+ const sourceOrigin = resolveSourceOrigin(request);
130
+ const fetchSite = _optionalChain([request, 'access', _3 => _3.headers, 'access', _4 => _4.get, 'call', _5 => _5("sec-fetch-site"), 'optionalAccess', _6 => _6.trim, 'call', _7 => _7(), 'access', _8 => _8.toLowerCase, 'call', _9 => _9()]);
131
+ if (!sourceOrigin) {
132
+ if (fetchSite !== "same-origin") {
133
+ throw new ServerActionRequestError(
134
+ "MISSING_ORIGIN",
135
+ 403,
136
+ "Server action request is missing same-origin metadata"
137
+ );
138
+ }
139
+ return;
140
+ }
141
+ const matchesRequest = sourceOrigin === requestUrl.origin || _chunkSVRTJOUFcjs.matchesHostHeader.call(void 0, sourceOrigin, request);
142
+ const matchesConfiguredOrigin = config.allowedOrigins.some(
143
+ (pattern) => _chunkSVRTJOUFcjs.matchesAllowedOrigin.call(void 0, sourceOrigin, pattern)
144
+ );
145
+ if (!matchesRequest && !matchesConfiguredOrigin) {
146
+ throw new ServerActionRequestError(
147
+ "INVALID_ORIGIN",
148
+ 403,
149
+ "Server action origin does not match the request origin"
150
+ );
151
+ }
152
+ if (fetchSite === "cross-site" && !matchesConfiguredOrigin) {
153
+ throw new ServerActionRequestError(
154
+ "INVALID_ORIGIN",
155
+ 403,
156
+ "Cross-site server action request was rejected"
157
+ );
158
+ }
159
+ }
160
+ _chunkS3JO3N4Hcjs.__name.call(void 0, validateServerActionRequest, "validateServerActionRequest");
161
+ async function prepareServerActionRequest(request, config, kind, actionId) {
162
+ validateServerActionRequest(request, config);
163
+ if (kind === "javascript") {
164
+ validateActionId(actionId);
165
+ }
166
+ const contentType = getSupportedContentType(request, kind);
167
+ const bytes = await readBodyWithLimit(request, config.bodySizeLimit);
168
+ if (kind === "form" || contentType === "multipart/form-data") {
169
+ return {
170
+ body: await parseFormData(request, bytes),
171
+ contentType
172
+ };
173
+ }
174
+ return {
175
+ body: new TextDecoder().decode(bytes),
176
+ contentType
177
+ };
178
+ }
179
+ _chunkS3JO3N4Hcjs.__name.call(void 0, prepareServerActionRequest, "prepareServerActionRequest");
180
+ function createServerActionRequestErrorResponse(error) {
181
+ if (!(error instanceof ServerActionRequestError)) {
182
+ return null;
183
+ }
184
+ const headers = new Headers({
185
+ "cache-control": "no-store",
186
+ "content-type": "text/plain; charset=utf-8",
187
+ "x-content-type-options": "nosniff"
188
+ });
189
+ if (error.status === 405) {
190
+ headers.set("allow", "POST");
191
+ }
192
+ return new Response(getPublicErrorMessage(error.status), {
193
+ status: error.status,
194
+ headers
195
+ });
196
+ }
197
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createServerActionRequestErrorResponse, "createServerActionRequestErrorResponse");
198
+ function sanitizeServerActionError(error) {
199
+ const declaredFailure = serializeServerFnFailure(error);
200
+ if (declaredFailure) return declaredFailure;
201
+ return {
202
+ name: "ServerActionError",
203
+ message: "Server function failed"
204
+ };
205
+ }
206
+ _chunkS3JO3N4Hcjs.__name.call(void 0, sanitizeServerActionError, "sanitizeServerActionError");
207
+ async function runWithServerActionRequest(request, callback) {
208
+ throwIfAborted(request.signal);
209
+ const context = {
210
+ request,
211
+ signal: request.signal,
212
+ invalidations: /* @__PURE__ */ new Set(),
213
+ cacheTasks: /* @__PURE__ */ new Set()
214
+ };
215
+ return getServerActionStorage().run(context, async () => {
216
+ try {
217
+ const result = await callback();
218
+ await Promise.all(context.cacheTasks);
219
+ return result;
220
+ } catch (error) {
221
+ await Promise.allSettled(context.cacheTasks);
222
+ throw error;
223
+ }
224
+ });
225
+ }
226
+ _chunkS3JO3N4Hcjs.__name.call(void 0, runWithServerActionRequest, "runWithServerActionRequest");
227
+ function getServerActionExecutionContext() {
228
+ return getServerActionStorage().getStore();
229
+ }
230
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getServerActionExecutionContext, "getServerActionExecutionContext");
231
+ function getServerActionSignal() {
232
+ return _nullishCoalesce(_optionalChain([getServerActionExecutionContext, 'call', _10 => _10(), 'optionalAccess', _11 => _11.signal]), () => ( getFallbackAbortController().signal));
233
+ }
234
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getServerActionSignal, "getServerActionSignal");
235
+ function getServerActionInvalidations() {
236
+ return Array.from(_nullishCoalesce(_optionalChain([getServerActionExecutionContext, 'call', _12 => _12(), 'optionalAccess', _13 => _13.invalidations]), () => ( [])));
237
+ }
238
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getServerActionInvalidations, "getServerActionInvalidations");
239
+ _chunkZEG3OPIBcjs.subscribeFarmCacheInvalidation.call(void 0, (key) => {
240
+ _optionalChain([getServerActionExecutionContext, 'call', _14 => _14(), 'optionalAccess', _15 => _15.invalidations, 'access', _16 => _16.add, 'call', _17 => _17(key)]);
241
+ });
242
+ _chunkZEG3OPIBcjs.subscribeFarmCacheTask.call(void 0, (task) => {
243
+ _optionalChain([getServerActionExecutionContext, 'call', _18 => _18(), 'optionalAccess', _19 => _19.cacheTasks, 'access', _20 => _20.add, 'call', _21 => _21(task)]);
244
+ });
245
+ function getServerActionStorage() {
246
+ const globalState = globalThis;
247
+ if (!globalState[SERVER_ACTION_STORAGE_KEY]) {
248
+ globalState[SERVER_ACTION_STORAGE_KEY] = new (0, _async_hooks.AsyncLocalStorage)();
249
+ }
250
+ return globalState[SERVER_ACTION_STORAGE_KEY];
251
+ }
252
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getServerActionStorage, "getServerActionStorage");
253
+ function getFallbackAbortController() {
254
+ const globalState = globalThis;
255
+ if (!globalState[FALLBACK_ABORT_CONTROLLER_KEY]) {
256
+ globalState[FALLBACK_ABORT_CONTROLLER_KEY] = new AbortController();
257
+ }
258
+ return globalState[FALLBACK_ABORT_CONTROLLER_KEY];
259
+ }
260
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFallbackAbortController, "getFallbackAbortController");
261
+ function resolveSourceOrigin(request) {
262
+ const result = _chunkSVRTJOUFcjs.getRequestSourceOrigin.call(void 0, request);
263
+ if (!result.ok) {
264
+ throw new ServerActionRequestError(
265
+ "INVALID_ORIGIN",
266
+ 403,
267
+ result.reason === "opaque-origin" ? "Opaque origins are not allowed" : "Invalid request origin"
268
+ );
269
+ }
270
+ return result.origin;
271
+ }
272
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveSourceOrigin, "resolveSourceOrigin");
273
+ function validateActionId(actionId) {
274
+ if (!actionId || actionId.length > 4096 || hasControlCharacters(actionId)) {
275
+ throw new ServerActionRequestError("INVALID_ACTION_ID", 400, "Invalid server action id");
276
+ }
277
+ }
278
+ _chunkS3JO3N4Hcjs.__name.call(void 0, validateActionId, "validateActionId");
279
+ function hasControlCharacters(value) {
280
+ for (let index = 0; index < value.length; index++) {
281
+ const code = value.charCodeAt(index);
282
+ if (code <= 31 || code === 127) return true;
283
+ }
284
+ return false;
285
+ }
286
+ _chunkS3JO3N4Hcjs.__name.call(void 0, hasControlCharacters, "hasControlCharacters");
287
+ function getSupportedContentType(request, kind) {
288
+ const header = _optionalChain([request, 'access', _22 => _22.headers, 'access', _23 => _23.get, 'call', _24 => _24("content-type"), 'optionalAccess', _25 => _25.trim, 'call', _26 => _26(), 'access', _27 => _27.toLowerCase, 'call', _28 => _28()]);
289
+ const contentType = _nullishCoalesce(_optionalChain([header, 'optionalAccess', _29 => _29.split, 'call', _30 => _30(";", 1), 'access', _31 => _31[0], 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]), () => ( ""));
290
+ const supported = kind === "form" ? FORM_ACTION_CONTENT_TYPES : JAVASCRIPT_ACTION_CONTENT_TYPES;
291
+ if (!supported.has(contentType)) {
292
+ throw new ServerActionRequestError(
293
+ "UNSUPPORTED_CONTENT_TYPE",
294
+ 415,
295
+ "Unsupported server action content type"
296
+ );
297
+ }
298
+ return contentType;
299
+ }
300
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getSupportedContentType, "getSupportedContentType");
301
+ async function readBodyWithLimit(request, limit) {
302
+ const contentLength = _optionalChain([request, 'access', _34 => _34.headers, 'access', _35 => _35.get, 'call', _36 => _36("content-length"), 'optionalAccess', _37 => _37.trim, 'call', _38 => _38()]);
303
+ if (contentLength) {
304
+ if (!/^\d+$/.test(contentLength)) {
305
+ throw new ServerActionRequestError(
306
+ "INVALID_CONTENT_LENGTH",
307
+ 400,
308
+ "Invalid content-length header"
309
+ );
310
+ }
311
+ if (Number(contentLength) > limit) {
312
+ throw new ServerActionRequestError("BODY_TOO_LARGE", 413, "Server action body is too large");
313
+ }
314
+ }
315
+ throwIfAborted(request.signal);
316
+ if (!request.body) return new Uint8Array();
317
+ const reader = request.body.getReader();
318
+ const chunks = [];
319
+ let total = 0;
320
+ const cancelBodyRead = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
321
+ void reader.cancel(request.signal.reason).catch(() => {
322
+ });
323
+ }, "cancelBodyRead");
324
+ request.signal.addEventListener("abort", cancelBodyRead, { once: true });
325
+ try {
326
+ while (true) {
327
+ throwIfAborted(request.signal);
328
+ const { done, value } = await reader.read();
329
+ if (done) break;
330
+ if (!value) continue;
331
+ total += value.byteLength;
332
+ if (total > limit) {
333
+ const error = new ServerActionRequestError(
334
+ "BODY_TOO_LARGE",
335
+ 413,
336
+ "Server action body is too large"
337
+ );
338
+ void reader.cancel(error).catch(() => {
339
+ });
340
+ throw error;
341
+ }
342
+ chunks.push(value);
343
+ }
344
+ } catch (error) {
345
+ if (request.signal.aborted) throwIfAborted(request.signal);
346
+ throw error;
347
+ } finally {
348
+ request.signal.removeEventListener("abort", cancelBodyRead);
349
+ reader.releaseLock();
350
+ }
351
+ throwIfAborted(request.signal);
352
+ const body = new Uint8Array(total);
353
+ let offset = 0;
354
+ for (const chunk of chunks) {
355
+ body.set(chunk, offset);
356
+ offset += chunk.byteLength;
357
+ }
358
+ return body;
359
+ }
360
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readBodyWithLimit, "readBodyWithLimit");
361
+ async function parseFormData(request, bytes) {
362
+ const body = new ArrayBuffer(bytes.byteLength);
363
+ new Uint8Array(body).set(bytes);
364
+ const copy = new Request(request.url, {
365
+ method: "POST",
366
+ headers: request.headers,
367
+ body
368
+ });
369
+ try {
370
+ return await copy.formData();
371
+ } catch (e) {
372
+ throw new ServerActionRequestError("INVALID_BODY", 400, "Invalid server action form body");
373
+ }
374
+ }
375
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseFormData, "parseFormData");
376
+ function getPublicErrorMessage(status) {
377
+ switch (status) {
378
+ case 400:
379
+ return "Bad Request";
380
+ case 403:
381
+ return "Forbidden";
382
+ case 405:
383
+ return "Method Not Allowed";
384
+ case 413:
385
+ return "Payload Too Large";
386
+ case 415:
387
+ return "Unsupported Media Type";
388
+ default:
389
+ return "Server Action Request Failed";
390
+ }
391
+ }
392
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getPublicErrorMessage, "getPublicErrorMessage");
393
+ function throwIfAborted(signal) {
394
+ if (!signal.aborted) return;
395
+ if (signal.reason !== void 0) throw signal.reason;
396
+ throw new DOMException("The operation was aborted", "AbortError");
397
+ }
398
+ _chunkS3JO3N4Hcjs.__name.call(void 0, throwIfAborted, "throwIfAborted");
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+ exports.FARM_SERVER_FN_FAILURE_SYMBOL = FARM_SERVER_FN_FAILURE_SYMBOL; exports.ServerFnFailure = ServerFnFailure; exports.ServerActionError = ServerActionError; exports.isServerFnFailure = isServerFnFailure; exports.createServerFnTransportError = createServerFnTransportError; exports.DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT; exports.ServerActionRequestError = ServerActionRequestError; exports.resolveServerActionsConfig = resolveServerActionsConfig; exports.validateServerActionRequest = validateServerActionRequest; exports.prepareServerActionRequest = prepareServerActionRequest; exports.createServerActionRequestErrorResponse = createServerActionRequestErrorResponse; exports.sanitizeServerActionError = sanitizeServerActionError; exports.runWithServerActionRequest = runWithServerActionRequest; exports.getServerActionExecutionContext = getServerActionExecutionContext; exports.getServerActionSignal = getServerActionSignal; exports.getServerActionInvalidations = getServerActionInvalidations;
@@ -0,0 +1,206 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/renderer.ts
6
+ var _module = require('module');
7
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
+ var _url = require('url');
9
+ var DEFAULT_RENDERER_CAPABILITIES = Object.freeze({
10
+ streaming: Object.freeze({ node: false, web: false }),
11
+ // Conservative default: assume a re-render rebuilds until a renderer states
12
+ // otherwise, so callers do not silently rely on reconciliation.
13
+ reconcilesRerenders: false,
14
+ functionComponents: false
15
+ });
16
+ function getFarmRendererCapabilities(renderer) {
17
+ const defaultStreaming = {
18
+ node: _nullishCoalesce(_optionalChain([renderer, 'optionalAccess', _ => _.capabilities, 'optionalAccess', _2 => _2.streaming, 'optionalAccess', _3 => _3.node]), () => ( DEFAULT_RENDERER_CAPABILITIES.streaming.node)),
19
+ web: _nullishCoalesce(_optionalChain([renderer, 'optionalAccess', _4 => _4.capabilities, 'optionalAccess', _5 => _5.streaming, 'optionalAccess', _6 => _6.web]), () => ( DEFAULT_RENDERER_CAPABILITIES.streaming.web))
20
+ };
21
+ const runtimes = Object.fromEntries(
22
+ ["node", "edge"].flatMap((runtime) => {
23
+ const override = _optionalChain([renderer, 'optionalAccess', _7 => _7.capabilities, 'optionalAccess', _8 => _8.streaming, 'optionalAccess', _9 => _9.runtimes, 'optionalAccess', _10 => _10[runtime]]);
24
+ if (!override) return [];
25
+ return [
26
+ [
27
+ runtime,
28
+ {
29
+ node: _nullishCoalesce(override.node, () => ( defaultStreaming.node)),
30
+ web: _nullishCoalesce(override.web, () => ( defaultStreaming.web))
31
+ }
32
+ ]
33
+ ];
34
+ })
35
+ );
36
+ return {
37
+ streaming: {
38
+ ...defaultStreaming,
39
+ ...Object.keys(runtimes).length > 0 ? { runtimes } : {}
40
+ },
41
+ reconcilesRerenders: _nullishCoalesce(_optionalChain([renderer, 'optionalAccess', _11 => _11.capabilities, 'optionalAccess', _12 => _12.reconcilesRerenders]), () => ( DEFAULT_RENDERER_CAPABILITIES.reconcilesRerenders)),
42
+ functionComponents: _nullishCoalesce(_optionalChain([renderer, 'optionalAccess', _13 => _13.capabilities, 'optionalAccess', _14 => _14.functionComponents]), () => ( DEFAULT_RENDERER_CAPABILITIES.functionComponents))
43
+ };
44
+ }
45
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmRendererCapabilities, "getFarmRendererCapabilities");
46
+ function getFarmRendererStreamingCapabilitiesForRuntime(renderer, runtime) {
47
+ const streaming = getFarmRendererCapabilities(renderer).streaming;
48
+ if (runtime === "unknown") return { node: streaming.node, web: streaming.web };
49
+ return _nullishCoalesce(_optionalChain([streaming, 'access', _15 => _15.runtimes, 'optionalAccess', _16 => _16[runtime]]), () => ( { node: streaming.node, web: streaming.web }));
50
+ }
51
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmRendererStreamingCapabilitiesForRuntime, "getFarmRendererStreamingCapabilitiesForRuntime");
52
+ function assertFarmRendererStreamingRuntime(name, renderer, runtimeModule, runtime) {
53
+ const declared = getFarmRendererStreamingCapabilitiesForRuntime(renderer, runtime);
54
+ const runtimeDeclaration = _optionalChain([runtimeModule, 'access', _17 => _17.capabilities, 'optionalAccess', _18 => _18.streaming]);
55
+ if (runtimeDeclaration) {
56
+ const advertised = getFarmRendererStreamingCapabilitiesForRuntime(
57
+ { capabilities: { streaming: runtimeDeclaration } },
58
+ runtime
59
+ );
60
+ if (declared.node && !advertised.node || declared.web && !advertised.web) {
61
+ throw new Error(
62
+ `Renderer \`${name}\` server module advertises ${JSON.stringify(advertised)} streaming for the ${runtime} runtime, which does not satisfy its descriptor ${JSON.stringify(declared)}.`
63
+ );
64
+ }
65
+ }
66
+ if (declared.node && typeof runtimeModule.renderToPipeableStream !== "function") {
67
+ throw new Error(
68
+ `Renderer \`${name}\` advertises Node streaming for the ${runtime} runtime but its server module does not export renderToPipeableStream().`
69
+ );
70
+ }
71
+ if (declared.web && typeof runtimeModule.renderToReadableStream !== "function") {
72
+ throw new Error(
73
+ `Renderer \`${name}\` advertises Web streaming for the ${runtime} runtime but its server module does not export renderToReadableStream().`
74
+ );
75
+ }
76
+ return declared;
77
+ }
78
+ _chunkS3JO3N4Hcjs.__name.call(void 0, assertFarmRendererStreamingRuntime, "assertFarmRendererStreamingRuntime");
79
+ var FARM_COMPONENT_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
80
+ function resolveFarmComponentExtensions(extensions = []) {
81
+ return Array.from(
82
+ new Set(
83
+ [...FARM_COMPONENT_EXTENSIONS, ...extensions].map((extension) => {
84
+ const normalized = extension.trim().toLowerCase();
85
+ return normalized.startsWith(".") ? normalized : `.${normalized}`;
86
+ })
87
+ )
88
+ ).filter((extension) => extension.length > 1);
89
+ }
90
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmComponentExtensions, "resolveFarmComponentExtensions");
91
+ function getFarmRendererComponentExtensions(renderer) {
92
+ return resolveFarmComponentExtensions(_optionalChain([renderer, 'optionalAccess', _19 => _19.componentExtensions]));
93
+ }
94
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmRendererComponentExtensions, "getFarmRendererComponentExtensions");
95
+ var REACT_RENDERER = Object.freeze({
96
+ name: "react",
97
+ vite: "@farm.js/core/renderer/react/vite",
98
+ server: "@farm.js/core/renderer/react/server",
99
+ client: "@farm.js/core/renderer/react/client",
100
+ jsxImportSource: "react",
101
+ dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
102
+ optimizeDeps: [
103
+ "react",
104
+ "react-dom",
105
+ "react-dom/client",
106
+ "react/jsx-runtime",
107
+ "react/jsx-dev-runtime"
108
+ ],
109
+ capabilities: {
110
+ streaming: {
111
+ node: true,
112
+ web: false,
113
+ runtimes: { edge: { node: false, web: true } }
114
+ },
115
+ reconcilesRerenders: true,
116
+ functionComponents: true
117
+ }
118
+ });
119
+ function defineRenderer(renderer) {
120
+ return renderer;
121
+ }
122
+ _chunkS3JO3N4Hcjs.__name.call(void 0, defineRenderer, "defineRenderer");
123
+ function resolveFarmRenderer(renderer) {
124
+ const resolved = renderer || REACT_RENDERER;
125
+ const fields = ["name", "vite", "server", "client"];
126
+ for (const field of fields) {
127
+ if (typeof resolved[field] !== "string" || resolved[field].trim().length === 0) {
128
+ throw new TypeError(`Farm renderer \`${field}\` must be a non-empty string.`);
129
+ }
130
+ }
131
+ return {
132
+ ...resolved,
133
+ componentExtensions: [...resolved.componentExtensions || []],
134
+ dedupe: [...resolved.dedupe || []],
135
+ optimizeDeps: [...resolved.optimizeDeps || []],
136
+ buildConcurrency: resolved.buildConcurrency || "parallel",
137
+ capabilities: getFarmRendererCapabilities(resolved),
138
+ options: resolved.options ? { ...resolved.options } : void 0
139
+ };
140
+ }
141
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmRenderer, "resolveFarmRenderer");
142
+ async function readFarmRendererWebStream(stream) {
143
+ const reader = stream.getReader();
144
+ const decoder = new TextDecoder();
145
+ let html = "";
146
+ while (true) {
147
+ const { done, value } = await reader.read();
148
+ if (done) break;
149
+ html += typeof value === "string" ? value : decoder.decode(value, { stream: true });
150
+ }
151
+ return html + decoder.decode();
152
+ }
153
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readFarmRendererWebStream, "readFarmRendererWebStream");
154
+ function isReactRenderer(renderer) {
155
+ return !renderer || renderer.name === "react";
156
+ }
157
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isReactRenderer, "isReactRenderer");
158
+ function resolveFarmRendererModule(root, specifier) {
159
+ const requireFromApp = _module.createRequire.call(void 0, _path2.default.join(_path2.default.resolve(root), "package.json"));
160
+ return requireFromApp.resolve(specifier);
161
+ }
162
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmRendererModule, "resolveFarmRendererModule");
163
+ function createFarmReactJsxPlugin() {
164
+ return {
165
+ name: "farm:react-jsx",
166
+ config(config) {
167
+ if (this && _optionalChain([this, 'access', _20 => _20.meta, 'optionalAccess', _21 => _21.rolldownVersion])) return;
168
+ if (config.esbuild === false || _optionalChain([config, 'access', _22 => _22.esbuild, 'optionalAccess', _23 => _23.jsx]) !== void 0) return;
169
+ return { esbuild: { jsx: "automatic" } };
170
+ }
171
+ };
172
+ }
173
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmReactJsxPlugin, "createFarmReactJsxPlugin");
174
+ async function loadFarmRendererVitePlugins(renderer, root, options = {}) {
175
+ if (renderer.vite === REACT_RENDERER.vite) return [createFarmReactJsxPlugin()];
176
+ const modulePath = resolveFarmRendererModule(root, renderer.vite);
177
+ const rendererModule = await import(_url.pathToFileURL.call(void 0, modulePath).href);
178
+ if (typeof rendererModule.createFarmRendererPlugin !== "function") {
179
+ throw new Error(
180
+ `Renderer \`${renderer.name}\` module ${renderer.vite} must export createFarmRendererPlugin().`
181
+ );
182
+ }
183
+ const created = await rendererModule.createFarmRendererPlugin({
184
+ ...options,
185
+ rendererOptions: renderer.options
186
+ });
187
+ if (!created) return [];
188
+ return Array.isArray(created) ? [...created] : [created];
189
+ }
190
+ _chunkS3JO3N4Hcjs.__name.call(void 0, loadFarmRendererVitePlugins, "loadFarmRendererVitePlugins");
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+ exports.getFarmRendererCapabilities = getFarmRendererCapabilities; exports.getFarmRendererStreamingCapabilitiesForRuntime = getFarmRendererStreamingCapabilitiesForRuntime; exports.assertFarmRendererStreamingRuntime = assertFarmRendererStreamingRuntime; exports.FARM_COMPONENT_EXTENSIONS = FARM_COMPONENT_EXTENSIONS; exports.resolveFarmComponentExtensions = resolveFarmComponentExtensions; exports.getFarmRendererComponentExtensions = getFarmRendererComponentExtensions; exports.REACT_RENDERER = REACT_RENDERER; exports.defineRenderer = defineRenderer; exports.resolveFarmRenderer = resolveFarmRenderer; exports.readFarmRendererWebStream = readFarmRendererWebStream; exports.isReactRenderer = isReactRenderer; exports.resolveFarmRendererModule = resolveFarmRendererModule; exports.loadFarmRendererVitePlugins = loadFarmRendererVitePlugins;
@@ -0,0 +1,24 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/write-file-if-changed.ts
6
+ var _fs = require('fs');
7
+ function writeFileIfChanged(filePath, content) {
8
+ try {
9
+ if (_fs.readFileSync.call(void 0, filePath, "utf8") === content) {
10
+ return false;
11
+ }
12
+ } catch (error) {
13
+ if (error.code !== "ENOENT") {
14
+ throw error;
15
+ }
16
+ }
17
+ _fs.writeFileSync.call(void 0, filePath, content, "utf8");
18
+ return true;
19
+ }
20
+ _chunkS3JO3N4Hcjs.__name.call(void 0, writeFileIfChanged, "writeFileIfChanged");
21
+
22
+
23
+
24
+ exports.writeFileIfChanged = writeFileIfChanged;
@@ -0,0 +1,20 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/response-body.ts
6
+ function omitFarmResponseBody(response) {
7
+ if (response.body) {
8
+ void response.body.cancel().catch(() => void 0);
9
+ }
10
+ return new Response(null, {
11
+ status: response.status,
12
+ statusText: response.statusText,
13
+ headers: response.headers
14
+ });
15
+ }
16
+ _chunkS3JO3N4Hcjs.__name.call(void 0, omitFarmResponseBody, "omitFarmResponseBody");
17
+
18
+
19
+
20
+ exports.omitFarmResponseBody = omitFarmResponseBody;