@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.
- package/dist/agent-runtime.d.mts +5 -2
- package/dist/agent-runtime.d.ts +5 -2
- package/dist/api/client.d.mts +3 -2
- package/dist/api/client.d.ts +3 -2
- package/dist/api/route-manager.d.mts +5 -2
- package/dist/api/route-manager.d.ts +5 -2
- package/dist/api/runtime.d.mts +3 -2
- package/dist/api/runtime.d.ts +3 -2
- package/dist/{api-client-C8d7BZNp.d.mts → api-client-B-n3pm_Q.d.mts} +2 -1
- package/dist/{api-client-BWrEbxfO.d.ts → api-client-C0_NZEBl.d.ts} +2 -1
- package/dist/api.d.mts +7 -4
- package/dist/api.d.ts +7 -4
- package/dist/{app-wIYse61b.d.ts → app-AyjEsCBq.d.ts} +3 -3
- package/dist/{app-B3nVSjen.d.mts → app-CYPHeOo_.d.mts} +3 -3
- package/dist/app-markdown.d.mts +6 -3
- package/dist/app-markdown.d.ts +6 -3
- package/dist/{chunk-FOGLGRDS.mjs → chunk-7HDZYYS4.mjs} +100 -8
- package/dist/{chunk-UE75PB52.mjs → chunk-IL5RWYK7.mjs} +1 -1
- package/dist/{chunk-GNTPTTLA.mjs → chunk-IXTEENRS.mjs} +1 -1
- package/dist/{chunk-JRF3C33L.mjs → chunk-NHHKW2T6.mjs} +5 -4
- package/dist/{chunk-NJ47VORC.mjs → chunk-NUD6XBMO.mjs} +1 -1
- package/dist/{chunk-FBHGHMOA.mjs → chunk-TYVVIQ5M.mjs} +10 -7
- package/dist/{chunk-W7IVHTOP.mjs → chunk-UQZPTIML.mjs} +15 -2
- package/dist/{chunk-S3QW3BIS.mjs → chunk-VVTREAG5.mjs} +89 -4
- package/dist/{client-plugins-C1EgdoJM.d.mts → client-plugins-CIPRtSsW.d.mts} +16 -4
- package/dist/{client-plugins-CslwYp3E.d.ts → client-plugins-CqVtZi5X.d.ts} +16 -4
- package/dist/client-plugins.d.mts +5 -2
- package/dist/client-plugins.d.ts +5 -2
- package/dist/client.d.mts +8 -7
- package/dist/client.d.ts +8 -7
- package/dist/config.d.mts +5 -2
- package/dist/config.d.ts +5 -2
- package/dist/{devtools-PCGEBRSC.mjs → devtools-IU7LKZOH.mjs} +2 -2
- package/dist/docs.cjs +74 -3
- package/dist/docs.mjs +3 -3
- package/dist/{route-C6UClI1z.d.mts → endpoint-Bu3XgeMK.d.mts} +3 -128
- package/dist/{route-CHBaW55F.d.ts → endpoint-kSAxE52R.d.ts} +3 -128
- package/dist/env.cjs +101 -8
- package/dist/env.d.mts +20 -2
- package/dist/env.d.ts +20 -2
- package/dist/env.mjs +3 -1
- package/dist/index.cjs +212 -19
- package/dist/index.d.mts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.mjs +20 -8
- package/dist/integrations.d.mts +5 -2
- package/dist/integrations.d.ts +5 -2
- package/dist/internal/app-markdown-runtime.d.mts +5 -2
- package/dist/internal/app-markdown-runtime.d.ts +5 -2
- package/dist/internal/build-runtime.cjs +264 -169
- package/dist/internal/build-runtime.d.mts +7 -4
- package/dist/internal/build-runtime.d.ts +7 -4
- package/dist/internal/build-runtime.mjs +6 -6
- package/dist/internal/cli-runtime.cjs +68 -4
- package/dist/internal/cli-runtime.mjs +2 -2
- package/dist/internal/client-error-overlay.cjs +1 -1
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +5 -2
- package/dist/internal/compression-runtime.d.ts +5 -2
- package/dist/internal/config-runtime.cjs +68 -4
- package/dist/internal/config-runtime.d.mts +6 -3
- package/dist/internal/config-runtime.d.ts +6 -3
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/internal/product-telemetry-runtime.cjs +1 -1
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.d.mts +11 -8
- package/dist/internal/production-runtime.d.ts +11 -8
- package/dist/{metadata-BsUcOEXg.d.ts → metadata-8g__AMPM.d.ts} +1 -1
- package/dist/{metadata-B1bxCPUY.d.mts → metadata-OMX6wFNf.d.mts} +1 -1
- package/dist/middleware.d.mts +7 -4
- package/dist/middleware.d.ts +7 -4
- package/dist/{nitro-ICBP5APY.mjs → nitro-3N4ZXRYM.mjs} +5 -2
- package/dist/plugin.cjs +108 -7
- package/dist/plugin.d.mts +5 -2
- package/dist/plugin.d.ts +5 -2
- package/dist/plugin.mjs +3 -3
- package/dist/{production-runtime-CsNn2-zx.d.ts → production-runtime-BJh7o6Cr.d.ts} +1 -1
- package/dist/{production-runtime-BDllolVh.d.mts → production-runtime-W3M0eNDV.d.mts} +1 -1
- package/dist/{render-plan-EG4hNFjy.d.ts → render-plan-Be4ZGTJP.d.ts} +1 -1
- package/dist/{render-plan-CNUlzylR.d.mts → render-plan-io7pvDNc.d.mts} +1 -1
- package/dist/renderer-client.d.mts +5 -4
- package/dist/renderer-client.d.ts +5 -4
- package/dist/{request-Blh_f7Z3.d.mts → request-DZkHYQ89.d.mts} +1 -1
- package/dist/{request-DsVSQVfD.d.ts → request-G8JhKr4F.d.ts} +1 -1
- package/dist/request.d.mts +6 -3
- package/dist/request.d.ts +6 -3
- package/dist/route-BxNJT447.d.ts +128 -0
- package/dist/route-C_eLaFTZ.d.mts +128 -0
- package/dist/{route-rendering-hUETRCbM.d.ts → route-rendering-BcLLPJgN.d.ts} +1 -1
- package/dist/{route-rendering-LT4XSoQK.d.mts → route-rendering-CbAKr1TY.d.mts} +1 -1
- package/dist/routes.d.mts +4 -2
- package/dist/routes.d.ts +4 -2
- package/dist/server-fn-client.d.mts +3 -2
- package/dist/server-fn-client.d.ts +3 -2
- package/dist/server-fn.cjs +141 -3
- package/dist/server-fn.d.mts +72 -1
- package/dist/server-fn.d.ts +72 -1
- package/dist/server-fn.mjs +12 -1
- package/dist/server-plugins.d.mts +6 -3
- package/dist/server-plugins.d.ts +6 -3
- package/dist/server-query-client.d.mts +1 -0
- package/dist/server-query-client.d.ts +1 -0
- package/dist/server-query.cjs +60 -3
- package/dist/server-query.d.mts +6 -1
- package/dist/server-query.d.ts +6 -1
- package/dist/server-query.mjs +3 -2
- package/dist/server.cjs +161 -11
- package/dist/server.d.mts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.mjs +6 -6
- package/dist/{spa-router-csKR9Ebj.d.mts → spa-router-BcS_4nqm.d.mts} +2 -2
- package/dist/{spa-router-Y_2FSJQK.d.ts → spa-router-BzFBUJkn.d.ts} +2 -2
- package/dist/testing.d.mts +5 -3
- package/dist/testing.d.ts +5 -3
- package/dist/{utils-DR2wfZAn.d.mts → utils-5kQP1mFR.d.mts} +1 -1
- package/dist/{utils-jISOE9SD.d.ts → utils-C4yrAhNc.d.ts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +246 -149
- package/dist/vite.d.mts +5 -2
- package/dist/vite.d.ts +5 -2
- package/dist/vite.mjs +3 -3
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
|
@@ -31,8 +31,26 @@ type FarmPublicEnv = FarmEnvTypes extends {
|
|
|
31
31
|
public: infer TPublic;
|
|
32
32
|
} ? TPublic extends Record<string, any> ? TPublic : Record<string, unknown> : Record<string, unknown>;
|
|
33
33
|
type FarmTypedEnv = ResolvedFarmEnv<FarmServerEnv, FarmPublicEnv>;
|
|
34
|
+
type FarmEnvRuntimeType = "string" | "number" | "boolean" | "json";
|
|
35
|
+
/**
|
|
36
|
+
* The env a server bundle carries. `runtime.server` lists server keys that are
|
|
37
|
+
* read from the server's environment instead of being stored in the bundle,
|
|
38
|
+
* with the type their parsed value had at build time.
|
|
39
|
+
*/
|
|
40
|
+
interface BundledFarmEnv extends ResolvedFarmEnv {
|
|
41
|
+
runtime?: {
|
|
42
|
+
server: Record<string, FarmEnvRuntimeType>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
34
45
|
declare function resolveEnv<TConfig extends FarmEnvConfig<any, any> | undefined>(config: TConfig, source?: Record<string, string | undefined>): InferEnv<NonNullable<TConfig>>;
|
|
35
|
-
|
|
46
|
+
/**
|
|
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.
|
|
51
|
+
*/
|
|
52
|
+
declare function createBundledEnv(env: ResolvedFarmEnv | FarmEnvConfig<any, any> | undefined, source?: Record<string, string | undefined>): BundledFarmEnv;
|
|
53
|
+
declare function setEnv(env: ResolvedFarmEnv | BundledFarmEnv): void;
|
|
36
54
|
declare function getResolvedEnv<TEnv extends ResolvedFarmEnv = FarmTypedEnv>(): TEnv;
|
|
37
55
|
declare function getEnv<TServer extends Record<string, any> = FarmServerEnv>(): TServer;
|
|
38
56
|
declare function getEnv<TKey extends Extract<keyof FarmServerEnv, string>>(key: TKey): FarmServerEnv[TKey];
|
|
@@ -42,4 +60,4 @@ declare const env: FarmServerEnv;
|
|
|
42
60
|
declare const serverEnv: Record<string, unknown>;
|
|
43
61
|
declare const publicEnv: FarmPublicEnv;
|
|
44
62
|
|
|
45
|
-
export { type EnvParser, type EnvSchema, type EnvShape, type FarmEnvConfig, type FarmEnvTypes, type FarmPublicEnv, type FarmServerEnv, type FarmTypedEnv, type InferEnv, type InferEnvParser, type InferEnvShape, type ResolvedFarmEnv, env, getEnv, getPublicEnv, getResolvedEnv, publicEnv, resolveEnv, serverEnv, setEnv };
|
|
63
|
+
export { type BundledFarmEnv, type EnvParser, type EnvSchema, type EnvShape, type FarmEnvConfig, type FarmEnvRuntimeType, type FarmEnvTypes, type FarmPublicEnv, type FarmServerEnv, type FarmTypedEnv, type InferEnv, type InferEnvParser, type InferEnvShape, type ResolvedFarmEnv, createBundledEnv, env, getEnv, getPublicEnv, getResolvedEnv, publicEnv, resolveEnv, serverEnv, setEnv };
|
package/dist/env.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createBundledEnv,
|
|
2
3
|
env,
|
|
3
4
|
getEnv,
|
|
4
5
|
getPublicEnv,
|
|
@@ -7,9 +8,10 @@ import {
|
|
|
7
8
|
resolveEnv,
|
|
8
9
|
serverEnv,
|
|
9
10
|
setEnv
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7HDZYYS4.mjs";
|
|
11
12
|
import "./chunk-LPEX4YW6.mjs";
|
|
12
13
|
export {
|
|
14
|
+
createBundledEnv,
|
|
13
15
|
env,
|
|
14
16
|
getEnv,
|
|
15
17
|
getPublicEnv,
|
package/dist/index.cjs
CHANGED
|
@@ -22038,7 +22038,7 @@ var init_server3 = __esm({
|
|
|
22038
22038
|
var version;
|
|
22039
22039
|
var init_package = __esm({
|
|
22040
22040
|
"package.json"() {
|
|
22041
|
-
version = "0.1.
|
|
22041
|
+
version = "0.1.16";
|
|
22042
22042
|
}
|
|
22043
22043
|
});
|
|
22044
22044
|
|
|
@@ -26373,21 +26373,40 @@ function resolveEnv(config, source = getProcessEnv()) {
|
|
|
26373
26373
|
};
|
|
26374
26374
|
return resolved;
|
|
26375
26375
|
}
|
|
26376
|
+
function createBundledEnv(env2, source = getProcessEnv()) {
|
|
26377
|
+
const resolved = normalizeResolvedEnv(env2 ?? {});
|
|
26378
|
+
const server = {};
|
|
26379
|
+
const runtime3 = {};
|
|
26380
|
+
for (const [key, value] of Object.entries(resolved.server)) {
|
|
26381
|
+
if (source[key] === void 0) {
|
|
26382
|
+
server[key] = value;
|
|
26383
|
+
} else {
|
|
26384
|
+
runtime3[key] = getRuntimeEnvType(value);
|
|
26385
|
+
}
|
|
26386
|
+
}
|
|
26387
|
+
return {
|
|
26388
|
+
server,
|
|
26389
|
+
public: resolved.public,
|
|
26390
|
+
...Object.keys(runtime3).length > 0 ? { runtime: { server: runtime3 } } : {}
|
|
26391
|
+
};
|
|
26392
|
+
}
|
|
26376
26393
|
function setEnv(env2) {
|
|
26377
|
-
currentEnv =
|
|
26394
|
+
currentEnv = prepareEnv(env2);
|
|
26378
26395
|
if (typeof window === "undefined") {
|
|
26379
26396
|
farmEnvGlobal[FARM_ENV_SYMBOL] = currentEnv;
|
|
26380
26397
|
}
|
|
26381
26398
|
}
|
|
26382
26399
|
function getResolvedEnv() {
|
|
26383
|
-
|
|
26400
|
+
const env2 = getCurrentEnv();
|
|
26401
|
+
if (typeof window === "undefined") readRuntimeServerEnv(env2);
|
|
26402
|
+
return env2;
|
|
26384
26403
|
}
|
|
26385
26404
|
function getEnv(key) {
|
|
26386
|
-
|
|
26405
|
+
const server = getEnvScope("server");
|
|
26387
26406
|
if (key === void 0) {
|
|
26388
|
-
return
|
|
26407
|
+
return server;
|
|
26389
26408
|
}
|
|
26390
|
-
return
|
|
26409
|
+
return readServerEnvKey(server, key);
|
|
26391
26410
|
}
|
|
26392
26411
|
function getPublicEnv(key) {
|
|
26393
26412
|
if (key === void 0) {
|
|
@@ -26428,7 +26447,7 @@ function createEnvProxy(scope) {
|
|
|
26428
26447
|
return void 0;
|
|
26429
26448
|
}
|
|
26430
26449
|
const env2 = getEnvScope(scope);
|
|
26431
|
-
return env2[property];
|
|
26450
|
+
return scope === "server" ? readServerEnvKey(env2, property) : env2[property];
|
|
26432
26451
|
},
|
|
26433
26452
|
ownKeys() {
|
|
26434
26453
|
return Reflect.ownKeys(getEnvScope(scope));
|
|
@@ -26451,10 +26470,75 @@ function createEnvProxy(scope) {
|
|
|
26451
26470
|
);
|
|
26452
26471
|
}
|
|
26453
26472
|
function getEnvScope(scope) {
|
|
26473
|
+
const env2 = getCurrentEnv();
|
|
26454
26474
|
if (scope === "server") {
|
|
26455
26475
|
assertServerEnvAccess();
|
|
26476
|
+
readRuntimeServerEnv(env2);
|
|
26477
|
+
}
|
|
26478
|
+
return env2[scope] || {};
|
|
26479
|
+
}
|
|
26480
|
+
function readServerEnvKey(server, key) {
|
|
26481
|
+
const value = server[key];
|
|
26482
|
+
if (value === void 0) {
|
|
26483
|
+
const state = getCurrentEnv()[FARM_ENV_RUNTIME_SYMBOL];
|
|
26484
|
+
if (state && key in state.pending && !state.warned.has(key)) {
|
|
26485
|
+
state.warned.add(key);
|
|
26486
|
+
console.warn(
|
|
26487
|
+
`[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.`
|
|
26488
|
+
);
|
|
26489
|
+
}
|
|
26490
|
+
}
|
|
26491
|
+
return value;
|
|
26492
|
+
}
|
|
26493
|
+
function readRuntimeServerEnv(env2) {
|
|
26494
|
+
const state = env2[FARM_ENV_RUNTIME_SYMBOL];
|
|
26495
|
+
if (!state) return;
|
|
26496
|
+
const source = getProcessEnv();
|
|
26497
|
+
for (const [key, type] of Object.entries(state.pending)) {
|
|
26498
|
+
const raw = source[key];
|
|
26499
|
+
if (raw === void 0) continue;
|
|
26500
|
+
env2.server[key] = coerceRuntimeEnvValue(raw, type);
|
|
26501
|
+
delete state.pending[key];
|
|
26502
|
+
}
|
|
26503
|
+
}
|
|
26504
|
+
function getRuntimeEnvType(value) {
|
|
26505
|
+
if (typeof value === "number") return "number";
|
|
26506
|
+
if (typeof value === "boolean") return "boolean";
|
|
26507
|
+
if (value !== null && typeof value === "object" && !(value instanceof Date)) return "json";
|
|
26508
|
+
return "string";
|
|
26509
|
+
}
|
|
26510
|
+
function coerceRuntimeEnvValue(raw, type) {
|
|
26511
|
+
if (type === "number") {
|
|
26512
|
+
const value = Number(raw);
|
|
26513
|
+
return raw.trim() !== "" && Number.isFinite(value) ? value : raw;
|
|
26514
|
+
}
|
|
26515
|
+
if (type === "boolean") {
|
|
26516
|
+
if (/^(true|1)$/i.test(raw.trim())) return true;
|
|
26517
|
+
if (/^(false|0|)$/i.test(raw.trim())) return false;
|
|
26518
|
+
return raw;
|
|
26519
|
+
}
|
|
26520
|
+
if (type === "json") {
|
|
26521
|
+
try {
|
|
26522
|
+
return JSON.parse(raw);
|
|
26523
|
+
} catch {
|
|
26524
|
+
return raw;
|
|
26525
|
+
}
|
|
26456
26526
|
}
|
|
26457
|
-
return
|
|
26527
|
+
return raw;
|
|
26528
|
+
}
|
|
26529
|
+
function prepareEnv(env2) {
|
|
26530
|
+
const normalized = normalizeResolvedEnv(env2);
|
|
26531
|
+
const runtime3 = env2.runtime?.server;
|
|
26532
|
+
if (!isRecord4(runtime3) || Object.keys(runtime3).length === 0) return normalized;
|
|
26533
|
+
const prepared = { server: { ...normalized.server }, public: normalized.public };
|
|
26534
|
+
Object.defineProperty(prepared, FARM_ENV_RUNTIME_SYMBOL, {
|
|
26535
|
+
value: {
|
|
26536
|
+
pending: { ...runtime3 },
|
|
26537
|
+
warned: /* @__PURE__ */ new Set()
|
|
26538
|
+
},
|
|
26539
|
+
enumerable: false
|
|
26540
|
+
});
|
|
26541
|
+
return prepared;
|
|
26458
26542
|
}
|
|
26459
26543
|
function assertServerEnvAccess() {
|
|
26460
26544
|
if (typeof window !== "undefined") {
|
|
@@ -26483,7 +26567,7 @@ function getCurrentEnv() {
|
|
|
26483
26567
|
function getInjectedEnv() {
|
|
26484
26568
|
try {
|
|
26485
26569
|
if (typeof __FARM_ENV__ !== "undefined" && __FARM_ENV__) {
|
|
26486
|
-
return
|
|
26570
|
+
return prepareEnv(__FARM_ENV__);
|
|
26487
26571
|
}
|
|
26488
26572
|
} catch {
|
|
26489
26573
|
}
|
|
@@ -26513,14 +26597,16 @@ function getProcessEnv() {
|
|
|
26513
26597
|
}
|
|
26514
26598
|
return {};
|
|
26515
26599
|
}
|
|
26516
|
-
var FARM_ENV_SYMBOL, farmEnvGlobal, currentEnv, env, serverEnv, publicEnv;
|
|
26600
|
+
var FARM_ENV_SYMBOL, FARM_ENV_RUNTIME_SYMBOL, farmEnvGlobal, currentEnv, env, serverEnv, publicEnv;
|
|
26517
26601
|
var init_env = __esm({
|
|
26518
26602
|
"src/env.ts"() {
|
|
26519
26603
|
"use strict";
|
|
26520
26604
|
FARM_ENV_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env");
|
|
26605
|
+
FARM_ENV_RUNTIME_SYMBOL = /* @__PURE__ */ Symbol.for("farm.env.runtime");
|
|
26521
26606
|
farmEnvGlobal = globalThis;
|
|
26522
26607
|
currentEnv = getInitialEnv();
|
|
26523
26608
|
__name(resolveEnv, "resolveEnv");
|
|
26609
|
+
__name(createBundledEnv, "createBundledEnv");
|
|
26524
26610
|
__name(setEnv, "setEnv");
|
|
26525
26611
|
__name(getResolvedEnv, "getResolvedEnv");
|
|
26526
26612
|
__name(getEnv, "getEnv");
|
|
@@ -26532,6 +26618,11 @@ var init_env = __esm({
|
|
|
26532
26618
|
__name(parseEnvValue, "parseEnvValue");
|
|
26533
26619
|
__name(createEnvProxy, "createEnvProxy");
|
|
26534
26620
|
__name(getEnvScope, "getEnvScope");
|
|
26621
|
+
__name(readServerEnvKey, "readServerEnvKey");
|
|
26622
|
+
__name(readRuntimeServerEnv, "readRuntimeServerEnv");
|
|
26623
|
+
__name(getRuntimeEnvType, "getRuntimeEnvType");
|
|
26624
|
+
__name(coerceRuntimeEnvValue, "coerceRuntimeEnvValue");
|
|
26625
|
+
__name(prepareEnv, "prepareEnv");
|
|
26535
26626
|
__name(assertServerEnvAccess, "assertServerEnvAccess");
|
|
26536
26627
|
__name(getInitialEnv, "getInitialEnv");
|
|
26537
26628
|
__name(getCurrentEnv, "getCurrentEnv");
|
|
@@ -39798,7 +39889,7 @@ function getEnvDefines(config, configEnv) {
|
|
|
39798
39889
|
)
|
|
39799
39890
|
};
|
|
39800
39891
|
if (configEnv?.isSsrBuild) {
|
|
39801
|
-
defines.__FARM_ENV__ = JSON.stringify(getFullEnvDefine(config));
|
|
39892
|
+
defines.__FARM_ENV__ = JSON.stringify(createBundledEnv(getFullEnvDefine(config)));
|
|
39802
39893
|
}
|
|
39803
39894
|
return defines;
|
|
39804
39895
|
}
|
|
@@ -44193,6 +44284,7 @@ var fs14, path38, import_node_url11, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifact
|
|
|
44193
44284
|
var init_vite2 = __esm({
|
|
44194
44285
|
"src/vite.ts"() {
|
|
44195
44286
|
"use strict";
|
|
44287
|
+
init_env();
|
|
44196
44288
|
init_app();
|
|
44197
44289
|
init_utils();
|
|
44198
44290
|
init_plugin();
|
|
@@ -45263,7 +45355,7 @@ export const farmRegistry: {
|
|
|
45263
45355
|
clientManifest?: any;
|
|
45264
45356
|
routePaths?: Record<string, string>;
|
|
45265
45357
|
} = {
|
|
45266
|
-
env: ${JSON.stringify(config.env
|
|
45358
|
+
env: ${JSON.stringify(createBundledEnv(config.env), null, 2)},
|
|
45267
45359
|
deploymentId: ${JSON.stringify(config.deploymentId)},
|
|
45268
45360
|
basePath: ${JSON.stringify(config.basePath)},
|
|
45269
45361
|
apiBasePath: ${JSON.stringify(apiBasePath)},
|
|
@@ -45767,7 +45859,7 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
45767
45859
|
farmRegistry.apiRouteManager = apiRouteManager;
|
|
45768
45860
|
farmRegistry.routeManager = routeManager;
|
|
45769
45861
|
farmRegistry.serverRenderer = serverRenderer;
|
|
45770
|
-
farmRegistry.env = config.env
|
|
45862
|
+
farmRegistry.env = createBundledEnv(config.env);
|
|
45771
45863
|
farmRegistry.deploymentId = config.deploymentId;
|
|
45772
45864
|
farmRegistry.basePath = config.basePath;
|
|
45773
45865
|
};
|
|
@@ -45832,6 +45924,7 @@ var import_path16;
|
|
|
45832
45924
|
var init_nitro = __esm({
|
|
45833
45925
|
"src/nitro/index.ts"() {
|
|
45834
45926
|
"use strict";
|
|
45927
|
+
init_env();
|
|
45835
45928
|
import_path16 = __toESM(require("path"));
|
|
45836
45929
|
init_workflows();
|
|
45837
45930
|
init_cron();
|
|
@@ -45914,7 +46007,11 @@ __export(src_exports, {
|
|
|
45914
46007
|
ServerActionRequestError: () => ServerActionRequestError,
|
|
45915
46008
|
ServerFnFailure: () => ServerFnFailure,
|
|
45916
46009
|
UnsupportedRateLimitStorageError: () => UnsupportedRateLimitStorageError,
|
|
46010
|
+
_attachServerFunctionDescriptor: () => _attachServerFunctionDescriptor,
|
|
46011
|
+
_describeServerFunction: () => _describeServerFunction,
|
|
46012
|
+
_invokeServerFunction: () => _invokeServerFunction,
|
|
45917
46013
|
_parseServerFnSchema: () => _parseServerFnSchema,
|
|
46014
|
+
_runServerFunctionForCaller: () => _runServerFunctionForCaller,
|
|
45918
46015
|
_runWithAfterNodeResponse: () => _runWithAfterNodeResponse,
|
|
45919
46016
|
_runWithAfterRequest: () => _runWithAfterRequest,
|
|
45920
46017
|
_runWithMiddlewareContext: () => _runWithMiddlewareContext,
|
|
@@ -45960,6 +46057,7 @@ __export(src_exports, {
|
|
|
45960
46057
|
cookies: () => cookies,
|
|
45961
46058
|
createAPIClient: () => createAPIClient,
|
|
45962
46059
|
createApiClients: () => createApiClients,
|
|
46060
|
+
createBundledEnv: () => createBundledEnv,
|
|
45963
46061
|
createClientOnlyFn: () => createClientOnlyFn,
|
|
45964
46062
|
createClientPluginManager: () => createClientPluginManager,
|
|
45965
46063
|
createCompressionPlugin: () => createCompressionPlugin,
|
|
@@ -46022,6 +46120,7 @@ __export(src_exports, {
|
|
|
46022
46120
|
createServerActionRequestErrorResponse: () => createServerActionRequestErrorResponse,
|
|
46023
46121
|
createServerFn: () => createServerFn,
|
|
46024
46122
|
createServerFnTransportError: () => createServerFnTransportError,
|
|
46123
|
+
createServerFunctionDescriptor: () => createServerFunctionDescriptor,
|
|
46025
46124
|
createServerMiddleware: () => createServerMiddleware,
|
|
46026
46125
|
createServerOnlyFn: () => createServerOnlyFn,
|
|
46027
46126
|
createServerQuery: () => createServerQuery,
|
|
@@ -52793,8 +52892,74 @@ init_server_action_security();
|
|
|
52793
52892
|
init_request_bridge();
|
|
52794
52893
|
init_cache();
|
|
52795
52894
|
init_server_fn_error();
|
|
52895
|
+
init_navigation_errors();
|
|
52796
52896
|
init_server_fn_error();
|
|
52797
52897
|
var FARM_SERVER_FN_SYMBOL = /* @__PURE__ */ Symbol.for("farm.server-fn");
|
|
52898
|
+
var FARM_SERVER_FUNCTION_DESCRIPTOR = /* @__PURE__ */ Symbol.for("farm.server-function.descriptor");
|
|
52899
|
+
var _ServerFnInputError = class _ServerFnInputError extends Error {
|
|
52900
|
+
constructor(cause) {
|
|
52901
|
+
super("Server function input is invalid");
|
|
52902
|
+
this.cause = cause;
|
|
52903
|
+
}
|
|
52904
|
+
};
|
|
52905
|
+
__name(_ServerFnInputError, "ServerFnInputError");
|
|
52906
|
+
var ServerFnInputError = _ServerFnInputError;
|
|
52907
|
+
function createServerFunctionDescriptor(kind, options, run) {
|
|
52908
|
+
return Object.freeze({
|
|
52909
|
+
kind,
|
|
52910
|
+
input: options.input,
|
|
52911
|
+
output: options.output,
|
|
52912
|
+
mcp: options.mcp === void 0 ? void 0 : Object.freeze({ ...options.mcp }),
|
|
52913
|
+
run
|
|
52914
|
+
});
|
|
52915
|
+
}
|
|
52916
|
+
__name(createServerFunctionDescriptor, "createServerFunctionDescriptor");
|
|
52917
|
+
function _attachServerFunctionDescriptor(target, descriptor) {
|
|
52918
|
+
Object.defineProperty(target, FARM_SERVER_FUNCTION_DESCRIPTOR, {
|
|
52919
|
+
value: descriptor,
|
|
52920
|
+
enumerable: false
|
|
52921
|
+
});
|
|
52922
|
+
}
|
|
52923
|
+
__name(_attachServerFunctionDescriptor, "_attachServerFunctionDescriptor");
|
|
52924
|
+
function getServerFunctionRunner(value) {
|
|
52925
|
+
if (typeof value !== "function") return void 0;
|
|
52926
|
+
return value[FARM_SERVER_FUNCTION_DESCRIPTOR];
|
|
52927
|
+
}
|
|
52928
|
+
__name(getServerFunctionRunner, "getServerFunctionRunner");
|
|
52929
|
+
function _runServerFunctionForCaller(value, input) {
|
|
52930
|
+
const runner = getServerFunctionRunner(value);
|
|
52931
|
+
if (!runner) throw new TypeError("Expected a function created with createServerFn");
|
|
52932
|
+
return runner.run(input);
|
|
52933
|
+
}
|
|
52934
|
+
__name(_runServerFunctionForCaller, "_runServerFunctionForCaller");
|
|
52935
|
+
function _describeServerFunction(value) {
|
|
52936
|
+
const runner = getServerFunctionRunner(value);
|
|
52937
|
+
if (!runner) return void 0;
|
|
52938
|
+
const { kind, input, output, mcp } = runner;
|
|
52939
|
+
return Object.freeze({ kind, input, output, mcp });
|
|
52940
|
+
}
|
|
52941
|
+
__name(_describeServerFunction, "_describeServerFunction");
|
|
52942
|
+
async function _invokeServerFunction(value, input, request2) {
|
|
52943
|
+
const runner = getServerFunctionRunner(value);
|
|
52944
|
+
if (!runner) {
|
|
52945
|
+
throw new TypeError("Expected a function created with createServerFn or createServerQuery");
|
|
52946
|
+
}
|
|
52947
|
+
try {
|
|
52948
|
+
const data = await runWithServerActionRequest(request2, () => runner.run(input));
|
|
52949
|
+
return { ok: true, data };
|
|
52950
|
+
} catch (error) {
|
|
52951
|
+
if (error instanceof ServerFnInputError) {
|
|
52952
|
+
return { ok: false, reason: "input", error: error.cause };
|
|
52953
|
+
}
|
|
52954
|
+
if (isServerFnFailure(error)) return { ok: false, reason: "failure", failure: error };
|
|
52955
|
+
const redirect3 = getFarmRedirectError(error);
|
|
52956
|
+
if (redirect3) {
|
|
52957
|
+
return { ok: false, reason: "redirect", url: redirect3.url, status: redirect3.status };
|
|
52958
|
+
}
|
|
52959
|
+
return { ok: false, reason: "error", error };
|
|
52960
|
+
}
|
|
52961
|
+
}
|
|
52962
|
+
__name(_invokeServerFunction, "_invokeServerFunction");
|
|
52798
52963
|
var UNSAFE_FORM_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
52799
52964
|
function createServerMiddleware(options) {
|
|
52800
52965
|
if (!options || typeof options.handler !== "function") {
|
|
@@ -52818,10 +52983,15 @@ function createServerFn(options) {
|
|
|
52818
52983
|
const middleware2 = resolveServerFnMiddleware(options.middleware);
|
|
52819
52984
|
const errors = normalizeServerFnErrors(options.errors);
|
|
52820
52985
|
const error = createServerFnErrorHandler(errors);
|
|
52821
|
-
const
|
|
52986
|
+
const run = /* @__PURE__ */ __name(async (value, labelInputErrors) => {
|
|
52822
52987
|
const formData = isFormData2(value) ? value : void 0;
|
|
52823
52988
|
const rawInput = formData ? formDataToObject2(formData) : value;
|
|
52824
|
-
|
|
52989
|
+
let input;
|
|
52990
|
+
try {
|
|
52991
|
+
input = await _parseServerFnSchema(options.input, rawInput, "input");
|
|
52992
|
+
} catch (cause) {
|
|
52993
|
+
throw labelInputErrors ? new ServerFnInputError(cause) : cause;
|
|
52994
|
+
}
|
|
52825
52995
|
const executionContext = getServerActionExecutionContext();
|
|
52826
52996
|
const request2 = executionContext?.request ?? _resolveCurrentRequest();
|
|
52827
52997
|
const signal = executionContext?.signal ?? request2?.signal ?? getServerActionSignal();
|
|
@@ -52847,7 +53017,8 @@ function createServerFn(options) {
|
|
|
52847
53017
|
await applyFarmCacheInvalidationTargets(declaration);
|
|
52848
53018
|
}
|
|
52849
53019
|
return parsedResult;
|
|
52850
|
-
}, "
|
|
53020
|
+
}, "run");
|
|
53021
|
+
const serverFn = /* @__PURE__ */ __name((value) => run(value, false), "serverFn");
|
|
52851
53022
|
Object.defineProperties(serverFn, {
|
|
52852
53023
|
[FARM_SERVER_FN_SYMBOL]: {
|
|
52853
53024
|
value: true,
|
|
@@ -52878,6 +53049,10 @@ function createServerFn(options) {
|
|
|
52878
53049
|
enumerable: false
|
|
52879
53050
|
}
|
|
52880
53051
|
});
|
|
53052
|
+
_attachServerFunctionDescriptor(
|
|
53053
|
+
serverFn,
|
|
53054
|
+
createServerFunctionDescriptor("action", options, (value) => run(value, true))
|
|
53055
|
+
);
|
|
52881
53056
|
return serverFn;
|
|
52882
53057
|
}
|
|
52883
53058
|
__name(createServerFn, "createServerFn");
|
|
@@ -53429,6 +53604,16 @@ function createServerQuery(options) {
|
|
|
53429
53604
|
enumerable: false
|
|
53430
53605
|
}
|
|
53431
53606
|
});
|
|
53607
|
+
_attachServerFunctionDescriptor(
|
|
53608
|
+
query,
|
|
53609
|
+
createServerFunctionDescriptor("query", options, async (value) => {
|
|
53610
|
+
const result = await _runServerFunctionForCaller(
|
|
53611
|
+
execute,
|
|
53612
|
+
value
|
|
53613
|
+
);
|
|
53614
|
+
return result.data;
|
|
53615
|
+
})
|
|
53616
|
+
);
|
|
53432
53617
|
return query;
|
|
53433
53618
|
}
|
|
53434
53619
|
__name(createServerQuery, "createServerQuery");
|
|
@@ -53786,6 +53971,7 @@ init_deployment();
|
|
|
53786
53971
|
init_generate_route_types();
|
|
53787
53972
|
|
|
53788
53973
|
// src/build/index.ts
|
|
53974
|
+
init_env();
|
|
53789
53975
|
init_config4();
|
|
53790
53976
|
var import_path17 = __toESM(require("path"));
|
|
53791
53977
|
var import_node_fs15 = require("fs");
|
|
@@ -53796,6 +53982,7 @@ init_server_path();
|
|
|
53796
53982
|
init_layers();
|
|
53797
53983
|
|
|
53798
53984
|
// src/nitro/universal-build.ts
|
|
53985
|
+
init_env();
|
|
53799
53986
|
init_config4();
|
|
53800
53987
|
|
|
53801
53988
|
// src/nitro/client-css-href.ts
|
|
@@ -58480,7 +58667,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
58480
58667
|
},
|
|
58481
58668
|
define: {
|
|
58482
58669
|
__FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
|
|
58483
|
-
__FARM_ENV__: JSON.stringify(config.env
|
|
58670
|
+
__FARM_ENV__: JSON.stringify(createBundledEnv(config.env)),
|
|
58484
58671
|
__FARM_PUBLIC_ENV__: JSON.stringify(config.env?.public || {})
|
|
58485
58672
|
},
|
|
58486
58673
|
plugins: [
|
|
@@ -63931,7 +64118,7 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
63931
64118
|
},
|
|
63932
64119
|
define: {
|
|
63933
64120
|
__FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
|
|
63934
|
-
__FARM_ENV__: JSON.stringify(config.env
|
|
64121
|
+
__FARM_ENV__: JSON.stringify(createBundledEnv(config.env)),
|
|
63935
64122
|
__FARM_PUBLIC_ENV__: JSON.stringify(config.env?.public || {})
|
|
63936
64123
|
},
|
|
63937
64124
|
plugins: [
|
|
@@ -64014,7 +64201,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
64014
64201
|
farmRegistry.apiRouteManager = apiRouteManager;
|
|
64015
64202
|
farmRegistry.routeManager = routeManager;
|
|
64016
64203
|
farmRegistry.serverRenderer = serverRenderer;
|
|
64017
|
-
farmRegistry.env = config.env
|
|
64204
|
+
farmRegistry.env = createBundledEnv(config.env);
|
|
64018
64205
|
const routePaths = {};
|
|
64019
64206
|
for (const [pattern, entry] of routeManager.getRoutes()) {
|
|
64020
64207
|
const bundledPath = entry.modulePath.replace(/.*\/src\/app\//, "").replace(/\.(tsx?|jsx?)$/, ".js");
|
|
@@ -67557,7 +67744,11 @@ __name(cookies, "cookies");
|
|
|
67557
67744
|
ServerActionRequestError,
|
|
67558
67745
|
ServerFnFailure,
|
|
67559
67746
|
UnsupportedRateLimitStorageError,
|
|
67747
|
+
_attachServerFunctionDescriptor,
|
|
67748
|
+
_describeServerFunction,
|
|
67749
|
+
_invokeServerFunction,
|
|
67560
67750
|
_parseServerFnSchema,
|
|
67751
|
+
_runServerFunctionForCaller,
|
|
67561
67752
|
_runWithAfterNodeResponse,
|
|
67562
67753
|
_runWithAfterRequest,
|
|
67563
67754
|
_runWithMiddlewareContext,
|
|
@@ -67603,6 +67794,7 @@ __name(cookies, "cookies");
|
|
|
67603
67794
|
cookies,
|
|
67604
67795
|
createAPIClient,
|
|
67605
67796
|
createApiClients,
|
|
67797
|
+
createBundledEnv,
|
|
67606
67798
|
createClientOnlyFn,
|
|
67607
67799
|
createClientPluginManager,
|
|
67608
67800
|
createCompressionPlugin,
|
|
@@ -67665,6 +67857,7 @@ __name(cookies, "cookies");
|
|
|
67665
67857
|
createServerActionRequestErrorResponse,
|
|
67666
67858
|
createServerFn,
|
|
67667
67859
|
createServerFnTransportError,
|
|
67860
|
+
createServerFunctionDescriptor,
|
|
67668
67861
|
createServerMiddleware,
|
|
67669
67862
|
createServerOnlyFn,
|
|
67670
67863
|
createServerQuery,
|