@flightdev/core 0.6.7

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 (187) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +541 -0
  3. package/dist/actions/index.d.ts +743 -0
  4. package/dist/actions/index.js +3 -0
  5. package/dist/actions/index.js.map +1 -0
  6. package/dist/adapters/index.d.ts +502 -0
  7. package/dist/adapters/index.js +3 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/cache/index.d.ts +191 -0
  10. package/dist/cache/index.js +3 -0
  11. package/dist/cache/index.js.map +1 -0
  12. package/dist/chunk-62HISNA3.js +354 -0
  13. package/dist/chunk-62HISNA3.js.map +1 -0
  14. package/dist/chunk-63LWTEDQ.js +341 -0
  15. package/dist/chunk-63LWTEDQ.js.map +1 -0
  16. package/dist/chunk-63SCEXD7.js +3 -0
  17. package/dist/chunk-63SCEXD7.js.map +1 -0
  18. package/dist/chunk-72MYOTUB.js +667 -0
  19. package/dist/chunk-72MYOTUB.js.map +1 -0
  20. package/dist/chunk-7CNW24MQ.js +257 -0
  21. package/dist/chunk-7CNW24MQ.js.map +1 -0
  22. package/dist/chunk-7WIEAUJT.js +300 -0
  23. package/dist/chunk-7WIEAUJT.js.map +1 -0
  24. package/dist/chunk-7ZZF4ULK.js +259 -0
  25. package/dist/chunk-7ZZF4ULK.js.map +1 -0
  26. package/dist/chunk-AE3JTS73.js +222 -0
  27. package/dist/chunk-AE3JTS73.js.map +1 -0
  28. package/dist/chunk-AP5NLUSB.js +258 -0
  29. package/dist/chunk-AP5NLUSB.js.map +1 -0
  30. package/dist/chunk-C37YQQI7.js +221 -0
  31. package/dist/chunk-C37YQQI7.js.map +1 -0
  32. package/dist/chunk-DCLVXFVH.js +225 -0
  33. package/dist/chunk-DCLVXFVH.js.map +1 -0
  34. package/dist/chunk-DZMWWDFD.js +223 -0
  35. package/dist/chunk-DZMWWDFD.js.map +1 -0
  36. package/dist/chunk-GCQZ4FHI.js +245 -0
  37. package/dist/chunk-GCQZ4FHI.js.map +1 -0
  38. package/dist/chunk-IPP44XY6.js +47 -0
  39. package/dist/chunk-IPP44XY6.js.map +1 -0
  40. package/dist/chunk-IW7FTQQX.js +267 -0
  41. package/dist/chunk-IW7FTQQX.js.map +1 -0
  42. package/dist/chunk-JX4YSCBH.js +428 -0
  43. package/dist/chunk-JX4YSCBH.js.map +1 -0
  44. package/dist/chunk-KX6UYWWR.js +229 -0
  45. package/dist/chunk-KX6UYWWR.js.map +1 -0
  46. package/dist/chunk-LWVETFJV.js +46 -0
  47. package/dist/chunk-LWVETFJV.js.map +1 -0
  48. package/dist/chunk-MCL2MCA2.js +285 -0
  49. package/dist/chunk-MCL2MCA2.js.map +1 -0
  50. package/dist/chunk-MZXCF35B.js +205 -0
  51. package/dist/chunk-MZXCF35B.js.map +1 -0
  52. package/dist/chunk-NCGPUFWV.js +96 -0
  53. package/dist/chunk-NCGPUFWV.js.map +1 -0
  54. package/dist/chunk-OEJMIE2Q.js +351 -0
  55. package/dist/chunk-OEJMIE2Q.js.map +1 -0
  56. package/dist/chunk-OYF2OAKS.js +394 -0
  57. package/dist/chunk-OYF2OAKS.js.map +1 -0
  58. package/dist/chunk-P6S43FYZ.js +316 -0
  59. package/dist/chunk-P6S43FYZ.js.map +1 -0
  60. package/dist/chunk-PL37KFRJ.js +3 -0
  61. package/dist/chunk-PL37KFRJ.js.map +1 -0
  62. package/dist/chunk-Q7BS5QC5.js +197 -0
  63. package/dist/chunk-Q7BS5QC5.js.map +1 -0
  64. package/dist/chunk-SDYPG3JD.js +288 -0
  65. package/dist/chunk-SDYPG3JD.js.map +1 -0
  66. package/dist/chunk-SUG56SZO.js +256 -0
  67. package/dist/chunk-SUG56SZO.js.map +1 -0
  68. package/dist/chunk-UVH5XJRP.js +164 -0
  69. package/dist/chunk-UVH5XJRP.js.map +1 -0
  70. package/dist/chunk-WZIJKCL3.js +282 -0
  71. package/dist/chunk-WZIJKCL3.js.map +1 -0
  72. package/dist/chunk-Y22AMGTM.js +3 -0
  73. package/dist/chunk-Y22AMGTM.js.map +1 -0
  74. package/dist/chunk-Z7G23XWU.js +200 -0
  75. package/dist/chunk-Z7G23XWU.js.map +1 -0
  76. package/dist/chunk-ZJU5M4IB.js +125 -0
  77. package/dist/chunk-ZJU5M4IB.js.map +1 -0
  78. package/dist/chunk-ZVC3ZWLM.js +52 -0
  79. package/dist/chunk-ZVC3ZWLM.js.map +1 -0
  80. package/dist/chunk-ZZZML7Y3.js +310 -0
  81. package/dist/chunk-ZZZML7Y3.js.map +1 -0
  82. package/dist/client.d.ts +25 -0
  83. package/dist/client.js +16 -0
  84. package/dist/client.js.map +1 -0
  85. package/dist/config/index.d.ts +170 -0
  86. package/dist/config/index.js +3 -0
  87. package/dist/config/index.js.map +1 -0
  88. package/dist/errors/index.d.ts +267 -0
  89. package/dist/errors/index.js +4 -0
  90. package/dist/errors/index.js.map +1 -0
  91. package/dist/file-router/index.d.ts +184 -0
  92. package/dist/file-router/index.js +3 -0
  93. package/dist/file-router/index.js.map +1 -0
  94. package/dist/file-router/streaming-hints.d.ts +129 -0
  95. package/dist/file-router/streaming-hints.js +3 -0
  96. package/dist/file-router/streaming-hints.js.map +1 -0
  97. package/dist/handlers/index.d.ts +59 -0
  98. package/dist/handlers/index.js +3 -0
  99. package/dist/handlers/index.js.map +1 -0
  100. package/dist/index.d.ts +588 -0
  101. package/dist/index.js +886 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/islands/index.d.ts +234 -0
  104. package/dist/islands/index.js +3 -0
  105. package/dist/islands/index.js.map +1 -0
  106. package/dist/middleware/index.d.ts +305 -0
  107. package/dist/middleware/index.js +3 -0
  108. package/dist/middleware/index.js.map +1 -0
  109. package/dist/react/index.d.ts +73 -0
  110. package/dist/react/index.js +52 -0
  111. package/dist/react/index.js.map +1 -0
  112. package/dist/render/index.d.ts +131 -0
  113. package/dist/render/index.js +3 -0
  114. package/dist/render/index.js.map +1 -0
  115. package/dist/router/index.d.ts +65 -0
  116. package/dist/router/index.js +3 -0
  117. package/dist/router/index.js.map +1 -0
  118. package/dist/rsc/adapters/index.d.ts +8 -0
  119. package/dist/rsc/adapters/index.js +7 -0
  120. package/dist/rsc/adapters/index.js.map +1 -0
  121. package/dist/rsc/adapters/preact.d.ts +97 -0
  122. package/dist/rsc/adapters/preact.js +3 -0
  123. package/dist/rsc/adapters/preact.js.map +1 -0
  124. package/dist/rsc/adapters/react.d.ts +82 -0
  125. package/dist/rsc/adapters/react.js +3 -0
  126. package/dist/rsc/adapters/react.js.map +1 -0
  127. package/dist/rsc/adapters/solid.d.ts +84 -0
  128. package/dist/rsc/adapters/solid.js +3 -0
  129. package/dist/rsc/adapters/solid.js.map +1 -0
  130. package/dist/rsc/adapters/vue.d.ts +80 -0
  131. package/dist/rsc/adapters/vue.js +3 -0
  132. package/dist/rsc/adapters/vue.js.map +1 -0
  133. package/dist/rsc/boundaries.d.ts +182 -0
  134. package/dist/rsc/boundaries.js +3 -0
  135. package/dist/rsc/boundaries.js.map +1 -0
  136. package/dist/rsc/context.d.ts +201 -0
  137. package/dist/rsc/context.js +3 -0
  138. package/dist/rsc/context.js.map +1 -0
  139. package/dist/rsc/index.d.ts +232 -0
  140. package/dist/rsc/index.js +15 -0
  141. package/dist/rsc/index.js.map +1 -0
  142. package/dist/rsc/legacy.d.ts +155 -0
  143. package/dist/rsc/legacy.js +3 -0
  144. package/dist/rsc/legacy.js.map +1 -0
  145. package/dist/rsc/payload.d.ts +262 -0
  146. package/dist/rsc/payload.js +3 -0
  147. package/dist/rsc/payload.js.map +1 -0
  148. package/dist/rsc/plugins/esbuild.d.ts +124 -0
  149. package/dist/rsc/plugins/esbuild.js +4 -0
  150. package/dist/rsc/plugins/esbuild.js.map +1 -0
  151. package/dist/rsc/plugins/index.d.ts +4 -0
  152. package/dist/rsc/plugins/index.js +6 -0
  153. package/dist/rsc/plugins/index.js.map +1 -0
  154. package/dist/rsc/plugins/rollup.d.ts +103 -0
  155. package/dist/rsc/plugins/rollup.js +4 -0
  156. package/dist/rsc/plugins/rollup.js.map +1 -0
  157. package/dist/rsc/renderer.d.ts +162 -0
  158. package/dist/rsc/renderer.js +5 -0
  159. package/dist/rsc/renderer.js.map +1 -0
  160. package/dist/rsc/stream.d.ts +129 -0
  161. package/dist/rsc/stream.js +3 -0
  162. package/dist/rsc/stream.js.map +1 -0
  163. package/dist/rsc/vite-plugin.d.ts +78 -0
  164. package/dist/rsc/vite-plugin.js +4 -0
  165. package/dist/rsc/vite-plugin.js.map +1 -0
  166. package/dist/server/index.d.ts +135 -0
  167. package/dist/server/index.js +6 -0
  168. package/dist/server/index.js.map +1 -0
  169. package/dist/streaming/adapters/index.d.ts +223 -0
  170. package/dist/streaming/adapters/index.js +3 -0
  171. package/dist/streaming/adapters/index.js.map +1 -0
  172. package/dist/streaming/conditional.d.ts +130 -0
  173. package/dist/streaming/conditional.js +3 -0
  174. package/dist/streaming/conditional.js.map +1 -0
  175. package/dist/streaming/index.d.ts +177 -0
  176. package/dist/streaming/index.js +3 -0
  177. package/dist/streaming/index.js.map +1 -0
  178. package/dist/streaming/observability.d.ts +201 -0
  179. package/dist/streaming/observability.js +4 -0
  180. package/dist/streaming/observability.js.map +1 -0
  181. package/dist/streaming/priority.d.ts +103 -0
  182. package/dist/streaming/priority.js +3 -0
  183. package/dist/streaming/priority.js.map +1 -0
  184. package/dist/utils/index.d.ts +42 -0
  185. package/dist/utils/index.js +4 -0
  186. package/dist/utils/index.js.map +1 -0
  187. package/package.json +228 -0
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @flightdev/core - Server Context
3
+ *
4
+ * API de contexto para Server Components.
5
+ * Provee acceso a datos del request de forma explícita y type-safe.
6
+ *
7
+ * Filosofía Flight:
8
+ * - Contexto EXPLÍCITO (no magia con AsyncLocalStorage)
9
+ * - Pasado como argumento (testeable, predecible)
10
+ * - Extensible con adapters custom
11
+ * - Inmutable por defecto
12
+ *
13
+ * @module @flightdev/core/rsc/context
14
+ */
15
+ /**
16
+ * Contexto del servidor disponible en Server Components
17
+ */
18
+ interface ServerContext {
19
+ /** Request actual (Web API Request) */
20
+ readonly request: Request;
21
+ /** Parámetros de ruta */
22
+ readonly params: Readonly<Record<string, string>>;
23
+ /** Search params de la URL */
24
+ readonly searchParams: URLSearchParams;
25
+ /** Headers del request */
26
+ readonly headers: Headers;
27
+ /** Accessor de cookies */
28
+ readonly cookies: CookieAccessor;
29
+ /** Headers de respuesta (mutables) */
30
+ readonly responseHeaders: Headers;
31
+ /** Signal para cancelación */
32
+ readonly signal: AbortSignal;
33
+ /** URL parseada */
34
+ readonly url: URL;
35
+ /** Método HTTP */
36
+ readonly method: string;
37
+ /** Context extensions (para adapters) */
38
+ readonly extensions: ContextExtensions;
39
+ }
40
+ /**
41
+ * Accessor para cookies con lazy parsing
42
+ */
43
+ interface CookieAccessor {
44
+ /** Obtiene el valor de una cookie */
45
+ get(name: string): string | undefined;
46
+ /** Obtiene todas las cookies */
47
+ getAll(): Readonly<Record<string, string>>;
48
+ /** Verifica si existe una cookie */
49
+ has(name: string): boolean;
50
+ }
51
+ /**
52
+ * Extensiones del contexto para adapters
53
+ */
54
+ interface ContextExtensions {
55
+ /** Obtiene una extensión */
56
+ get<T>(key: string): T | undefined;
57
+ /** Verifica si existe una extensión */
58
+ has(key: string): boolean;
59
+ }
60
+ /**
61
+ * Opciones para crear ServerContext
62
+ */
63
+ interface ServerContextOptions {
64
+ /** Parámetros de ruta */
65
+ params?: Record<string, string>;
66
+ /** Extensiones custom */
67
+ extensions?: Record<string, unknown>;
68
+ /** Headers de respuesta iniciales */
69
+ responseHeaders?: HeadersInit;
70
+ }
71
+ /**
72
+ * Crea un ServerContext a partir de un Request
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const ctx = createServerContext(request, {
77
+ * params: { id: '123' }
78
+ * });
79
+ *
80
+ * // En un Server Component
81
+ * async function UserPage(props, ctx: ServerContext) {
82
+ * const userId = ctx.params.id;
83
+ * const user = await db.users.get(userId);
84
+ * return <UserProfile user={user} />;
85
+ * }
86
+ * ```
87
+ */
88
+ declare function createServerContext(request: Request, options?: ServerContextOptions): ServerContext;
89
+ /**
90
+ * Obtiene un header del request
91
+ */
92
+ declare function getHeader(ctx: ServerContext, name: string): string | null;
93
+ /**
94
+ * Obtiene todos los headers como objeto
95
+ */
96
+ declare function getHeaders(ctx: ServerContext): Record<string, string>;
97
+ /**
98
+ * Verifica si el request es un POST/PUT/PATCH/DELETE (mutation request)
99
+ */
100
+ declare function isMutationRequest(ctx: ServerContext): boolean;
101
+ /**
102
+ * Verifica si el request acepta JSON
103
+ */
104
+ declare function acceptsJson(ctx: ServerContext): boolean;
105
+ /**
106
+ * Verifica si el request es AJAX/fetch
107
+ */
108
+ declare function isAjaxRequest(ctx: ServerContext): boolean;
109
+ /**
110
+ * Verifica si el request viene de un bot
111
+ */
112
+ declare function isBotRequest(ctx: ServerContext): boolean;
113
+ /**
114
+ * Verifica si el cliente soporta streaming
115
+ */
116
+ declare function supportsStreaming(ctx: ServerContext): boolean;
117
+ /**
118
+ * Obtiene el idioma preferido del cliente
119
+ */
120
+ declare function getPreferredLanguage(ctx: ServerContext, available: string[]): string | undefined;
121
+ /**
122
+ * Sets a cookie in the response
123
+ */
124
+ declare function setCookie(ctx: ServerContext, name: string, value: string, options?: CookieOptions): void;
125
+ /**
126
+ * Deletes a cookie
127
+ */
128
+ declare function deleteCookie(ctx: ServerContext, name: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
129
+ /**
130
+ * Cookie options
131
+ */
132
+ interface CookieOptions {
133
+ /** Max age in seconds */
134
+ maxAge?: number;
135
+ /** Expiration date */
136
+ expires?: Date;
137
+ /** Cookie path */
138
+ path?: string;
139
+ /** Cookie domain */
140
+ domain?: string;
141
+ /** HTTPS only */
142
+ secure?: boolean;
143
+ /** Not accessible via JavaScript */
144
+ httpOnly?: boolean;
145
+ /** SameSite attribute */
146
+ sameSite?: 'Strict' | 'Lax' | 'None';
147
+ }
148
+ /**
149
+ * Sets cache control headers
150
+ */
151
+ declare function setCacheControl(ctx: ServerContext, options: CacheControlOptions): void;
152
+ /**
153
+ * Cache control options
154
+ */
155
+ interface CacheControlOptions {
156
+ public?: boolean;
157
+ private?: boolean;
158
+ noCache?: boolean;
159
+ noStore?: boolean;
160
+ maxAge?: number;
161
+ sMaxAge?: number;
162
+ staleWhileRevalidate?: number;
163
+ staleIfError?: number;
164
+ mustRevalidate?: boolean;
165
+ immutable?: boolean;
166
+ }
167
+ /**
168
+ * Not found error - triggers 404 handling
169
+ */
170
+ declare function notFound(message?: string): never;
171
+ /**
172
+ * Check if error is a not found error
173
+ */
174
+ declare function isNotFoundError(error: unknown): boolean;
175
+ /**
176
+ * Redirect error - triggers redirect handling
177
+ */
178
+ declare function redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): never;
179
+ /**
180
+ * Check if error is a redirect error
181
+ */
182
+ declare function isRedirectError(error: unknown): error is Error & {
183
+ __flight_redirect: {
184
+ url: string;
185
+ status: number;
186
+ };
187
+ };
188
+ /**
189
+ * Get redirect info from error
190
+ */
191
+ declare function getRedirectInfo(error: Error & {
192
+ __flight_redirect: {
193
+ url: string;
194
+ status: number;
195
+ };
196
+ }): {
197
+ url: string;
198
+ status: number;
199
+ };
200
+
201
+ export { type CacheControlOptions, type ContextExtensions, type CookieAccessor, type CookieOptions, type ServerContext, type ServerContextOptions, acceptsJson, createServerContext, deleteCookie, getHeader, getHeaders, getPreferredLanguage, getRedirectInfo, isAjaxRequest, isBotRequest, isMutationRequest, isNotFoundError, isRedirectError, notFound, redirect, setCacheControl, setCookie, supportsStreaming };
@@ -0,0 +1,3 @@
1
+ export { acceptsJson, createServerContext, deleteCookie, getHeader, getHeaders, getPreferredLanguage, getRedirectInfo, isAjaxRequest, isBotRequest, isMutationRequest, isNotFoundError, isRedirectError, notFound, redirect, setCacheControl, setCookie, supportsStreaming } from '../chunk-MZXCF35B.js';
2
+ //# sourceMappingURL=context.js.map
3
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"context.js"}
@@ -0,0 +1,232 @@
1
+ import { ServerContext } from './context.js';
2
+ export { CacheControlOptions, ContextExtensions, CookieAccessor, CookieOptions, ServerContextOptions, acceptsJson, createServerContext, deleteCookie, getHeader, getHeaders, getPreferredLanguage, getRedirectInfo, isAjaxRequest, isBotRequest, isMutationRequest, isNotFoundError, isRedirectError, notFound, redirect, setCacheControl, setCookie, supportsStreaming } from './context.js';
3
+ import { FlightElement } from './payload.js';
4
+ export { ClientReferenceChunk, ErrorBoundaryChunk, FlightChunk, FlightClientElement, FlightFragmentElement, FlightHostElement, FlightLazyElement, FlightNullElement, FlightPayloadError, FlightSerializationError, FlightSuspenseElement, FlightTextElement, HintChunk, MetaChunk, SerializedSpecialValue, SerializedValue, ServerComponentChunk, ServerReferenceChunk, SpecialValueType, clientRef, createActionChunk, createClientChunk, createErrorChunk, createHintChunk, createServerChunk, deserialize, fragment, generateChunkId, h, isFlightElement, resetChunkIdCounter, serialize, suspense, text, toFlightElement } from './payload.js';
5
+ export { BoundaryRegistry, BoundaryType, CLIENT_REFERENCE, ClientReference, ComponentBoundary, ModuleAnalysis, SERVER_REFERENCE, ServerReference, analyzeModule, createClientReference, createServerReference, detectAsyncComponents, detectBoundaryType, detectInlineServerActions, getReferenceId, globalRegistry, hasUseClientDirective, hasUseServerDirective, isClientReference, isServerReference, registerClientComponent, registerServerAction } from './boundaries.js';
6
+ export { FlightResponseOptions, FlightStreamError, FlightStreamOptions, FlightStreamResult, consumeFlightStream, createFlightResponse, createFlightStream, createFlightStreamFromArray, createHybridResponse, createStreamController, mergeFlightStreams, parseFlightStream, parseFlightStreamSync, prettyPrintChunks, transformFlightStream } from './stream.js';
7
+ export { ComponentFn, ElementTypeInfo, FlightRenderer, RenderOptions, RenderResult, UIAdapter, createRenderer, renderServerComponent, renderServerComponentStreaming } from './renderer.js';
8
+ export { ReactConsumerOptions, ReactServerComponent, createReactAdapter, createReactConsumer, markAsClientComponent } from './adapters/react.js';
9
+ export { ClientManifestEntry, FlightRSCPluginOptions, ServerManifestEntry, default as flightRSC } from './vite-plugin.js';
10
+ export { AsyncErrorBoundaryOptions, ComponentType, ClientComponent as LegacyClientComponent, ServerComponent as LegacyServerComponent, RenderContext, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError as legacyIsNotFoundError, isRedirectError as legacyIsRedirectError, notFound as legacyNotFound, redirect as legacyRedirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withAsyncErrorBoundary, withErrorBoundary } from './legacy.js';
11
+ import 'react';
12
+ import 'vite';
13
+
14
+ /**
15
+ * @flightdev/core - RSC Type Helpers
16
+ *
17
+ * Type utilities for async server components, loaders, and actions.
18
+ * These types provide better TypeScript inference and developer experience.
19
+ *
20
+ * @module @flightdev/core/rsc/types
21
+ */
22
+
23
+ /**
24
+ * Type for async server components with data fetching.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const UserPage: AsyncServerComponent<{ id: string }> = async ({ id }, ctx) => {
29
+ * const user = await db.users.get(id);
30
+ * return h('div', null, text(user.name));
31
+ * };
32
+ * ```
33
+ */
34
+ type AsyncServerComponent<Props = Record<string, unknown>, Result = FlightElement> = (props: Props, ctx: ServerContext) => Promise<Result>;
35
+ /**
36
+ * Type for sync server components.
37
+ */
38
+ type SyncServerComponent<Props = Record<string, unknown>, Result = FlightElement> = (props: Props, ctx: ServerContext) => Result;
39
+ /**
40
+ * Union type for any server component (sync or async).
41
+ */
42
+ type ServerComponent<Props = Record<string, unknown>, Result = FlightElement> = AsyncServerComponent<Props, Result> | SyncServerComponent<Props, Result>;
43
+ /**
44
+ * Context provided to loader functions.
45
+ */
46
+ interface LoaderContext {
47
+ /** Route parameters extracted from the URL path */
48
+ params: Record<string, string>;
49
+ /** The incoming request object */
50
+ request: Request;
51
+ /** URL search parameters */
52
+ searchParams: URLSearchParams;
53
+ }
54
+ /**
55
+ * Type for loader functions.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * export const loader: LoaderFn = async ({ params }) => {
60
+ * const user = await db.users.get(params.id);
61
+ * return { user };
62
+ * };
63
+ * ```
64
+ */
65
+ type LoaderFn<T = unknown> = (context: LoaderContext) => Promise<T> | T;
66
+ /**
67
+ * Infer the return type of a loader function.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * export async function loader() {
72
+ * return { count: 42, items: ['a', 'b'] };
73
+ * }
74
+ *
75
+ * // Type is { count: number; items: string[] }
76
+ * type Data = InferLoaderData<typeof loader>;
77
+ * ```
78
+ */
79
+ type InferLoaderData<T extends (...args: never[]) => unknown> = Awaited<ReturnType<T>>;
80
+ /**
81
+ * Context provided to action functions.
82
+ */
83
+ interface ActionContext {
84
+ /** The incoming request object */
85
+ request: Request;
86
+ /** Route parameters extracted from the URL path */
87
+ params: Record<string, string>;
88
+ }
89
+ /**
90
+ * Type for action functions.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * export const action: ActionFn = async ({ request }) => {
95
+ * const formData = await request.formData();
96
+ * await db.items.create({ name: formData.get('name') });
97
+ * return { success: true };
98
+ * };
99
+ * ```
100
+ */
101
+ type ActionFn<T = unknown> = (context: ActionContext) => Promise<T> | T;
102
+ /**
103
+ * Infer the return type of an action function.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * export async function action() {
108
+ * return { success: true, id: '123' };
109
+ * }
110
+ *
111
+ * // Type is { success: boolean; id: string }
112
+ * type Result = InferActionReturn<typeof action>;
113
+ * ```
114
+ */
115
+ type InferActionReturn<T extends (...args: never[]) => unknown> = Awaited<ReturnType<T>>;
116
+ /**
117
+ * Extract props type from a component function.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * async function UserCard(props: { name: string; age: number }) {
122
+ * return <div>{props.name}</div>;
123
+ * }
124
+ *
125
+ * // Type is { name: string; age: number }
126
+ * type Props = ComponentProps<typeof UserCard>;
127
+ * ```
128
+ */
129
+ type ComponentProps<T> = T extends (props: infer P, ...args: unknown[]) => unknown ? P : never;
130
+ /**
131
+ * Extract the return type of a component (after awaiting if async).
132
+ */
133
+ type ComponentReturn<T> = T extends (...args: unknown[]) => infer R ? Awaited<R> : never;
134
+ /**
135
+ * Props for page components with route parameters.
136
+ */
137
+ interface PageProps<Params extends Record<string, string> = Record<string, string>> {
138
+ /** Route parameters from dynamic segments */
139
+ params: Params;
140
+ /** URL search parameters */
141
+ searchParams?: Record<string, string | string[]>;
142
+ }
143
+ /**
144
+ * Type for page components.
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const PostPage: PageComponent<{ slug: string }> = async ({ params }) => {
149
+ * const post = await getPost(params.slug);
150
+ * return <article>{post.title}</article>;
151
+ * };
152
+ * ```
153
+ */
154
+ type PageComponent<Params extends Record<string, string> = Record<string, string>> = AsyncServerComponent<PageProps<Params>>;
155
+ /**
156
+ * Props for layout components.
157
+ */
158
+ interface LayoutProps<Params extends Record<string, string> = Record<string, string>> {
159
+ /** Child components to render */
160
+ children: FlightElement;
161
+ /** Route parameters from dynamic segments */
162
+ params: Params;
163
+ }
164
+ /**
165
+ * Type for layout components.
166
+ */
167
+ type LayoutComponent<Params extends Record<string, string> = Record<string, string>> = ServerComponent<LayoutProps<Params>>;
168
+ /**
169
+ * Props for error boundary components.
170
+ */
171
+ interface ErrorProps {
172
+ /** The error that was thrown */
173
+ error: Error;
174
+ /** Function to reset the error boundary */
175
+ reset: () => void;
176
+ }
177
+ /**
178
+ * Type for error components.
179
+ */
180
+ type ErrorComponent = (props: ErrorProps) => FlightElement;
181
+ /**
182
+ * Type for loading components (shown during Suspense).
183
+ */
184
+ type LoadingComponent = () => FlightElement;
185
+ /**
186
+ * Generate metadata for a page.
187
+ */
188
+ type GenerateMetadata<Params extends Record<string, string> = Record<string, string>> = (props: PageProps<Params>) => Promise<Metadata> | Metadata;
189
+ /**
190
+ * Page metadata type.
191
+ */
192
+ interface Metadata {
193
+ title?: string | {
194
+ default: string;
195
+ template?: string;
196
+ };
197
+ description?: string;
198
+ keywords?: string[];
199
+ authors?: Array<{
200
+ name: string;
201
+ url?: string;
202
+ }>;
203
+ openGraph?: {
204
+ title?: string;
205
+ description?: string;
206
+ images?: string[];
207
+ url?: string;
208
+ type?: string;
209
+ };
210
+ twitter?: {
211
+ card?: 'summary' | 'summary_large_image' | 'player' | 'app';
212
+ title?: string;
213
+ description?: string;
214
+ images?: string[];
215
+ };
216
+ robots?: string | {
217
+ index?: boolean;
218
+ follow?: boolean;
219
+ };
220
+ }
221
+
222
+ /**
223
+ * Server Component function type
224
+ * @deprecated Use AsyncServerComponent or ServerComponent from './types.js'
225
+ */
226
+ type ServerComponentFn<P = unknown, R = FlightElement> = (props: P, ctx: ServerContext) => R | Promise<R>;
227
+ /**
228
+ * Server Action function type
229
+ */
230
+ type ServerActionFn<Args extends unknown[] = unknown[], R = unknown> = (...args: Args) => Promise<R>;
231
+
232
+ export { type ActionContext, type ActionFn, type AsyncServerComponent, type ComponentProps, type ComponentReturn, type ErrorComponent, type ErrorProps, FlightElement, type GenerateMetadata, type InferActionReturn, type InferLoaderData, type LayoutComponent, type LayoutProps, type LoaderContext, type LoaderFn, type LoadingComponent, type Metadata, type PageComponent, type PageProps, type ServerActionFn, type ServerComponent, type ServerComponentFn, ServerContext, type SyncServerComponent };
@@ -0,0 +1,15 @@
1
+ import '../chunk-63SCEXD7.js';
2
+ import '../chunk-Y22AMGTM.js';
3
+ export { createReactAdapter, createReactConsumer, markAsClientComponent } from '../chunk-AE3JTS73.js';
4
+ import '../chunk-DCLVXFVH.js';
5
+ import '../chunk-7ZZF4ULK.js';
6
+ import '../chunk-KX6UYWWR.js';
7
+ export { acceptsJson, createServerContext, deleteCookie, getHeader, getHeaders, getPreferredLanguage, getRedirectInfo, isAjaxRequest, isBotRequest, isMutationRequest, isNotFoundError, isRedirectError, notFound, redirect, setCacheControl, setCookie, supportsStreaming } from '../chunk-MZXCF35B.js';
8
+ export { FlightStreamError, consumeFlightStream, createFlightResponse, createFlightStream, createFlightStreamFromArray, createHybridResponse, createStreamController, mergeFlightStreams, parseFlightStream, parseFlightStreamSync, prettyPrintChunks, transformFlightStream } from '../chunk-SUG56SZO.js';
9
+ export { FlightRenderer, createRenderer, renderServerComponent, renderServerComponentStreaming } from '../chunk-P6S43FYZ.js';
10
+ export { FlightPayloadError, FlightSerializationError, clientRef, createActionChunk, createClientChunk, createErrorChunk, createHintChunk, createServerChunk, deserialize, fragment, generateChunkId, h, isFlightElement, resetChunkIdCounter, serialize, suspense, text, toFlightElement } from '../chunk-7CNW24MQ.js';
11
+ export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError as legacyIsNotFoundError, isRedirectError as legacyIsRedirectError, notFound as legacyNotFound, redirect as legacyRedirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withAsyncErrorBoundary, withErrorBoundary } from '../chunk-Z7G23XWU.js';
12
+ export { flightRSC } from '../chunk-63LWTEDQ.js';
13
+ export { BoundaryRegistry, CLIENT_REFERENCE, SERVER_REFERENCE, analyzeModule, createClientReference, createServerReference, detectAsyncComponents, detectBoundaryType, detectInlineServerActions, getReferenceId, globalRegistry, hasUseClientDirective, hasUseServerDirective, isClientReference, isServerReference, registerClientComponent, registerServerAction } from '../chunk-AP5NLUSB.js';
14
+ //# sourceMappingURL=index.js.map
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @flightdev/core - Legacy RSC Support
3
+ *
4
+ * Backward compatibility module for the original RSC implementation.
5
+ * Use the new API from './index.js' for new features.
6
+ *
7
+ * @deprecated Use the new RSC API instead
8
+ * @module @flightdev/core/rsc/legacy
9
+ */
10
+ /**
11
+ * Component rendering context
12
+ * @deprecated Use ServerContext from './context.js' instead
13
+ */
14
+ interface RenderContext {
15
+ /** Current request */
16
+ request: Request;
17
+ /** Route params */
18
+ params: Record<string, string>;
19
+ /** Search params */
20
+ searchParams: URLSearchParams;
21
+ /** Request headers */
22
+ headers: Headers;
23
+ /** Cookies */
24
+ cookies: Map<string, string>;
25
+ }
26
+ /**
27
+ * Server component definition
28
+ * @deprecated Use ServerComponentFn from './index.js' instead
29
+ */
30
+ interface ServerComponent<P = unknown> {
31
+ (props: P, context: RenderContext): Promise<string> | string;
32
+ /** Mark as server component */
33
+ __flight_server?: true;
34
+ /** Dependencies for hydration */
35
+ __flight_deps?: string[];
36
+ }
37
+ /**
38
+ * Client component definition
39
+ * @deprecated Use ClientReference from './boundaries.js' instead
40
+ */
41
+ interface ClientComponent<P = unknown> {
42
+ (props: P): unknown;
43
+ /** Mark as client component */
44
+ __flight_client?: true;
45
+ /** Client bundle path */
46
+ __flight_bundle?: string;
47
+ }
48
+ /**
49
+ * Component type detection
50
+ */
51
+ type ComponentType = 'server' | 'client' | 'hybrid';
52
+ /**
53
+ * Execute an async server component
54
+ * @deprecated Use the new rendering pipeline instead
55
+ */
56
+ declare function executeServerComponent<P>(component: ServerComponent<P>, props: P, context: RenderContext): Promise<string>;
57
+ /**
58
+ * Create a render context from a Request
59
+ * @deprecated Use createServerContext from './context.js' instead
60
+ */
61
+ declare function createRenderContext(request: Request, params?: Record<string, string>): RenderContext;
62
+ /**
63
+ * Server-side fetch with automatic caching
64
+ */
65
+ declare function serverFetch<T>(url: string, options?: RequestInit & {
66
+ revalidate?: number | false;
67
+ tags?: string[];
68
+ }): Promise<T>;
69
+ /**
70
+ * Invalidate cache by tag
71
+ */
72
+ declare function revalidateTag(tag: string): void;
73
+ /**
74
+ * Invalidate cache by path
75
+ */
76
+ declare function revalidatePath(path: string): void;
77
+ /**
78
+ * Serialize props for transmission to client
79
+ * @deprecated Use serialize from './payload.js' instead
80
+ */
81
+ declare function serializeProps(props: unknown): string;
82
+ /**
83
+ * Deserialize props on client
84
+ * @deprecated Use deserialize from './payload.js' instead
85
+ */
86
+ declare function deserializeProps<T>(serialized: string): T;
87
+ /**
88
+ * Create a client boundary placeholder
89
+ * @deprecated Use clientRef from './payload.js' instead
90
+ */
91
+ declare function createClientBoundary(componentId: string, props: unknown, fallback?: string): string;
92
+ /**
93
+ * Helper to create an async server component
94
+ * @deprecated Use async Server Components directly
95
+ */
96
+ declare function createAsyncComponent<P, T>(fetcher: (props: P, context: RenderContext) => Promise<T>, renderer: (data: T, props: P) => string): ServerComponent<P>;
97
+ /**
98
+ * Compose multiple server components
99
+ * @deprecated Use Promise.all with async components
100
+ */
101
+ declare function composeComponents(...components: Array<() => Promise<string> | string>): () => Promise<string>;
102
+ /**
103
+ * Options for async error boundary
104
+ */
105
+ interface AsyncErrorBoundaryOptions<P, R> {
106
+ /** Fallback to render on error */
107
+ fallback: (error: Error, props: P) => R;
108
+ /** Optional callback when error occurs */
109
+ onError?: (error: Error, props: P, context: RenderContext) => void;
110
+ /** Whether to rethrow certain errors (e.g., redirects, not found) */
111
+ rethrowNavigation?: boolean;
112
+ }
113
+ /**
114
+ * Wrap an async server component with comprehensive error handling.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const SafeUserPage = withAsyncErrorBoundary(UserPage, {
119
+ * fallback: (error, props) => `<div>Error loading user ${props.id}</div>`,
120
+ * onError: (error, props) => console.error(`Failed to load user ${props.id}:`, error),
121
+ * rethrowNavigation: true,
122
+ * });
123
+ * ```
124
+ */
125
+ declare function withAsyncErrorBoundary<P, R = string>(component: (props: P, context: RenderContext) => Promise<R> | R, options: AsyncErrorBoundaryOptions<P, R>): (props: P, context: RenderContext) => Promise<R>;
126
+ /**
127
+ * Wrap a server component with error handling
128
+ * @deprecated Use withAsyncErrorBoundary instead
129
+ */
130
+ declare function withErrorBoundary<P>(component: ServerComponent<P>, errorFallback: (error: Error) => string): ServerComponent<P>;
131
+ /**
132
+ * Throw a not found error
133
+ * @deprecated Use notFound from './context.js' instead
134
+ */
135
+ declare function notFound(): never;
136
+ /**
137
+ * Check if error is not found
138
+ * @deprecated Use isNotFoundError from './context.js' instead
139
+ */
140
+ declare function isNotFoundError(error: unknown): boolean;
141
+ /**
142
+ * Server-side redirect
143
+ * @deprecated Use redirect from './context.js' instead
144
+ */
145
+ declare function redirect(url: string, type?: 'replace' | 'push'): never;
146
+ /**
147
+ * Check if error is redirect
148
+ * @deprecated Use isRedirectError from './context.js' instead
149
+ */
150
+ declare function isRedirectError(error: unknown): {
151
+ url: string;
152
+ type: string;
153
+ } | null;
154
+
155
+ export { type AsyncErrorBoundaryOptions, type ClientComponent, type ComponentType, type RenderContext, type ServerComponent, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withAsyncErrorBoundary, withErrorBoundary };
@@ -0,0 +1,3 @@
1
+ export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withAsyncErrorBoundary, withErrorBoundary } from '../chunk-Z7G23XWU.js';
2
+ //# sourceMappingURL=legacy.js.map
3
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"legacy.js"}