@farm.js/core 0.1.0-beta.20 → 0.1.0-beta.22
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/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime.d.mts +96 -0
- package/dist/agent-runtime.d.ts +96 -0
- package/dist/agent-runtime.mjs +1 -1
- package/dist/api/route-manager.d.mts +68 -0
- package/dist/api/route-manager.d.ts +68 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.cjs +22 -19
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +50 -0
- package/dist/api.d.ts +50 -0
- package/dist/api.mjs +2 -1
- package/dist/app-BB8GCH1g.d.ts +306 -0
- package/dist/app-DwsTpyNZ.d.mts +306 -0
- package/dist/app-markdown.d.mts +24 -0
- package/dist/app-markdown.d.ts +24 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/{chunk-MIUW47JX.mjs → chunk-2PEJGY5V.mjs} +15 -20
- package/dist/chunk-2PEJGY5V.mjs.map +1 -0
- package/dist/{chunk-RIXKJPGI.mjs → chunk-42325TLU.mjs} +2 -2
- package/dist/{chunk-UNDUIGWC.mjs → chunk-A53LP5QG.mjs} +2 -2
- package/dist/chunk-A53LP5QG.mjs.map +1 -0
- package/dist/{chunk-7BX7NEA7.mjs → chunk-CEVMYGDL.mjs} +2 -2
- package/dist/chunk-CEVMYGDL.mjs.map +1 -0
- package/dist/{chunk-ZYDQS2TT.mjs → chunk-CRN3AH35.mjs} +1 -1
- package/dist/chunk-CRN3AH35.mjs.map +1 -0
- package/dist/{chunk-4KTN2BLF.mjs → chunk-DAUR3WUZ.mjs} +2 -2
- package/dist/{chunk-4KTN2BLF.mjs.map → chunk-DAUR3WUZ.mjs.map} +1 -1
- package/dist/chunk-GIELMNBG.mjs +15 -0
- package/dist/chunk-GIELMNBG.mjs.map +1 -0
- package/dist/{chunk-4EATUJFO.mjs → chunk-ICTGDDV4.mjs} +20 -22
- package/dist/chunk-ICTGDDV4.mjs.map +1 -0
- package/dist/{chunk-5VHPEW6N.mjs → chunk-LLPN5SEZ.mjs} +2 -2
- package/dist/{chunk-TMZEK265.mjs → chunk-XBKXKJX5.mjs} +32 -37
- package/dist/chunk-XBKXKJX5.mjs.map +1 -0
- package/dist/{chunk-ZRMJY4G2.mjs → chunk-ZP73P4VR.mjs} +12 -10
- package/dist/{chunk-ZRMJY4G2.mjs.map → chunk-ZP73P4VR.mjs.map} +1 -1
- package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
- package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
- package/dist/client-BT1mFQas.d.mts +447 -0
- package/dist/client-Nn0q4eO4.d.ts +447 -0
- package/dist/client-cache-CIlyBlmx.d.ts +6 -0
- package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
- package/dist/client-plugins-CbRum1fj.d.ts +2088 -0
- package/dist/client-plugins-QQntVkrv.d.mts +2088 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/config.d.mts +31 -0
- package/dist/config.d.ts +31 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/{devtools-4RDGBT72.mjs → devtools-52FYXIEK.mjs} +3 -3
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.mts +80 -0
- package/dist/docs.d.ts +80 -0
- package/dist/docs.mjs +3 -3
- package/dist/env-types.d.mts +12 -0
- package/dist/env-types.d.ts +12 -0
- package/dist/env.d.mts +45 -0
- package/dist/env.d.ts +45 -0
- package/dist/environment/vite.d.mts +22 -0
- package/dist/environment/vite.d.ts +22 -0
- package/dist/environment.d.mts +18 -0
- package/dist/environment.d.ts +18 -0
- package/dist/font.d.mts +95 -0
- package/dist/font.d.ts +95 -0
- package/dist/headers.d.mts +22 -0
- package/dist/headers.d.ts +22 -0
- package/dist/i18n/client.d.mts +32 -0
- package/dist/i18n/client.d.ts +32 -0
- package/dist/i18n/index.d.mts +20 -0
- package/dist/i18n/index.d.ts +20 -0
- package/dist/i18n/server.d.mts +30 -0
- package/dist/i18n/server.d.ts +30 -0
- package/dist/image/server.d.mts +37 -0
- package/dist/image/server.d.ts +37 -0
- package/dist/image/sharp.d.mts +7 -0
- package/dist/image/sharp.d.ts +7 -0
- package/dist/image-config-Duob7wER.d.mts +50 -0
- package/dist/image-config-Duob7wER.d.ts +50 -0
- package/dist/image.d.mts +39 -0
- package/dist/image.d.ts +39 -0
- package/dist/index.cjs +72 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +477 -0
- package/dist/index.d.ts +477 -0
- package/dist/index.mjs +11 -10
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integrations.cjs.map +1 -1
- package/dist/integrations.d.mts +24 -0
- package/dist/integrations.d.ts +24 -0
- package/dist/integrations.mjs +1 -1
- package/dist/internal/build-runtime.cjs +56 -54
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +41 -0
- package/dist/internal/build-runtime.d.ts +41 -0
- package/dist/internal/build-runtime.mjs +9 -8
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/internal/metadata-image-runtime.d.mts +25 -0
- package/dist/internal/metadata-image-runtime.d.ts +25 -0
- package/dist/internal/production-node-env.d.mts +12 -0
- package/dist/internal/production-node-env.d.ts +12 -0
- package/dist/internal/production-runtime.d.mts +66 -0
- package/dist/internal/production-runtime.d.ts +66 -0
- package/dist/island-CfGru1MO.d.mts +9 -0
- package/dist/island-CfGru1MO.d.ts +9 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/metadata-B5jBJHq1.d.ts +22 -0
- package/dist/metadata-BxOJ4FJl.d.mts +22 -0
- package/dist/middleware.cjs +17 -17
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +171 -0
- package/dist/middleware.d.ts +171 -0
- package/dist/middleware.mjs +3 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/observability.d.mts +335 -0
- package/dist/observability.d.ts +335 -0
- package/dist/params-BALtrRim.d.ts +15 -0
- package/dist/params-ry-lxqmy.d.mts +15 -0
- package/dist/plugin-BJDf43dc.d.mts +165 -0
- package/dist/plugin-BJDf43dc.d.ts +165 -0
- package/dist/plugin.cjs +42 -48
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.mjs +6 -5
- package/dist/production-runtime-Bxua86uR.d.mts +81 -0
- package/dist/production-runtime-CZqXjRVi.d.ts +81 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-7V0GaZK_.d.mts +6 -0
- package/dist/request-B5XYBv5a.d.ts +6 -0
- package/dist/request.d.mts +25 -0
- package/dist/request.d.ts +25 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +226 -0
- package/dist/routes.d.ts +226 -0
- package/dist/runtime-Bpp-c28k.d.ts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-Q3u74Nbq.d.mts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-plugins.d.mts +57 -0
- package/dist/server-plugins.d.ts +57 -0
- package/dist/server-query-client.d.mts +51 -0
- package/dist/server-query-client.d.ts +51 -0
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server.cjs +45 -67
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +51 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.mjs +11 -25
- package/dist/server.mjs.map +1 -1
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/types-DTzm4TCl.d.mts +78 -0
- package/dist/types-DTzm4TCl.d.ts +78 -0
- package/dist/utils-s9pN0Yep.d.mts +23 -0
- package/dist/utils-xTFxzu47.d.ts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +44 -50
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +24 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.mjs +5 -4
- package/dist/workflows-CusFV6mn.d.mts +153 -0
- package/dist/workflows-CusFV6mn.d.ts +153 -0
- package/dist/workflows.d.mts +1 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-4EATUJFO.mjs.map +0 -1
- package/dist/chunk-7BX7NEA7.mjs.map +0 -1
- package/dist/chunk-MIUW47JX.mjs.map +0 -1
- package/dist/chunk-TMZEK265.mjs.map +0 -1
- package/dist/chunk-UNDUIGWC.mjs.map +0 -1
- package/dist/chunk-ZYDQS2TT.mjs.map +0 -1
- /package/dist/{chunk-RIXKJPGI.mjs.map → chunk-42325TLU.mjs.map} +0 -0
- /package/dist/{chunk-5VHPEW6N.mjs.map → chunk-LLPN5SEZ.mjs.map} +0 -0
- /package/dist/{devtools-4RDGBT72.mjs.map → devtools-52FYXIEK.mjs.map} +0 -0
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
declare function applyFarmCacheInvalidations(keys: unknown): void;
|
|
2
|
+
|
|
3
|
+
type RevalidateTagProfile = "max" | "default" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | {
|
|
4
|
+
expire?: number;
|
|
5
|
+
};
|
|
6
|
+
interface FarmCacheOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Tag cached data so it can be invalidated with revalidateTag/updateTag.
|
|
9
|
+
*/
|
|
10
|
+
tags?: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Path tags let revalidatePath invalidate data tied to a route.
|
|
13
|
+
*/
|
|
14
|
+
paths?: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Time in seconds before the entry becomes stale. False means no TTL.
|
|
17
|
+
*/
|
|
18
|
+
revalidate?: number | false;
|
|
19
|
+
}
|
|
20
|
+
interface FarmCacheSetOptions extends FarmCacheOptions {
|
|
21
|
+
createdAt?: number;
|
|
22
|
+
}
|
|
23
|
+
type RouteDataCacheKey = string | readonly unknown[];
|
|
24
|
+
type FarmCacheInvalidationTarget = {
|
|
25
|
+
key: RouteDataCacheKey;
|
|
26
|
+
} | {
|
|
27
|
+
path: string;
|
|
28
|
+
} | {
|
|
29
|
+
tag: string;
|
|
30
|
+
};
|
|
31
|
+
declare const FARM_DEFINED_CACHE_KEY_DATA: unique symbol;
|
|
32
|
+
/**
|
|
33
|
+
* A regular Farm cache key carrying the data shape stored under that key.
|
|
34
|
+
*
|
|
35
|
+
* The brand exists only in TypeScript. At runtime the value remains the
|
|
36
|
+
* original string or structured array, so all existing cache APIs continue to
|
|
37
|
+
* accept untyped keys.
|
|
38
|
+
*/
|
|
39
|
+
type DefinedCacheKey<TData, TKey extends RouteDataCacheKey = RouteDataCacheKey> = TKey & {
|
|
40
|
+
readonly [FARM_DEFINED_CACHE_KEY_DATA]: TData;
|
|
41
|
+
};
|
|
42
|
+
type CacheKeyFactory<TData, TArguments extends readonly unknown[], TKey extends RouteDataCacheKey = RouteDataCacheKey> = (...args: TArguments) => DefinedCacheKey<TData, TKey>;
|
|
43
|
+
type InferCacheKeyData<TKey> = TKey extends DefinedCacheKey<infer TData, RouteDataCacheKey> ? TData : unknown;
|
|
44
|
+
/**
|
|
45
|
+
* Optionally add a data type to an existing string/array cache-key factory.
|
|
46
|
+
*
|
|
47
|
+
* This helper does not introduce a new runtime key representation. Calling the
|
|
48
|
+
* returned factory produces the exact key returned by `factory`.
|
|
49
|
+
*/
|
|
50
|
+
declare function defineCacheKey<TData>(): <const TArguments extends readonly unknown[], const TKey extends RouteDataCacheKey>(factory: (...args: TArguments) => TKey) => CacheKeyFactory<TData, TArguments, TKey>;
|
|
51
|
+
interface FarmCacheEntry<T = unknown> {
|
|
52
|
+
key: string;
|
|
53
|
+
value: T;
|
|
54
|
+
tags: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* Adapter tag versions captured before the cached value was produced.
|
|
57
|
+
* A later version makes the entry stale across every server instance.
|
|
58
|
+
*/
|
|
59
|
+
tagVersions?: Readonly<Record<string, number>>;
|
|
60
|
+
createdAt: number;
|
|
61
|
+
createdVersion?: number;
|
|
62
|
+
revalidate?: number | false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Asynchronous persistence contract used by distributed Farm caches.
|
|
66
|
+
*
|
|
67
|
+
* Implementations are responsible for serializing cache entries and making
|
|
68
|
+
* tag version updates atomic when the backing service supports it.
|
|
69
|
+
*/
|
|
70
|
+
interface FarmCacheAdapter {
|
|
71
|
+
readonly name?: string;
|
|
72
|
+
get<T = unknown>(key: string): Promise<FarmCacheEntry<T> | null | undefined>;
|
|
73
|
+
set<T = unknown>(key: string, entry: FarmCacheEntry<T>): Promise<void>;
|
|
74
|
+
delete(key: string): Promise<void>;
|
|
75
|
+
clear?(): Promise<void>;
|
|
76
|
+
getTagVersions?(tags: readonly string[]): Promise<Readonly<Record<string, number>>>;
|
|
77
|
+
invalidateTags?(tags: readonly string[]): Promise<void>;
|
|
78
|
+
/** Atomically acquire a short-lived regeneration lease. */
|
|
79
|
+
acquireLease?(key: string, ttlMs: number): Promise<string | null | undefined>;
|
|
80
|
+
/** Release the lease only when the supplied ownership token still matches. */
|
|
81
|
+
releaseLease?(key: string, token: string): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
interface FarmCacheUserConfig {
|
|
84
|
+
/** Shared cache implementation, for example a Redis-backed adapter. */
|
|
85
|
+
adapter?: FarmCacheAdapter;
|
|
86
|
+
/** Prefix isolating applications and deployments sharing one adapter. */
|
|
87
|
+
namespace?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Coordinate cache fills across processes when the adapter implements
|
|
90
|
+
* acquireLease/releaseLease. Set false to disable.
|
|
91
|
+
*/
|
|
92
|
+
lease?: false | {
|
|
93
|
+
ttlMs?: number;
|
|
94
|
+
waitTimeoutMs?: number;
|
|
95
|
+
pollIntervalMs?: number;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
interface FarmCacheStorage {
|
|
99
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
100
|
+
setItem<T = unknown>(key: string, value: T): Promise<unknown>;
|
|
101
|
+
removeItem(key: string): Promise<unknown>;
|
|
102
|
+
clear?(base?: string): Promise<unknown>;
|
|
103
|
+
}
|
|
104
|
+
interface StorageFarmCacheAdapterOptions {
|
|
105
|
+
/** Prefix used inside the supplied storage client. */
|
|
106
|
+
base?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Adapt a Farm/unstorage-compatible key-value client to the cache contract.
|
|
110
|
+
*
|
|
111
|
+
* This is a portable baseline adapter. Provider-specific adapters should use
|
|
112
|
+
* their atomic increment/transaction primitives for tag invalidation.
|
|
113
|
+
*/
|
|
114
|
+
declare function storageCacheAdapter(storage: FarmCacheStorage, options?: StorageFarmCacheAdapterOptions): FarmCacheAdapter;
|
|
115
|
+
interface GetFarmCacheEntryOptions {
|
|
116
|
+
allowStale?: boolean;
|
|
117
|
+
now?: number;
|
|
118
|
+
}
|
|
119
|
+
interface FarmCacheStaleEntry {
|
|
120
|
+
tags: Iterable<string>;
|
|
121
|
+
createdAt: number;
|
|
122
|
+
createdVersion?: number;
|
|
123
|
+
revalidate?: number | false;
|
|
124
|
+
}
|
|
125
|
+
declare class FarmDataCache {
|
|
126
|
+
private entries;
|
|
127
|
+
private inflight;
|
|
128
|
+
private invalidatedTagVersions;
|
|
129
|
+
private version;
|
|
130
|
+
private adapter?;
|
|
131
|
+
private namespace;
|
|
132
|
+
private local;
|
|
133
|
+
private lease;
|
|
134
|
+
constructor(config?: FarmCacheUserConfig);
|
|
135
|
+
configure(config?: FarmCacheUserConfig): void;
|
|
136
|
+
get adapterName(): string;
|
|
137
|
+
get hasAdapter(): boolean;
|
|
138
|
+
get size(): number;
|
|
139
|
+
get<T>(key: string, options?: GetFarmCacheEntryOptions): T | undefined;
|
|
140
|
+
getEntry<T = unknown>(key: string, options?: GetFarmCacheEntryOptions): FarmCacheEntry<T> | undefined;
|
|
141
|
+
getEntryAsync<T = unknown>(key: string, options?: GetFarmCacheEntryOptions): Promise<FarmCacheEntry<T> | undefined>;
|
|
142
|
+
set<T>(key: string, value: T, options?: FarmCacheSetOptions): FarmCacheEntry<T>;
|
|
143
|
+
setAsync<T>(key: string, value: T, options?: FarmCacheSetOptions, tagVersions?: Readonly<Record<string, number>>): Promise<FarmCacheEntry<T>>;
|
|
144
|
+
delete(key: string): boolean;
|
|
145
|
+
deleteAsync(key: string): Promise<boolean>;
|
|
146
|
+
clear(): void;
|
|
147
|
+
clearAsync(): Promise<void>;
|
|
148
|
+
isStale(entry: FarmCacheStaleEntry, now?: number): boolean;
|
|
149
|
+
isStaleAsync(entry: FarmCacheEntry, now?: number): Promise<boolean>;
|
|
150
|
+
revalidateTag(tag: string, options?: {
|
|
151
|
+
source?: "revalidateTag" | "updateTag";
|
|
152
|
+
profile?: RevalidateTagProfile;
|
|
153
|
+
}): number;
|
|
154
|
+
revalidateTagAsync(tag: string, options?: {
|
|
155
|
+
source?: "revalidateTag" | "updateTag";
|
|
156
|
+
profile?: RevalidateTagProfile;
|
|
157
|
+
}): Promise<number>;
|
|
158
|
+
revalidatePath(routePath: string): number;
|
|
159
|
+
revalidatePathAsync(routePath: string): Promise<number>;
|
|
160
|
+
getOrSet<T>(key: string, producer: () => Promise<T> | T, options?: FarmCacheOptions): Promise<T>;
|
|
161
|
+
private fillCacheEntry;
|
|
162
|
+
private waitForAdapterEntry;
|
|
163
|
+
private countEntriesForTag;
|
|
164
|
+
private countEntriesForTags;
|
|
165
|
+
private invalidateTag;
|
|
166
|
+
private toPublicEntry;
|
|
167
|
+
private hydrateLocalEntry;
|
|
168
|
+
private createAdapterKey;
|
|
169
|
+
private createAdapterTag;
|
|
170
|
+
private getAdapterTagVersions;
|
|
171
|
+
private isAdapterEntryStale;
|
|
172
|
+
}
|
|
173
|
+
declare function getFarmDataCache(): FarmDataCache;
|
|
174
|
+
declare function configureFarmCache(config: FarmCacheUserConfig | undefined): void;
|
|
175
|
+
declare function unstable_cache<Args extends unknown[], Result>(fn: (...args: Args) => Result | Promise<Result>, keyParts?: readonly unknown[], options?: FarmCacheOptions): (...args: Args) => Promise<Result>;
|
|
176
|
+
declare function revalidateTag(_tag: string, _profile?: RevalidateTagProfile): void | Promise<void>;
|
|
177
|
+
declare function updateTag(tag: string): void | Promise<void>;
|
|
178
|
+
declare function revalidatePath(routePath: string): void | Promise<void>;
|
|
179
|
+
declare function invalidate(key: RouteDataCacheKey): void | Promise<void>;
|
|
180
|
+
declare function invalidateRouteData(key: RouteDataCacheKey): void | Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Apply a normalized set of invalidation targets and return browser cache keys
|
|
183
|
+
* that should be carried with an action/endpoint response.
|
|
184
|
+
*/
|
|
185
|
+
declare function applyFarmCacheInvalidationTargets(targets: readonly FarmCacheInvalidationTarget[]): Promise<readonly string[]>;
|
|
186
|
+
declare function createPathCacheTag(routePath: string): string;
|
|
187
|
+
declare function createRouteDataCacheTag(key: RouteDataCacheKey): string;
|
|
188
|
+
declare function createRouteDataCacheKey(key: RouteDataCacheKey): string;
|
|
189
|
+
declare function normalizeRevalidatePath(routePath: string): string;
|
|
190
|
+
declare function createFarmCacheKey(parts: readonly unknown[]): string;
|
|
191
|
+
|
|
192
|
+
export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeMiddlewareModule
|
|
3
3
|
} from "./chunk-P7QDS5AT.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createCliColors
|
|
6
|
+
} from "./chunk-GIELMNBG.mjs";
|
|
4
7
|
import {
|
|
5
8
|
sendWebResponse
|
|
6
9
|
} from "./chunk-QGOHVJ6J.mjs";
|
|
@@ -14,8 +17,7 @@ import {
|
|
|
14
17
|
emitFarmEvent
|
|
15
18
|
} from "./chunk-7ZY5AIJO.mjs";
|
|
16
19
|
import {
|
|
17
|
-
__name
|
|
18
|
-
__require
|
|
20
|
+
__name
|
|
19
21
|
} from "./chunk-CGILA3WO.mjs";
|
|
20
22
|
|
|
21
23
|
// src/middleware/context.ts
|
|
@@ -354,23 +356,16 @@ var _MiddlewareManager = class _MiddlewareManager {
|
|
|
354
356
|
if (applicable.length === 0) {
|
|
355
357
|
return false;
|
|
356
358
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
].join(" ");
|
|
368
|
-
console.log(log);
|
|
369
|
-
} catch {
|
|
370
|
-
console.log(
|
|
371
|
-
`[FARM] [MIDDLEWARE] [${method}] Executing ${pathname} (${applicable.length} middleware)`
|
|
372
|
-
);
|
|
373
|
-
}
|
|
359
|
+
const pc = createCliColors();
|
|
360
|
+
const log = [
|
|
361
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
362
|
+
pc.dim("[") + pc.bold(pc.magenta("MIDDLEWARE")) + pc.dim("]"),
|
|
363
|
+
pc.dim("[") + pc.bold(pc.white(method.padEnd(3))) + pc.dim("]"),
|
|
364
|
+
pc.gray("Executing middleware: "),
|
|
365
|
+
pc.gray(pathname),
|
|
366
|
+
pc.dim(` (${(Date.now() - startTime).toFixed(2)}ms)`)
|
|
367
|
+
].join(" ");
|
|
368
|
+
console.log(log);
|
|
374
369
|
for (const entry of applicable) {
|
|
375
370
|
const { mw, routeMatch } = entry;
|
|
376
371
|
const configMatch = mw.config ? this.matchesConfig(routePathname, mw.config, ctx) : { matched: true };
|
|
@@ -636,4 +631,4 @@ export {
|
|
|
636
631
|
createContext,
|
|
637
632
|
MiddlewareManager
|
|
638
633
|
};
|
|
639
|
-
//# sourceMappingURL=chunk-
|
|
634
|
+
//# sourceMappingURL=chunk-2PEJGY5V.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/middleware/context.ts","../src/middleware/manager.ts"],"sourcesContent":["/**\n * Middleware Context Implementation\n */\n\nimport type { IncomingMessage, ServerResponse } from \"http\";\nimport type { ViteDevServer } from \"vite\";\nimport type { MiddlewareContext, CookieJar, CookieOptions } from \"./types\";\n\n/**\n * Parse cookies from Cookie header\n */\nfunction parseCookies(cookieHeader?: string): Record<string, string> {\n if (!cookieHeader) return {};\n\n return cookieHeader.split(\";\").reduce(\n (cookies, cookie) => {\n const [name, ...rest] = cookie.split(\"=\");\n const value = rest.join(\"=\").trim();\n if (name && value) {\n cookies[name.trim()] = decodeURIComponent(value);\n }\n return cookies;\n },\n {} as Record<string, string>,\n );\n}\n\n/**\n * Serialize a cookie\n */\nfunction serializeCookie(name: string, value: string, options: CookieOptions = {}): string {\n let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;\n\n if (options.maxAge) {\n cookie += `; Max-Age=${options.maxAge}`;\n }\n\n if (options.expires) {\n cookie += `; Expires=${options.expires.toUTCString()}`;\n }\n\n if (options.path) {\n cookie += `; Path=${options.path}`;\n } else {\n cookie += \"; Path=/\";\n }\n\n if (options.domain) {\n cookie += `; Domain=${options.domain}`;\n }\n\n if (options.secure) {\n cookie += \"; Secure\";\n }\n\n if (options.httpOnly) {\n cookie += \"; HttpOnly\";\n }\n\n if (options.sameSite) {\n cookie += `; SameSite=${options.sameSite.charAt(0).toUpperCase() + options.sameSite.slice(1)}`;\n }\n\n return cookie;\n}\n\n/**\n * Cookie Jar implementation\n */\nclass CookieJarImpl implements CookieJar {\n private cookies: Record<string, string>;\n private setCookies: string[] = [];\n\n constructor(\n private req: IncomingMessage,\n private res: ServerResponse,\n ) {\n this.cookies = parseCookies(req.headers.cookie);\n }\n\n get(name: string): string | undefined {\n return this.cookies[name];\n }\n\n set(name: string, value: string, options: CookieOptions = {}): void {\n this.cookies[name] = value;\n const cookieString = serializeCookie(name, value, options);\n this.setCookies.push(cookieString);\n\n // Update Set-Cookie header\n this.res.setHeader(\"Set-Cookie\", this.setCookies);\n }\n\n delete(name: string): void {\n delete this.cookies[name];\n const cookieString = serializeCookie(name, \"\", {\n maxAge: 0,\n expires: new Date(0),\n });\n this.setCookies.push(cookieString);\n this.res.setHeader(\"Set-Cookie\", this.setCookies);\n }\n\n getAll(): Record<string, string> {\n return { ...this.cookies };\n }\n}\n\n/**\n * Create a middleware context from request/response\n */\nexport function createContext(\n req: IncomingMessage,\n res: ServerResponse,\n viteServer?: ViteDevServer,\n parent?: MiddlewareContext[\"parent\"],\n): MiddlewareContext {\n const url = new URL(req.url || \"/\", `http://${req.headers.host || \"localhost\"}`);\n const headers = new Map<string, string>();\n const data = parent?.data ? new Map(parent.data) : new Map<string, any>();\n const locals = parent?.locals ? new Map(parent.locals) : new Map<string, any>();\n const cookies = new CookieJarImpl(req, res);\n\n // Copy existing headers\n Object.entries(req.headers).forEach(([key, value]) => {\n if (typeof value === \"string\") {\n headers.set(key, value);\n } else if (Array.isArray(value)) {\n headers.set(key, value.join(\", \"));\n }\n });\n\n if (parent?.headers) {\n for (const [key, value] of Object.entries(parent.headers)) {\n headers.set(key, value);\n }\n }\n\n let handled = false;\n\n const ctx: MiddlewareContext = {\n request: req,\n response: res,\n url,\n pathname: url.pathname,\n searchParams: url.searchParams,\n method: req.method || \"GET\",\n params: {},\n route: url.pathname,\n parent,\n vite: {\n isDev: process.env.NODE_ENV !== \"production\",\n hmr: !!viteServer?.hot,\n server: viteServer,\n },\n data,\n locals,\n headers,\n cookies,\n _handled: false,\n\n redirect(redirectUrl: string, status = 307): void {\n if (handled) {\n console.warn(\"Response already sent, cannot redirect\");\n return;\n }\n\n ctx._redirectUrl = redirectUrl;\n ctx._handled = true;\n handled = true;\n\n res.writeHead(status, {\n Location: redirectUrl,\n \"Content-Type\": \"text/plain\",\n });\n res.end(`Redirecting to ${redirectUrl}`);\n },\n\n rewrite(rewriteUrl: string): void {\n ctx._rewriteUrl = rewriteUrl;\n // Update the URL for downstream middleware\n const newUrl = new URL(rewriteUrl, `http://${req.headers.host || \"localhost\"}`);\n ctx.url = newUrl;\n ctx.pathname = newUrl.pathname;\n ctx.searchParams = newUrl.searchParams;\n // Update the original request URL\n req.url = rewriteUrl;\n },\n\n json(jsonData: any, status = 200): void {\n if (handled) {\n console.warn(\"Response already sent, cannot send JSON\");\n return;\n }\n\n ctx._handled = true;\n handled = true;\n\n res.writeHead(status, {\n \"Content-Type\": \"application/json\",\n });\n res.end(JSON.stringify(jsonData));\n },\n\n text(content: string, status = 200): void {\n if (handled) {\n console.warn(\"Response already sent, cannot send text\");\n return;\n }\n\n ctx._handled = true;\n handled = true;\n\n res.writeHead(status, {\n \"Content-Type\": \"text/plain\",\n });\n res.end(content);\n },\n\n html(content: string, status = 200): void {\n if (handled) {\n console.warn(\"Response already sent, cannot send HTML\");\n return;\n }\n\n ctx._handled = true;\n handled = true;\n\n res.writeHead(status, {\n \"Content-Type\": \"text/html\",\n });\n res.end(content);\n },\n };\n\n return ctx;\n}\n","/**\n * Middleware Manager\n *\n * Discovers and executes middleware files in the file system\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { ViteDevServer } from \"vite\";\nimport type { IncomingMessage, ServerResponse } from \"http\";\nimport type {\n FarmMiddlewareConfig,\n MiddlewareFunction,\n MiddlewareMatcher,\n MiddlewareConfig,\n MiddlewareContext,\n MiddlewareResult,\n} from \"./types\";\nimport { createContext } from \"./context\";\nimport { normalizeMiddlewareModule } from \"./module\";\nimport { logger } from \"../utils\";\nimport { sendWebResponse } from \"../server/response\";\nimport { emitFarmEvent } from \"../observability\";\nimport { stripFarmLocaleFromPathname } from \"../i18n/routing\";\nimport type { ResolvedFarmI18nConfig } from \"../i18n/types\";\nimport { createCliColors } from \"../cli-colors\";\n\nexport interface DiscoveredMiddleware {\n path: string;\n filePath: string;\n handlers: MiddlewareFunction[];\n config?: MiddlewareConfig;\n source?: \"config\" | \"file\";\n}\n\nfunction isMiddlewareResponse(value: unknown): value is Response {\n return value instanceof Response;\n}\n\n/**\n * Middleware Manager - discovers and executes middleware\n */\nexport class MiddlewareManager {\n private middleware: DiscoveredMiddleware[] = [];\n private configMiddleware: DiscoveredMiddleware[] = [];\n private globalConfig?: MiddlewareConfig;\n private viteServer?: ViteDevServer;\n private appDirs: string[];\n private i18n?: ResolvedFarmI18nConfig;\n\n constructor(\n appDir: string | readonly string[],\n viteServer?: ViteDevServer,\n config?: FarmMiddlewareConfig,\n i18n?: ResolvedFarmI18nConfig,\n ) {\n this.appDirs = Array.isArray(appDir) ? [...appDir] : [appDir as string];\n this.viteServer = viteServer;\n this.i18n = i18n;\n this.configure(config);\n }\n\n configure(config?: FarmMiddlewareConfig): void {\n this.configMiddleware = [];\n this.globalConfig = undefined;\n\n if (!config) return;\n\n const entries = Array.isArray(config) ? config : [config];\n\n for (const [index, entry] of entries.entries()) {\n const handlers = this.getConfigHandlers(entry);\n const middlewareConfig = this.toMiddlewareConfig(entry);\n\n if (handlers.length === 0) {\n this.globalConfig = middlewareConfig;\n continue;\n }\n\n this.configMiddleware.push({\n path: \"/\",\n filePath: `farm.config.ts#middleware-${index}`,\n handlers,\n config: middlewareConfig,\n source: \"config\",\n });\n }\n }\n\n /**\n * Discover all middleware.ts files\n */\n async discover(): Promise<void> {\n const middlewareByPath = new Map<string, DiscoveredMiddleware>();\n for (const appDir of this.appDirs) {\n const discovered: DiscoveredMiddleware[] = [];\n await this.discoverInDirectory(appDir, \"/\", discovered);\n for (const middleware of discovered) {\n middlewareByPath.set(middleware.path, middleware);\n }\n }\n this.middleware = Array.from(middlewareByPath.values());\n\n // Sort by path depth (root first, then nested)\n this.middleware.sort((a, b) => {\n const depthA = a.path.split(\"/\").length;\n const depthB = b.path.split(\"/\").length;\n return depthA - depthB;\n });\n\n if (process.env.FARM_VERBOSE && this.middleware.length > 0) {\n logger.success(`Discovered ${this.middleware.length} middleware files`);\n for (const mw of this.middleware) {\n logger.info(` ${mw.path} (${mw.handlers.length} handlers)`);\n }\n }\n }\n\n /**\n * Recursively discover middleware files\n */\n private async discoverInDirectory(\n dir: string,\n routePath: string,\n discovered: DiscoveredMiddleware[],\n ): Promise<void> {\n if (!fs.existsSync(dir)) {\n return;\n }\n\n // Check for middleware.ts in current directory\n const middlewareFile = this.findMiddlewareFile(dir);\n if (middlewareFile) {\n const middleware = await this.loadMiddleware(middlewareFile, routePath);\n if (middleware) {\n discovered.push(middleware);\n }\n }\n\n // Recursively check subdirectories\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory() && !entry.name.startsWith(\".\") && !entry.name.startsWith(\"_\")) {\n const subPath = path.join(dir, entry.name);\n const subRoutePath = path.posix.join(routePath, entry.name);\n await this.discoverInDirectory(subPath, subRoutePath, discovered);\n }\n }\n }\n\n /**\n * Find middleware file in directory\n */\n private findMiddlewareFile(dir: string): string | null {\n const extensions = [\".ts\", \".tsx\", \".js\", \".jsx\"];\n for (const ext of extensions) {\n const filePath = path.join(dir, `middleware${ext}`);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n return null;\n }\n\n /**\n * Load a middleware file\n */\n private async loadMiddleware(\n filePath: string,\n routePath: string,\n ): Promise<DiscoveredMiddleware | null> {\n try {\n // Load the module\n let module: any;\n if (this.viteServer) {\n module = await this.viteServer.ssrLoadModule(filePath);\n } else {\n const fileUrl = `file://${filePath}`;\n module = await import(/* @vite-ignore */ fileUrl);\n }\n\n const normalized = normalizeMiddlewareModule(module, routePath);\n if (!normalized) {\n logger.warn(\n `Middleware file ${filePath} must export a default handler or a named middleware handler`,\n );\n return null;\n }\n\n return {\n path: routePath,\n filePath,\n handlers: normalized.handlers,\n config: normalized.config,\n source: \"file\",\n };\n } catch (error) {\n logger.error(`Failed to load middleware ${filePath}: ${error}`);\n return null;\n }\n }\n\n /**\n * Execute middleware for a request\n */\n async execute(req: IncomingMessage, res: ServerResponse): Promise<boolean> {\n const url = new URL(req.url || \"/\", `http://${req.headers.host || \"localhost\"}`);\n const pathname = url.pathname;\n const routePathname = this.i18n?.enabled\n ? stripFarmLocaleFromPathname(pathname, this.i18n)\n : pathname;\n const method = req.method || \"GET\";\n const startTime = Date.now();\n\n let parentData: MiddlewareContext[\"parent\"] | undefined;\n let ctx = createContext(req, res, this.viteServer);\n\n if (this.globalConfig) {\n const globalMatch = this.matchesConfig(routePathname, this.globalConfig, ctx);\n if (!globalMatch.matched) {\n return false;\n }\n if (globalMatch.params) {\n ctx.params = { ...ctx.params, ...globalMatch.params };\n }\n }\n\n // Find applicable middleware (config entries first, then cascading files)\n const applicable: Array<{\n mw: DiscoveredMiddleware;\n routeMatch: { matched: boolean; params?: Record<string, string> };\n }> = [\n ...this.configMiddleware.map((mw) => ({ mw, routeMatch: { matched: true } })),\n ...this.middleware\n .map((mw) => ({ mw, routeMatch: this.matchRoutePath(routePathname, mw.path) }))\n .filter((entry) => entry.routeMatch.matched),\n ];\n\n if (applicable.length === 0) {\n return false; // No middleware to run\n }\n const pc = createCliColors();\n const log = [\n pc.dim(\"[\") + pc.bold(pc.blue(\"FARM\")) + pc.dim(\"]\"),\n pc.dim(\"[\") + pc.bold(pc.magenta(\"MIDDLEWARE\")) + pc.dim(\"]\"),\n pc.dim(\"[\") + pc.bold(pc.white(method.padEnd(3))) + pc.dim(\"]\"),\n pc.gray(\"Executing middleware: \"),\n pc.gray(pathname),\n pc.dim(` (${(Date.now() - startTime).toFixed(2)}ms)`),\n ].join(\" \");\n console.log(log);\n\n // Execute middleware in cascade order\n for (const entry of applicable) {\n // Check matcher configuration\n const { mw, routeMatch } = entry;\n const configMatch = mw.config\n ? this.matchesConfig(routePathname, mw.config, ctx)\n : { matched: true };\n if (!configMatch.matched) {\n continue;\n }\n if (routeMatch.params) {\n ctx.params = { ...ctx.params, ...routeMatch.params };\n }\n if (configMatch.params) {\n ctx.params = { ...ctx.params, ...configMatch.params };\n }\n\n // Create new context with parent data\n if (parentData) {\n ctx = createContext(req, res, this.viteServer, parentData);\n if (routeMatch.params) {\n ctx.params = { ...ctx.params, ...routeMatch.params };\n }\n if (configMatch.params) {\n ctx.params = { ...ctx.params, ...configMatch.params };\n }\n }\n\n const middlewareStartTime = Date.now();\n const middlewareEvent = {\n route: mw.path,\n pathname,\n name: mw.filePath,\n };\n emitFarmEvent({ type: \"middleware.start\", ...middlewareEvent });\n\n try {\n // Execute all handlers in this middleware\n let handlerIndex = 0;\n let returnedResponse: Response | undefined;\n const executeNext = async (): Promise<MiddlewareResult> => {\n if (handlerIndex < mw.handlers.length) {\n const handler = mw.handlers[handlerIndex++];\n const result = await handler(ctx, executeNext);\n if (isMiddlewareResponse(result)) {\n returnedResponse = result;\n return result;\n }\n }\n return returnedResponse;\n };\n\n const result = await executeNext();\n const response = isMiddlewareResponse(result) ? result : returnedResponse;\n if (response) {\n if (!res.headersSent && !res.writableEnded) {\n for (const [key, value] of ctx.headers) {\n try {\n res.setHeader(key, value);\n } catch (error) {}\n }\n }\n emitFarmEvent({\n type: \"middleware.shortCircuit\",\n ...middlewareEvent,\n status: response.status,\n });\n await sendWebResponse(res, response);\n return true;\n }\n\n // Check if response has been sent or handled by middleware helpers.\n if (ctx._handled || res.headersSent || res.writableEnded) {\n emitFarmEvent({\n type: \"middleware.shortCircuit\",\n ...middlewareEvent,\n status: res.statusCode,\n });\n return true;\n }\n\n emitFarmEvent({\n type: \"middleware.complete\",\n ...middlewareEvent,\n durationMs: Date.now() - middlewareStartTime,\n });\n } catch (error) {\n emitFarmEvent({\n type: \"middleware.error\",\n ...middlewareEvent,\n error,\n });\n throw error;\n }\n\n parentData = {\n data: new Map(ctx.data),\n locals: new Map(ctx.locals),\n headers: Object.fromEntries(ctx.headers),\n };\n }\n\n if (!res.headersSent && !res.writableEnded) {\n for (const [key, value] of ctx.headers) {\n try {\n res.setHeader(key, value);\n } catch (error) {}\n }\n }\n\n (req as any).__FARM_MIDDLEWARE_DATA__ = new Map(ctx.data);\n (req as any).__FARM_MIDDLEWARE_CONTEXT__ = new Map(ctx.locals);\n\n return false; // Continue to page rendering\n }\n\n /**\n * Check if pathname matches middleware config\n */\n private matchesConfig(\n pathname: string,\n config: MiddlewareConfig,\n ctx: MiddlewareContext,\n ): { matched: boolean; params?: Record<string, string> } {\n // Check exclusions\n if (config.exclude) {\n for (const pattern of config.exclude) {\n if (this.matchPattern(pattern, pathname).matched) {\n return { matched: false };\n }\n }\n }\n\n // Check matchers\n if (config.matcher) {\n for (const matcher of this.toMatcherList(config.matcher)) {\n if (typeof matcher === \"string\" || matcher instanceof RegExp) {\n const result = this.matchPattern(matcher, pathname);\n if (result.matched) {\n return result;\n }\n } else if (typeof matcher === \"function\") {\n return { matched: matcher(ctx) };\n }\n }\n return { matched: false };\n }\n\n return { matched: true };\n }\n\n /**\n * Match a pattern against pathname\n */\n private matchPattern(\n pattern: string | RegExp,\n pathname: string,\n ): { matched: boolean; params?: Record<string, string> } {\n if (pattern instanceof RegExp) {\n pattern.lastIndex = 0;\n const match = pattern.exec(pathname);\n return {\n matched: !!match,\n params: match?.groups ? { ...match.groups } : undefined,\n };\n }\n\n if (pattern === \"*\" || pattern === \"/(.*)\") {\n return { matched: true };\n }\n\n if (pattern.endsWith(\"(.*)\")) {\n const prefix = pattern.slice(0, -4);\n return { matched: pathname === prefix || pathname.startsWith(`${prefix}/`) };\n }\n\n const { regex, params } = this.compilePathPattern(pattern);\n const match = regex.exec(pathname);\n if (!match) {\n return { matched: false };\n }\n\n const values: Record<string, string> = {};\n params.forEach((param, index) => {\n values[param] = decodeURIComponent(match[index + 1] || \"\");\n });\n\n return {\n matched: true,\n params: Object.keys(values).length > 0 ? values : undefined,\n };\n }\n\n /**\n * Reload middleware (for HMR)\n */\n async reload(): Promise<void> {\n await this.discover();\n }\n\n getMiddlewares(): DiscoveredMiddleware[] {\n return [...this.configMiddleware, ...this.middleware];\n }\n\n hasMiddleware(): boolean {\n return this.configMiddleware.length > 0 || this.middleware.length > 0;\n }\n\n private matchRoutePath(\n pathname: string,\n middlewarePath: string,\n ): { matched: boolean; params?: Record<string, string> } {\n if (middlewarePath === \"/\") return { matched: true };\n\n const exactMatch = this.matchPattern(middlewarePath, pathname);\n if (exactMatch.matched) {\n return exactMatch;\n }\n\n const nestedMatch = this.matchPattern(`${middlewarePath}/:__farmRest*`, pathname);\n if (!nestedMatch.matched) {\n return { matched: false };\n }\n\n const params = { ...nestedMatch.params };\n delete params.__farmRest;\n return {\n matched: true,\n params: Object.keys(params).length > 0 ? params : undefined,\n };\n }\n\n private toMatcherList(matcher: MiddlewareConfig[\"matcher\"]): MiddlewareMatcher[] {\n if (!matcher) return [];\n return Array.isArray(matcher) ? matcher : [matcher];\n }\n\n private getConfigHandlers(\n entry:\n | MiddlewareConfig\n | (MiddlewareConfig & {\n handler?: MiddlewareFunction;\n handlers?: MiddlewareFunction[];\n }),\n ): MiddlewareFunction[] {\n const handlers: MiddlewareFunction[] = [];\n if (\"handler\" in entry && typeof entry.handler === \"function\") {\n handlers.push(entry.handler);\n }\n if (\"handlers\" in entry && Array.isArray(entry.handlers)) {\n handlers.push(...entry.handlers.filter((handler) => typeof handler === \"function\"));\n }\n return handlers;\n }\n\n private toMiddlewareConfig(\n entry: MiddlewareConfig & {\n handler?: MiddlewareFunction;\n handlers?: MiddlewareFunction[];\n },\n ): MiddlewareConfig {\n const { matcher, exclude, runtime } = entry;\n return { matcher, exclude, runtime };\n }\n\n private compilePathPattern(pattern: string): { regex: RegExp; params: string[] } {\n const params: string[] = [];\n const segments = pattern.split(\"/\").filter(Boolean);\n\n if (segments.length === 0) {\n return { regex: /^\\/$/, params };\n }\n\n const parts = segments.map((segment) => {\n if (segment === \"**\") {\n return \"(?:/.*)?\";\n }\n\n if (segment === \"*\") {\n return \"/[^/]+\";\n }\n\n if (segment.startsWith(\":\")) {\n const { name, modifier } = this.parseColonParam(segment);\n params.push(name);\n\n if (modifier === \"*\") {\n return \"(?:/(.*))?\";\n }\n if (modifier === \"+\") {\n return \"/(.+)\";\n }\n return \"/([^/]+)\";\n }\n\n if (segment.startsWith(\"[...\") && segment.endsWith(\"]\")) {\n params.push(segment.slice(4, -1));\n return \"(?:/(.*))?\";\n }\n\n if (segment.startsWith(\"[\") && segment.endsWith(\"]\")) {\n params.push(segment.slice(1, -1));\n return \"/([^/]+)\";\n }\n\n return `/${this.escapeRegex(segment).replace(/\\\\\\*/g, \"[^/]*\")}`;\n });\n\n return {\n regex: new RegExp(`^${parts.join(\"\")}$`),\n params,\n };\n }\n\n private parseColonParam(segment: string): { name: string; modifier?: string } {\n const raw = segment.slice(1);\n const last = raw[raw.length - 1];\n const modifier = last === \"*\" || last === \"+\" || last === \"?\" ? last : undefined;\n return {\n name: modifier ? raw.slice(0, -1) : raw,\n modifier,\n };\n }\n\n private escapeRegex(value: string): string {\n return value.replace(/[|\\\\{}()[\\]^$+?.]/g, \"\\\\$&\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAS,aAAa,cAA+C;AACnE,MAAI,CAAC,aAAc,QAAO,CAAC;AAE3B,SAAO,aAAa,MAAM,GAAG,EAAE;AAAA,IAC7B,CAAC,SAAS,WAAW;AACnB,YAAM,CAAC,MAAM,GAAG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AA,MACT;AAEA,UAAI,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GAAG;AACpD,eAAO,KAAK,QAAQ,MAAM,GAAG,EAAE,CAAC;AAChC,eAAO;AAAA,MACT;AAEA,aAAO,IAAI,KAAK,YAAY,OAAO,EAAE,QAAQ,SAAS,OAAO,CAAC;AAAA,IAChE,CAAC;AAED,WAAO;AAAA,MACL,OAAO,IAAI,OAAO,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,gBAAgB,SAAsD;AAC5E,UAAM,MAAM,QAAQ,MAAM,CAAC;AAC3B,UAAM,OAAO,IAAI,IAAI,SAAS,CAAC;AAC/B,UAAM,WAAW,SAAS,OAAO,SAAS,OAAO,SAAS,MAAM,OAAO;AACvE,WAAO;AAAA,MACL,MAAM,WAAW,IAAI,MAAM,GAAG,EAAE,IAAI;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,YAAY,OAAuB;AACzC,WAAO,MAAM,QAAQ,sBAAsB,MAAM;AAAA,EACnD;AACF;AAzhB+B;AAAxB,IAAM,oBAAN;","names":["result","match"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MiddlewareManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2PEJGY5V.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-CGILA3WO.mjs";
|
|
@@ -455,4 +455,4 @@ export {
|
|
|
455
455
|
hasMiddlewareData,
|
|
456
456
|
farmMiddlewarePlugin
|
|
457
457
|
};
|
|
458
|
-
//# sourceMappingURL=chunk-
|
|
458
|
+
//# sourceMappingURL=chunk-42325TLU.mjs.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getRequestContextSnapshot,
|
|
10
10
|
hasRequestContext,
|
|
11
11
|
setRequestContext
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CRN3AH35.mjs";
|
|
13
13
|
import {
|
|
14
14
|
__name
|
|
15
15
|
} from "./chunk-CGILA3WO.mjs";
|
|
@@ -670,4 +670,4 @@ export {
|
|
|
670
670
|
PluginManager,
|
|
671
671
|
definePlugin
|
|
672
672
|
};
|
|
673
|
-
//# sourceMappingURL=chunk-
|
|
673
|
+
//# sourceMappingURL=chunk-A53LP5QG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { FarmConfig, FarmRequest, FarmResponse } from \"./types\";\nimport type { ViteDevServer } from \"vite\";\nimport type { FarmClientPlugin } from \"./client/plugin\";\nimport { getResolvedEnv, type ResolvedFarmEnv } from \"./env\";\nimport {\n clearRequestContext,\n deleteRequestContext,\n getRequestContext,\n getRequestContextSnapshot,\n hasRequestContext,\n setRequestContext,\n} from \"./request-context\";\nimport { getFarmPluginIntegrationContext } from \"./plugin-integration-context\";\n\ntype MaybePromise<T> = T | Promise<T>;\ndeclare const FARM_PLUGIN_INTEGRATION_INSTANCE: unique symbol;\ndeclare const FARM_PLUGIN_INTEGRATION_BOUND: unique symbol;\n\nexport interface FarmPluginIntegrationContext<TInstance = unknown> {\n /** Key used to register the integration in farm.config.ts. */\n readonly key: string;\n readonly category: string;\n readonly type: string;\n readonly instance: TInstance;\n readonly serverRuntime: boolean;\n}\n\nexport class FarmRuntimeShutdownError extends Error {\n readonly errors: readonly unknown[];\n\n constructor(message: string, errors: readonly unknown[]) {\n super(message);\n this.name = \"FarmRuntimeShutdownError\";\n this.errors = errors;\n }\n}\n\nexport interface PluginRequestContext {\n set: (\n target: FarmRequest | Request,\n key: string,\n value: any,\n options?: { exposeToPage?: boolean },\n ) => void;\n get: <T = any>(target: FarmRequest | Request, key: string) => T | undefined;\n has: (target: FarmRequest | Request, key: string) => boolean;\n delete: (target: FarmRequest | Request, key: string) => boolean;\n clear: (target: FarmRequest | Request) => void;\n getAll: (target: FarmRequest | Request, options?: { exposedOnly?: boolean }) => Map<string, any>;\n}\n\nexport interface FarmRequestStore {\n set(key: string, value: unknown, options?: { exposeToPage?: boolean }): void;\n get<T = unknown>(key: string): T | undefined;\n has(key: string): boolean;\n delete(key: string): boolean;\n clear(): void;\n snapshot(options?: { exposedOnly?: boolean }): Map<string, unknown>;\n}\n\nexport interface FarmPluginContext<TIntegrationInstance = unknown> {\n config: FarmConfig;\n viteServer?: ViteDevServer;\n isDev: boolean;\n isProd: boolean;\n /** The owning integration when this plugin is contributed through `integration.plugins`. */\n readonly integration?: Readonly<FarmPluginIntegrationContext<TIntegrationInstance>>;\n /** Register resource cleanup that must run when the application runtime closes. */\n lifecycle: FarmPluginLifecycle;\n /** @deprecated Use `ctx.req` inside request hooks. */\n requestContext: PluginRequestContext;\n}\n\ntype FarmPluginHookContext<\n TContext,\n TIntegrationInstance,\n TIntegrationBound extends boolean,\n> = TIntegrationBound extends true\n ? Omit<TContext, \"integration\"> & {\n /** The owning integration bound by `definePlugin.forIntegration<T>()`. */\n readonly integration: Readonly<FarmPluginIntegrationContext<TIntegrationInstance>>;\n }\n : TContext;\n\nexport interface FarmPluginLifecycle {\n /**\n * Register a database, storage, queue, or other resource disposer.\n * Disposers run once in reverse registration order after plugin shutdown hooks.\n */\n onShutdown(dispose: () => void | Promise<void>): () => void;\n}\n\nexport interface FarmRequestPluginContext<\n TIntegrationInstance = unknown,\n> extends FarmPluginContext<TIntegrationInstance> {\n /** Request-scoped values for the current hook invocation. */\n readonly req: FarmRequestStore;\n}\n\nexport interface RouteDiscoveredPayload {\n kind: \"page\" | \"layout\";\n pattern: string;\n modulePath: string;\n}\n\nexport interface RoutesGeneratedPayload {\n routes: RouteDiscoveredPayload[];\n pageCount: number;\n layoutCount: number;\n}\n\nexport interface MiddlewareDiscoveredPayload {\n path: string;\n filePath: string;\n handlerCount: number;\n}\n\nexport interface APIRouteDiscoveredPayload {\n path: string;\n filePath: string;\n methods: string[];\n}\n\nexport interface RouteMatchPayload {\n pathname: string;\n method?: string;\n}\n\nexport interface RouteMatchResultPayload {\n pathname: string;\n matched: boolean;\n routePattern: string | null;\n params: Record<string, string>;\n layoutPatterns: string[];\n}\n\nexport interface RenderLifecyclePayload {\n pathname: string;\n method: string;\n routePattern: string | null;\n params: Record<string, string>;\n}\n\nexport interface APIHandlerLifecyclePayload {\n pathname: string;\n method: string;\n routePath?: string;\n}\n\nexport interface ErrorLifecyclePayload {\n phase: string;\n error: unknown;\n meta?: Record<string, unknown>;\n}\n\nexport interface HMRUpdatePayload {\n file: string;\n modules: string[];\n}\n\nexport interface BundleLifecyclePayload {\n root: string;\n preset: string;\n universal: boolean;\n distDir: string;\n outputDir?: string;\n}\n\nexport interface BundleResultPayload extends BundleLifecyclePayload {\n success: boolean;\n}\n\nexport interface NitroBuildLifecyclePayload {\n root: string;\n preset: string;\n distDir: string;\n outputDir: string;\n}\n\nexport interface ShutdownPayload {\n reason: string;\n}\n\nexport type FarmPluginRuntimeKind =\n | \"request\"\n | \"page\"\n | \"api\"\n | \"action\"\n | \"integration\"\n | \"docs\"\n | \"asset\"\n | (string & {});\n\nexport interface FarmPluginRouteRuntimePayload {\n pathname: string;\n pattern?: string | null;\n params?: Record<string, string>;\n}\n\nexport interface FarmPluginSetupContext<\n TIntegrationInstance = unknown,\n> extends FarmPluginContext<TIntegrationInstance> {\n env: ResolvedFarmEnv;\n}\n\nexport interface FarmPluginStateContext<\n TState = unknown,\n TIntegrationInstance = unknown,\n> extends FarmPluginContext<TIntegrationInstance> {\n state: TState;\n}\n\nexport interface FarmPluginRuntimeBaseEvent<\n TState = unknown,\n TIntegrationInstance = unknown,\n> extends FarmPluginStateContext<TState, TIntegrationInstance> {\n request: Request;\n /** Request-scoped values shared by plugin hooks. */\n req: FarmRequestStore;\n kind: FarmPluginRuntimeKind;\n route?: FarmPluginRouteRuntimePayload;\n signal: AbortSignal;\n waitUntil(promise: Promise<unknown>): void;\n}\n\nexport type FarmPluginRuntimeContextEvent<\n TState = unknown,\n TIntegrationInstance = unknown,\n> = FarmPluginRuntimeBaseEvent<TState, TIntegrationInstance>;\n\nexport interface FarmPluginRuntimeBeforeEvent<\n TState = unknown,\n TRequestContext extends object = Record<string, unknown>,\n TIntegrationInstance = unknown,\n> extends FarmPluginRuntimeBaseEvent<TState, TIntegrationInstance> {\n ctx: Readonly<TRequestContext>;\n}\n\nexport interface FarmPluginRuntimeAfterEvent<\n TState = unknown,\n TRequestContext extends object = Record<string, unknown>,\n TIntegrationInstance = unknown,\n> extends FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance> {\n response: Response;\n durationMs: number;\n}\n\nexport interface FarmPluginRuntimeErrorEvent<\n TState = unknown,\n TRequestContext extends object = Record<string, unknown>,\n TIntegrationInstance = unknown,\n> extends FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance> {\n error: unknown;\n durationMs: number;\n}\n\nexport type FarmPluginRuntimeStartEvent<\n TState = unknown,\n TIntegrationInstance = unknown,\n> = FarmPluginStateContext<TState, TIntegrationInstance>;\n\nexport interface FarmPluginRuntimeCloseEvent<TState = unknown, TIntegrationInstance = unknown>\n extends FarmPluginStateContext<TState, TIntegrationInstance>, ShutdownPayload {}\n\ntype FarmPluginContextFor<\n TIntegrationInstance,\n TIntegrationBound extends boolean,\n> = FarmPluginHookContext<\n FarmPluginContext<TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n>;\n\ntype FarmRequestPluginContextFor<\n TIntegrationInstance,\n TIntegrationBound extends boolean,\n> = FarmPluginHookContext<\n FarmRequestPluginContext<TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n>;\n\ntype FarmPluginSetupContextFor<\n TIntegrationInstance,\n TIntegrationBound extends boolean,\n> = FarmPluginHookContext<\n FarmPluginSetupContext<TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n>;\n\ntype FarmPluginStateContextFor<\n TState,\n TIntegrationInstance,\n TIntegrationBound extends boolean,\n> = FarmPluginHookContext<\n FarmPluginStateContext<TState, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n>;\n\ntype FarmPluginRuntimeEventFor<\n TEvent,\n TIntegrationInstance,\n TIntegrationBound extends boolean,\n> = FarmPluginHookContext<TEvent, TIntegrationInstance, TIntegrationBound>;\n\nexport interface FarmPluginRuntimeHooks<\n TState = unknown,\n TRequestContext extends object = Record<string, unknown>,\n TIntegrationInstance = unknown,\n TIntegrationBound extends boolean = false,\n> {\n start?(\n event: FarmPluginRuntimeEventFor<\n FarmPluginRuntimeStartEvent<TState, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n >,\n ): MaybePromise<void>;\n context?(\n event: FarmPluginRuntimeEventFor<\n FarmPluginRuntimeContextEvent<TState, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n >,\n ): MaybePromise<TRequestContext>;\n before?(\n event: FarmPluginRuntimeEventFor<\n FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n >,\n ): MaybePromise<Request | Response | void>;\n after?(\n event: FarmPluginRuntimeEventFor<\n FarmPluginRuntimeAfterEvent<TState, TRequestContext, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n >,\n ): MaybePromise<Response | void>;\n error?(\n event: FarmPluginRuntimeEventFor<\n FarmPluginRuntimeErrorEvent<TState, TRequestContext, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n >,\n ): MaybePromise<void>;\n close?(\n event: FarmPluginRuntimeEventFor<\n FarmPluginRuntimeCloseEvent<TState, TIntegrationInstance>,\n TIntegrationInstance,\n TIntegrationBound\n >,\n ): MaybePromise<void>;\n}\n\nexport interface FarmPluginRuntimeRequestOptions {\n kind?: FarmPluginRuntimeKind;\n route?: FarmPluginRouteRuntimePayload;\n waitUntil?: (promise: Promise<unknown>) => void;\n}\n\nexport type FarmPluginRuntimeRequestHandler = (request: Request) => MaybePromise<Response>;\n\nexport interface FarmPluginRuntimeSession {\n request: Request;\n response?: Response;\n ctx: Readonly<Record<string, unknown>>;\n startedAt: number;\n options: FarmPluginRuntimeRequestOptions;\n waitUntil(promise: Promise<unknown>): void;\n}\n\nexport type FarmPluginDiscoveredRoute =\n | RouteDiscoveredPayload\n | ({ kind: \"middleware\" } & MiddlewareDiscoveredPayload)\n | ({ kind: \"api\" } & APIRouteDiscoveredPayload);\n\nexport interface FarmPluginRouterHooks<\n TState = unknown,\n TIntegrationInstance = unknown,\n TIntegrationBound extends boolean = false,\n> {\n discovered?(\n route: FarmPluginDiscoveredRoute,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n generated?(\n routes: RoutesGeneratedPayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n before?(\n route: RouteMatchPayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n after?(\n result: RouteMatchResultPayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n}\n\nexport interface FarmPluginRenderHooks<\n TState = unknown,\n TIntegrationInstance = unknown,\n TIntegrationBound extends boolean = false,\n> {\n before?(\n render: RenderLifecyclePayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n html?(\n html: string,\n render: RenderLifecyclePayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<string | void>;\n}\n\nexport interface FarmPluginBuildHooks<\n TState = unknown,\n TIntegrationInstance = unknown,\n TIntegrationBound extends boolean = false,\n> {\n before?(\n bundle: BundleLifecyclePayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n configure?(\n buildConfig: any,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<any>;\n after?(\n result: BundleResultPayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n}\n\nexport interface FarmPluginDevHooks<\n TState = unknown,\n TIntegrationInstance = unknown,\n TIntegrationBound extends boolean = false,\n> {\n server?(\n viteServer: ViteDevServer,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n update?(\n update: HMRUpdatePayload,\n context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>,\n ): MaybePromise<void>;\n}\n\nexport interface FarmPluginClientConfig<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientPlugin<TState, TPublic> {\n /** Explicitly public, JSON-safe data embedded in the browser bundle. */\n public?: TPublic;\n}\n\nexport interface FarmPlugin<\n TState = any,\n TRequestContext extends object = Record<string, unknown>,\n TClientState = any,\n TClientPublic = any,\n TIntegrationInstance = unknown,\n TIntegrationBound extends boolean = false,\n> {\n name: string;\n version?: string;\n enforce?: \"pre\" | \"post\";\n\n /** Transform Farm config before it is resolved. */\n configure?: (\n config: FarmConfig,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => MaybePromise<FarmConfig | void>;\n /** Initialize private plugin state once for this plugin manager. */\n setup?: (\n context: FarmPluginSetupContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => MaybePromise<TState>;\n\n runtime?: FarmPluginRuntimeHooks<\n TState,\n TRequestContext,\n TIntegrationInstance,\n TIntegrationBound\n >;\n router?: FarmPluginRouterHooks<TState, TIntegrationInstance, TIntegrationBound>;\n render?: FarmPluginRenderHooks<TState, TIntegrationInstance, TIntegrationBound>;\n build?: FarmPluginBuildHooks<TState, TIntegrationInstance, TIntegrationBound>;\n dev?: FarmPluginDevHooks<TState, TIntegrationInstance, TIntegrationBound>;\n /** Optional browser lifecycle for this logical plugin. */\n client?: FarmPluginClientConfig<TClientState, TClientPublic>;\n\n /** @internal Carries the expected integration instance type without runtime data. */\n readonly [FARM_PLUGIN_INTEGRATION_INSTANCE]?: (instance: TIntegrationInstance) => void;\n /** @internal Prevents integration-bound plugins from being registered globally. */\n readonly [FARM_PLUGIN_INTEGRATION_BOUND]?: TIntegrationBound;\n\n /** @deprecated Use `setup` instead. */\n init?: (\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `runtime.start` instead. */\n ready?: (\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `dev.server` instead. */\n devServerCreated?: (\n viteServer: ViteDevServer,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n\n /** @deprecated Use `configure` instead. */\n config?: (\n config: FarmConfig,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => FarmConfig | Promise<FarmConfig>;\n configResolved?: (\n config: FarmConfig,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `build.before` instead. */\n buildStart?: (\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `build.after` instead. */\n buildEnd?: (\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n\n /** @deprecated Use `router.discovered` instead. */\n routeDiscovered?: (\n route: RouteDiscoveredPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `router.generated` instead. */\n routesGenerated?: (\n routes: RoutesGeneratedPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `router.discovered` instead. */\n middlewareDiscovered?: (\n middleware: MiddlewareDiscoveredPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `router.discovered` instead. */\n apiRouteDiscovered?: (\n route: APIRouteDiscoveredPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `router.before` instead. */\n beforeRouteMatch?: (\n route: RouteMatchPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `router.after` instead. */\n afterRouteMatch?: (\n result: RouteMatchResultPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `render.before` instead. */\n beforeRender?: (\n render: RenderLifecyclePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `render.html` instead. */\n afterRender?: (\n html: string,\n render: RenderLifecyclePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => string | Promise<string> | void | Promise<void>;\n /** @deprecated Use `runtime.before` instead. */\n beforeApiHandler?: (\n request: Request,\n api: APIHandlerLifecyclePayload,\n context: FarmRequestPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => Request | Promise<Request> | void | Promise<void>;\n /** @deprecated Use `runtime.after` instead. */\n afterApiHandler?: (\n response: Response,\n api: APIHandlerLifecyclePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => Response | Promise<Response> | void | Promise<void>;\n onError?: (\n error: ErrorLifecyclePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `dev.update` instead. */\n hmrUpdate?: (\n update: HMRUpdatePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `build.before` instead. */\n beforeBundle?: (\n bundle: BundleLifecyclePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `build.after` instead. */\n afterBundle?: (\n result: BundleResultPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `build.configure` instead. */\n beforeNitroBuild?: (\n nitroConfig: any,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => any | Promise<any>;\n afterNitroBuild?: (\n payload: NitroBuildLifecyclePayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use `runtime.close` instead. */\n shutdown?: (\n payload: ShutdownPayload,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n\n /** @deprecated Use the Web Request based `runtime.before` hook instead. */\n beforeRequest?: (\n req: FarmRequest,\n res: FarmResponse,\n context: FarmRequestPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n /** @deprecated Use the Web Response based `runtime.after` hook instead. */\n afterResponse?: (\n req: FarmRequest,\n res: FarmResponse,\n context: FarmRequestPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => void | Promise<void>;\n\n // Transform hooks\n /** @deprecated Use `render.html` instead. */\n transformHTML?: (\n html: string,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => string | Promise<string>;\n /** @deprecated Use `render.before` or `render.html` instead. */\n transformPage?: (\n component: any,\n context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>,\n ) => any | Promise<any>;\n}\n\nexport class PluginManager {\n private plugins: FarmPlugin[] = [];\n private hookPresence = new Map<keyof FarmPlugin, boolean>();\n private runtimeHookPresence = new Map<\"context\" | \"before\" | \"after\" | \"error\", boolean>();\n private context: FarmPluginContext;\n private pluginStates = new Map<FarmPlugin, unknown>();\n private setupComplete = false;\n private initialized = false;\n private runtimeReady = false;\n private runtimeClosed = false;\n private runtimeStartPromise?: Promise<void>;\n private runtimeClosePromise?: Promise<void>;\n private runtimeShutdownHooksRunning = false;\n private runtimeDisposers: Array<() => void | Promise<void>> = [];\n private runtimeRequestContexts = new WeakMap<Request, Readonly<Record<string, unknown>>>();\n private failedRuntimeSessions = new WeakSet<FarmPluginRuntimeSession>();\n\n constructor(context: Omit<FarmPluginContext, \"requestContext\" | \"lifecycle\">) {\n this.context = {\n ...context,\n lifecycle: {\n onShutdown: (dispose) => {\n if (typeof dispose !== \"function\") {\n throw new TypeError(\"Farm lifecycle.onShutdown requires a cleanup function\");\n }\n if (this.runtimeClosePromise || this.runtimeClosed) {\n throw new Error(\"Farm runtime cleanup cannot be registered after shutdown begins\");\n }\n\n this.runtimeDisposers.push(dispose);\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n const index = this.runtimeDisposers.indexOf(dispose);\n if (index >= 0) this.runtimeDisposers.splice(index, 1);\n };\n },\n },\n requestContext: {\n set(target, key, value, options) {\n setRequestContext(target as object, key, value, options);\n },\n get(target, key) {\n return getRequestContext(target as object, key);\n },\n has(target, key) {\n return hasRequestContext(target as object, key);\n },\n delete(target, key) {\n return deleteRequestContext(target as object, key);\n },\n clear(target) {\n clearRequestContext(target as object);\n },\n getAll(target, options) {\n return getRequestContextSnapshot(target as object, options);\n },\n },\n };\n }\n\n private createPluginHookContext(\n plugin: FarmPlugin,\n context: FarmPluginContext = this.context,\n ): FarmPluginContext {\n const integration = getFarmPluginIntegrationContext(plugin);\n return integration ? { ...context, integration } : context;\n }\n\n private createRequestHookContext(\n target: FarmRequest | Request,\n plugin: FarmPlugin,\n ): FarmRequestPluginContext {\n const requestContext = this.context.requestContext;\n\n return {\n ...this.createPluginHookContext(plugin),\n req: {\n set(key, value, options) {\n requestContext.set(target, key, value, options);\n },\n get(key) {\n return requestContext.get(target, key);\n },\n has(key) {\n return requestContext.has(target, key);\n },\n delete(key) {\n return requestContext.delete(target, key);\n },\n clear() {\n requestContext.clear(target);\n },\n snapshot(options) {\n return requestContext.getAll(target, options);\n },\n },\n };\n }\n\n private copyRequestStore(source: FarmRequest | Request, target: FarmRequest | Request): void {\n const requestContext = this.context.requestContext;\n const values = requestContext.getAll(source);\n const exposed = requestContext.getAll(source, { exposedOnly: true });\n\n for (const [key, value] of values) {\n requestContext.set(target, key, value, {\n exposeToPage: exposed.has(key),\n });\n }\n }\n\n private copyRuntimeRequestContext(source: Request, target: Request): void {\n const runtimeContext = this.runtimeRequestContexts.get(source);\n if (runtimeContext) {\n this.runtimeRequestContexts.set(target, runtimeContext);\n }\n }\n\n private createRuntimeBaseEvent(\n plugin: FarmPlugin,\n request: Request,\n options: FarmPluginRuntimeRequestOptions,\n waitUntil: (promise: Promise<unknown>) => void,\n ): FarmPluginRuntimeBaseEvent {\n return {\n ...this.createStateHookContext(plugin),\n request,\n req: this.createRequestHookContext(request, plugin).req,\n kind: options.kind ?? \"request\",\n route: options.route,\n signal: request.signal,\n waitUntil,\n };\n }\n\n private async createRuntimeRequestContext(\n request: Request,\n options: FarmPluginRuntimeRequestOptions,\n waitUntil: (promise: Promise<unknown>) => void,\n ): Promise<Readonly<Record<string, unknown>>> {\n const values: Record<string, unknown> = {};\n const owners = new Map<string, string>();\n\n for (const plugin of this.getSortedPlugins()) {\n const createContext = plugin.runtime?.context;\n if (!createContext) continue;\n\n const result = await createContext(\n this.createRuntimeBaseEvent(plugin, request, options, waitUntil),\n );\n if (result === undefined) continue;\n if (!result || typeof result !== \"object\" || Array.isArray(result)) {\n throw new TypeError(`Farm plugin \"${plugin.name}\" runtime.context must return an object`);\n }\n\n for (const [key, value] of Object.entries(result)) {\n const owner = owners.get(key);\n if (owner) {\n throw new Error(\n `Farm plugin context key \"${key}\" from \"${plugin.name}\" conflicts with \"${owner}\"`,\n );\n }\n owners.set(key, plugin.name);\n values[key] = value;\n }\n }\n\n const runtimeContext = Object.freeze(values);\n this.runtimeRequestContexts.set(request, runtimeContext);\n return runtimeContext;\n }\n\n private async runRuntimeErrorHooks(\n request: Request,\n error: unknown,\n ctx: Readonly<Record<string, unknown>>,\n durationMs: number,\n options: FarmPluginRuntimeRequestOptions,\n waitUntil: (promise: Promise<unknown>) => void,\n ): Promise<void> {\n for (const plugin of this.getSortedPlugins()) {\n const onError = plugin.runtime?.error;\n if (!onError) continue;\n\n try {\n await onError({\n ...this.createRuntimeBaseEvent(plugin, request, options, waitUntil),\n ctx,\n error,\n durationMs,\n });\n } catch (hookError) {\n console.error(`Farm plugin \"${plugin.name}\" runtime.error failed:`, hookError);\n }\n }\n\n try {\n await this.runHookParallel(\"onError\", {\n phase: \"runtime\",\n error,\n meta: {\n kind: options.kind ?? \"request\",\n pathname: new URL(request.url).pathname,\n durationMs,\n },\n });\n } catch (hookError) {\n console.error(\"Farm plugin onError hook failed:\", hookError);\n }\n }\n\n private createStateHookContext(\n plugin: FarmPlugin,\n context: FarmPluginContext = this.context,\n ): FarmPluginStateContext {\n return {\n ...this.createPluginHookContext(plugin, context),\n state: this.pluginStates.get(plugin),\n };\n }\n\n private getPluginHooks(\n plugin: FarmPlugin,\n hookName: keyof FarmPlugin,\n ): Array<(...args: any[]) => any> {\n const hooks: Array<(...args: any[]) => any> = [];\n const legacyHook = plugin[hookName];\n if (typeof legacyHook === \"function\") {\n hooks.push(legacyHook);\n }\n\n const withState = (context: FarmPluginContext) => this.createStateHookContext(plugin, context);\n\n switch (hookName) {\n case \"config\":\n if (plugin.configure) {\n hooks.push((config: FarmConfig, context: FarmPluginContext) =>\n plugin.configure?.(config, context),\n );\n }\n break;\n case \"ready\":\n if (plugin.runtime?.start) {\n hooks.push((context: FarmPluginContext) => plugin.runtime?.start?.(withState(context)));\n }\n break;\n case \"shutdown\":\n if (plugin.runtime?.close) {\n hooks.push((payload: ShutdownPayload, context: FarmPluginContext) =>\n plugin.runtime?.close?.({\n ...withState(context),\n reason: payload.reason,\n }),\n );\n }\n break;\n case \"routeDiscovered\":\n if (plugin.router?.discovered) {\n hooks.push((route: RouteDiscoveredPayload, context: FarmPluginContext) =>\n plugin.router?.discovered?.(route, withState(context)),\n );\n }\n break;\n case \"middlewareDiscovered\":\n if (plugin.router?.discovered) {\n hooks.push((route: MiddlewareDiscoveredPayload, context: FarmPluginContext) =>\n plugin.router?.discovered?.({ kind: \"middleware\", ...route }, withState(context)),\n );\n }\n break;\n case \"apiRouteDiscovered\":\n if (plugin.router?.discovered) {\n hooks.push((route: APIRouteDiscoveredPayload, context: FarmPluginContext) =>\n plugin.router?.discovered?.({ kind: \"api\", ...route }, withState(context)),\n );\n }\n break;\n case \"routesGenerated\":\n if (plugin.router?.generated) {\n hooks.push((routes: RoutesGeneratedPayload, context: FarmPluginContext) =>\n plugin.router?.generated?.(routes, withState(context)),\n );\n }\n break;\n case \"beforeRouteMatch\":\n if (plugin.router?.before) {\n hooks.push((route: RouteMatchPayload, context: FarmPluginContext) =>\n plugin.router?.before?.(route, withState(context)),\n );\n }\n break;\n case \"afterRouteMatch\":\n if (plugin.router?.after) {\n hooks.push((result: RouteMatchResultPayload, context: FarmPluginContext) =>\n plugin.router?.after?.(result, withState(context)),\n );\n }\n break;\n case \"beforeRender\":\n if (plugin.render?.before) {\n hooks.push((render: RenderLifecyclePayload, context: FarmPluginContext) =>\n plugin.render?.before?.(render, withState(context)),\n );\n }\n break;\n case \"afterRender\":\n if (plugin.render?.html) {\n hooks.push((html: string, render: RenderLifecyclePayload, context: FarmPluginContext) =>\n plugin.render?.html?.(html, render, withState(context)),\n );\n }\n break;\n case \"beforeBundle\":\n if (plugin.build?.before) {\n hooks.push((bundle: BundleLifecyclePayload, context: FarmPluginContext) =>\n plugin.build?.before?.(bundle, withState(context)),\n );\n }\n break;\n case \"beforeNitroBuild\":\n if (plugin.build?.configure) {\n hooks.push((buildConfig: any, context: FarmPluginContext) =>\n plugin.build?.configure?.(buildConfig, withState(context)),\n );\n }\n break;\n case \"afterBundle\":\n if (plugin.build?.after) {\n hooks.push((result: BundleResultPayload, context: FarmPluginContext) =>\n plugin.build?.after?.(result, withState(context)),\n );\n }\n break;\n case \"devServerCreated\":\n if (plugin.dev?.server) {\n hooks.push((server: ViteDevServer, context: FarmPluginContext) =>\n plugin.dev?.server?.(server, withState(context)),\n );\n }\n break;\n case \"hmrUpdate\":\n if (plugin.dev?.update) {\n hooks.push((update: HMRUpdatePayload, context: FarmPluginContext) =>\n plugin.dev?.update?.(update, withState(context)),\n );\n }\n break;\n }\n\n return hooks;\n }\n\n private getHookContext(\n plugin: FarmPlugin,\n hookName: keyof FarmPlugin,\n args: any[],\n ): FarmPluginContext {\n if (\n hookName === \"beforeRequest\" ||\n hookName === \"afterResponse\" ||\n hookName === \"beforeApiHandler\"\n ) {\n const target = args[0];\n if (target && typeof target === \"object\") {\n return this.createRequestHookContext(target, plugin);\n }\n }\n\n return this.createPluginHookContext(plugin);\n }\n\n addPlugin(plugin: FarmPlugin) {\n this.plugins.push(plugin);\n this.hookPresence.clear();\n this.runtimeHookPresence.clear();\n }\n\n addPlugins(plugins: FarmPlugin[]) {\n for (const plugin of plugins) {\n this.addPlugin(plugin);\n }\n }\n\n getPlugins(): FarmPlugin[] {\n return [...this.plugins];\n }\n\n getSortedPlugins(): FarmPlugin[] {\n const pre = this.plugins.filter((p) => p.enforce === \"pre\");\n const normal = this.plugins.filter((p) => !p.enforce);\n const post = this.plugins.filter((p) => p.enforce === \"post\");\n return [...pre, ...normal, ...post];\n }\n\n hasHook(hookName: keyof FarmPlugin): boolean {\n const cached = this.hookPresence.get(hookName);\n if (cached !== undefined) return cached;\n\n const present = this.plugins.some((plugin) => this.getPluginHooks(plugin, hookName).length > 0);\n this.hookPresence.set(hookName, present);\n return present;\n }\n\n hasRuntimeHook(hookName: \"context\" | \"before\" | \"after\" | \"error\"): boolean {\n const cached = this.runtimeHookPresence.get(hookName);\n if (cached !== undefined) return cached;\n\n const present = this.plugins.some((plugin) => typeof plugin.runtime?.[hookName] === \"function\");\n this.runtimeHookPresence.set(hookName, present);\n return present;\n }\n\n hasRuntimeRequestHooks(): boolean {\n return (\n this.hasRuntimeHook(\"context\") ||\n this.hasRuntimeHook(\"before\") ||\n this.hasRuntimeHook(\"after\") ||\n this.hasRuntimeHook(\"error\")\n );\n }\n\n copyRequestContext(source: FarmRequest | Request, target: FarmRequest | Request): void {\n this.copyRequestStore(source, target);\n if (source instanceof Request && target instanceof Request) {\n this.copyRuntimeRequestContext(source, target);\n }\n }\n\n async setupPlugins(): Promise<void> {\n if (this.setupComplete) return;\n\n for (const plugin of this.getSortedPlugins()) {\n if (!plugin.setup) continue;\n const state = await plugin.setup({\n ...this.createPluginHookContext(plugin),\n env: getResolvedEnv(),\n });\n this.pluginStates.set(plugin, state);\n }\n\n this.setupComplete = true;\n }\n\n async startRuntime(): Promise<void> {\n if (this.runtimeReady) return;\n if (this.runtimeStartPromise) return this.runtimeStartPromise;\n\n this.runtimeStartPromise = (async () => {\n if (!this.initialized) {\n await this.runHookParallel(\"init\");\n }\n await this.setupPlugins();\n if (!this.runtimeReady) {\n await this.runHookParallel(\"ready\");\n }\n })();\n\n try {\n await this.runtimeStartPromise;\n } catch (error) {\n this.runtimeStartPromise = undefined;\n throw error;\n }\n }\n\n async closeRuntime(reason = \"runtime-closed\"): Promise<void> {\n if (this.runtimeClosePromise) return this.runtimeClosePromise;\n if (this.runtimeClosed) return;\n\n this.runtimeClosePromise = (async () => {\n const errors: unknown[] = [];\n this.runtimeShutdownHooksRunning = true;\n try {\n await this.runHookParallel(\"shutdown\", { reason });\n } catch (error) {\n if (error instanceof FarmRuntimeShutdownError) errors.push(...error.errors);\n else errors.push(error);\n } finally {\n this.runtimeShutdownHooksRunning = false;\n }\n\n const disposers = this.runtimeDisposers.splice(0).reverse();\n for (const dispose of disposers) {\n try {\n await dispose();\n } catch (error) {\n errors.push(error);\n }\n }\n\n this.runtimeClosed = true;\n if (errors.length > 0) {\n throw new FarmRuntimeShutdownError(\"Farm runtime shutdown failed\", errors);\n }\n })();\n return this.runtimeClosePromise;\n }\n\n async beginRuntimeRequest(\n request: Request,\n options: FarmPluginRuntimeRequestOptions = {},\n ): Promise<FarmPluginRuntimeSession> {\n await this.startRuntime();\n\n const startedAt = Date.now();\n const waitUntil = options.waitUntil\n ? (promise: Promise<unknown>) => options.waitUntil?.(Promise.resolve(promise))\n : (promise: Promise<unknown>) => {\n void Promise.resolve(promise).catch(() => {});\n };\n let activeRequest = request;\n let runtimeContext: Readonly<Record<string, unknown>> = Object.freeze({});\n\n try {\n runtimeContext = await this.createRuntimeRequestContext(activeRequest, options, waitUntil);\n\n let response: Response | undefined;\n for (const plugin of this.getSortedPlugins()) {\n const before = plugin.runtime?.before;\n if (!before) continue;\n\n const result = await before({\n ...this.createRuntimeBaseEvent(plugin, activeRequest, options, waitUntil),\n ctx: runtimeContext,\n });\n\n if (result instanceof Request) {\n this.copyRequestStore(activeRequest, result);\n this.copyRuntimeRequestContext(activeRequest, result);\n activeRequest = result;\n continue;\n }\n if (result instanceof Response) {\n response = result;\n break;\n }\n if (result !== undefined) {\n throw new TypeError(\n `Farm plugin \"${plugin.name}\" runtime.before must return a Request, Response, or undefined`,\n );\n }\n }\n\n return {\n request: activeRequest,\n response,\n ctx: runtimeContext,\n startedAt,\n options,\n waitUntil,\n };\n } catch (error) {\n await this.runRuntimeErrorHooks(\n activeRequest,\n error,\n runtimeContext,\n Date.now() - startedAt,\n options,\n waitUntil,\n );\n throw error;\n }\n }\n\n async endRuntimeRequest(\n session: FarmPluginRuntimeSession,\n initialResponse: Response,\n ): Promise<Response> {\n let response = initialResponse;\n\n try {\n for (const plugin of this.getSortedPlugins()) {\n const after = plugin.runtime?.after;\n if (!after) continue;\n\n const result = await after({\n ...this.createRuntimeBaseEvent(\n plugin,\n session.request,\n session.options,\n session.waitUntil,\n ),\n ctx: session.ctx,\n response,\n durationMs: Date.now() - session.startedAt,\n });\n if (result !== undefined) {\n if (!(result instanceof Response)) {\n throw new TypeError(\n `Farm plugin \"${plugin.name}\" runtime.after must return a Response or undefined`,\n );\n }\n response = result;\n }\n }\n\n return response;\n } catch (error) {\n await this.failRuntimeRequest(session, error);\n throw error;\n }\n }\n\n async failRuntimeRequest(session: FarmPluginRuntimeSession, error: unknown): Promise<void> {\n if (this.failedRuntimeSessions.has(session)) return;\n this.failedRuntimeSessions.add(session);\n await this.runRuntimeErrorHooks(\n session.request,\n error,\n session.ctx,\n Date.now() - session.startedAt,\n session.options,\n session.waitUntil,\n );\n }\n\n async runRuntimeRequest(\n request: Request,\n handler: FarmPluginRuntimeRequestHandler,\n options: FarmPluginRuntimeRequestOptions = {},\n ): Promise<Response> {\n const session = await this.beginRuntimeRequest(request, options);\n try {\n const response = session.response ?? (await handler(session.request));\n if (!(response instanceof Response)) {\n throw new TypeError(\"Farm plugin runtime handlers must return a Response\");\n }\n return await this.endRuntimeRequest(session, response);\n } catch (error) {\n await this.failRuntimeRequest(session, error);\n throw error;\n }\n }\n\n async runHook<K extends keyof FarmPlugin>(hookName: K, ...args: any[]): Promise<any> {\n const plugins = this.getSortedPlugins();\n\n for (const plugin of plugins) {\n for (const hook of this.getPluginHooks(plugin, hookName)) {\n const hookContext = this.getHookContext(plugin, hookName, args);\n const result = await (hook as any).apply(plugin, [...args, hookContext]);\n if (result !== undefined) {\n return result;\n }\n }\n }\n }\n\n async runHookSerial<K extends keyof FarmPlugin>(\n hookName: K,\n initialValue: any,\n ...args: any[]\n ): Promise<any> {\n const plugins = this.getSortedPlugins();\n let value = initialValue;\n\n for (const plugin of plugins) {\n for (const hook of this.getPluginHooks(plugin, hookName)) {\n const hookArgs = [value, ...args];\n const hookContext = this.getHookContext(plugin, hookName, hookArgs);\n const result = await (hook as any).apply(plugin, [...hookArgs, hookContext]);\n if (result !== undefined) {\n if (\n hookName === \"beforeApiHandler\" &&\n result !== value &&\n value &&\n result &&\n typeof value === \"object\" &&\n typeof result === \"object\"\n ) {\n this.copyRequestStore(value as FarmRequest | Request, result as FarmRequest | Request);\n }\n value = result;\n }\n }\n }\n\n return value;\n }\n\n async runHookParallel<K extends keyof FarmPlugin>(hookName: K, ...args: any[]): Promise<boolean> {\n return this.runHookParallelFiltered(hookName, () => true, ...args);\n }\n\n /** @internal Runs hooks for only the plugins selected by the runtime adapter. */\n async runHookParallelFiltered<K extends keyof FarmPlugin>(\n hookName: K,\n include: (plugin: FarmPlugin) => boolean,\n ...args: any[]\n ): Promise<boolean> {\n if (hookName === \"shutdown\" && !this.runtimeShutdownHooksRunning) {\n await this.closeRuntime(args[0]?.reason);\n return false;\n }\n\n const plugins = this.getSortedPlugins().filter(include);\n\n // Run selected hooks sequentially for deterministic execution and short-circuiting.\n const sequentialHooks = new Set<keyof FarmPlugin>([\n \"ready\",\n \"shutdown\",\n \"beforeRequest\",\n \"afterResponse\",\n \"beforeApiHandler\",\n \"afterApiHandler\",\n \"beforeRouteMatch\",\n \"afterRouteMatch\",\n \"beforeRender\",\n \"afterRender\",\n ]);\n\n if (sequentialHooks.has(hookName)) {\n const shutdownErrors: unknown[] = [];\n for (const plugin of plugins) {\n for (const hook of this.getPluginHooks(plugin, hookName)) {\n // Check if response is already sent (only for beforeRequest)\n if (hookName === \"beforeRequest\") {\n const res = args[1];\n if (res && res.writableEnded) {\n return true;\n }\n }\n\n const hookContext = this.getHookContext(plugin, hookName, args);\n try {\n await (hook as any).apply(plugin, [...args, hookContext]);\n } catch (error) {\n if (hookName !== \"shutdown\") throw error;\n shutdownErrors.push(error);\n }\n\n // Check again after plugin execution (only for beforeRequest)\n if (hookName === \"beforeRequest\") {\n const res = args[1];\n if (res && res.writableEnded) {\n return true;\n }\n }\n }\n }\n if (hookName === \"shutdown\" && shutdownErrors.length > 0) {\n throw new FarmRuntimeShutdownError(\"Farm plugin shutdown hooks failed\", shutdownErrors);\n }\n } else {\n // Run other hooks in parallel\n const promises: Promise<any>[] = [];\n for (const plugin of plugins) {\n for (const hook of this.getPluginHooks(plugin, hookName)) {\n const hookContext = this.getHookContext(plugin, hookName, args);\n promises.push((hook as any).apply(plugin, [...args, hookContext]));\n }\n }\n await Promise.all(promises);\n }\n\n if (hookName === \"init\") this.initialized = true;\n if (hookName === \"ready\") this.runtimeReady = true;\n\n return false;\n }\n\n updateContext(updates: Partial<FarmPluginContext>) {\n this.context = {\n ...this.context,\n ...updates,\n requestContext: this.context.requestContext,\n };\n }\n}\n\nexport function definePlugin<\n TState = undefined,\n TRequestContext extends object = Record<string, never>,\n TClientState = unknown,\n TClientPublic = undefined,\n TIntegrationInstance = unknown,\n>(\n plugin: FarmPlugin<\n TState,\n TRequestContext,\n TClientState,\n TClientPublic,\n TIntegrationInstance,\n false\n >,\n): FarmPlugin<TState, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, false> {\n return plugin;\n}\n\nexport namespace definePlugin {\n /** Bind an integration instance type while preserving inference for plugin state and context. */\n export function forIntegration<TIntegrationInstance>() {\n return function defineBoundPlugin<\n TState = undefined,\n TRequestContext extends object = Record<string, never>,\n TClientState = unknown,\n TClientPublic = undefined,\n >(\n plugin: FarmPlugin<\n TState,\n TRequestContext,\n TClientState,\n TClientPublic,\n TIntegrationInstance,\n true\n >,\n ): FarmPlugin<\n TState,\n TRequestContext,\n TClientState,\n TClientPublic,\n TIntegrationInstance,\n true\n > {\n return plugin;\n };\n }\n}\nexport { farmPlugin } from \"./vite\";\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BO,IAAM,4BAAN,MAAM,kCAAiC,MAAM;AAAA,EAGlD,YAAY,SAAiB,QAA4B;AACvD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AARoD;AAA7C,IAAM,2BAAN;AA0mBA,IAAM,iBAAN,MAAM,eAAc;AAAA,EAiBzB,YAAY,SAAkE;AAhB9E,SAAQ,UAAwB,CAAC;AACjC,SAAQ,eAAe,oBAAI,IAA+B;AAC1D,SAAQ,sBAAsB,oBAAI,IAAuD;AAEzF,SAAQ,eAAe,oBAAI,IAAyB;AACpD,SAAQ,gBAAgB;AACxB,SAAQ,cAAc;AACtB,SAAQ,eAAe;AACvB,SAAQ,gBAAgB;AAGxB,SAAQ,8BAA8B;AACtC,SAAQ,mBAAsD,CAAC;AAC/D,SAAQ,yBAAyB,oBAAI,QAAoD;AACzF,SAAQ,wBAAwB,oBA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K,CAAC;AAClB,gBAAI,OAAO,IAAI,eAAe;AAC5B,qBAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,UAAI,aAAa,cAAc,eAAe,SAAS,GAAG;AACxD,cAAM,IAAI,yBAAyB,qCAAqC,cAAc;AAAA,MACxF;AAAA,IACF,OAAO;AAEL,YAAM,WAA2B,CAAC;AAClC,iBAAW,UAAU,SAAS;AAC5B,mBAAW,QAAQ,KAAK,eAAe,QAAQ,QAAQ,GAAG;AACxD,gBAAM,cAAc,KAAK,eAAe,QAAQ,UAAU,IAAI;AAC9D,mBAAS,KAAM,KAAa,MAAM,QAAQ,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC;AAAA,QACnE;AAAA,MACF;AACA,YAAM,QAAQ,IAAI,QAAQ;AAAA,IAC5B;AAEA,QAAI,aAAa,OAAQ,MAAK,cAAc;AAC5C,QAAI,aAAa,QAAS,MAAK,eAAe;AAE9C,WAAO;AAAA,EACT;AAAA,EAEA,cAAc,SAAqC;AACjD,SAAK,UAAU;AAAA,MACb,GAAG,KAAK;AAAA,MACR,GAAG;AAAA,MACH,gBAAgB,KAAK,QAAQ;AAAA,IAC/B;AAAA,EACF;AACF;AAlwB2B;AAApB,IAAM,gBAAN;AAowBA,SAAS,aAOd,QAQ+F;AAC/F,SAAO;AACT;AAjBgB;AAAA,CAmBT,CAAUA,kBAAV;AAEE,WAAS,iBAAuC;AACrD,WAAO,gCAAS,kBAMd,QAeA;AACA,aAAO;AAAA,IACT,GAvBO;AAAA,EAwBT;AAzBO,EAAAA,cAAS;AAAA;AAAA,GAFD;","names":["definePlugin"]}
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
} from "./chunk-GXASWWJU.mjs";
|
|
44
44
|
import {
|
|
45
45
|
resolveIntegrationPlugins
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-CRN3AH35.mjs";
|
|
47
47
|
import {
|
|
48
48
|
resolveFarmI18nConfig
|
|
49
49
|
} from "./chunk-FQYDHKKU.mjs";
|
|
@@ -497,4 +497,4 @@ export {
|
|
|
497
497
|
resolveConfig,
|
|
498
498
|
loadConfig
|
|
499
499
|
};
|
|
500
|
-
//# sourceMappingURL=chunk-
|
|
500
|
+
//# sourceMappingURL=chunk-CEVMYGDL.mjs.map
|