@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.
- package/LICENSE +21 -0
- package/README.md +541 -0
- package/dist/actions/index.d.ts +743 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/adapters/index.d.ts +502 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/cache/index.d.ts +191 -0
- package/dist/cache/index.js +3 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/chunk-62HISNA3.js +354 -0
- package/dist/chunk-62HISNA3.js.map +1 -0
- package/dist/chunk-63LWTEDQ.js +341 -0
- package/dist/chunk-63LWTEDQ.js.map +1 -0
- package/dist/chunk-63SCEXD7.js +3 -0
- package/dist/chunk-63SCEXD7.js.map +1 -0
- package/dist/chunk-72MYOTUB.js +667 -0
- package/dist/chunk-72MYOTUB.js.map +1 -0
- package/dist/chunk-7CNW24MQ.js +257 -0
- package/dist/chunk-7CNW24MQ.js.map +1 -0
- package/dist/chunk-7WIEAUJT.js +300 -0
- package/dist/chunk-7WIEAUJT.js.map +1 -0
- package/dist/chunk-7ZZF4ULK.js +259 -0
- package/dist/chunk-7ZZF4ULK.js.map +1 -0
- package/dist/chunk-AE3JTS73.js +222 -0
- package/dist/chunk-AE3JTS73.js.map +1 -0
- package/dist/chunk-AP5NLUSB.js +258 -0
- package/dist/chunk-AP5NLUSB.js.map +1 -0
- package/dist/chunk-C37YQQI7.js +221 -0
- package/dist/chunk-C37YQQI7.js.map +1 -0
- package/dist/chunk-DCLVXFVH.js +225 -0
- package/dist/chunk-DCLVXFVH.js.map +1 -0
- package/dist/chunk-DZMWWDFD.js +223 -0
- package/dist/chunk-DZMWWDFD.js.map +1 -0
- package/dist/chunk-GCQZ4FHI.js +245 -0
- package/dist/chunk-GCQZ4FHI.js.map +1 -0
- package/dist/chunk-IPP44XY6.js +47 -0
- package/dist/chunk-IPP44XY6.js.map +1 -0
- package/dist/chunk-IW7FTQQX.js +267 -0
- package/dist/chunk-IW7FTQQX.js.map +1 -0
- package/dist/chunk-JX4YSCBH.js +428 -0
- package/dist/chunk-JX4YSCBH.js.map +1 -0
- package/dist/chunk-KX6UYWWR.js +229 -0
- package/dist/chunk-KX6UYWWR.js.map +1 -0
- package/dist/chunk-LWVETFJV.js +46 -0
- package/dist/chunk-LWVETFJV.js.map +1 -0
- package/dist/chunk-MCL2MCA2.js +285 -0
- package/dist/chunk-MCL2MCA2.js.map +1 -0
- package/dist/chunk-MZXCF35B.js +205 -0
- package/dist/chunk-MZXCF35B.js.map +1 -0
- package/dist/chunk-NCGPUFWV.js +96 -0
- package/dist/chunk-NCGPUFWV.js.map +1 -0
- package/dist/chunk-OEJMIE2Q.js +351 -0
- package/dist/chunk-OEJMIE2Q.js.map +1 -0
- package/dist/chunk-OYF2OAKS.js +394 -0
- package/dist/chunk-OYF2OAKS.js.map +1 -0
- package/dist/chunk-P6S43FYZ.js +316 -0
- package/dist/chunk-P6S43FYZ.js.map +1 -0
- package/dist/chunk-PL37KFRJ.js +3 -0
- package/dist/chunk-PL37KFRJ.js.map +1 -0
- package/dist/chunk-Q7BS5QC5.js +197 -0
- package/dist/chunk-Q7BS5QC5.js.map +1 -0
- package/dist/chunk-SDYPG3JD.js +288 -0
- package/dist/chunk-SDYPG3JD.js.map +1 -0
- package/dist/chunk-SUG56SZO.js +256 -0
- package/dist/chunk-SUG56SZO.js.map +1 -0
- package/dist/chunk-UVH5XJRP.js +164 -0
- package/dist/chunk-UVH5XJRP.js.map +1 -0
- package/dist/chunk-WZIJKCL3.js +282 -0
- package/dist/chunk-WZIJKCL3.js.map +1 -0
- package/dist/chunk-Y22AMGTM.js +3 -0
- package/dist/chunk-Y22AMGTM.js.map +1 -0
- package/dist/chunk-Z7G23XWU.js +200 -0
- package/dist/chunk-Z7G23XWU.js.map +1 -0
- package/dist/chunk-ZJU5M4IB.js +125 -0
- package/dist/chunk-ZJU5M4IB.js.map +1 -0
- package/dist/chunk-ZVC3ZWLM.js +52 -0
- package/dist/chunk-ZVC3ZWLM.js.map +1 -0
- package/dist/chunk-ZZZML7Y3.js +310 -0
- package/dist/chunk-ZZZML7Y3.js.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.js +16 -0
- package/dist/client.js.map +1 -0
- package/dist/config/index.d.ts +170 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/errors/index.d.ts +267 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/file-router/index.d.ts +184 -0
- package/dist/file-router/index.js +3 -0
- package/dist/file-router/index.js.map +1 -0
- package/dist/file-router/streaming-hints.d.ts +129 -0
- package/dist/file-router/streaming-hints.js +3 -0
- package/dist/file-router/streaming-hints.js.map +1 -0
- package/dist/handlers/index.d.ts +59 -0
- package/dist/handlers/index.js +3 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.d.ts +588 -0
- package/dist/index.js +886 -0
- package/dist/index.js.map +1 -0
- package/dist/islands/index.d.ts +234 -0
- package/dist/islands/index.js +3 -0
- package/dist/islands/index.js.map +1 -0
- package/dist/middleware/index.d.ts +305 -0
- package/dist/middleware/index.js +3 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/react/index.d.ts +73 -0
- package/dist/react/index.js +52 -0
- package/dist/react/index.js.map +1 -0
- package/dist/render/index.d.ts +131 -0
- package/dist/render/index.js +3 -0
- package/dist/render/index.js.map +1 -0
- package/dist/router/index.d.ts +65 -0
- package/dist/router/index.js +3 -0
- package/dist/router/index.js.map +1 -0
- package/dist/rsc/adapters/index.d.ts +8 -0
- package/dist/rsc/adapters/index.js +7 -0
- package/dist/rsc/adapters/index.js.map +1 -0
- package/dist/rsc/adapters/preact.d.ts +97 -0
- package/dist/rsc/adapters/preact.js +3 -0
- package/dist/rsc/adapters/preact.js.map +1 -0
- package/dist/rsc/adapters/react.d.ts +82 -0
- package/dist/rsc/adapters/react.js +3 -0
- package/dist/rsc/adapters/react.js.map +1 -0
- package/dist/rsc/adapters/solid.d.ts +84 -0
- package/dist/rsc/adapters/solid.js +3 -0
- package/dist/rsc/adapters/solid.js.map +1 -0
- package/dist/rsc/adapters/vue.d.ts +80 -0
- package/dist/rsc/adapters/vue.js +3 -0
- package/dist/rsc/adapters/vue.js.map +1 -0
- package/dist/rsc/boundaries.d.ts +182 -0
- package/dist/rsc/boundaries.js +3 -0
- package/dist/rsc/boundaries.js.map +1 -0
- package/dist/rsc/context.d.ts +201 -0
- package/dist/rsc/context.js +3 -0
- package/dist/rsc/context.js.map +1 -0
- package/dist/rsc/index.d.ts +232 -0
- package/dist/rsc/index.js +15 -0
- package/dist/rsc/index.js.map +1 -0
- package/dist/rsc/legacy.d.ts +155 -0
- package/dist/rsc/legacy.js +3 -0
- package/dist/rsc/legacy.js.map +1 -0
- package/dist/rsc/payload.d.ts +262 -0
- package/dist/rsc/payload.js +3 -0
- package/dist/rsc/payload.js.map +1 -0
- package/dist/rsc/plugins/esbuild.d.ts +124 -0
- package/dist/rsc/plugins/esbuild.js +4 -0
- package/dist/rsc/plugins/esbuild.js.map +1 -0
- package/dist/rsc/plugins/index.d.ts +4 -0
- package/dist/rsc/plugins/index.js +6 -0
- package/dist/rsc/plugins/index.js.map +1 -0
- package/dist/rsc/plugins/rollup.d.ts +103 -0
- package/dist/rsc/plugins/rollup.js +4 -0
- package/dist/rsc/plugins/rollup.js.map +1 -0
- package/dist/rsc/renderer.d.ts +162 -0
- package/dist/rsc/renderer.js +5 -0
- package/dist/rsc/renderer.js.map +1 -0
- package/dist/rsc/stream.d.ts +129 -0
- package/dist/rsc/stream.js +3 -0
- package/dist/rsc/stream.js.map +1 -0
- package/dist/rsc/vite-plugin.d.ts +78 -0
- package/dist/rsc/vite-plugin.js +4 -0
- package/dist/rsc/vite-plugin.js.map +1 -0
- package/dist/server/index.d.ts +135 -0
- package/dist/server/index.js +6 -0
- package/dist/server/index.js.map +1 -0
- package/dist/streaming/adapters/index.d.ts +223 -0
- package/dist/streaming/adapters/index.js +3 -0
- package/dist/streaming/adapters/index.js.map +1 -0
- package/dist/streaming/conditional.d.ts +130 -0
- package/dist/streaming/conditional.js +3 -0
- package/dist/streaming/conditional.js.map +1 -0
- package/dist/streaming/index.d.ts +177 -0
- package/dist/streaming/index.js +3 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/observability.d.ts +201 -0
- package/dist/streaming/observability.js +4 -0
- package/dist/streaming/observability.js.map +1 -0
- package/dist/streaming/priority.d.ts +103 -0
- package/dist/streaming/priority.js +3 -0
- package/dist/streaming/priority.js.map +1 -0
- package/dist/utils/index.d.ts +42 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- 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"}
|