@farm.js/core 0.1.0-beta.21 → 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.
Files changed (210) hide show
  1. package/dist/after.d.mts +25 -0
  2. package/dist/after.d.ts +25 -0
  3. package/dist/agent-runtime.d.mts +96 -0
  4. package/dist/agent-runtime.d.ts +96 -0
  5. package/dist/api/route-manager.d.mts +68 -0
  6. package/dist/api/route-manager.d.ts +68 -0
  7. package/dist/api/runtime.d.mts +3 -0
  8. package/dist/api/runtime.d.ts +3 -0
  9. package/dist/api.cjs +22 -19
  10. package/dist/api.cjs.map +1 -1
  11. package/dist/api.d.mts +50 -0
  12. package/dist/api.d.ts +50 -0
  13. package/dist/api.mjs +2 -1
  14. package/dist/app-BB8GCH1g.d.ts +306 -0
  15. package/dist/app-DwsTpyNZ.d.mts +306 -0
  16. package/dist/app-markdown.d.mts +24 -0
  17. package/dist/app-markdown.d.ts +24 -0
  18. package/dist/cache.d.mts +192 -0
  19. package/dist/cache.d.ts +192 -0
  20. package/dist/{chunk-MIUW47JX.mjs → chunk-2PEJGY5V.mjs} +15 -20
  21. package/dist/chunk-2PEJGY5V.mjs.map +1 -0
  22. package/dist/{chunk-RIXKJPGI.mjs → chunk-42325TLU.mjs} +2 -2
  23. package/dist/{chunk-I3UWA2P2.mjs → chunk-DAUR3WUZ.mjs} +2 -2
  24. package/dist/{chunk-I3UWA2P2.mjs.map → chunk-DAUR3WUZ.mjs.map} +1 -1
  25. package/dist/chunk-GIELMNBG.mjs +15 -0
  26. package/dist/chunk-GIELMNBG.mjs.map +1 -0
  27. package/dist/{chunk-4EATUJFO.mjs → chunk-ICTGDDV4.mjs} +20 -22
  28. package/dist/chunk-ICTGDDV4.mjs.map +1 -0
  29. package/dist/{chunk-FKKM7HVF.mjs → chunk-XBKXKJX5.mjs} +30 -35
  30. package/dist/chunk-XBKXKJX5.mjs.map +1 -0
  31. package/dist/{chunk-VIC7NJ77.mjs → chunk-ZP73P4VR.mjs} +2 -2
  32. package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
  33. package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
  34. package/dist/client-BT1mFQas.d.mts +447 -0
  35. package/dist/client-Nn0q4eO4.d.ts +447 -0
  36. package/dist/client-cache-CIlyBlmx.d.ts +6 -0
  37. package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
  38. package/dist/client-plugins-CbRum1fj.d.ts +2088 -0
  39. package/dist/client-plugins-QQntVkrv.d.mts +2088 -0
  40. package/dist/client-plugins.d.mts +24 -0
  41. package/dist/client-plugins.d.ts +24 -0
  42. package/dist/client.d.mts +452 -0
  43. package/dist/client.d.ts +452 -0
  44. package/dist/config.d.mts +31 -0
  45. package/dist/config.d.ts +31 -0
  46. package/dist/cron.d.mts +78 -0
  47. package/dist/cron.d.ts +78 -0
  48. package/dist/deferred.d.mts +42 -0
  49. package/dist/deferred.d.ts +42 -0
  50. package/dist/deployment.d.mts +36 -0
  51. package/dist/deployment.d.ts +36 -0
  52. package/dist/docs.d.mts +80 -0
  53. package/dist/docs.d.ts +80 -0
  54. package/dist/env-types.d.mts +12 -0
  55. package/dist/env-types.d.ts +12 -0
  56. package/dist/env.d.mts +45 -0
  57. package/dist/env.d.ts +45 -0
  58. package/dist/environment/vite.d.mts +22 -0
  59. package/dist/environment/vite.d.ts +22 -0
  60. package/dist/environment.d.mts +18 -0
  61. package/dist/environment.d.ts +18 -0
  62. package/dist/font.d.mts +95 -0
  63. package/dist/font.d.ts +95 -0
  64. package/dist/headers.d.mts +22 -0
  65. package/dist/headers.d.ts +22 -0
  66. package/dist/i18n/client.d.mts +32 -0
  67. package/dist/i18n/client.d.ts +32 -0
  68. package/dist/i18n/index.d.mts +20 -0
  69. package/dist/i18n/index.d.ts +20 -0
  70. package/dist/i18n/server.d.mts +30 -0
  71. package/dist/i18n/server.d.ts +30 -0
  72. package/dist/image/server.d.mts +37 -0
  73. package/dist/image/server.d.ts +37 -0
  74. package/dist/image/sharp.d.mts +7 -0
  75. package/dist/image/sharp.d.ts +7 -0
  76. package/dist/image-config-Duob7wER.d.mts +50 -0
  77. package/dist/image-config-Duob7wER.d.ts +50 -0
  78. package/dist/image.d.mts +39 -0
  79. package/dist/image.d.ts +39 -0
  80. package/dist/index.cjs +66 -69
  81. package/dist/index.cjs.map +1 -1
  82. package/dist/index.d.mts +477 -0
  83. package/dist/index.d.ts +477 -0
  84. package/dist/index.mjs +7 -6
  85. package/dist/index.mjs.map +1 -1
  86. package/dist/integration-api-CHT2OKAf.d.mts +93 -0
  87. package/dist/integration-api-CHT2OKAf.d.ts +93 -0
  88. package/dist/integrations.d.mts +24 -0
  89. package/dist/integrations.d.ts +24 -0
  90. package/dist/internal/build-runtime.cjs +50 -50
  91. package/dist/internal/build-runtime.cjs.map +1 -1
  92. package/dist/internal/build-runtime.d.mts +41 -0
  93. package/dist/internal/build-runtime.d.ts +41 -0
  94. package/dist/internal/build-runtime.mjs +5 -4
  95. package/dist/internal/client-runtime.d.mts +17 -0
  96. package/dist/internal/client-runtime.d.ts +17 -0
  97. package/dist/internal/config-runtime.d.mts +41 -0
  98. package/dist/internal/config-runtime.d.ts +41 -0
  99. package/dist/internal/metadata-image-runtime.d.mts +25 -0
  100. package/dist/internal/metadata-image-runtime.d.ts +25 -0
  101. package/dist/internal/production-node-env.d.mts +12 -0
  102. package/dist/internal/production-node-env.d.ts +12 -0
  103. package/dist/internal/production-runtime.d.mts +66 -0
  104. package/dist/internal/production-runtime.d.ts +66 -0
  105. package/dist/island-CfGru1MO.d.mts +9 -0
  106. package/dist/island-CfGru1MO.d.ts +9 -0
  107. package/dist/markdown.d.mts +60 -0
  108. package/dist/markdown.d.ts +60 -0
  109. package/dist/metadata-B5jBJHq1.d.ts +22 -0
  110. package/dist/metadata-BxOJ4FJl.d.mts +22 -0
  111. package/dist/middleware.cjs +17 -17
  112. package/dist/middleware.cjs.map +1 -1
  113. package/dist/middleware.d.mts +171 -0
  114. package/dist/middleware.d.ts +171 -0
  115. package/dist/middleware.mjs +3 -2
  116. package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
  117. package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
  118. package/dist/navigation.d.mts +14 -0
  119. package/dist/navigation.d.ts +14 -0
  120. package/dist/observability.d.mts +335 -0
  121. package/dist/observability.d.ts +335 -0
  122. package/dist/params-BALtrRim.d.ts +15 -0
  123. package/dist/params-ry-lxqmy.d.mts +15 -0
  124. package/dist/plugin-BJDf43dc.d.mts +165 -0
  125. package/dist/plugin-BJDf43dc.d.ts +165 -0
  126. package/dist/plugin.cjs +42 -48
  127. package/dist/plugin.cjs.map +1 -1
  128. package/dist/plugin.d.mts +24 -0
  129. package/dist/plugin.d.ts +24 -0
  130. package/dist/plugin.mjs +4 -3
  131. package/dist/production-runtime-Bxua86uR.d.mts +81 -0
  132. package/dist/production-runtime-CZqXjRVi.d.ts +81 -0
  133. package/dist/query/client.d.mts +61 -0
  134. package/dist/query/client.d.ts +61 -0
  135. package/dist/query/index.d.mts +90 -0
  136. package/dist/query/index.d.ts +90 -0
  137. package/dist/query/parsers.d.mts +25 -0
  138. package/dist/query/parsers.d.ts +25 -0
  139. package/dist/query/server.d.mts +55 -0
  140. package/dist/query/server.d.ts +55 -0
  141. package/dist/request-7V0GaZK_.d.mts +6 -0
  142. package/dist/request-B5XYBv5a.d.ts +6 -0
  143. package/dist/request.d.mts +25 -0
  144. package/dist/request.d.ts +25 -0
  145. package/dist/resolver-DJqjLMg_.d.mts +14 -0
  146. package/dist/resolver-IH4RmPEl.d.ts +14 -0
  147. package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
  148. package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
  149. package/dist/router.d.mts +36 -0
  150. package/dist/router.d.ts +36 -0
  151. package/dist/routes.d.mts +226 -0
  152. package/dist/routes.d.ts +226 -0
  153. package/dist/runtime-Bpp-c28k.d.ts +231 -0
  154. package/dist/runtime-Cxpq6xZN.d.mts +27 -0
  155. package/dist/runtime-Q3u74Nbq.d.mts +231 -0
  156. package/dist/runtime-bv63eUiO.d.ts +27 -0
  157. package/dist/server-action-security.d.mts +45 -0
  158. package/dist/server-action-security.d.ts +45 -0
  159. package/dist/server-fn-client.d.mts +33 -0
  160. package/dist/server-fn-client.d.ts +33 -0
  161. package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
  162. package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
  163. package/dist/server-fn.d.mts +121 -0
  164. package/dist/server-fn.d.ts +121 -0
  165. package/dist/server-plugins.d.mts +57 -0
  166. package/dist/server-plugins.d.ts +57 -0
  167. package/dist/server-query-client.d.mts +51 -0
  168. package/dist/server-query-client.d.ts +51 -0
  169. package/dist/server-query.d.mts +37 -0
  170. package/dist/server-query.d.ts +37 -0
  171. package/dist/server.cjs +45 -67
  172. package/dist/server.cjs.map +1 -1
  173. package/dist/server.d.mts +51 -0
  174. package/dist/server.d.ts +51 -0
  175. package/dist/server.mjs +8 -22
  176. package/dist/server.mjs.map +1 -1
  177. package/dist/storage.d.mts +52 -0
  178. package/dist/storage.d.ts +52 -0
  179. package/dist/testing.d.mts +103 -0
  180. package/dist/testing.d.ts +103 -0
  181. package/dist/transport-BmbGTXA5.d.mts +49 -0
  182. package/dist/transport-BmbGTXA5.d.ts +49 -0
  183. package/dist/types-BMxWr97v.d.mts +81 -0
  184. package/dist/types-BMxWr97v.d.ts +81 -0
  185. package/dist/types-D1A6-XvH.d.mts +73 -0
  186. package/dist/types-D1A6-XvH.d.ts +73 -0
  187. package/dist/types-DTzm4TCl.d.mts +78 -0
  188. package/dist/types-DTzm4TCl.d.ts +78 -0
  189. package/dist/utils-s9pN0Yep.d.mts +23 -0
  190. package/dist/utils-xTFxzu47.d.ts +23 -0
  191. package/dist/version.cjs +1 -1
  192. package/dist/version.cjs.map +1 -1
  193. package/dist/version.d.mts +3 -0
  194. package/dist/version.d.ts +3 -0
  195. package/dist/version.mjs +1 -1
  196. package/dist/vite.cjs +44 -50
  197. package/dist/vite.cjs.map +1 -1
  198. package/dist/vite.d.mts +24 -0
  199. package/dist/vite.d.ts +24 -0
  200. package/dist/vite.mjs +4 -3
  201. package/dist/workflows-CusFV6mn.d.mts +153 -0
  202. package/dist/workflows-CusFV6mn.d.ts +153 -0
  203. package/dist/workflows.d.mts +1 -0
  204. package/dist/workflows.d.ts +1 -0
  205. package/package.json +1 -1
  206. package/dist/chunk-4EATUJFO.mjs.map +0 -1
  207. package/dist/chunk-FKKM7HVF.mjs.map +0 -1
  208. package/dist/chunk-MIUW47JX.mjs.map +0 -1
  209. /package/dist/{chunk-RIXKJPGI.mjs.map → chunk-42325TLU.mjs.map} +0 -0
  210. /package/dist/{chunk-VIC7NJ77.mjs.map → chunk-ZP73P4VR.mjs.map} +0 -0
