@farm.js/core 0.1.0-beta.16 → 0.1.0-beta.17

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 (215) hide show
  1. package/dist/after.d.mts +25 -0
  2. package/dist/after.d.ts +25 -0
  3. package/dist/agent-runtime.d.mts +96 -0
  4. package/dist/agent-runtime.d.ts +96 -0
  5. package/dist/api/route-manager.d.mts +66 -0
  6. package/dist/api/route-manager.d.ts +66 -0
  7. package/dist/api/runtime.d.mts +3 -0
  8. package/dist/api/runtime.d.ts +3 -0
  9. package/dist/api.d.mts +48 -0
  10. package/dist/api.d.ts +48 -0
  11. package/dist/app-B0tE1I3o.d.ts +306 -0
  12. package/dist/app-Dv2JJb7X.d.mts +306 -0
  13. package/dist/app-markdown.d.mts +24 -0
  14. package/dist/app-markdown.d.ts +24 -0
  15. package/dist/cache.d.mts +192 -0
  16. package/dist/cache.d.ts +192 -0
  17. package/dist/{chunk-AN3PQVKH.mjs → chunk-2FLBZFPG.mjs} +9 -7
  18. package/dist/chunk-2FLBZFPG.mjs.map +1 -0
  19. package/dist/chunk-E257KFBU.mjs +227 -0
  20. package/dist/chunk-E257KFBU.mjs.map +1 -0
  21. package/dist/{chunk-SLDBGSC3.mjs → chunk-JAEAE27K.mjs} +2 -2
  22. package/dist/{chunk-T2KL7VEL.mjs → chunk-PZXBQKCH.mjs} +13 -4
  23. package/dist/chunk-PZXBQKCH.mjs.map +1 -0
  24. package/dist/{chunk-UXUAWNO5.mjs → chunk-RIXKJPGI.mjs} +117 -55
  25. package/dist/chunk-RIXKJPGI.mjs.map +1 -0
  26. package/dist/{chunk-OSWV5IJB.mjs → chunk-T2M5QANG.mjs} +32 -9
  27. package/dist/chunk-T2M5QANG.mjs.map +1 -0
  28. package/dist/{chunk-BWJC5ZOD.mjs → chunk-VFDBC3W7.mjs} +2 -2
  29. package/dist/{chunk-BWJC5ZOD.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
  30. package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
  31. package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
  32. package/dist/client-BT1mFQas.d.mts +447 -0
  33. package/dist/client-Nn0q4eO4.d.ts +447 -0
  34. package/dist/client-cache-CIlyBlmx.d.ts +6 -0
  35. package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
  36. package/dist/client-plugins-278AvYHE.d.mts +2021 -0
  37. package/dist/client-plugins-CTQAkr7R.d.ts +2021 -0
  38. package/dist/client-plugins.d.mts +24 -0
  39. package/dist/client-plugins.d.ts +24 -0
  40. package/dist/client.d.mts +452 -0
  41. package/dist/client.d.ts +452 -0
  42. package/dist/config.d.mts +31 -0
  43. package/dist/config.d.ts +31 -0
  44. package/dist/cron.d.mts +78 -0
  45. package/dist/cron.d.ts +78 -0
  46. package/dist/deferred.d.mts +42 -0
  47. package/dist/deferred.d.ts +42 -0
  48. package/dist/deployment.d.mts +36 -0
  49. package/dist/deployment.d.ts +36 -0
  50. package/dist/{devtools-E4YNCY5J.mjs → devtools-K2ERKGNI.mjs} +3 -3
  51. package/dist/docs.cjs.map +1 -1
  52. package/dist/docs.d.mts +80 -0
  53. package/dist/docs.d.ts +80 -0
  54. package/dist/docs.mjs +3 -3
  55. package/dist/env-types.d.mts +12 -0
  56. package/dist/env-types.d.ts +12 -0
  57. package/dist/env.d.mts +45 -0
  58. package/dist/env.d.ts +45 -0
  59. package/dist/environment/vite.d.mts +22 -0
  60. package/dist/environment/vite.d.ts +22 -0
  61. package/dist/environment.d.mts +18 -0
  62. package/dist/environment.d.ts +18 -0
  63. package/dist/font.d.mts +95 -0
  64. package/dist/font.d.ts +95 -0
  65. package/dist/headers.d.mts +22 -0
  66. package/dist/headers.d.ts +22 -0
  67. package/dist/i18n/client.d.mts +32 -0
  68. package/dist/i18n/client.d.ts +32 -0
  69. package/dist/i18n/index.d.mts +20 -0
  70. package/dist/i18n/index.d.ts +20 -0
  71. package/dist/i18n/server.d.mts +30 -0
  72. package/dist/i18n/server.d.ts +30 -0
  73. package/dist/image/server.d.mts +37 -0
  74. package/dist/image/server.d.ts +37 -0
  75. package/dist/image/sharp.d.mts +7 -0
  76. package/dist/image/sharp.d.ts +7 -0
  77. package/dist/image-config-Duob7wER.d.mts +50 -0
  78. package/dist/image-config-Duob7wER.d.ts +50 -0
  79. package/dist/image.d.mts +39 -0
  80. package/dist/image.d.ts +39 -0
  81. package/dist/index.cjs +293 -58
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.d.mts +477 -0
  84. package/dist/index.d.ts +477 -0
  85. package/dist/index.mjs +22 -18
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/integration-api-CHT2OKAf.d.mts +93 -0
  88. package/dist/integration-api-CHT2OKAf.d.ts +93 -0
  89. package/dist/integrations.d.mts +24 -0
  90. package/dist/integrations.d.ts +24 -0
  91. package/dist/internal/build-runtime.cjs +306 -137
  92. package/dist/internal/build-runtime.cjs.map +1 -1
  93. package/dist/internal/build-runtime.d.mts +41 -0
  94. package/dist/internal/build-runtime.d.ts +41 -0
  95. package/dist/internal/build-runtime.mjs +7 -7
  96. package/dist/internal/client-runtime.d.mts +17 -0
  97. package/dist/internal/client-runtime.d.ts +17 -0
  98. package/dist/internal/config-runtime.cjs +140 -1
  99. package/dist/internal/config-runtime.cjs.map +1 -1
  100. package/dist/internal/config-runtime.d.mts +41 -0
  101. package/dist/internal/config-runtime.d.ts +41 -0
  102. package/dist/internal/config-runtime.mjs +2 -2
  103. package/dist/internal/metadata-image-runtime.d.mts +25 -0
  104. package/dist/internal/metadata-image-runtime.d.ts +25 -0
  105. package/dist/internal/production-node-env.d.mts +12 -0
  106. package/dist/internal/production-node-env.d.ts +12 -0
  107. package/dist/internal/production-runtime.d.mts +44 -0
  108. package/dist/internal/production-runtime.d.ts +44 -0
  109. package/dist/island-CfGru1MO.d.mts +9 -0
  110. package/dist/island-CfGru1MO.d.ts +9 -0
  111. package/dist/markdown.d.mts +60 -0
  112. package/dist/markdown.d.ts +60 -0
  113. package/dist/metadata-DmCudMw_.d.mts +22 -0
  114. package/dist/metadata-xghtOlbR.d.ts +22 -0
  115. package/dist/middleware.cjs +116 -98
  116. package/dist/middleware.cjs.map +1 -1
  117. package/dist/middleware.d.mts +171 -0
  118. package/dist/middleware.d.ts +171 -0
  119. package/dist/middleware.mjs +5 -2
  120. package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
  121. package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
  122. package/dist/navigation.d.mts +14 -0
  123. package/dist/navigation.d.ts +14 -0
  124. package/dist/observability.d.mts +335 -0
  125. package/dist/observability.d.ts +335 -0
  126. package/dist/params-BALtrRim.d.ts +15 -0
  127. package/dist/params-ry-lxqmy.d.mts +15 -0
  128. package/dist/plugin-BJDf43dc.d.mts +165 -0
  129. package/dist/plugin-BJDf43dc.d.ts +165 -0
  130. package/dist/plugin.cjs +132 -0
  131. package/dist/plugin.cjs.map +1 -1
  132. package/dist/plugin.d.mts +24 -0
  133. package/dist/plugin.d.ts +24 -0
  134. package/dist/plugin.mjs +4 -4
  135. package/dist/production-runtime-BLxSv9cU.d.ts +79 -0
  136. package/dist/production-runtime-DFN2_RXq.d.mts +79 -0
  137. package/dist/query/client.d.mts +61 -0
  138. package/dist/query/client.d.ts +61 -0
  139. package/dist/query/index.d.mts +90 -0
  140. package/dist/query/index.d.ts +90 -0
  141. package/dist/query/parsers.d.mts +25 -0
  142. package/dist/query/parsers.d.ts +25 -0
  143. package/dist/query/server.d.mts +55 -0
  144. package/dist/query/server.d.ts +55 -0
  145. package/dist/request-Cq5d6qmE.d.mts +6 -0
  146. package/dist/request-LoxDW3lp.d.ts +6 -0
  147. package/dist/request.d.mts +25 -0
  148. package/dist/request.d.ts +25 -0
  149. package/dist/resolver-DJqjLMg_.d.mts +14 -0
  150. package/dist/resolver-IH4RmPEl.d.ts +14 -0
  151. package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
  152. package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
  153. package/dist/router.d.mts +36 -0
  154. package/dist/router.d.ts +36 -0
  155. package/dist/routes.d.mts +226 -0
  156. package/dist/routes.d.ts +226 -0
  157. package/dist/runtime-BA9TOSu1.d.mts +231 -0
  158. package/dist/runtime-Cxpq6xZN.d.mts +27 -0
  159. package/dist/runtime-DTAQ2HDv.d.ts +231 -0
  160. package/dist/runtime-bv63eUiO.d.ts +27 -0
  161. package/dist/server-action-security.d.mts +45 -0
  162. package/dist/server-action-security.d.ts +45 -0
  163. package/dist/server-fn-client.d.mts +33 -0
  164. package/dist/server-fn-client.d.ts +33 -0
  165. package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
  166. package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
  167. package/dist/server-fn.d.mts +121 -0
  168. package/dist/server-fn.d.ts +121 -0
  169. package/dist/server-plugins.d.mts +57 -0
  170. package/dist/server-plugins.d.ts +57 -0
  171. package/dist/server-query-client.d.mts +51 -0
  172. package/dist/server-query-client.d.ts +51 -0
  173. package/dist/server-query.d.mts +37 -0
  174. package/dist/server-query.d.ts +37 -0
  175. package/dist/server.cjs +170 -3
  176. package/dist/server.cjs.map +1 -1
  177. package/dist/server.d.mts +51 -0
  178. package/dist/server.d.ts +51 -0
  179. package/dist/server.mjs +6 -6
  180. package/dist/storage.d.mts +52 -0
  181. package/dist/storage.d.ts +52 -0
  182. package/dist/testing.d.mts +103 -0
  183. package/dist/testing.d.ts +103 -0
  184. package/dist/transport-BmbGTXA5.d.mts +49 -0
  185. package/dist/transport-BmbGTXA5.d.ts +49 -0
  186. package/dist/types-BMxWr97v.d.mts +81 -0
  187. package/dist/types-BMxWr97v.d.ts +81 -0
  188. package/dist/types-D1A6-XvH.d.mts +73 -0
  189. package/dist/types-D1A6-XvH.d.ts +73 -0
  190. package/dist/types-DTzm4TCl.d.mts +78 -0
  191. package/dist/types-DTzm4TCl.d.ts +78 -0
  192. package/dist/utils-B6GaYNJL.d.ts +23 -0
  193. package/dist/utils-CKSHiip6.d.mts +23 -0
  194. package/dist/version.cjs +1 -1
  195. package/dist/version.cjs.map +1 -1
  196. package/dist/version.d.mts +3 -0
  197. package/dist/version.d.ts +3 -0
  198. package/dist/version.mjs +1 -1
  199. package/dist/vite.cjs +140 -2
  200. package/dist/vite.cjs.map +1 -1
  201. package/dist/vite.d.mts +24 -0
  202. package/dist/vite.d.ts +24 -0
  203. package/dist/vite.mjs +4 -4
  204. package/dist/workflows.d.mts +110 -0
  205. package/dist/workflows.d.ts +110 -0
  206. package/package.json +1 -1
  207. package/types/middleware.d.ts +36 -11
  208. package/dist/chunk-AN3PQVKH.mjs.map +0 -1
  209. package/dist/chunk-I4CUBGVF.mjs +0 -93
  210. package/dist/chunk-I4CUBGVF.mjs.map +0 -1
  211. package/dist/chunk-OSWV5IJB.mjs.map +0 -1
  212. package/dist/chunk-T2KL7VEL.mjs.map +0 -1
  213. package/dist/chunk-UXUAWNO5.mjs.map +0 -1
  214. /package/dist/{chunk-SLDBGSC3.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
  215. /package/dist/{devtools-E4YNCY5J.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
@@ -0,0 +1,41 @@
1
+ import { be as ResolvedFarmConfig } from '../client-plugins-278AvYHE.mjs';
2
+ export { ah as loadConfig, ag as resolveConfig, ai as resolveDeployConfig } from '../client-plugins-278AvYHE.mjs';
3
+ import { FarmProductionViteRuntime } from './config-runtime.mjs';
4
+ export { l as logger } from '../utils-CKSHiip6.mjs';
5
+ import '../plugin-BJDf43dc.mjs';
6
+ import 'react';
7
+ import 'http';
8
+ import '../types-D1A6-XvH.mjs';
9
+ import 'db0';
10
+ import 'unstorage';
11
+ import '../integration-api-CHT2OKAf.mjs';
12
+ import '@farming-labs/orm';
13
+ import '../types-DTzm4TCl.mjs';
14
+ import '@farming-labs/docs';
15
+ import '../markdown.mjs';
16
+ import '../observability.mjs';
17
+ import 'vite';
18
+ import '../workflows.mjs';
19
+ import '../cron.mjs';
20
+ import '../env.mjs';
21
+ import '../server-action-security.mjs';
22
+ import '../server-fn-error-DDh14a0V.mjs';
23
+ import '../image-config-Duob7wER.mjs';
24
+ import '../types-BMxWr97v.mjs';
25
+ import '../cache.mjs';
26
+ import '../route-runtime-DoOHzCAD.mjs';
27
+ import '../font.mjs';
28
+
29
+ interface BuildOptions {
30
+ preset?: string;
31
+ root?: string;
32
+ universal?: boolean;
33
+ /** @internal Production Vite preload started by the CLI. */
34
+ productionVite?: FarmProductionViteRuntime | Promise<FarmProductionViteRuntime>;
35
+ }
36
+ /**
37
+ * Build Farm.js application for production
38
+ */
39
+ declare function build(config: ResolvedFarmConfig, options?: BuildOptions): Promise<void>;
40
+
41
+ export { build };
@@ -0,0 +1,41 @@
1
+ import { be as ResolvedFarmConfig } from '../client-plugins-CTQAkr7R.js';
2
+ export { ah as loadConfig, ag as resolveConfig, ai as resolveDeployConfig } from '../client-plugins-CTQAkr7R.js';
3
+ import { FarmProductionViteRuntime } from './config-runtime.js';
4
+ export { l as logger } from '../utils-B6GaYNJL.js';
5
+ import '../plugin-BJDf43dc.js';
6
+ import 'react';
7
+ import 'http';
8
+ import '../types-D1A6-XvH.js';
9
+ import 'db0';
10
+ import 'unstorage';
11
+ import '../integration-api-CHT2OKAf.js';
12
+ import '@farming-labs/orm';
13
+ import '../types-DTzm4TCl.js';
14
+ import '@farming-labs/docs';
15
+ import '../markdown.js';
16
+ import '../observability.js';
17
+ import 'vite';
18
+ import '../workflows.js';
19
+ import '../cron.js';
20
+ import '../env.js';
21
+ import '../server-action-security.js';
22
+ import '../server-fn-error-DDh14a0V.js';
23
+ import '../image-config-Duob7wER.js';
24
+ import '../types-BMxWr97v.js';
25
+ import '../cache.js';
26
+ import '../route-runtime-DoOHzCAD.js';
27
+ import '../font.js';
28
+
29
+ interface BuildOptions {
30
+ preset?: string;
31
+ root?: string;
32
+ universal?: boolean;
33
+ /** @internal Production Vite preload started by the CLI. */
34
+ productionVite?: FarmProductionViteRuntime | Promise<FarmProductionViteRuntime>;
35
+ }
36
+ /**
37
+ * Build Farm.js application for production
38
+ */
39
+ declare function build(config: ResolvedFarmConfig, options?: BuildOptions): Promise<void>;
40
+
41
+ export { build };
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  build
3
- } from "../chunk-AN3PQVKH.mjs";
3
+ } from "../chunk-2FLBZFPG.mjs";
4
4
  import "../chunk-4S3ORGFA.mjs";
5
5
  import "../chunk-SL6HTIOK.mjs";
6
- import "../chunk-SLDBGSC3.mjs";
6
+ import "../chunk-JAEAE27K.mjs";
7
7
  import "../chunk-V7RBCSDJ.mjs";
8
8
  import {
9
9
  loadConfig,
10
10
  resolveConfig,
11
11
  resolveDeployConfig
12
- } from "../chunk-T2KL7VEL.mjs";
12
+ } from "../chunk-PZXBQKCH.mjs";
13
13
  import "../chunk-UVCIEUJC.mjs";
