@farm.js/core 0.1.15 → 0.1.16

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 (123) hide show
  1. package/dist/agent-runtime.d.mts +5 -2
  2. package/dist/agent-runtime.d.ts +5 -2
  3. package/dist/api/client.d.mts +3 -2
  4. package/dist/api/client.d.ts +3 -2
  5. package/dist/api/route-manager.d.mts +5 -2
  6. package/dist/api/route-manager.d.ts +5 -2
  7. package/dist/api/runtime.d.mts +3 -2
  8. package/dist/api/runtime.d.ts +3 -2
  9. package/dist/{api-client-C8d7BZNp.d.mts → api-client-B-n3pm_Q.d.mts} +2 -1
  10. package/dist/{api-client-BWrEbxfO.d.ts → api-client-C0_NZEBl.d.ts} +2 -1
  11. package/dist/api.d.mts +7 -4
  12. package/dist/api.d.ts +7 -4
  13. package/dist/{app-wIYse61b.d.ts → app-AyjEsCBq.d.ts} +3 -3
  14. package/dist/{app-B3nVSjen.d.mts → app-CYPHeOo_.d.mts} +3 -3
  15. package/dist/app-markdown.d.mts +6 -3
  16. package/dist/app-markdown.d.ts +6 -3
  17. package/dist/{chunk-FOGLGRDS.mjs → chunk-7HDZYYS4.mjs} +100 -8
  18. package/dist/{chunk-UE75PB52.mjs → chunk-IL5RWYK7.mjs} +1 -1
  19. package/dist/{chunk-GNTPTTLA.mjs → chunk-IXTEENRS.mjs} +1 -1
  20. package/dist/{chunk-JRF3C33L.mjs → chunk-NHHKW2T6.mjs} +5 -4
  21. package/dist/{chunk-NJ47VORC.mjs → chunk-NUD6XBMO.mjs} +1 -1
  22. package/dist/{chunk-FBHGHMOA.mjs → chunk-TYVVIQ5M.mjs} +10 -7
  23. package/dist/{chunk-W7IVHTOP.mjs → chunk-UQZPTIML.mjs} +15 -2
  24. package/dist/{chunk-S3QW3BIS.mjs → chunk-VVTREAG5.mjs} +89 -4
  25. package/dist/{client-plugins-C1EgdoJM.d.mts → client-plugins-CIPRtSsW.d.mts} +16 -4
  26. package/dist/{client-plugins-CslwYp3E.d.ts → client-plugins-CqVtZi5X.d.ts} +16 -4
  27. package/dist/client-plugins.d.mts +5 -2
  28. package/dist/client-plugins.d.ts +5 -2
  29. package/dist/client.d.mts +8 -7
  30. package/dist/client.d.ts +8 -7
  31. package/dist/config.d.mts +5 -2
  32. package/dist/config.d.ts +5 -2
  33. package/dist/{devtools-PCGEBRSC.mjs → devtools-IU7LKZOH.mjs} +2 -2
  34. package/dist/docs.cjs +74 -3
  35. package/dist/docs.mjs +3 -3
  36. package/dist/{route-C6UClI1z.d.mts → endpoint-Bu3XgeMK.d.mts} +3 -128
  37. package/dist/{route-CHBaW55F.d.ts → endpoint-kSAxE52R.d.ts} +3 -128
  38. package/dist/env.cjs +101 -8
  39. package/dist/env.d.mts +20 -2
  40. package/dist/env.d.ts +20 -2
  41. package/dist/env.mjs +3 -1
  42. package/dist/index.cjs +212 -19
  43. package/dist/index.d.mts +16 -15
  44. package/dist/index.d.ts +16 -15
  45. package/dist/index.mjs +20 -8
  46. package/dist/integrations.d.mts +5 -2
  47. package/dist/integrations.d.ts +5 -2
  48. package/dist/internal/app-markdown-runtime.d.mts +5 -2
  49. package/dist/internal/app-markdown-runtime.d.ts +5 -2
  50. package/dist/internal/build-runtime.cjs +264 -169
  51. package/dist/internal/build-runtime.d.mts +7 -4
  52. package/dist/internal/build-runtime.d.ts +7 -4
  53. package/dist/internal/build-runtime.mjs +6 -6
  54. package/dist/internal/cli-runtime.cjs +68 -4
  55. package/dist/internal/cli-runtime.mjs +2 -2
  56. package/dist/internal/client-error-overlay.cjs +1 -1
  57. package/dist/internal/client-error-overlay.mjs +1 -1
  58. package/dist/internal/compression-runtime.d.mts +5 -2
  59. package/dist/internal/compression-runtime.d.ts +5 -2
  60. package/dist/internal/config-runtime.cjs +68 -4
  61. package/dist/internal/config-runtime.d.mts +6 -3
  62. package/dist/internal/config-runtime.d.ts +6 -3
  63. package/dist/internal/config-runtime.mjs +2 -2
  64. package/dist/internal/product-telemetry-runtime.cjs +1 -1
  65. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  66. package/dist/internal/production-runtime.d.mts +11 -8
  67. package/dist/internal/production-runtime.d.ts +11 -8
  68. package/dist/{metadata-BsUcOEXg.d.ts → metadata-8g__AMPM.d.ts} +1 -1
  69. package/dist/{metadata-B1bxCPUY.d.mts → metadata-OMX6wFNf.d.mts} +1 -1
  70. package/dist/middleware.d.mts +7 -4
  71. package/dist/middleware.d.ts +7 -4
  72. package/dist/{nitro-ICBP5APY.mjs → nitro-3N4ZXRYM.mjs} +5 -2
  73. package/dist/plugin.cjs +108 -7
  74. package/dist/plugin.d.mts +5 -2
  75. package/dist/plugin.d.ts +5 -2
  76. package/dist/plugin.mjs +3 -3
  77. package/dist/{production-runtime-CsNn2-zx.d.ts → production-runtime-BJh7o6Cr.d.ts} +1 -1
  78. package/dist/{production-runtime-BDllolVh.d.mts → production-runtime-W3M0eNDV.d.mts} +1 -1
  79. package/dist/{render-plan-EG4hNFjy.d.ts → render-plan-Be4ZGTJP.d.ts} +1 -1
  80. package/dist/{render-plan-CNUlzylR.d.mts → render-plan-io7pvDNc.d.mts} +1 -1
  81. package/dist/renderer-client.d.mts +5 -4
  82. package/dist/renderer-client.d.ts +5 -4
  83. package/dist/{request-Blh_f7Z3.d.mts → request-DZkHYQ89.d.mts} +1 -1
  84. package/dist/{request-DsVSQVfD.d.ts → request-G8JhKr4F.d.ts} +1 -1
  85. package/dist/request.d.mts +6 -3
  86. package/dist/request.d.ts +6 -3
  87. package/dist/route-BxNJT447.d.ts +128 -0
  88. package/dist/route-C_eLaFTZ.d.mts +128 -0
  89. package/dist/{route-rendering-hUETRCbM.d.ts → route-rendering-BcLLPJgN.d.ts} +1 -1
  90. package/dist/{route-rendering-LT4XSoQK.d.mts → route-rendering-CbAKr1TY.d.mts} +1 -1
  91. package/dist/routes.d.mts +4 -2
  92. package/dist/routes.d.ts +4 -2
  93. package/dist/server-fn-client.d.mts +3 -2
  94. package/dist/server-fn-client.d.ts +3 -2
  95. package/dist/server-fn.cjs +141 -3
  96. package/dist/server-fn.d.mts +72 -1
  97. package/dist/server-fn.d.ts +72 -1
  98. package/dist/server-fn.mjs +12 -1
  99. package/dist/server-plugins.d.mts +6 -3
  100. package/dist/server-plugins.d.ts +6 -3
  101. package/dist/server-query-client.d.mts +1 -0
  102. package/dist/server-query-client.d.ts +1 -0
  103. package/dist/server-query.cjs +60 -3
  104. package/dist/server-query.d.mts +6 -1
  105. package/dist/server-query.d.ts +6 -1
  106. package/dist/server-query.mjs +3 -2
  107. package/dist/server.cjs +161 -11
  108. package/dist/server.d.mts +9 -8
  109. package/dist/server.d.ts +9 -8
  110. package/dist/server.mjs +6 -6
  111. package/dist/{spa-router-csKR9Ebj.d.mts → spa-router-BcS_4nqm.d.mts} +2 -2
  112. package/dist/{spa-router-Y_2FSJQK.d.ts → spa-router-BzFBUJkn.d.ts} +2 -2
  113. package/dist/testing.d.mts +5 -3
  114. package/dist/testing.d.ts +5 -3
  115. package/dist/{utils-DR2wfZAn.d.mts → utils-5kQP1mFR.d.mts} +1 -1
  116. package/dist/{utils-jISOE9SD.d.ts → utils-C4yrAhNc.d.ts} +1 -1
  117. package/dist/version.cjs +1 -1
  118. package/dist/version.mjs +1 -1
  119. package/dist/vite.cjs +246 -149
  120. package/dist/vite.d.mts +5 -2
  121. package/dist/vite.d.ts +5 -2
  122. package/dist/vite.mjs +3 -3
  123. package/package.json +1 -1