@@ -0,0 +1,171 @@
1
+ import { cU as MiddlewareChain, cZ as RateLimitStorage, c_ as RateLimitStatus, c$ as MemoryRateLimitStorageOptions, cP as MiddlewareContext, a2 as FarmMiddlewareConfig, cQ as MiddlewareFunction, dx as MiddlewareConfig, M as MiddlewareProps } from './client-plugins-QQntVkrv.mjs';
2
+ export { cV as CookieJar, cW as CookieOptions, d1 as MiddlewareResult, cT as MiddlewareStore, d0 as NextFunction, cX as RateLimitConfig, cY as RateLimitIncrementResult, a1 as ReadonlyMiddlewareStore, cR as RequestMiddleware, cS as RequestMiddlewareContext } from './client-plugins-QQntVkrv.mjs';
3
+ import { IncomingMessage, ServerResponse } from 'http';
4
+ import { ViteDevServer, Plugin } from 'vite';
5
+ import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.mjs';
6
+ export { _ as _runWithMiddlewareContext, b as _runWithMiddlewareData, a as applyProductionMiddlewareHeaders, c as createProductionMiddlewareRunner, g as getMiddlewareContext, d as getMiddlewareData, e as getMiddlewareValue } from './production-runtime-Bxua86uR.mjs';
7
+ import './plugin-BJDf43dc.mjs';
8
+ import 'react';
9
+ import './types-D1A6-XvH.mjs';
10
+ import 'db0';
11
+ import 'unstorage';
12
+ import './integration-api-CHT2OKAf.mjs';
13
+ import '@farming-labs/orm';
14
+ import './types-DTzm4TCl.mjs';
15
+ import '@farming-labs/docs';
16
+ import './markdown.mjs';
17
+ import './observability.mjs';
18
+ import './workflows-CusFV6mn.mjs';
19
+ import './cron.mjs';
20
+ import './env.mjs';
21
+ import './server-action-security.mjs';
22
+ import './server-fn-error-DDh14a0V.mjs';
23
+ import './image-config-Duob7wER.mjs';
24
+ import './cache.mjs';
25
+ import './route-runtime-DoOHzCAD.mjs';
26
+ import './font.mjs';
27
+
28
+ /**
29
+ * Middleware Chain Builder
30
+ */
31
+
32
+ declare class UnsupportedRateLimitStorageError extends TypeError {
33
+ constructor();
34
+ }
35
+ /** Create an atomic, process-local fixed-window rate-limit store. */
36
+ declare function memoryRateLimitStorage(options?: MemoryRateLimitStorageOptions): RateLimitStorage;
37
+ /**
38
+ * Get rate limit status for a key
39
+ * @example
40
+ * const status = await getRateLimitStatus('user:123', 100, storage);
41
+ */
42
+ declare function getRateLimitStatus(key: string, limit: number, storage?: RateLimitStorage): Promise<RateLimitStatus>;
43
+ declare function middleware(basePath?: string): MiddlewareChain;
44
+
45
+ /**
46
+ * Middleware Context Implementation
47
+ */
48
+
49
+ /**
50
+ * Create a middleware context from request/response
51
+ */
52
+ declare function createContext(req: IncomingMessage, res: ServerResponse, viteServer?: ViteDevServer, parent?: MiddlewareContext["parent"]): MiddlewareContext;
53
+
54
+ /**
55
+ * Middleware Manager
56
+ *
57
+ * Discovers and executes middleware files in the file system
58
+ */
59
+
60
+ interface DiscoveredMiddleware {
61
+ path: string;
62
+ filePath: string;
63
+ handlers: MiddlewareFunction[];
64
+ config?: MiddlewareConfig;
65
+ source?: "config" | "file";
66
+ }
67
+ /**
68
+ * Middleware Manager - discovers and executes middleware
69
+ */
70
+ declare class MiddlewareManager {
71
+ private middleware;
72
+ private configMiddleware;
73
+ private globalConfig?;
74
+ private viteServer?;
75
+ private appDirs;
76
+ private i18n?;
77
+ constructor(appDir: string | readonly string[], viteServer?: ViteDevServer, config?: FarmMiddlewareConfig, i18n?: ResolvedFarmI18nConfig);
78
+ configure(config?: FarmMiddlewareConfig): void;
79
+ /**
80
+ * Discover all middleware.ts files
81
+ */
82
+ discover(): Promise<void>;
83
+ /**
84
+ * Recursively discover middleware files
85
+ */
86
+ private discoverInDirectory;
87
+ /**
88
+ * Find middleware file in directory
89
+ */
90
+ private findMiddlewareFile;
91
+ /**
92
+ * Load a middleware file
93
+ */
94
+ private loadMiddleware;
95
+ /**
96
+ * Execute middleware for a request
97
+ */
98
+ execute(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
99
+ /**
100
+ * Check if pathname matches middleware config
101
+ */
102
+ private matchesConfig;
103
+ /**
104
+ * Match a pattern against pathname
105
+ */
106
+ private matchPattern;
107
+ /**
108
+ * Reload middleware (for HMR)
109
+ */
110
+ reload(): Promise<void>;
111
+ getMiddlewares(): DiscoveredMiddleware[];
112
+ hasMiddleware(): boolean;
113
+ private matchRoutePath;
114
+ private toMatcherList;
115
+ private getConfigHandlers;
116
+ private toMiddlewareConfig;
117
+ private compilePathPattern;
118
+ private parseColonParam;
119
+ private escapeRegex;
120
+ }
121
+
122
+ /**
123
+ * Middleware helper utilities for pages
124
+ */
125
+
126
+ /**
127
+ * Unwrap middleware data from PageProps
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * export default async function Page(props: PageProps) {
132
+ * const { user, stats } = await unwrapMiddleware(props.middleware, {
133
+ * user: null,
134
+ * stats: { views: 0, clicks: 0 }
135
+ * });
136
+ *
137
+ * return <div>Welcome {user?.name}</div>;
138
+ * }
139
+ * ```
140
+ */
141
+ declare function unwrapMiddleware<T extends Record<string, any>>(middleware: MiddlewareProps | undefined, defaults?: Partial<T>): Partial<T>;
142
+ /**
143
+ * Get a single value from middleware with a default
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * export default async function Page(props: PageProps) {
148
+ * const user = await getMiddlewareValue(props.middleware, 'user', null);
149
+ * return <div>Welcome {user?.name || 'Guest'}</div>;
150
+ * }
151
+ * ```
152
+ */
153
+ declare function getFromMiddleware<T = any>(middleware: MiddlewareProps | undefined, key: string, defaultValue?: T): T | undefined;
154
+ /**
155
+ * Check if middleware data exists
156
+ */
157
+ declare function hasMiddlewareData(middleware: MiddlewareProps | undefined): boolean;
158
+
159
+ /**
160
+ * Standalone Vite middleware support used by Farm's RSC and API plugins.
161
+ */
162
+
163
+ interface FarmMiddlewarePluginOptions {
164
+ /** Source directory (default: `src`). */
165
+ srcDir?: string;
166
+ /** Enable debug logging. */
167
+ debug?: boolean;
168
+ }
169
+ declare function farmMiddlewarePlugin(options?: FarmMiddlewarePluginOptions): Plugin;
170
+
171
+ export { FarmMiddlewareConfig, type FarmMiddlewarePluginOptions, MemoryRateLimitStorageOptions, MiddlewareChain, MiddlewareConfig, MiddlewareContext, MiddlewareFunction, MiddlewareManager, RateLimitStatus, RateLimitStorage, UnsupportedRateLimitStorageError, createContext, farmMiddlewarePlugin, getFromMiddleware, getRateLimitStatus, hasMiddlewareData, memoryRateLimitStorage, middleware, unwrapMiddleware };
@@ -0,0 +1,171 @@
1
+ import { cU as MiddlewareChain, cZ as RateLimitStorage, c_ as RateLimitStatus, c$ as MemoryRateLimitStorageOptions, cP as MiddlewareContext, a2 as FarmMiddlewareConfig, cQ as MiddlewareFunction, dx as MiddlewareConfig, M as MiddlewareProps } from './client-plugins-CbRum1fj.js';
2
+ export { cV as CookieJar, cW as CookieOptions, d1 as MiddlewareResult, cT as MiddlewareStore, d0 as NextFunction, cX as RateLimitConfig, cY as RateLimitIncrementResult, a1 as ReadonlyMiddlewareStore, cR as RequestMiddleware, cS as RequestMiddlewareContext } from './client-plugins-CbRum1fj.js';
3
+ import { IncomingMessage, ServerResponse } from 'http';
4
+ import { ViteDevServer, Plugin } from 'vite';
5
+ import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.js';
6
+ export { _ as _runWithMiddlewareContext, b as _runWithMiddlewareData, a as applyProductionMiddlewareHeaders, c as createProductionMiddlewareRunner, g as getMiddlewareContext, d as getMiddlewareData, e as getMiddlewareValue } from './production-runtime-CZqXjRVi.js';
7
+ import './plugin-BJDf43dc.js';
8
+ import 'react';
9
+ import './types-D1A6-XvH.js';
10
+ import 'db0';
11
+ import 'unstorage';
12
+ import './integration-api-CHT2OKAf.js';
13
+ import '@farming-labs/orm';
14
+ import './types-DTzm4TCl.js';
15
+ import '@farming-labs/docs';
16
+ import './markdown.js';
17
+ import './observability.js';
18
+ import './workflows-CusFV6mn.js';
19
+ import './cron.js';
20
+ import './env.js';
21
+ import './server-action-security.js';
22
+ import './server-fn-error-DDh14a0V.js';
23
+ import './image-config-Duob7wER.js';
24
+ import './cache.js';
25
+ import './route-runtime-DoOHzCAD.js';
26
+ import './font.js';
27
+
28
+ /**
29
+ * Middleware Chain Builder
30
+ */
31
+
32
+ declare class UnsupportedRateLimitStorageError extends TypeError {
33
+ constructor();
34
+ }
35
+ /** Create an atomic, process-local fixed-window rate-limit store. */
36
+ declare function memoryRateLimitStorage(options?: MemoryRateLimitStorageOptions): RateLimitStorage;
37
+ /**
38
+ * Get rate limit status for a key
39
+ * @example
40
+ * const status = await getRateLimitStatus('user:123', 100, storage);
41
+ */
42
+ declare function getRateLimitStatus(key: string, limit: number, storage?: RateLimitStorage): Promise<RateLimitStatus>;
43
+ declare function middleware(basePath?: string): MiddlewareChain;
44
+
45
+ /**
46
+ * Middleware Context Implementation
47
+ */
48
+
49
+ /**
50
+ * Create a middleware context from request/response
51
+ */
52
+ declare function createContext(req: IncomingMessage, res: ServerResponse, viteServer?: ViteDevServer, parent?: MiddlewareContext["parent"]): MiddlewareContext;
53
+
54
+ /**
55
+ * Middleware Manager
56
+ *
57
+ * Discovers and executes middleware files in the file system
58
+ */
59
+
60
+ interface DiscoveredMiddleware {
61
+ path: string;
62
+ filePath: string;
63
+ handlers: MiddlewareFunction[];
64
+ config?: MiddlewareConfig;
65
+ source?: "config" | "file";
66
+ }
67
+ /**
68
+ * Middleware Manager - discovers and executes middleware
69
+ */
70
+ declare class MiddlewareManager {
71
+ private middleware;
72
+ private configMiddleware;
73
+ private globalConfig?;
74
+ private viteServer?;
75
+ private appDirs;
76
+ private i18n?;
77
+ constructor(appDir: string | readonly string[], viteServer?: ViteDevServer, config?: FarmMiddlewareConfig, i18n?: ResolvedFarmI18nConfig);
78
+ configure(config?: FarmMiddlewareConfig): void;
79
+ /**
80
+ * Discover all middleware.ts files
81
+ */
82
+ discover(): Promise<void>;
83
+ /**
84
+ * Recursively discover middleware files
85
+ */
86
+ private discoverInDirectory;
87
+ /**
88
+ * Find middleware file in directory
89
+ */
90
+ private findMiddlewareFile;
91
+ /**
92
+ * Load a middleware file
93
+ */
94
+ private loadMiddleware;
95
+ /**
96
+ * Execute middleware for a request
97
+ */
98
+ execute(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
99
+ /**
100
+ * Check if pathname matches middleware config
101
+ */
102
+ private matchesConfig;
103
+ /**
104
+ * Match a pattern against pathname
105
+ */
106
+ private matchPattern;
107
+ /**
108
+ * Reload middleware (for HMR)
109
+ */
110
+ reload(): Promise<void>;
111
+ getMiddlewares(): DiscoveredMiddleware[];
112
+ hasMiddleware(): boolean;
113
+ private matchRoutePath;
114
+ private toMatcherList;
115
+ private getConfigHandlers;
116
+ private toMiddlewareConfig;
117
+ private compilePathPattern;
118
+ private parseColonParam;
119
+ private escapeRegex;
120
+ }
121
+
122
+ /**
123
+ * Middleware helper utilities for pages
124
+ */
125
+
126
+ /**
127
+ * Unwrap middleware data from PageProps
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * export default async function Page(props: PageProps) {
132
+ * const { user, stats } = await unwrapMiddleware(props.middleware, {
133
+ * user: null,
134
+ * stats: { views: 0, clicks: 0 }
135
+ * });
136
+ *
137
+ * return <div>Welcome {user?.name}</div>;
138
+ * }
139
+ * ```
140
+ */
141
+ declare function unwrapMiddleware<T extends Record<string, any>>(middleware: MiddlewareProps | undefined, defaults?: Partial<T>): Partial<T>;
142
+ /**
143
+ * Get a single value from middleware with a default
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * export default async function Page(props: PageProps) {
148
+ * const user = await getMiddlewareValue(props.middleware, 'user', null);
149
+ * return <div>Welcome {user?.name || 'Guest'}</div>;
150
+ * }
151
+ * ```
152
+ */
153
+ declare function getFromMiddleware<T = any>(middleware: MiddlewareProps | undefined, key: string, defaultValue?: T): T | undefined;
154
+ /**
155
+ * Check if middleware data exists
156
+ */
157
+ declare function hasMiddlewareData(middleware: MiddlewareProps | undefined): boolean;
158
+
159
+ /**
160
+ * Standalone Vite middleware support used by Farm's RSC and API plugins.
161
+ */
162
+
163
+ interface FarmMiddlewarePluginOptions {
164
+ /** Source directory (default: `src`). */
165
+ srcDir?: string;
166
+ /** Enable debug logging. */
167
+ debug?: boolean;
168
+ }
169
+ declare function farmMiddlewarePlugin(options?: FarmMiddlewarePluginOptions): Plugin;
170
+
171
+ export { FarmMiddlewareConfig, type FarmMiddlewarePluginOptions, MemoryRateLimitStorageOptions, MiddlewareChain, MiddlewareConfig, MiddlewareContext, MiddlewareFunction, MiddlewareManager, RateLimitStatus, RateLimitStorage, UnsupportedRateLimitStorageError, createContext, farmMiddlewarePlugin, getFromMiddleware, getRateLimitStatus, hasMiddlewareData, memoryRateLimitStorage, middleware, unwrapMiddleware };
@@ -7,7 +7,7 @@ import {
7
7
  memoryRateLimitStorage,
8
8
  middleware,
9
9
  unwrapMiddleware
10
- } from "./chunk-RIXKJPGI.mjs";
10
+ } from "./chunk-42325TLU.mjs";
11
11
  import {
12
12
  applyProductionMiddlewareHeaders,
13
13
  createProductionMiddlewareRunner
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  MiddlewareManager,
17
17
  createContext
18
- } from "./chunk-MIUW47JX.mjs";
18
+ } from "./chunk-2PEJGY5V.mjs";
19
19
  import {
20
20
  _runWithMiddlewareContext,
21
21
  _runWithMiddlewareData,
@@ -23,6 +23,7 @@ import {
23
23
  getMiddlewareData,
24
24
  getMiddlewareValue
25
25
  } from "./chunk-P7QDS5AT.mjs";
26
+ import "./chunk-GIELMNBG.mjs";
26
27
  import "./chunk-QGOHVJ6J.mjs";
27
28
  import "./chunk-J4FNJ5IU.mjs";
28
29
  import "./chunk-RHIFZZUI.mjs";
@@ -0,0 +1,13 @@
1
+ type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
2
+ interface FarmRedirectSignal {
3
+ url: string;
4
+ status: FarmRedirectStatus;
5
+ }
6
+ declare function redirect(url: string, status?: FarmRedirectStatus): never;
7
+ declare function permanentRedirect(url: string): never;
8
+ declare function notFound(): never;
9
+ declare function isFarmRedirectError(error: unknown): boolean;
10
+ declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
11
+ declare function isFarmNotFoundError(error: unknown): boolean;
12
+
13
+ export { type FarmRedirectSignal as F, isFarmRedirectError as a, type FarmRedirectStatus as b, getFarmRedirectError as g, isFarmNotFoundError as i, notFound as n, permanentRedirect as p, redirect as r };
@@ -0,0 +1,13 @@
1
+ type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
2
+ interface FarmRedirectSignal {
3
+ url: string;
4
+ status: FarmRedirectStatus;
5
+ }
6
+ declare function redirect(url: string, status?: FarmRedirectStatus): never;
7
+ declare function permanentRedirect(url: string): never;
8
+ declare function notFound(): never;
9
+ declare function isFarmRedirectError(error: unknown): boolean;
10
+ declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
11
+ declare function isFarmNotFoundError(error: unknown): boolean;
12
+
13
+ export { type FarmRedirectSignal as F, isFarmRedirectError as a, type FarmRedirectStatus as b, getFarmRedirectError as g, isFarmNotFoundError as i, notFound as n, permanentRedirect as p, redirect as r };
@@ -0,0 +1,14 @@
1
+ export { F as FarmRedirectSignal, b as FarmRedirectStatus, g as getFarmRedirectError, i as isFarmNotFoundError, a as isFarmRedirectError, n as notFound, p as permanentRedirect, r as redirect } from './navigation-errors-Dvwpzaer.mjs';
2
+
3
+ declare function useRouter(): {
4
+ push: (href: string) => void;
5
+ replace: (href: string) => void;
6
+ back: () => void;
7
+ forward: () => void;
8
+ refresh(): void;
9
+ prefetch(_href: string): Promise<void>;
10
+ };
11
+ declare function usePathname(): string;
12
+ declare function useSearchParams(): URLSearchParams;
13
+
14
+ export { usePathname, useRouter, useSearchParams };
@@ -0,0 +1,14 @@
1
+ export { F as FarmRedirectSignal, b as FarmRedirectStatus, g as getFarmRedirectError, i as isFarmNotFoundError, a as isFarmRedirectError, n as notFound, p as permanentRedirect, r as redirect } from './navigation-errors-Dvwpzaer.js';
2
+
3
+ declare function useRouter(): {
4
+ push: (href: string) => void;
5
+ replace: (href: string) => void;
6
+ back: () => void;
7
+ forward: () => void;
8
+ refresh(): void;
9
+ prefetch(_href: string): Promise<void>;
10
+ };
11
+ declare function usePathname(): string;
12
+ declare function useSearchParams(): URLSearchParams;
13
+
14
+ export { usePathname, useRouter, useSearchParams };