14
14
  import "../chunk-DJSGLHCN.mjs";
15
15
  import "../chunk-RQ633A5I.mjs";
16
- import "../chunk-OSWV5IJB.mjs";
16
+ import "../chunk-T2M5QANG.mjs";
17
17
  import "../chunk-LGHEOHBU.mjs";
18
18
  import "../chunk-FRPWCMMG.mjs";
19
19
  import "../chunk-53MVSX3R.mjs";
@@ -25,7 +25,7 @@ import "../chunk-USWZZUEH.mjs";
25
25
  import "../chunk-XMFTIVJH.mjs";
26
26
  import "../chunk-7HO6AEOP.mjs";
27
27
  import "../chunk-USLFXFFH.mjs";
28
- import "../chunk-I4CUBGVF.mjs";
28
+ import "../chunk-E257KFBU.mjs";
29
29
  import "../chunk-7MABZJIM.mjs";
30
30
  import "../chunk-YW7OBE6Q.mjs";
31
31
  import "../chunk-74YTBPTY.mjs";
@@ -37,9 +37,9 @@ import "../chunk-7FBJLMQH.mjs";
37
37
  import "../chunk-XIVV5IWN.mjs";
38
38
  import "../chunk-GXASWWJU.mjs";
39
39
  import "../chunk-K4667E2Q.mjs";
