@farm.js/core 0.1.16 → 0.1.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 (180) hide show
  1. package/dist/agent-runtime.d.mts +3 -3
  2. package/dist/agent-runtime.d.ts +3 -3
  3. package/dist/api/client.cjs +62 -28
  4. package/dist/api/client.d.mts +3 -3
  5. package/dist/api/client.d.ts +3 -3
  6. package/dist/api/client.mjs +3 -3
  7. package/dist/api/route-manager.cjs +69 -32
  8. package/dist/api/route-manager.d.mts +3 -3
  9. package/dist/api/route-manager.d.ts +3 -3
  10. package/dist/api/route-manager.mjs +5 -5
  11. package/dist/api/runtime.cjs +65 -29
  12. package/dist/api/runtime.d.mts +3 -3
  13. package/dist/api/runtime.d.ts +3 -3
  14. package/dist/api/runtime.mjs +6 -3
  15. package/dist/{api-client-B-n3pm_Q.d.mts → api-client-Cx54IR5g.d.mts} +2 -2
  16. package/dist/{api-client-C0_NZEBl.d.ts → api-client-DykpaKcY.d.ts} +2 -2
  17. package/dist/api.cjs +106 -33
  18. package/dist/api.d.mts +5 -5
  19. package/dist/api.d.ts +5 -5
  20. package/dist/api.mjs +8 -8
  21. package/dist/{app-AyjEsCBq.d.ts → app-BHY_10Lm.d.ts} +3 -3
  22. package/dist/{app-CYPHeOo_.d.mts → app-BMk0do23.d.mts} +3 -3
  23. package/dist/app-markdown.d.mts +4 -4
  24. package/dist/app-markdown.d.ts +4 -4
  25. package/dist/app-markdown.mjs +3 -3
  26. package/dist/cache.cjs +62 -28
  27. package/dist/cache.d.mts +11 -1
  28. package/dist/cache.d.ts +11 -1
  29. package/dist/cache.mjs +1 -1
  30. package/dist/{chunk-7HDZYYS4.mjs → chunk-4OOBRCJX.mjs} +27 -5
  31. package/dist/{chunk-NHHKW2T6.mjs → chunk-56DAX2BE.mjs} +170 -52
  32. package/dist/{chunk-B76DT5Y6.mjs → chunk-57J3Y7Y3.mjs} +1 -1
  33. package/dist/{chunk-MOQNHLTS.mjs → chunk-5QOEPUYE.mjs} +5 -2
  34. package/dist/{chunk-HKLRP3BN.mjs → chunk-5SPPCN5J.mjs} +1 -1
  35. package/dist/{chunk-LUC2FAGW.mjs → chunk-6VQIKZZO.mjs} +1 -1
  36. package/dist/{chunk-7ZWL7XOU.mjs → chunk-76DG3LF3.mjs} +1 -1
  37. package/dist/{chunk-EWDK36MM.mjs → chunk-A72YEUZ3.mjs} +1 -1
  38. package/dist/{chunk-ZHOIQC6U.mjs → chunk-ATERBVHQ.mjs} +2 -2
  39. package/dist/{chunk-27JNCYEK.mjs → chunk-EN7WTEAY.mjs} +2 -2
  40. package/dist/{chunk-IGO2HEV7.mjs → chunk-F6SJAKFJ.mjs} +62 -28
  41. package/dist/{chunk-GSDIZACQ.mjs → chunk-FG5H2VCJ.mjs} +2 -2
  42. package/dist/{chunk-LZK5CXDW.mjs → chunk-KLSSO6YD.mjs} +2 -2
  43. package/dist/{chunk-KUO3GBPK.mjs → chunk-L6V3P73N.mjs} +1 -1
  44. package/dist/{chunk-TYVVIQ5M.mjs → chunk-MVIWBEJF.mjs} +32 -25
  45. package/dist/{chunk-KTGFMHET.mjs → chunk-N6UROPT7.mjs} +1 -1
  46. package/dist/{chunk-NDD2YVGU.mjs → chunk-NRVGEI5I.mjs} +10 -3
  47. package/dist/{chunk-IXTEENRS.mjs → chunk-QGVJVSNX.mjs} +5 -5
  48. package/dist/{chunk-6SCB2MXB.mjs → chunk-SXHV42UQ.mjs} +16 -1
  49. package/dist/{chunk-OWTIOHON.mjs → chunk-SYGGPS4A.mjs} +2 -2
  50. package/dist/{chunk-NC333MFA.mjs → chunk-TSWW5BVH.mjs} +7 -4
  51. package/dist/{chunk-LK6FGAQR.mjs → chunk-UDBJCUPA.mjs} +7 -4
  52. package/dist/{chunk-NUD6XBMO.mjs → chunk-UTBVHYS3.mjs} +2 -2
  53. package/dist/{chunk-76MNRHTS.mjs → chunk-UUYF3CHN.mjs} +2 -2
  54. package/dist/{chunk-VVTREAG5.mjs → chunk-WD4YXVLV.mjs} +11 -3
  55. package/dist/{chunk-UQZPTIML.mjs → chunk-WD5PNSOB.mjs} +2 -2
  56. package/dist/{chunk-DPZUDPVJ.mjs → chunk-XP777LRD.mjs} +1 -1
  57. package/dist/{chunk-KATQ6I56.mjs → chunk-XWAYMDLB.mjs} +1 -1
  58. package/dist/{chunk-IL5RWYK7.mjs → chunk-YD4J4XCI.mjs} +1 -1
  59. package/dist/{chunk-Q3MDL7TM.mjs → chunk-ZCNJKLA2.mjs} +30 -11
  60. package/dist/{client-plugins-CqVtZi5X.d.ts → client-plugins-C089bQhN.d.ts} +2 -2
  61. package/dist/{client-plugins-CIPRtSsW.d.mts → client-plugins-JXXmZliS.d.mts} +2 -2
  62. package/dist/client-plugins.d.mts +3 -3
  63. package/dist/client-plugins.d.ts +3 -3
  64. package/dist/client.cjs +62 -28
  65. package/dist/client.d.mts +8 -8
  66. package/dist/client.d.ts +8 -8
  67. package/dist/client.mjs +6 -6
  68. package/dist/config.d.mts +3 -3
  69. package/dist/config.d.ts +3 -3
  70. package/dist/cron.mjs +2 -2
  71. package/dist/{devtools-IU7LKZOH.mjs → devtools-UFVTMQX5.mjs} +7 -7
  72. package/dist/docs.cjs +18 -10
  73. package/dist/docs.mjs +9 -9
  74. package/dist/{endpoint-kSAxE52R.d.ts → endpoint-1zA994xL.d.ts} +1 -1
  75. package/dist/{endpoint-Bu3XgeMK.d.mts → endpoint-DAc96i93.d.mts} +1 -1
  76. package/dist/env.cjs +39 -5
  77. package/dist/env.d.mts +5 -3
  78. package/dist/env.d.ts +5 -3
  79. package/dist/env.mjs +2 -1
  80. package/dist/index.cjs +311 -93
  81. package/dist/index.d.mts +14 -14
  82. package/dist/index.d.ts +14 -14
  83. package/dist/index.mjs +34 -34
  84. package/dist/integrations.d.mts +3 -3
  85. package/dist/integrations.d.ts +3 -3
  86. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  87. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  88. package/dist/internal/app-markdown-runtime.mjs +2 -2
  89. package/dist/internal/build-runtime.cjs +342 -121
  90. package/dist/internal/build-runtime.d.mts +5 -5
  91. package/dist/internal/build-runtime.d.ts +5 -5
  92. package/dist/internal/build-runtime.mjs +23 -23
  93. package/dist/internal/cli-runtime.cjs +77 -31
  94. package/dist/internal/cli-runtime.mjs +13 -13
  95. package/dist/internal/client-error-overlay.cjs +1 -1
  96. package/dist/internal/client-error-overlay.mjs +1 -1
  97. package/dist/internal/compression-runtime.d.mts +3 -3
  98. package/dist/internal/compression-runtime.d.ts +3 -3
  99. package/dist/internal/config-runtime.cjs +14 -2
  100. package/dist/internal/config-runtime.d.mts +4 -4
  101. package/dist/internal/config-runtime.d.ts +4 -4
  102. package/dist/internal/config-runtime.mjs +7 -7
  103. package/dist/internal/product-telemetry-runtime.cjs +1 -1
  104. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  105. package/dist/internal/production-runtime.cjs +101 -41
  106. package/dist/internal/production-runtime.d.mts +9 -9
  107. package/dist/internal/production-runtime.d.ts +9 -9
  108. package/dist/internal/production-runtime.mjs +6 -6
  109. package/dist/markdown.cjs +16 -1
  110. package/dist/markdown.mjs +1 -1
  111. package/dist/{metadata-8g__AMPM.d.ts → metadata-BcNJP4fq.d.ts} +1 -1
  112. package/dist/{metadata-OMX6wFNf.d.mts → metadata-C1Z9vLbb.d.mts} +1 -1
  113. package/dist/middleware.cjs +10 -3
  114. package/dist/middleware.d.mts +5 -5
  115. package/dist/middleware.d.ts +5 -5
  116. package/dist/middleware.mjs +4 -4
  117. package/dist/{nitro-3N4ZXRYM.mjs → nitro-CVZ36JM5.mjs} +4 -4
  118. package/dist/plugin.cjs +256 -105
  119. package/dist/plugin.d.mts +3 -3
  120. package/dist/plugin.d.ts +3 -3
  121. package/dist/plugin.mjs +19 -19
  122. package/dist/{production-runtime-W3M0eNDV.d.mts → production-runtime-jcrTlRTb.d.mts} +1 -1
  123. package/dist/{production-runtime-BJh7o6Cr.d.ts → production-runtime-oKmC0WU-.d.ts} +1 -1
  124. package/dist/{render-plan-io7pvDNc.d.mts → render-plan-BLIfc4jt.d.mts} +1 -1
  125. package/dist/{render-plan-Be4ZGTJP.d.ts → render-plan-DOB9cV-h.d.ts} +1 -1
  126. package/dist/renderer-client.cjs +62 -28
  127. package/dist/renderer-client.d.mts +5 -5
  128. package/dist/renderer-client.d.ts +5 -5
  129. package/dist/renderer-client.mjs +3 -3
  130. package/dist/{request-DZkHYQ89.d.mts → request-Cr53NRHr.d.mts} +1 -1
  131. package/dist/{request-G8JhKr4F.d.ts → request-Dt2gNuQD.d.ts} +1 -1
  132. package/dist/request.d.mts +4 -4
  133. package/dist/request.d.ts +4 -4
  134. package/dist/{route-C_eLaFTZ.d.mts → route-B0XrsrFk.d.mts} +1 -1
  135. package/dist/{route-BxNJT447.d.ts → route-DOEpbyWZ.d.ts} +1 -1
  136. package/dist/{route-rendering-BcLLPJgN.d.ts → route-rendering-CWYd8Mv1.d.ts} +1 -1
  137. package/dist/{route-rendering-CbAKr1TY.d.mts → route-rendering-CeFBEAoZ.d.mts} +1 -1
  138. package/dist/routes.cjs +68 -31
  139. package/dist/routes.d.mts +4 -4
  140. package/dist/routes.d.ts +4 -4
  141. package/dist/routes.mjs +2 -2
  142. package/dist/server-fn-client.d.mts +3 -3
  143. package/dist/server-fn-client.d.ts +3 -3
  144. package/dist/server-fn.cjs +72 -30
  145. package/dist/server-fn.d.mts +1 -1
  146. package/dist/server-fn.d.ts +1 -1
  147. package/dist/server-fn.mjs +2 -2
  148. package/dist/server-plugins.d.mts +4 -4
  149. package/dist/server-plugins.d.ts +4 -4
  150. package/dist/server-query-client.cjs +62 -28
  151. package/dist/server-query-client.d.mts +1 -1
  152. package/dist/server-query-client.d.ts +1 -1
  153. package/dist/server-query-client.mjs +4 -4
  154. package/dist/server-query.cjs +72 -30
  155. package/dist/server-query.d.mts +1 -1
  156. package/dist/server-query.d.ts +1 -1
  157. package/dist/server-query.mjs +3 -3
  158. package/dist/server.cjs +239 -80
  159. package/dist/server.d.mts +9 -9
  160. package/dist/server.d.ts +9 -9
  161. package/dist/server.mjs +22 -22
  162. package/dist/{spa-router-BcS_4nqm.d.mts → spa-router-CQWiYGxS.d.mts} +2 -2
  163. package/dist/{spa-router-BzFBUJkn.d.ts → spa-router-Wjiw-8hB.d.ts} +2 -2
  164. package/dist/testing.cjs +73 -32
  165. package/dist/testing.d.mts +3 -3
  166. package/dist/testing.d.ts +3 -3
  167. package/dist/testing.mjs +11 -7
  168. package/dist/{utils-C4yrAhNc.d.ts → utils-B0XJmG_b.d.ts} +1 -1
  169. package/dist/{utils-5kQP1mFR.d.mts → utils-uUxF0K0P.d.mts} +1 -1
  170. package/dist/version.cjs +1 -1
  171. package/dist/version.mjs +1 -1
  172. package/dist/vite.cjs +260 -109
  173. package/dist/vite.d.mts +3 -3
  174. package/dist/vite.d.ts +3 -3
  175. package/dist/vite.mjs +19 -19
  176. package/dist/workflows.mjs +2 -2
  177. package/package.json +2 -2
  178. package/dist/{chunk-VO5SCWF5.mjs → chunk-BNGS6KJ6.mjs} +0 -0
  179. package/dist/{chunk-MUUZJLCI.mjs → chunk-EGJDUF4Q.mjs} +3 -3
  180. package/dist/{chunk-4L7SZOHZ.mjs → chunk-YHOCRI4H.mjs} +3 -3