package/dist/vite.cjs CHANGED
@@ -31,6 +31,212 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  ));
32
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
33
 
34
+ // src/env.ts
35
+ function createBundledEnv(env2, source = getProcessEnv()) {
36
+ const resolved = normalizeResolvedEnv(env2 ?? {});
37
+ const server = {};
38
+ const runtime3 = {};
39
+ for (const [key, value] of Object.entries(resolved.server)) {
40
+ if (source[key] === void 0) {
41
+ server[key] = value;
42
+ } else {
43
+ runtime3[key] = getRuntimeEnvType(value);
44
+ }
45
+ }
46
+ return {
47
+ server,
48
+ public: resolved.public,
49
+ ...Object.keys(runtime3).length > 0 ? { runtime: { server: runtime3 } } : {}
50
+ };
51
+ }
52
+ function createEnvProxy(scope) {
53
+ return new Proxy(
54
+ {},
55
+ {
56
+ get(_target, property) {
57
+ if (typeof property === "symbol") {
58
+ return void 0;
59
+ }
60
+ const env2 = getEnvScope(scope);
61
+ return scope === "server" ? readServerEnvKey(env2, property) : env2[property];
62
+ },
63
+ ownKeys() {
64
+ return Reflect.ownKeys(getEnvScope(scope));
65
+ },
66
+ getOwnPropertyDescriptor(_target, property) {
67
+ const env2 = getEnvScope(scope);
68
+ if (!(property in env2)) {
69
+ return void 0;
70
+ }
71
+ return {
72
+ enumerable: true,
73
+ configurable: true,
74
+ value: env2[property]
75
+ };
76
+ },
77
+ has(_target, property) {
78
+ return property in getEnvScope(scope);
79
+ }
80
+ }
81
+ );
82
+ }
83
+ function getEnvScope(scope) {
84
+ const env2 = getCurrentEnv();
85
+ if (scope === "server") {
86
+ assertServerEnvAccess();
87
+ readRuntimeServerEnv(env2);
88
+ }
89
+ return env2[scope] || {};
90
+ }
91
+ function readServerEnvKey(server, key) {
92
+ const value = server[key];
93
+ if (value === void 0) {
94
+ const state = getCurrentEnv()[FARM_ENV_RUNTIME_SYMBOL];
95
+ if (state && key in state.pending && !state.warned.has(key)) {
96
+ state.warned.add(key);
97
+ console.warn(
98
+ `[Farm] Server env "${key}" was set when this app was built but is not set where the server runs, so it reads as undefined. Farm reads server env at runtime and does not store it in the build output; set "${key}" in the server's environment.`
99
+ );
100
+ }
101
+ }
102
+ return value;
103
+ }
104
+ function readRuntimeServerEnv(env2) {
105
+ const state = env2[FARM_ENV_RUNTIME_SYMBOL];
106
+ if (!state) return;
107
+ const source = getProcessEnv();
108
+ for (const [key, type] of Object.entries(state.pending)) {
109
+ const raw = source[key];
110
+ if (raw === void 0) continue;
111
+ env2.server[key] = coerceRuntimeEnvValue(raw, type);
112
+ delete state.pending[key];
113
+ }
114
+ }
115
+ function getRuntimeEnvType(value) {
116
+ if (typeof value === "number") return "number";
117
+ if (typeof value === "boolean") return "boolean";
118
+ if (value !== null && typeof value === "object" && !(value instanceof Date)) return "json";
119
+ return "string";
120
+ }
121
+ function coerceRuntimeEnvValue(raw, type) {
122
+ if (type === "number") {
123
+ const value = Number(raw);
124
+ return raw.trim() !== "" && Number.isFinite(value) ? value : raw;
125
+ }
126
+ if (type === "boolean") {
127
+ if (/^(true|1)$/i.test(raw.trim())) return true;
128
+ if (/^(false|0|)$/i.test(raw.trim())) return false;
129
+ return raw;
130
+ }
131
+ if (type === "json") {
132
+ try {
133
+ return JSON.parse(raw);
134
+ } catch {
135
+ return raw;
136
+ }
137
+ }
138
+ return raw;
139
+ }
140
+ function prepareEnv(env2) {
141
+ const normalized = normalizeResolvedEnv(env2);
142
+ const runtime3 = env2.runtime?.server;
143
+ if (!isRecord(runtime3) || Object.keys(runtime3).length === 0) return normalized;
144
+ const prepared = { server: { ...normalized.server }, public: normalized.public };
145
+ Object.defineProperty(prepared, FARM_ENV_RUNTIME_SYMBOL, {
146
+ value: {
147
+ pending: { ...runtime3 },
148
+ warned: /* @__PURE__ */ new Set()
149
+ },
150
+ enumerable: false
151
+ });
152
+ return prepared;
153
+ }
154
+ function assertServerEnvAccess() {
155
+ if (typeof window !== "undefined") {
156
+ throw new Error("Farm server env is not available in the browser. Use publicEnv.");
157
+ }
158
+ }
159
+ function getInitialEnv() {
160
+ const injectedEnv = getInjectedEnv();
161
+ if (injectedEnv) {
162
+ return injectedEnv;
163
+ }
164
+ if (typeof window === "undefined" && farmEnvGlobal[FARM_ENV_SYMBOL]) {
165
+ return normalizeResolvedEnv(farmEnvGlobal[FARM_ENV_SYMBOL]);
166
+ }
167
+ return {
168
+ server: {},
169
+ public: getInjectedPublicEnv()
170
+ };
171
+ }
172
+ function getCurrentEnv() {
173
+ if (typeof window === "undefined" && farmEnvGlobal[FARM_ENV_SYMBOL]) {
174
+ return farmEnvGlobal[FARM_ENV_SYMBOL];
175
+ }
176
+ return currentEnv;
177
+ }
178
+ function getInjectedEnv() {
179
+ try {
180
+ if (typeof __FARM_ENV__ !== "undefined" && __FARM_ENV__) {
181
+ return prepareEnv(__FARM_ENV__);
182
+ }
183
+ } catch {
184
+ }
185
+ return null;
186
+ }
187
+ function getInjectedPublicEnv() {
188
+ try {
189
+ if (typeof __FARM_PUBLIC_ENV__ !== "undefined" && __FARM_PUBLIC_ENV__) {
190
+ return __FARM_PUBLIC_ENV__;
191
+ }
192
+ } catch {
193
+ }
194
+ return {};
195
+ }
196
+ function normalizeResolvedEnv(env2) {
197
+ return {
198
+ server: isRecord(env2.server) ? env2.server : {},
199
+ public: isRecord(env2.public) ? env2.public : {}
200
+ };
201
+ }
202
+ function isRecord(value) {
203
+ return !!value && typeof value === "object" && !Array.isArray(value);
204
+ }
205
+ function getProcessEnv() {
206
+ if (typeof process !== "undefined" && process.env) {
207
+ return process.env;
208
+ }
209
+ return {};
210
+ }
211
+ var FARM_ENV_SYMBOL, FARM_ENV_RUNTIME_SYMBOL, farmEnvGlobal, currentEnv, env, publicEnv;
212
+ var init_env = __esm({
213
+ "src/env.ts"() {
214
+ "use strict";
215
+ FARM_ENV_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env");
216
+ FARM_ENV_RUNTIME_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env.runtime");
217
+ farmEnvGlobal = globalThis;
218
+ currentEnv = getInitialEnv();
219
+ __name(createBundledEnv, "createBundledEnv");
220
+ env = createEnvProxy("server");
221
+ publicEnv = createEnvProxy("public");
222
+ __name(createEnvProxy, "createEnvProxy");
223
+ __name(getEnvScope, "getEnvScope");
224
+ __name(readServerEnvKey, "readServerEnvKey");
225
+ __name(readRuntimeServerEnv, "readRuntimeServerEnv");
226
+ __name(getRuntimeEnvType, "getRuntimeEnvType");
227
+ __name(coerceRuntimeEnvValue, "coerceRuntimeEnvValue");
228
+ __name(prepareEnv, "prepareEnv");
229
+ __name(assertServerEnvAccess, "assertServerEnvAccess");
230
+ __name(getInitialEnv, "getInitialEnv");
231
+ __name(getCurrentEnv, "getCurrentEnv");
232
+ __name(getInjectedEnv, "getInjectedEnv");
233
+ __name(getInjectedPublicEnv, "getInjectedPublicEnv");
234
+ __name(normalizeResolvedEnv, "normalizeResolvedEnv");
235
+ __name(isRecord, "isRecord");
236
+ __name(getProcessEnv, "getProcessEnv");
237
+ }
238
+ });
239
+
34
240
  // src/app-markdown-config.ts