40
+ import "../chunk-T4QJQK76.mjs";
40
41
  import "../chunk-MIUW47JX.mjs";
41
42
  import "../chunk-P7QDS5AT.mjs";
42
- import "../chunk-T4QJQK76.mjs";
43
43
  import "../chunk-E6EPN5BT.mjs";
44
44
  import "../chunk-QGOHVJ6J.mjs";
45
45
  import "../chunk-ARRYKOI5.mjs";
@@ -55,7 +55,7 @@ import {
55
55
  import "../chunk-HMRFYJK6.mjs";
56
56
  import "../chunk-RHIFZZUI.mjs";
57
57
  import "../chunk-LM2YNO4U.mjs";
58
- import "../chunk-BWJC5ZOD.mjs";
58
+ import "../chunk-VFDBC3W7.mjs";
59
59
  import "../chunk-B3FFOIWS.mjs";
60
60
  import "../chunk-ITN462YM.mjs";
61
61
  import "../chunk-3HIVDX7J.mjs";
@@ -0,0 +1,17 @@
1
+ export { i as installChunkErrorRecovery } from '../chunk-recovery-lnQFzcQP.mjs';
2
+ import { F as FarmIslandStrategy } from '../island-CfGru1MO.mjs';
3
+ export { c as createClientPluginManager } from '../plugin-BJDf43dc.mjs';
4
+
5
+ interface ScheduleFarmIslandHydrationOptions<T> {
6
+ container: Element;
7
+ strategy?: FarmIslandStrategy | null;
8
+ signal?: AbortSignal;
9
+ hydrate: () => T | Promise<T>;
10
+ }
11
+ /**
12
+ * Defer importing and hydrating a server-rendered client boundary until its
13
+ * configured trigger. The returned promise resolves with the hydration result.
14
+ */
15
+ declare function scheduleFarmIslandHydration<T>({ container, strategy, signal, hydrate, }: ScheduleFarmIslandHydrationOptions<T>): Promise<T | undefined>;
16
+
17
+ export { scheduleFarmIslandHydration };
@@ -0,0 +1,17 @@
1
+ export { i as installChunkErrorRecovery } from '../chunk-recovery-lnQFzcQP.js';
2
+ import { F as FarmIslandStrategy } from '../island-CfGru1MO.js';
3
+ export { c as createClientPluginManager } from '../plugin-BJDf43dc.js';
4
+
5
+ interface ScheduleFarmIslandHydrationOptions<T> {
6
+ container: Element;
7
+ strategy?: FarmIslandStrategy | null;
8
+ signal?: AbortSignal;
9
+ hydrate: () => T | Promise<T>;
10
+ }
11
+ /**
12
+ * Defer importing and hydrating a server-rendered client boundary until its
13
+ * configured trigger. The returned promise resolves with the hydration result.
14
+ */
15
+ declare function scheduleFarmIslandHydration<T>({ container, strategy, signal, hydrate, }: ScheduleFarmIslandHydrationOptions<T>): Promise<T | undefined>;
16
+
17
+ export { scheduleFarmIslandHydration };
@@ -3817,6 +3817,138 @@ function normalizeBudget(value, fallback) {
3817
3817
  }
3818
3818
  __name(normalizeBudget, "normalizeBudget");
3819
3819
 
3820
+ // src/security.ts
3821
+ function resolveFarmSecurityConfig(input) {
3822
+ if (input === void 0) return { csp: false };
3823
+ if (!isPlainRecord(input)) {
3824
+ throw new TypeError("security must be an object containing the csp option.");
3825
+ }
3826
+ if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
3827
+ throw new TypeError(
3828
+ "security.contentSecurityPolicy is not supported. Use security.csp instead."
3829
+ );
3830
+ }
3831
+ const csp = input.csp;
3832
+ if (csp === void 0 || csp === false) return { csp: false };
3833
+ if (typeof csp === "string") {
3834
+ return {
3835
+ csp: {
3836
+ value: validateSerializedCsp(csp),
3837
+ reportOnly: false
3838
+ }
3839
+ };
3840
+ }
3841
+ if (!isPlainRecord(csp)) {
3842
+ throw new TypeError("security.csp must be a policy string, false, or an options object.");
3843
+ }
3844
+ const reportOnly = validateReportOnly(csp.reportOnly);
3845
+ if (Object.prototype.hasOwnProperty.call(csp, "value")) {
3846
+ if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
3847
+ throw new TypeError(
3848
+ "Resolved security.csp values cannot include policy or directives options."
3849
+ );
3850
+ }
3851
+ return {
3852
+ csp: {
3853
+ value: validateSerializedCsp(csp.value),
3854
+ reportOnly
3855
+ }
3856
+ };
3857
+ }
3858
+ const { policy, directives } = csp;
3859
+ if (policy !== void 0 && directives !== void 0) {
3860
+ throw new TypeError("security.csp accepts either policy or directives, not both.");
3861
+ }
3862
+ if (policy === void 0 && directives === void 0) {
3863
+ throw new TypeError("security.csp requires a policy string or directives object.");
3864
+ }
3865
+ return {
3866
+ csp: {
3867
+ value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
3868
+ reportOnly
3869
+ }
3870
+ };
3871
+ }
3872
+ __name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
3873
+ function serializeFarmCspDirectives(directives) {
3874
+ if (!isPlainRecord(directives)) {
3875
+ throw new TypeError("security.csp.directives must be an object.");
3876
+ }
3877
+ const serialized = [];
3878
+ const normalizedNames = /* @__PURE__ */ new Set();
3879
+ for (const [configuredName, configuredValue] of Object.entries(directives)) {
3880
+ if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
3881
+ continue;
3882
+ }
3883
+ const name = normalizeDirectiveName(configuredName);
3884
+ if (normalizedNames.has(name)) {
3885
+ throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
3886
+ }
3887
+ normalizedNames.add(name);
3888
+ const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
3889
+ validateDirectiveValue
3890
+ );
3891
+ serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
3892
+ }
3893
+ if (serialized.length === 0) {
3894
+ throw new TypeError("security.csp.directives must contain at least one enabled directive.");
3895
+ }
3896
+ return serialized.join("; ");
3897
+ }
3898
+ __name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
3899
+ function getFarmSecurityHeader(security) {
3900
+ if (!security.csp) return void 0;
3901
+ return {
3902
+ key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
3903
+ value: security.csp.value
3904
+ };
3905
+ }
3906
+ __name(getFarmSecurityHeader, "getFarmSecurityHeader");
3907
+ function normalizeDirectiveName(value) {
3908
+ const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
3909
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
3910
+ throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
3911
+ }
3912
+ return name;
3913
+ }
3914
+ __name(normalizeDirectiveName, "normalizeDirectiveName");
3915
+ function validateDirectiveValue(value) {
3916
+ if (typeof value !== "string") {
3917
+ throw new TypeError("security.csp directive values must be strings or booleans.");
3918
+ }
3919
+ const normalized = value.trim();
3920
+ if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
3921
+ throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
3922
+ }
3923
+ return normalized;
3924
+ }
3925
+ __name(validateDirectiveValue, "validateDirectiveValue");
3926
+ function validateSerializedCsp(value) {
3927
+ if (typeof value !== "string") {
3928
+ throw new TypeError("security.csp policy must be a non-empty single-line string.");
3929
+ }
3930
+ const normalized = value.trim().replace(/;+$/g, "").trim();
3931
+ if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
3932
+ throw new TypeError("security.csp policy must be a non-empty single-line string.");
3933
+ }
3934
+ return normalized;
3935
+ }
3936
+ __name(validateSerializedCsp, "validateSerializedCsp");
3937
+ function validateReportOnly(value) {
3938
+ if (value === void 0) return false;
3939
+ if (typeof value !== "boolean") {
3940
+ throw new TypeError("security.csp.reportOnly must be a boolean.");
3941
+ }
3942
+ return value;
3943
+ }
3944
+ __name(validateReportOnly, "validateReportOnly");
3945
+ function isPlainRecord(value) {
3946
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
3947
+ const prototype = Object.getPrototypeOf(value);
3948
+ return prototype === Object.prototype || prototype === null;
3949
+ }
3950
+ __name(isPlainRecord, "isPlainRecord");
3951
+
3820
3952
  // src/config.ts