package/dist/docs.cjs CHANGED
@@ -3468,6 +3468,7 @@ function createFarmDocsHandler(docs, options) {
3468
3468
  if (!isFarmDocsRequest(docs, request)) return null;
3469
3469
  const page = loadPage(contentDir, docs, request);
3470
3470
  if (!page) return null;
3471
+ const negotiatesAccept = !requestUrl.pathname.endsWith(".md");
3471
3472
  if (shouldReturnMarkdown(request)) {
3472
3473
  const origin = new URL(request.url).origin;
3473
3474
  return omitFarmDocsHeadBody(
@@ -3482,7 +3483,8 @@ function createFarmDocsHandler(docs, options) {
3482
3483
  status: 200,
3483
3484
  headers: {
3484
3485
  "Content-Type": "text/markdown; charset=utf-8",
3485
- "Cache-Control": "public, max-age=60"
3486
+ "Cache-Control": "public, max-age=60",
3487
+ ...negotiatesAccept ? { Vary: "Accept" } : {}
3486
3488
  }
3487
3489
  }
3488
3490
  )
@@ -3512,6 +3514,7 @@ function createFarmDocsHandler(docs, options) {
3512
3514
  headers: {
3513
3515
  "Content-Type": "text/html; charset=utf-8",
3514
3516
  "Cache-Control": "public, s-maxage=60, stale-while-revalidate=300",
3517
+ Vary: "Accept",
3515
3518
  ...fontPreloadHeader ? { Link: fontPreloadHeader } : {}
3516
3519
  }
3517
3520
  }
@@ -4635,6 +4638,19 @@ function normalizeMatcher(matcher) {
4635
4638
  }
4636
4639
  __name(normalizeMatcher, "normalizeMatcher");
4637
4640
 
4641
+ // src/utils/runtime-env.ts
4642
+ function getFarmRuntimeBindings() {
4643
+ const runtimeBindings = globalThis.__env__;
4644
+ return runtimeBindings && typeof runtimeBindings === "object" ? runtimeBindings : void 0;
4645
+ }
4646
+ __name(getFarmRuntimeBindings, "getFarmRuntimeBindings");
4647
+ function readFarmEnvironmentValue(name) {
4648
+ const runtimeValue = getFarmRuntimeBindings()?.[name];
4649
+ if (typeof runtimeValue === "string") return runtimeValue;
4650
+ return typeof process !== "undefined" ? process.env?.[name] : void 0;
4651
+ }
4652
+ __name(readFarmEnvironmentValue, "readFarmEnvironmentValue");
4653
+
4638
4654
  // src/workflows.ts
4639
4655
  var import_node_path6 = require("path");
4640
4656
 
@@ -4703,9 +4719,8 @@ __name(readServerEnvKey, "readServerEnvKey");
4703
4719
  function readRuntimeServerEnv(env2) {
4704
4720
  const state = env2[FARM_ENV_RUNTIME_SYMBOL];
4705
4721
  if (!state) return;
4706
- const source = getProcessEnv();
4707
4722
  for (const [key, type] of Object.entries(state.pending)) {
4708
- const raw = source[key];
4723
+ const raw = readFarmEnvironmentValue(key);
4709
4724
  if (raw === void 0) continue;
4710
4725
  env2.server[key] = coerceRuntimeEnvValue(raw, type);
4711
4726
  delete state.pending[key];
@@ -4805,13 +4820,6 @@ function isRecord(value) {
4805
4820
  return !!value && typeof value === "object" && !Array.isArray(value);
4806
4821
  }
4807
4822
  __name(isRecord, "isRecord");
4808
- function getProcessEnv() {
4809
- if (typeof process !== "undefined" && process.env) {
4810
- return process.env;
4811
- }
4812
- return {};
4813
- }
4814
- __name(getProcessEnv, "getProcessEnv");
4815
4823
 
4816
4824
  // src/app-markdown-config.ts
4817
4825
  var import_node_path7 = __toESM(require("path"));
package/dist/docs.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createFarmDocsAdapterHandler,
5
5
  hasFarmDocsRuntimeAdapter,
6
6
  isFarmDocsAPIRequest
7
- } from "./chunk-NUD6XBMO.mjs";
7
+ } from "./chunk-UTBVHYS3.mjs";
8
8
  import {
9
9
  createFarmDocsHandler,
10
10
  discoverFarmDocsPages,
@@ -13,10 +13,10 @@ import {
13
13
  isFarmDocsRequest,
14
14
  loadFarmDocsPage,
15
15
  resolveFarmDocsContentDir
16
- } from "./chunk-MOQNHLTS.mjs";
16
+ } from "./chunk-5QOEPUYE.mjs";
17
17
  import "./chunk-UP4CW6WP.mjs";
18
18
  import "./chunk-TFQG7TBC.mjs";
19
- import "./chunk-IXTEENRS.mjs";
19
+ import "./chunk-QGVJVSNX.mjs";
20
20
  import "./chunk-XZNTNMHT.mjs";
21
21
  import "./chunk-TVGP4BBZ.mjs";
22
22
  import "./chunk-FZC7EEPM.mjs";
@@ -24,16 +24,16 @@ import "./chunk-JBSVKMC5.mjs";
24
24
  import "./chunk-7WPA7GBZ.mjs";
25
25
  import "./chunk-IILNZK5G.mjs";
26
26
  import "./chunk-OLYK7EAK.mjs";
27
- import "./chunk-Q3MDL7TM.mjs";
27
+ import "./chunk-ZCNJKLA2.mjs";
28
28
  import "./chunk-G2KY33I6.mjs";
29
- import "./chunk-4L7SZOHZ.mjs";
29
+ import "./chunk-YHOCRI4H.mjs";
30
30
  import "./chunk-QCFFHV5H.mjs";
31
- import "./chunk-7HDZYYS4.mjs";
31
+ import "./chunk-4OOBRCJX.mjs";
32
32
  import "./chunk-FA2W42OV.mjs";
33
- import "./chunk-6SCB2MXB.mjs";
34
- import "./chunk-MUUZJLCI.mjs";
35
- import "./chunk-ONUEYC6N.mjs";
33
+ import "./chunk-SXHV42UQ.mjs";
34
+ import "./chunk-EGJDUF4Q.mjs";
36
35
  import "./chunk-2UC36WAC.mjs";
36
+ import "./chunk-ONUEYC6N.mjs";
37
37
  import "./chunk-AELACLOB.mjs";
38
38
  import "./chunk-JLCQGPXE.mjs";
39
39
  import "./chunk-FP2INE7H.mjs";
@@ -364,4 +364,4 @@ declare function OPTIONS<T = any>(handler: EndpointHandler<never, never, never,
364
364
  declare function OPTIONS<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
365
365
  declare function OPTIONS<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
366
366
 
367
- export { type AnyEndpointMiddleware as A, type MultipartValues as B, type TypedFormData as C, DELETE as D, type EndpointMiddlewareResult as E, type MultipartSchema as F, GET as G, HEAD as H, type InferEndpointMiddlewareContext as I, type FarmStreamResponse as J, type FarmAPIStream as K, multipart as L, type MultipartField as M, isMultipartSchema as N, OPTIONS as O, POST as P, QUERY as Q, type RouteSchema as R, toFormData as S, type TypedEndpoint as T, jsonStream as U, isJSONStreamResponse as V, readJSONStream as W, isFarmAPIStream as X, type OpenAPISecurityMode as Y, type RouteSchemaOutput as a, type EndpointMCPOptions as b, type RouteSchemaInput as c, type EndpointMCPMetadata as d, EndpointFailure as e, type EndpointOpenAPIMetadata as f, type EndpointErrorSchema as g, type EndpointErrorDefinition as h, type EndpointErrorDefinitions as i, type EndpointErrorContracts as j, type EndpointErrorHandler as k, type EndpointFail as l, isEndpointFailure as m, type EndpointParamValue as n, type EndpointParams as o, parseRouteSchema as p, type EndpointMiddlewareContext as q, type EndpointMiddleware as r, type EndpointInvalidationTarget as s, type EndpointInvalidationContext as t, type EndpointInvalidations as u, type EndpointOptions as v, type EndpointHandler as w, createEndpoint as x, PUT as y, PATCH as z };
367
+ export { type AnyEndpointMiddleware as A, type MultipartValues as B, type TypedFormData as C, DELETE as D, type EndpointMiddlewareResult as E, type MultipartSchema as F, GET as G, HEAD as H, type InferEndpointMiddlewareContext as I, type FarmStreamResponse as J, type FarmAPIStream as K, multipart as L, type MultipartField as M, isMultipartSchema as N, OPTIONS as O, POST as P, QUERY as Q, type RouteSchema as R, toFormData as S, type TypedEndpoint as T, jsonStream as U, isJSONStreamResponse as V, readJSONStream as W, isFarmAPIStream as X, type OpenAPISecurityMode as Y, type RouteSchemaOutput as a, type EndpointMCPOptions as b, type RouteSchemaInput as c, type EndpointMCPMetadata as d, EndpointFailure as e, type EndpointOpenAPIMetadata as f, type EndpointErrorSchema as g, type EndpointErrorDefinition as h, isEndpointFailure as i, type EndpointErrorDefinitions as j, type EndpointErrorContracts as k, type EndpointErrorHandler as l, type EndpointFail as m, type EndpointParamValue as n, type EndpointParams as o, parseRouteSchema as p, type EndpointMiddlewareContext as q, type EndpointMiddleware as r, type EndpointInvalidationTarget as s, type EndpointInvalidationContext as t, type EndpointInvalidations as u, type EndpointOptions as v, type EndpointHandler as w, createEndpoint as x, PUT as y, PATCH as z };
@@ -364,4 +364,4 @@ declare function OPTIONS<T = any>(handler: EndpointHandler<never, never, never,
364
364
  declare function OPTIONS<const TOptions extends MethodlessEndpointOptions, TResponse = any>(options: TOptions, handler: ValidatedEndpointHandlerFromOptions<TOptions, TResponse>): CreatedEndpointFromOptions<TOptions, TResponse>;
365
365
  declare function OPTIONS<TBody extends AnySchema = never, TQuery extends AnySchema = never, THeaders extends AnySchema = never, TResponse = any>(options: Omit<EndpointOptions<TBody, TQuery, THeaders, readonly []>, "method">, handler: EndpointHandler<TBody, TQuery, THeaders, TResponse>): CreatedEndpoint<TBody, TQuery, THeaders, TResponse>;
366
366
 
367
- export { type AnyEndpointMiddleware as A, type MultipartValues as B, type TypedFormData as C, DELETE as D, type EndpointMiddlewareResult as E, type MultipartSchema as F, GET as G, HEAD as H, type InferEndpointMiddlewareContext as I, type FarmStreamResponse as J, type FarmAPIStream as K, multipart as L, type MultipartField as M, isMultipartSchema as N, OPTIONS as O, POST as P, QUERY as Q, type RouteSchema as R, toFormData as S, type TypedEndpoint as T, jsonStream as U, isJSONStreamResponse as V, readJSONStream as W, isFarmAPIStream as X, type OpenAPISecurityMode as Y, type RouteSchemaOutput as a, type EndpointMCPOptions as b, type RouteSchemaInput as c, type EndpointMCPMetadata as d, EndpointFailure as e, type EndpointOpenAPIMetadata as f, type EndpointErrorSchema as g, type EndpointErrorDefinition as h, type EndpointErrorDefinitions as i, type EndpointErrorContracts as j, type EndpointErrorHandler as k, type EndpointFail as l, isEndpointFailure as m, type EndpointParamValue as n, type EndpointParams as o, parseRouteSchema as p, type EndpointMiddlewareContext as q, type EndpointMiddleware as r, type EndpointInvalidationTarget as s, type EndpointInvalidationContext as t, type EndpointInvalidations as u, type EndpointOptions as v, type EndpointHandler as w, createEndpoint as x, PUT as y, PATCH as z };
367
+ export { type AnyEndpointMiddleware as A, type MultipartValues as B, type TypedFormData as C, DELETE as D, type EndpointMiddlewareResult as E, type MultipartSchema as F, GET as G, HEAD as H, type InferEndpointMiddlewareContext as I, type FarmStreamResponse as J, type FarmAPIStream as K, multipart as L, type MultipartField as M, isMultipartSchema as N, OPTIONS as O, POST as P, QUERY as Q, type RouteSchema as R, toFormData as S, type TypedEndpoint as T, jsonStream as U, isJSONStreamResponse as V, readJSONStream as W, isFarmAPIStream as X, type OpenAPISecurityMode as Y, type RouteSchemaOutput as a, type EndpointMCPOptions as b, type RouteSchemaInput as c, type EndpointMCPMetadata as d, EndpointFailure as e, type EndpointOpenAPIMetadata as f, type EndpointErrorSchema as g, type EndpointErrorDefinition as h, isEndpointFailure as i, type EndpointErrorDefinitions as j, type EndpointErrorContracts as k, type EndpointErrorHandler as l, type EndpointFail as m, type EndpointParamValue as n, type EndpointParams as o, parseRouteSchema as p, type EndpointMiddlewareContext as q, type EndpointMiddleware as r, type EndpointInvalidationTarget as s, type EndpointInvalidationContext as t, type EndpointInvalidations as u, type EndpointOptions as v, type EndpointHandler as w, createEndpoint as x, PUT as y, PATCH as z };
package/dist/env.cjs CHANGED
@@ -32,6 +32,21 @@ __export(env_exports, {
32
32
  setEnv: () => setEnv
33
33
  });
34
34
  module.exports = __toCommonJS(env_exports);
35
+
36
+ // src/utils/runtime-env.ts
37
+ function getFarmRuntimeBindings() {
38
+ const runtimeBindings = globalThis.__env__;
39
+ return runtimeBindings && typeof runtimeBindings === "object" ? runtimeBindings : void 0;
40
+ }
41
+ __name(getFarmRuntimeBindings, "getFarmRuntimeBindings");
42
+ function readFarmEnvironmentValue(name) {
43
+ const runtimeValue = getFarmRuntimeBindings()?.[name];
44
+ if (typeof runtimeValue === "string") return runtimeValue;
45
+ return typeof process !== "undefined" ? process.env?.[name] : void 0;
46
+ }
47
+ __name(readFarmEnvironmentValue, "readFarmEnvironmentValue");
48
+
49
+ // src/env.ts
35
50
  var FARM_ENV_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env");
36
51
  var FARM_ENV_RUNTIME_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env.runtime");
37
52
  var farmEnvGlobal = globalThis;
@@ -49,10 +64,12 @@ function createBundledEnv(env2, source = getProcessEnv()) {
49
64
  const server = {};
50
65
  const runtime = {};
51
66
  for (const [key, value] of Object.entries(resolved.server)) {
52
- if (source[key] === void 0) {
53
- server[key] = value;
67
+ const raw = source[key];
68
+ const type = getRuntimeEnvType(value);
69
+ if (raw !== void 0 && isSameEnvValue(coerceRuntimeEnvValue(raw, type), value)) {
70
+ runtime[key] = type;
54
71
  } else {
55
- runtime[key] = getRuntimeEnvType(value);
72
+ server[key] = value;
56
73
  }
57
74
  }
58
75
  return {
@@ -177,9 +194,8 @@ __name(readServerEnvKey, "readServerEnvKey");
177
194
  function readRuntimeServerEnv(env2) {
178
195
  const state = env2[FARM_ENV_RUNTIME_SYMBOL];
179
196
  if (!state) return;
180
- const source = getProcessEnv();
181
197
  for (const [key, type] of Object.entries(state.pending)) {
182
- const raw = source[key];
198
+ const raw = readFarmEnvironmentValue(key);
183
199
  if (raw === void 0) continue;
184
200
  env2.server[key] = coerceRuntimeEnvValue(raw, type);
185
201
  delete state.pending[key];
@@ -213,6 +229,24 @@ function coerceRuntimeEnvValue(raw, type) {
213
229
  return raw;
214
230
  }
215
231
  __name(coerceRuntimeEnvValue, "coerceRuntimeEnvValue");
232
+ function isSameEnvValue(left, right) {
233
+ if (Object.is(left, right)) return true;
234
+ if (Array.isArray(left) || Array.isArray(right)) {
235
+ return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((item, index) => isSameEnvValue(item, right[index]));
236
+ }
237
+ if (!isPlainObject(left) || !isPlainObject(right)) return false;
238
+ const keys = Object.keys(left);
239
+ return keys.length === Object.keys(right).length && keys.every(
240
+ (key) => Object.prototype.hasOwnProperty.call(right, key) && isSameEnvValue(left[key], right[key])
241
+ );
242
+ }
243
+ __name(isSameEnvValue, "isSameEnvValue");
244
+ function isPlainObject(value) {
245
+ if (!value || typeof value !== "object") return false;
246
+ const prototype = Object.getPrototypeOf(value);
247
+ return prototype === Object.prototype || prototype === null;
248
+ }
249
+ __name(isPlainObject, "isPlainObject");
216
250
  function prepareEnv(env2) {
217
251
  const normalized = normalizeResolvedEnv(env2);
218
252
  const runtime = env2.runtime?.server;
package/dist/env.d.mts CHANGED
@@ -45,9 +45,11 @@ interface BundledFarmEnv extends ResolvedFarmEnv {
45
45
  declare function resolveEnv<TConfig extends FarmEnvConfig<any, any> | undefined>(config: TConfig, source?: Record<string, string | undefined>): InferEnv<NonNullable<TConfig>>;
46
46
  /**
47
47
  * Prepare resolved env for a server bundle. Server values that came from the
48
- * build environment are left out and read from `process.env` when the server
49
- * uses them, so secrets never land in build output and a restart picks up a
50
- * rotated value. Values a parser produced without an env var (defaults) stay.
48
+ * build environment are left out and read from the server's environment when
49
+ * the server uses them, so secrets never land in build output and a restart
50
+ * picks up a rotated value. Values a parser produced without an env var
51
+ * (defaults) stay, and so do values the runtime cannot rebuild from the raw
52
+ * string, because the parser itself does not run in the server bundle.
51
53
  */
52
54
  declare function createBundledEnv(env: ResolvedFarmEnv | FarmEnvConfig<any, any> | undefined, source?: Record<string, string | undefined>): BundledFarmEnv;
53
55
  declare function setEnv(env: ResolvedFarmEnv | BundledFarmEnv): void;
package/dist/env.d.ts CHANGED
@@ -45,9 +45,11 @@ interface BundledFarmEnv extends ResolvedFarmEnv {
45
45
  declare function resolveEnv<TConfig extends FarmEnvConfig<any, any> | undefined>(config: TConfig, source?: Record<string, string | undefined>): InferEnv<NonNullable<TConfig>>;
46
46
  /**
47
47
  * Prepare resolved env for a server bundle. Server values that came from the
48
- * build environment are left out and read from `process.env` when the server
49
- * uses them, so secrets never land in build output and a restart picks up a
50
- * rotated value. Values a parser produced without an env var (defaults) stay.
48
+ * build environment are left out and read from the server's environment when
49
+ * the server uses them, so secrets never land in build output and a restart
50
+ * picks up a rotated value. Values a parser produced without an env var
51
+ * (defaults) stay, and so do values the runtime cannot rebuild from the raw
52
+ * string, because the parser itself does not run in the server bundle.
51
53
  */
52
54
  declare function createBundledEnv(env: ResolvedFarmEnv | FarmEnvConfig<any, any> | undefined, source?: Record<string, string | undefined>): BundledFarmEnv;
53
55
  declare function setEnv(env: ResolvedFarmEnv | BundledFarmEnv): void;
package/dist/env.mjs CHANGED
@@ -8,7 +8,8 @@ import {
8
8
  resolveEnv,
9
9
  serverEnv,
10
10
  setEnv
11
- } from "./chunk-7HDZYYS4.mjs";
11
+ } from "./chunk-4OOBRCJX.mjs";
12
+ import "./chunk-ONUEYC6N.mjs";
12
13
  import "./chunk-LPEX4YW6.mjs";
13
14
  export {
14
15
  createBundledEnv,