35
241
  function resolveMdxConfig(config) {
36
242
  return {
@@ -8942,7 +9148,7 @@ function serializeFarmLlmsTxt(value) {
8942
9148
  return value.endsWith("\n") ? value : `${value}
8943
9149
  `;
8944
9150
  }
8945
- if (!isRecord2(value)) {
9151
+ if (!isRecord3(value)) {
8946
9152
  throw new TypeError("llms.ts must return llms.txt text, an llms.txt object, or a Response");
8947
9153
  }
8948
9154
  const title = requireText(value.title, "llms.ts must return a non-empty title");
@@ -8955,7 +9161,7 @@ function serializeFarmLlmsTxt(value) {
8955
9161
  if (summary?.trim()) blocks.push(`> ${toSingleLine(summary)}`);
8956
9162
  if (details?.trim()) blocks.push(details.trim());
8957
9163
  for (const [sectionIndex, section] of (value.sections ?? []).entries()) {
8958
- if (!isRecord2(section)) {
9164
+ if (!isRecord3(section)) {
8959
9165
  throw new TypeError(`llms.ts section ${sectionIndex} must be an object`);
8960
9166
  }
8961
9167
  const sectionTitle = requireText(
@@ -8967,7 +9173,7 @@ function serializeFarmLlmsTxt(value) {
8967
9173
  }
8968
9174
  const links = section.links.map((link, linkIndex) => {
8969
9175
  const where = `llms.ts section "${sectionTitle}" link ${linkIndex}`;
8970
- if (!isRecord2(link)) throw new TypeError(`${where} must be an object`);
9176
+ if (!isRecord3(link)) throw new TypeError(`${where} must be an object`);
8971
9177
  const linkTitle = requireText(link.title, `${where} must include a non-empty title`);
8972
9178
  const url = requireText(link.url, `${where} must include a non-empty url`);
8973
9179
  const description = optionalText(link.description, `${where} description must be a string`);
@@ -9053,10 +9259,10 @@ async function mapWithConcurrency(items, limit, run) {
9053
9259
  return results;
9054
9260
  }
9055
9261
  function readMetadataTitle(metadata) {
9056
- if (!isRecord2(metadata)) return void 0;
9262
+ if (!isRecord3(metadata)) return void 0;
9057
9263
  const { title } = metadata;
9058
9264
  if (typeof title === "string") return title.trim() || void 0;
9059
- if (isRecord2(title)) {
9265
+ if (isRecord3(title)) {
9060
9266
  for (const key of ["absolute", "default"]) {
9061
9267
  const value = title[key];
9062
9268
  if (typeof value === "string" && value.trim()) return value.trim();
@@ -9065,7 +9271,7 @@ function readMetadataTitle(metadata) {
9065
9271
  return void 0;
9066
9272
  }
9067
9273
  function readMetadataString(metadata, key) {
9068
- if (!isRecord2(metadata)) return void 0;
9274
+ if (!isRecord3(metadata)) return void 0;
9069
9275
  const value = metadata[key];
9070
9276
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
9071
9277
  }
@@ -9097,7 +9303,7 @@ function optionalText(value, message) {
9097
9303
  if (typeof value !== "string") throw new TypeError(message);
9098
9304
  return value;
9099
9305
  }
9100
- function isRecord2(value) {
9306
+ function isRecord3(value) {
9101
9307
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
9102
9308
  }
9103
9309
  var init_llms_txt = __esm({
@@ -9123,7 +9329,7 @@ var init_llms_txt = __esm({
9123
9329
  __name(escapeLinkUrl, "escapeLinkUrl");
9124
9330
  __name(requireText, "requireText");
9125
9331
  __name(optionalText, "optionalText");
9126
- __name(isRecord2, "isRecord");
9332
+ __name(isRecord3, "isRecord");
9127
9333
  }
9128
9334
  });
9129
9335
 
@@ -10346,116 +10552,6 @@ var init_config3 = __esm({
10346
10552
  }
10347
10553
  });
10348
10554
 
10349
- // src/env.ts
10350
- function createEnvProxy(scope) {
10351
- return new Proxy(
10352
- {},
10353
- {
10354
- get(_target, property) {
10355
- if (typeof property === "symbol") {
10356
- return void 0;
10357
- }
10358
- const env2 = getEnvScope(scope);
10359
- return env2[property];
10360
- },
10361
- ownKeys() {
10362
- return Reflect.ownKeys(getEnvScope(scope));
10363
- },
10364
- getOwnPropertyDescriptor(_target, property) {
10365
- const env2 = getEnvScope(scope);
10366
- if (!(property in env2)) {
10367
- return void 0;
10368
- }
10369
- return {
10370
- enumerable: true,
10371
- configurable: true,
10372
- value: env2[property]
10373
- };
10374
- },
10375
- has(_target, property) {
10376
- return property in getEnvScope(scope);
10377
- }
10378
- }
10379
- );
10380
- }
10381
- function getEnvScope(scope) {
10382
- if (scope === "server") {
10383
- assertServerEnvAccess();
10384
- }
10385
- return getCurrentEnv()[scope] || {};
10386
- }
10387
- function assertServerEnvAccess() {
10388
- if (typeof window !== "undefined") {
10389
- throw new Error("Farm server env is not available in the browser. Use publicEnv.");
10390
- }
10391
- }
10392
- function getInitialEnv() {
10393
- const injectedEnv = getInjectedEnv();
10394
- if (injectedEnv) {
10395
- return injectedEnv;
10396
- }
10397
- if (typeof window === "undefined" && farmEnvGlobal[FARM_ENV_SYMBOL]) {
10398
- return normalizeResolvedEnv(farmEnvGlobal[FARM_ENV_SYMBOL]);
10399
- }
10400
- return {
10401
- server: {},
10402
- public: getInjectedPublicEnv()
10403
- };
10404
- }
10405
- function getCurrentEnv() {
10406
- if (typeof window === "undefined" && farmEnvGlobal[FARM_ENV_SYMBOL]) {
10407
- return farmEnvGlobal[FARM_ENV_SYMBOL];
10408
- }
10409
- return currentEnv;
10410
- }
10411
- function getInjectedEnv() {
10412
- try {
10413
- if (typeof __FARM_ENV__ !== "undefined" && __FARM_ENV__) {
10414
- return normalizeResolvedEnv(__FARM_ENV__);
10415
- }
10416
- } catch {
10417
- }
10418
- return null;
10419
- }
10420
- function getInjectedPublicEnv() {
10421
- try {
10422
- if (typeof __FARM_PUBLIC_ENV__ !== "undefined" && __FARM_PUBLIC_ENV__) {
10423
- return __FARM_PUBLIC_ENV__;
10424
- }
10425
- } catch {
10426
- }
10427
- return {};
10428
- }
10429
- function normalizeResolvedEnv(env2) {
10430
- return {
10431
- server: isRecord4(env2.server) ? env2.server : {},
10432
- public: isRecord4(env2.public) ? env2.public : {}
10433
- };
10434
- }
10435
- function isRecord4(value) {
10436
- return !!value && typeof value === "object" && !Array.isArray(value);
10437
- }
10438
- var FARM_ENV_SYMBOL, farmEnvGlobal, currentEnv, env, publicEnv;
10439
- var init_env = __esm({
10440
- "src/env.ts"() {
10441
- "use strict";
10442
- FARM_ENV_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env");
10443
- farmEnvGlobal = globalThis;
10444
- currentEnv = getInitialEnv();
10445
- env = createEnvProxy("server");
10446
- publicEnv = createEnvProxy("public");
10447
- __name(createEnvProxy, "createEnvProxy");
10448
- __name(getEnvScope, "getEnvScope");
10449
- __name(assertServerEnvAccess, "assertServerEnvAccess");
10450
- __name(getInitialEnv, "getInitialEnv");
10451
- __name(getCurrentEnv, "getCurrentEnv");
10452
- __name(getInjectedEnv, "getInjectedEnv");
10453
- __name(getInjectedPublicEnv, "getInjectedPublicEnv");
10454
- __name(normalizeResolvedEnv, "normalizeResolvedEnv");
10455
- __name(isRecord4, "isRecord");
10456
- }
10457
- });
10458
-
10459
10555
  // src/plugin-dependencies.ts
10460
10556
  function pluginShortName(name2) {
10461
10557
  return name2.slice(Math.max(name2.lastIndexOf(":"), name2.lastIndexOf("/")) + 1);
@@ -17453,6 +17549,7 @@ __export(vite_exports, {
17453
17549
  withFarmRequestTracing: () => withFarmRequestTracing
17454
17550
  });
17455
17551
  module.exports = __toCommonJS(vite_exports);
17552
+ init_env();
17456
17553
 
17457
17554
  // src/app.ts
17458
17555
  init_app_markdown_config();
@@ -21470,11 +21567,11 @@ function mergeMetadata(base, next) {
21470
21567
  __name(mergeMetadata, "mergeMetadata");
21471
21568
  function mergeMetadataTitle(base, next) {
21472
21569
  if (next === void 0) return base;
21473
- const parentTemplate = isRecord(base) ? normalizeContent(base.template) : void 0;
21570
+ const parentTemplate = isRecord2(base) ? normalizeContent(base.template) : void 0;
21474
21571
  if (typeof next === "string") {
21475
21572
  return parentTemplate ? applyTitleTemplate(parentTemplate, next) : next;
21476
21573
  }
21477
- if (!isRecord(next)) return next;
21574
+ if (!isRecord2(next)) return next;
21478
21575
  const defaultTitle = normalizeContent(next.default) ?? resolveMetadataTitle(base);
21479
21576
  return {
21480
21577
  ...next,
@@ -21525,8 +21622,8 @@ __name(addMetadataImageReference, "addMetadataImageReference");
21525
21622
  var MARKDOWN_MIME_TYPE = "text/markdown";
21526
21623
  function addMetadataMarkdownAlternate(metadata, href) {
21527
21624
  if (!href) return metadata;
21528
- const alternates = isRecord(metadata.alternates) ? metadata.alternates : {};
21529
- const types = isRecord(alternates.types) ? alternates.types : {};
21625
+ const alternates = isRecord2(metadata.alternates) ? metadata.alternates : {};
21626
+ const types = isRecord2(alternates.types) ? alternates.types : {};
21530
21627
  if (Object.keys(types).some((type) => type.toLowerCase() === MARKDOWN_MIME_TYPE)) {
21531
21628
  return metadata;
21532
21629
  }
@@ -21559,26 +21656,26 @@ function renderMetadataHead(metadata, options = {}) {
21559
21656
  appendMetaName(tags, "creator", resolvedMetadata.creator);
21560
21657
  appendMetaName(tags, "publisher", resolvedMetadata.publisher);
21561
21658
  appendMetaName(tags, "robots", normalizeRobots(resolvedMetadata.robots));
21562
- if (isRecord(resolvedMetadata.robots)) {
21659
+ if (isRecord2(resolvedMetadata.robots)) {
21563
21660
  appendMetaName(tags, "googlebot", normalizeRobots(resolvedMetadata.robots.googleBot));
21564
21661
  }
21565
21662
  const alternates = resolvedMetadata.alternates;
21566
- const explicitCanonical = isRecord(alternates) ? alternates.canonical : void 0;
21663
+ const explicitCanonical = isRecord2(alternates) ? alternates.canonical : void 0;
21567
21664
  const canonicalHref = explicitCanonical != null ? resolveMetadataUrl(explicitCanonical, metadataBase) : options.pathname ? resolveMetadataUrl(sanitizeSelfCanonicalPathname(options.pathname), metadataBase) : void 0;
21568
21665
  if (canonicalHref) {
21569
21666
  appendLink(tags, "canonical", canonicalHref);
21570
21667
  }
21571
- if (isRecord(alternates) && isRecord(alternates.languages)) {
21668
+ if (isRecord2(alternates) && isRecord2(alternates.languages)) {
21572
21669
  for (const [language, href] of Object.entries(alternates.languages)) {
21573
21670
  appendLink(tags, "alternate", resolveMetadataUrl(href, metadataBase), {
21574
21671
  hreflang: language
21575
21672
  });
21576
21673
  }
21577
21674
  }
21578
- if (isRecord(alternates) && isRecord(alternates.types)) {
21675
+ if (isRecord2(alternates) && isRecord2(alternates.types)) {
21579
21676
  for (const [type, value] of Object.entries(alternates.types)) {
21580
21677
  for (const entry of normalizeArray(value)) {
21581
- const link = isRecord(entry) ? entry : { url: entry };
21678
+ const link = isRecord2(entry) ? entry : { url: entry };
21582
21679
  appendLink(tags, "alternate", resolveMetadataUrl(link.url, metadataBase), {
21583
21680
  type,
21584
21681
  title: link.title
@@ -21602,14 +21699,14 @@ function renderMetadataHead(metadata, options = {}) {
21602
21699
  const jsonLdConfig = options.jsonLd === true ? {} : options.jsonLd;
21603
21700
  const jsonLdScript = renderFarmAgentJsonLd(jsonLdConfig, {
21604
21701
  metadataBase,
21605
- siteName: isRecord(resolvedMetadata.openGraph) ? normalizeContent(resolvedMetadata.openGraph.siteName) : void 0,
21702
+ siteName: isRecord2(resolvedMetadata.openGraph) ? normalizeContent(resolvedMetadata.openGraph.siteName) : void 0,
21606
21703
  title: explicitTitle,
21607
21704
  description: normalizeContent(resolvedMetadata.description)
21608
21705
  });
21609
21706
  if (jsonLdScript) tags.push(jsonLdScript);
21610
21707
  }
21611
21708
  for (const entry of normalizeArray(resolvedMetadata.jsonLd)) {
21612
- if (!isRecord(entry)) continue;
21709
+ if (!isRecord2(entry)) continue;
21613
21710
  tags.push(
21614
21711
  `<script type="application/ld+json" ${FARM_METADATA_ATTRIBUTE}>${serializeJsonLd(entry)}</script>`
21615
21712
  );
@@ -21624,7 +21721,7 @@ function renderMetadataHead(metadata, options = {}) {
21624
21721
  }
21625
21722
  __name(renderMetadataHead, "renderMetadataHead");
21626
21723
  function mergeNestedMetadata(base, next) {
21627
- if (isRecord(base) && isRecord(next)) {
21724
+ if (isRecord2(base) && isRecord2(next)) {
21628
21725
  return {
21629
21726
  ...base,
21630
21727
  ...next
@@ -21634,7 +21731,7 @@ function mergeNestedMetadata(base, next) {
21634
21731
  }
21635
21732
  __name(mergeNestedMetadata, "mergeNestedMetadata");
21636
21733
  function appendOpenGraph(tags, openGraph, metadataBase) {
21637
- if (!isRecord(openGraph)) return;
21734
+ if (!isRecord2(openGraph)) return;
21638
21735
  appendMetaProperty(tags, "og:title", openGraph.title);
21639
21736
  appendMetaProperty(tags, "og:description", openGraph.description);
21640
21737
  appendMetaProperty(tags, "og:url", resolveMetadataUrl(openGraph.url, metadataBase));
@@ -21666,7 +21763,7 @@ function appendOpenGraph(tags, openGraph, metadataBase) {
21666
21763
  }
21667
21764
  __name(appendOpenGraph, "appendOpenGraph");
21668
21765
  function appendTwitter(tags, twitter, metadataBase) {
21669
- if (!isRecord(twitter)) return;
21766
+ if (!isRecord2(twitter)) return;
21670
21767
  appendMetaName(tags, "twitter:card", twitter.card);
21671
21768
  appendMetaName(tags, "twitter:site", twitter.site);
21672
21769
  appendMetaName(tags, "twitter:creator", twitter.creator);
@@ -21679,7 +21776,7 @@ function appendTwitter(tags, twitter, metadataBase) {
21679
21776
  }
21680
21777
  __name(appendTwitter, "appendTwitter");
21681
21778
  function appendNamedMetaRecord(tags, record) {
21682
- if (!isRecord(record)) return;
21779
+ if (!isRecord2(record)) return;
21683
21780
  for (const [name2, value] of Object.entries(record)) {
21684
21781
  for (const content of normalizeArray(value)) {
21685
21782
  appendMetaName(tags, name2, content, true);
@@ -21694,7 +21791,7 @@ function appendIcons(tags, icons, metadataBase) {
21694
21791
  appendLink(tags, "icon", resolveMetadataUrl(icons, metadataBase));
21695
21792
  return tags.length > initialTagCount2;
21696
21793
  }
21697
- if (!isRecord(icons)) return false;
21794
+ if (!isRecord2(icons)) return false;
21698
21795
  const initialTagCount = tags.length;
21699
21796
  appendIconList(tags, "icon", icons.icon, metadataBase);
21700
21797
  appendIconList(tags, "shortcut icon", icons.shortcut, metadataBase);
@@ -21709,7 +21806,7 @@ function appendIconList(tags, rel, value, metadataBase) {
21709
21806
  appendLink(tags, rel, resolveMetadataUrl(icon2, metadataBase));
21710
21807
  continue;
21711
21808
  }
21712
- if (!isRecord(icon2)) continue;
21809
+ if (!isRecord2(icon2)) continue;
21713
21810
  appendLink(tags, rel, resolveMetadataUrl(icon2.url, metadataBase), {
21714
21811
  sizes: icon2.sizes,
21715
21812
  type: icon2.type
@@ -21740,7 +21837,7 @@ var VERIFICATION_META_NAMES = [
21740
21837
  ["yandex", "yandex-verification"]
21741
21838
  ];
21742
21839
  function appendVerification(tags, verification) {
21743
- if (!isRecord(verification)) return;
21840
+ if (!isRecord2(verification)) return;
21744
21841
  for (const [key, name2] of VERIFICATION_META_NAMES) {
21745
21842
  for (const token of normalizeArray(verification[key])) {
21746
21843
  appendMetaName(tags, name2, token);
@@ -21766,7 +21863,7 @@ function normalizeMetadataImages(value, metadataBase) {
21766
21863
  if (typeof item === "string") {
21767
21864
  return { url: resolveMetadataUrl(item, metadataBase) || item };
21768
21865
  }
21769
- if (!isRecord(item)) return null;
21866
+ if (!isRecord2(item)) return null;
21770
21867
  const rawUrl = item.url || item.src;
21771
21868
  const url = resolveMetadataUrl(rawUrl, metadataBase);
21772
21869
  if (!url) return null;
@@ -21791,7 +21888,7 @@ function hasMetadataImages(value) {
21791
21888
  __name(hasMetadataImages, "hasMetadataImages");
21792
21889
  function resolveMetadataTitle(title) {
21793
21890
  if (typeof title === "string") return title;
21794
- if (isRecord(title)) {
21891
+ if (isRecord2(title)) {
21795
21892
  return normalizeContent(title.default);
21796
21893
  }
21797
21894
  return void 0;
@@ -21811,7 +21908,7 @@ var ROBOTS_VALUES = [
21811
21908
  ];
21812
21909
  function normalizeRobots(robots) {
21813
21910
  if (typeof robots === "string") return robots;
21814
- if (!isRecord(robots)) return void 0;
21911
+ if (!isRecord2(robots)) return void 0;
21815
21912
  const values = [];
21816
21913
  if (typeof robots.index === "boolean") values.push(robots.index ? "index" : "noindex");
21817
21914
  if (typeof robots.follow === "boolean") values.push(robots.follow ? "follow" : "nofollow");
@@ -21872,10 +21969,10 @@ function normalizeContent(value) {
21872
21969
  return void 0;
21873
21970
  }
21874
21971
  __name(normalizeContent, "normalizeContent");
21875
- function isRecord(value) {
21972
+ function isRecord2(value) {
21876
21973
  return !!value && typeof value === "object" && !Array.isArray(value);
21877
21974
  }
21878
- __name(isRecord, "isRecord");
21975
+ __name(isRecord2, "isRecord");
21879
21976
  function escapeText(value) {
21880
21977
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
21881
21978
  }
@@ -23919,10 +24016,10 @@ function isResponse2(value) {
23919
24016
  ));
23920
24017
  }
23921
24018
  __name(isResponse2, "isResponse");
23922
- function isRecord3(value) {
24019
+ function isRecord4(value) {
23923
24020
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
23924
24021
  }
23925
- __name(isRecord3, "isRecord");
24022
+ __name(isRecord4, "isRecord");
23926
24023
  function resolveCacheControl2(revalidate) {
23927
24024
  if (revalidate === false) {
23928
24025
  return "public, max-age=31536000, immutable";
@@ -23942,7 +24039,7 @@ function serializeSitemap(value) {
23942
24039
  throw new TypeError("sitemap.ts must return an array or a Response");
23943
24040
  }
23944
24041
  const entries = value.map((candidate, index) => {
23945
- if (!isRecord3(candidate) || typeof candidate.url !== "string" || !candidate.url) {
24042
+ if (!isRecord4(candidate) || typeof candidate.url !== "string" || !candidate.url) {
23946
24043
  throw new TypeError(`sitemap.ts entry ${index} must include a non-empty url`);
23947
24044
  }
23948
24045
  return candidate;
@@ -23984,7 +24081,7 @@ function toArray2(value) {
23984
24081
  }
23985
24082
  __name(toArray2, "toArray");
23986
24083
  function serializeRobots(value) {
23987
- if (!isRecord3(value)) {
24084
+ if (!isRecord4(value)) {
23988
24085
  throw new TypeError("robots.ts must return a robots object or a Response");
23989
24086
  }
23990
24087
  const robots = value;
@@ -23993,7 +24090,7 @@ function serializeRobots(value) {
23993
24090
  throw new TypeError("robots.ts must return at least one rule");
23994
24091
  }
23995
24092
  const sections = rules.map((rule, index) => {
23996
- if (!isRecord3(rule)) {
24093
+ if (!isRecord4(rule)) {
23997
24094
  throw new TypeError(`robots.ts rule ${index} must be an object`);
23998
24095
  }
23999
24096
  const userAgents = toArray2(rule.userAgent).filter(
@@ -24017,7 +24114,7 @@ function serializeRobots(value) {
24017
24114
  }
24018
24115
  __name(serializeRobots, "serializeRobots");
24019
24116
  function serializeManifest(value) {
24020
- if (!isRecord3(value)) {
24117
+ if (!isRecord4(value)) {
24021
24118
  throw new TypeError("manifest.ts must return a manifest object or a Response");
24022
24119
  }
24023
24120
  return `${JSON.stringify(value, null, 2)}
@@ -25079,7 +25176,7 @@ _setFarmThemeServerSnapshotResolver(() => {
25079
25176
  });
25080
25177
 
25081
25178
  // package.json
25082
- var version = "0.1.15";
25179
+ var version = "0.1.16";
25083
25180
 
25084
25181
  // src/version.ts
25085
25182
  var FARM_VERSION = version;
@@ -33092,7 +33189,7 @@ function getEnvDefines(config, configEnv) {
33092
33189
  )
33093
33190
  };
33094
33191
  if (configEnv?.isSsrBuild) {
33095
- defines.__FARM_ENV__ = JSON.stringify(getFullEnvDefine(config));
33192
+ defines.__FARM_ENV__ = JSON.stringify(createBundledEnv(getFullEnvDefine(config)));
33096
33193
  }
33097
33194
  return defines;
33098
33195
  }
package/dist/vite.d.mts CHANGED
@@ -1,11 +1,12 @@
1
1
  import 'vite';
2
- export { f9 as ClientCachePersistenceEntryCode, y as defineConfig, f1 as farmI18nClientBridgePlugin, x as farmPlugin, f2 as farmServerOnlyEntriesPlugin, f7 as generateClientCachePersistenceCode, f8 as resolveFarmClientCacheAdapterEntry, f4 as rewriteEarlySsrRelativeImports, f6 as shouldEmitFarmClientRootHmr, f5 as transformIsolatedClientBoundaryModule, f3 as withFarmRequestTracing } from './client-plugins-C1EgdoJM.mjs';
2
+ export { fa as ClientCachePersistenceEntryCode, y as defineConfig, f2 as farmI18nClientBridgePlugin, x as farmPlugin, f3 as farmServerOnlyEntriesPlugin, f8 as generateClientCachePersistenceCode, f9 as resolveFarmClientCacheAdapterEntry, f5 as rewriteEarlySsrRelativeImports, f7 as shouldEmitFarmClientRootHmr, f6 as transformIsolatedClientBoundaryModule, f4 as withFarmRequestTracing } from './client-plugins-CIPRtSsW.mjs';
3
3
  import './after.mjs';
4
4
  import './renderer.mjs';
5
5
  import './island-CfGru1MO.mjs';
6
6
  export { d as createFarmNodeRequestAbortSignal } from './workflows-CR9ex-gz.mjs';
7
7
  import './lifecycle-DK06VuKP.mjs';
8
- import './route-C6UClI1z.mjs';
8
+ import './route-C_eLaFTZ.mjs';
9
+ import './endpoint-Bu3XgeMK.mjs';
9
10
  import './cache.mjs';
10
11
  import 'http';
11
12
  import './markdown.mjs';
@@ -28,6 +29,8 @@ import './server-fn-error-DDh14a0V.mjs';
28
29
  import 'esbuild';
29
30
  import './image-config-Duob7wER.mjs';
30
31
  import './types-Z0aotQ8w.mjs';
32
+ import './server-fn.mjs';
33
+ import './server-query.mjs';
31
34
  import './types-DQnyD3VD.mjs';
32
35
  import './font.mjs';
33
36
  import 'node:http';
package/dist/vite.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import 'vite';
2
- export { f9 as ClientCachePersistenceEntryCode, y as defineConfig, f1 as farmI18nClientBridgePlugin, x as farmPlugin, f2 as farmServerOnlyEntriesPlugin, f7 as generateClientCachePersistenceCode, f8 as resolveFarmClientCacheAdapterEntry, f4 as rewriteEarlySsrRelativeImports, f6 as shouldEmitFarmClientRootHmr, f5 as transformIsolatedClientBoundaryModule, f3 as withFarmRequestTracing } from './client-plugins-CslwYp3E.js';
2
+ export { fa as ClientCachePersistenceEntryCode, y as defineConfig, f2 as farmI18nClientBridgePlugin, x as farmPlugin, f3 as farmServerOnlyEntriesPlugin, f8 as generateClientCachePersistenceCode, f9 as resolveFarmClientCacheAdapterEntry, f5 as rewriteEarlySsrRelativeImports, f7 as shouldEmitFarmClientRootHmr, f6 as transformIsolatedClientBoundaryModule, f4 as withFarmRequestTracing } from './client-plugins-CqVtZi5X.js';
3
3
  import './after.js';
4
4
  import './renderer.js';
5
5
  import './island-CfGru1MO.js';
6
6
  export { d as createFarmNodeRequestAbortSignal } from './workflows-CR9ex-gz.js';
7
7
  import './lifecycle-DK06VuKP.js';
8
- import './route-CHBaW55F.js';
8
+ import './route-BxNJT447.js';
9
+ import './endpoint-kSAxE52R.js';
9
10
  import './cache.js';
10
11
  import 'http';
11
12
  import './markdown.js';
@@ -28,6 +29,8 @@ import './server-fn-error-DDh14a0V.js';
28
29
  import 'esbuild';
29
30
  import './image-config-Duob7wER.js';
30
31
  import './types-Z0aotQ8w.js';
32
+ import './server-fn.js';
33
+ import './server-query.js';
31
34
  import './types-DQnyD3VD.js';
32
35
  import './font.js';
33
36
  import 'node:http';