3821
3953
  var FARM_RESOLVED_CUSTOM_CONTEXT = /* @__PURE__ */ Symbol.for("farm.resolvedCustomContext");
3822
3954
  function normalizeDeployTarget(target) {
@@ -4092,6 +4224,8 @@ async function resolveConfig(userConfig, mode) {
4092
4224
  const routeRules = normalizeRouteRules(userConfig.routeRules);
4093
4225
  const routeRuleRedirects = routeRulesToRedirects(routeRules);
4094
4226
  const routeRuleHeaders = routeRulesToHeaders(routeRules);
4227
+ const security = resolveFarmSecurityConfig(userConfig.security);
4228
+ const securityHeader = getFarmSecurityHeader(security);
4095
4229
  const deploy = resolveDeployConfig(userConfig);
4096
4230
  const root = userConfig.root || process.cwd();
4097
4231
  const srcDir = userConfig.srcDir || "src";
@@ -4147,7 +4281,11 @@ async function resolveConfig(userConfig, mode) {
4147
4281
  trailingSlash: userConfig.trailingSlash ?? false,
4148
4282
  redirects: /* @__PURE__ */ __name(() => [...redirects, ...routeRuleRedirects], "redirects"),
4149
4283
  rewrites: /* @__PURE__ */ __name(() => rewrites, "rewrites"),
4150
- headers: /* @__PURE__ */ __name(() => [...headers, ...routeRuleHeaders], "headers"),
4284
+ headers: /* @__PURE__ */ __name(() => [
4285
+ ...headers,
4286
+ ...routeRuleHeaders,
4287
+ ...securityHeader ? [{ source: "/*", headers: [securityHeader] }] : []
4288
+ ], "headers"),
4151
4289
  routeRules,
4152
4290
  images: resolveFarmImageConfig(userConfig.images),
4153
4291
  performance: resolveFarmPerformanceConfig(userConfig.performance),
@@ -4166,6 +4304,7 @@ async function resolveConfig(userConfig, mode) {
4166
4304
  notFound: userConfig.notFound || {},
4167
4305
  context: userConfig.context || (() => void 0),
4168
4306
  serverActions: resolveServerActionsConfig(userConfig.serverActions),
4307
+ security,
4169
4308
  deploymentId,
4170
4309
  output: userConfig.output || "standalone",
4171
4310
  distDir: userConfig.distDir || ".farm",