@flight-framework/core 0.0.3 → 0.2.0

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{chunk-5KF3QQWZ.js → chunk-3AY23FZP.js} +5 -19
  3. package/dist/chunk-3AY23FZP.js.map +1 -0
  4. package/dist/chunk-4F77J5TY.js +324 -0
  5. package/dist/chunk-4F77J5TY.js.map +1 -0
  6. package/dist/{chunk-CLMFEKYM.js → chunk-54HPVE7N.js} +67 -2
  7. package/dist/chunk-54HPVE7N.js.map +1 -0
  8. package/dist/chunk-5GUCB2CG.js +300 -0
  9. package/dist/chunk-5GUCB2CG.js.map +1 -0
  10. package/dist/chunk-62C7LX2E.js +205 -0
  11. package/dist/chunk-62C7LX2E.js.map +1 -0
  12. package/dist/chunk-63SCEXD7.js +3 -0
  13. package/dist/chunk-63SCEXD7.js.map +1 -0
  14. package/dist/chunk-6BDCTUQY.js +282 -0
  15. package/dist/chunk-6BDCTUQY.js.map +1 -0
  16. package/dist/chunk-6CD5FIYI.js +252 -0
  17. package/dist/chunk-6CD5FIYI.js.map +1 -0
  18. package/dist/chunk-6XZQPPYC.js +285 -0
  19. package/dist/chunk-6XZQPPYC.js.map +1 -0
  20. package/dist/chunk-BJIMTO2I.js +213 -0
  21. package/dist/chunk-BJIMTO2I.js.map +1 -0
  22. package/dist/chunk-CLZSB5QD.js +258 -0
  23. package/dist/chunk-CLZSB5QD.js.map +1 -0
  24. package/dist/chunk-K2CQZPCG.js +257 -0
  25. package/dist/chunk-K2CQZPCG.js.map +1 -0
  26. package/dist/chunk-MQQLYWZZ.js +288 -0
  27. package/dist/chunk-MQQLYWZZ.js.map +1 -0
  28. package/dist/chunk-MRLCNFSD.js +341 -0
  29. package/dist/chunk-MRLCNFSD.js.map +1 -0
  30. package/dist/chunk-PSJPMEQK.js +212 -0
  31. package/dist/chunk-PSJPMEQK.js.map +1 -0
  32. package/dist/chunk-Q62ZQ6FM.js +218 -0
  33. package/dist/chunk-Q62ZQ6FM.js.map +1 -0
  34. package/dist/{chunk-ABNCAPQB.js → chunk-RSVA2EYO.js} +2 -2
  35. package/dist/chunk-RSVA2EYO.js.map +1 -0
  36. package/dist/chunk-T3S5YC7L.js +256 -0
  37. package/dist/chunk-T3S5YC7L.js.map +1 -0
  38. package/dist/chunk-WFAWAHJH.js +267 -0
  39. package/dist/chunk-WFAWAHJH.js.map +1 -0
  40. package/dist/chunk-WOEIJWGJ.js +351 -0
  41. package/dist/chunk-WOEIJWGJ.js.map +1 -0
  42. package/dist/chunk-XOIYNY4I.js +164 -0
  43. package/dist/chunk-XOIYNY4I.js.map +1 -0
  44. package/dist/chunk-XSY5AAXT.js +125 -0
  45. package/dist/chunk-XSY5AAXT.js.map +1 -0
  46. package/dist/chunk-Y22AMGTM.js +3 -0
  47. package/dist/chunk-Y22AMGTM.js.map +1 -0
  48. package/dist/file-router/index.d.ts +9 -0
  49. package/dist/file-router/index.js +1 -1
  50. package/dist/file-router/streaming-hints.d.ts +129 -0
  51. package/dist/file-router/streaming-hints.js +3 -0
  52. package/dist/file-router/streaming-hints.js.map +1 -0
  53. package/dist/index.d.ts +9 -1
  54. package/dist/index.js +23 -5
  55. package/dist/index.js.map +1 -1
  56. package/dist/islands/index.d.ts +234 -0
  57. package/dist/islands/index.js +3 -0
  58. package/dist/islands/index.js.map +1 -0
  59. package/dist/rsc/adapters/index.d.ts +8 -0
  60. package/dist/rsc/adapters/index.js +7 -0
  61. package/dist/rsc/adapters/index.js.map +1 -0
  62. package/dist/rsc/adapters/preact.d.ts +97 -0
  63. package/dist/rsc/adapters/preact.js +3 -0
  64. package/dist/rsc/adapters/preact.js.map +1 -0
  65. package/dist/rsc/adapters/react.d.ts +82 -0
  66. package/dist/rsc/adapters/react.js +3 -0
  67. package/dist/rsc/adapters/react.js.map +1 -0
  68. package/dist/rsc/adapters/solid.d.ts +84 -0
  69. package/dist/rsc/adapters/solid.js +3 -0
  70. package/dist/rsc/adapters/solid.js.map +1 -0
  71. package/dist/rsc/adapters/vue.d.ts +80 -0
  72. package/dist/rsc/adapters/vue.js +3 -0
  73. package/dist/rsc/adapters/vue.js.map +1 -0
  74. package/dist/rsc/boundaries.d.ts +182 -0
  75. package/dist/rsc/boundaries.js +3 -0
  76. package/dist/rsc/boundaries.js.map +1 -0
  77. package/dist/rsc/context.d.ts +201 -0
  78. package/dist/rsc/context.js +3 -0
  79. package/dist/rsc/context.js.map +1 -0
  80. package/dist/rsc/index.d.ts +20 -124
  81. package/dist/rsc/index.js +13 -1
  82. package/dist/rsc/legacy.d.ts +131 -0
  83. package/dist/rsc/legacy.js +3 -0
  84. package/dist/rsc/legacy.js.map +1 -0
  85. package/dist/rsc/payload.d.ts +262 -0
  86. package/dist/rsc/payload.js +3 -0
  87. package/dist/rsc/payload.js.map +1 -0
  88. package/dist/rsc/plugins/esbuild.d.ts +124 -0
  89. package/dist/rsc/plugins/esbuild.js +4 -0
  90. package/dist/rsc/plugins/esbuild.js.map +1 -0
  91. package/dist/rsc/plugins/index.d.ts +4 -0
  92. package/dist/rsc/plugins/index.js +6 -0
  93. package/dist/rsc/plugins/index.js.map +1 -0
  94. package/dist/rsc/plugins/rollup.d.ts +103 -0
  95. package/dist/rsc/plugins/rollup.js +4 -0
  96. package/dist/rsc/plugins/rollup.js.map +1 -0
  97. package/dist/rsc/renderer.d.ts +160 -0
  98. package/dist/rsc/renderer.js +5 -0
  99. package/dist/rsc/renderer.js.map +1 -0
  100. package/dist/rsc/stream.d.ts +129 -0
  101. package/dist/rsc/stream.js +3 -0
  102. package/dist/rsc/stream.js.map +1 -0
  103. package/dist/rsc/vite-plugin.d.ts +78 -0
  104. package/dist/rsc/vite-plugin.js +4 -0
  105. package/dist/rsc/vite-plugin.js.map +1 -0
  106. package/dist/streaming/adapters/index.d.ts +223 -0
  107. package/dist/streaming/adapters/index.js +3 -0
  108. package/dist/streaming/adapters/index.js.map +1 -0
  109. package/dist/streaming/conditional.d.ts +130 -0
  110. package/dist/streaming/conditional.js +3 -0
  111. package/dist/streaming/conditional.js.map +1 -0
  112. package/dist/streaming/index.d.ts +8 -0
  113. package/dist/streaming/index.js +1 -1
  114. package/dist/streaming/observability.d.ts +201 -0
  115. package/dist/streaming/observability.js +4 -0
  116. package/dist/streaming/observability.js.map +1 -0
  117. package/dist/streaming/priority.d.ts +103 -0
  118. package/dist/streaming/priority.js +3 -0
  119. package/dist/streaming/priority.js.map +1 -0
  120. package/package.json +180 -100
  121. package/dist/chunk-5KF3QQWZ.js.map +0 -1
  122. package/dist/chunk-ABNCAPQB.js.map +0 -1
  123. package/dist/chunk-CLMFEKYM.js.map +0 -1
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @flight-framework/core - Component Boundary Detection
3
+ *
4
+ * Sistema de detección de boundaries client/server para Server Components.
5
+ * Soporta directivas 'use client' y 'use server' tanto a nivel de archivo
6
+ * como inline en funciones.
7
+ *
8
+ * Filosofía Flight:
9
+ * - Detección en build-time (no runtime overhead)
10
+ * - Soporte para directivas estándar de React
11
+ * - Extensible para otros frameworks
12
+ * - Zero dependencies
13
+ *
14
+ * @module @flight-framework/core/rsc/boundaries
15
+ */
16
+ /**
17
+ * Tipo de boundary de componente
18
+ */
19
+ type BoundaryType = 'server' | 'client' | 'shared';
20
+ /**
21
+ * Información de un boundary detectado
22
+ */
23
+ interface ComponentBoundary {
24
+ /** Tipo de boundary */
25
+ type: BoundaryType;
26
+ /** ID del módulo (path relativo o absoluto) */
27
+ moduleId: string;
28
+ /** Nombre del export */
29
+ exportName: string;
30
+ /** Línea donde se detectó la directiva */
31
+ line?: number;
32
+ /** Es una directiva inline (dentro de función) */
33
+ inline?: boolean;
34
+ /** Metadata adicional */
35
+ meta?: Record<string, unknown>;
36
+ }
37
+ /**
38
+ * Resultado del análisis de un módulo
39
+ */
40
+ interface ModuleAnalysis {
41
+ /** Path del módulo */
42
+ moduleId: string;
43
+ /** Directiva a nivel de archivo ('use client' o 'use server') */
44
+ fileDirective?: 'client' | 'server';
45
+ /** Boundaries detectados */
46
+ boundaries: ComponentBoundary[];
47
+ /** Exports que son Server Actions */
48
+ serverActions: string[];
49
+ /** Exports que son Client Components */
50
+ clientComponents: string[];
51
+ /** El módulo tiene componentes async */
52
+ hasAsyncComponents: boolean;
53
+ }
54
+ /**
55
+ * Referencia a un Client Component
56
+ */
57
+ interface ClientReference<T = unknown> {
58
+ $$typeof: symbol;
59
+ $$id: string;
60
+ $$async: boolean;
61
+ __flight_client: true;
62
+ __flight_module: string;
63
+ __flight_export: string;
64
+ (props: T extends (props: infer P) => unknown ? P : unknown): unknown;
65
+ }
66
+ /**
67
+ * Referencia a una Server Function (Action)
68
+ */
69
+ interface ServerReference<T extends (...args: unknown[]) => unknown = (...args: unknown[]) => unknown> {
70
+ $$typeof: symbol;
71
+ $$id: string;
72
+ $$bound: unknown[] | null;
73
+ __flight_server: true;
74
+ __flight_action: string;
75
+ (...args: Parameters<T>): Promise<ReturnType<T>>;
76
+ }
77
+ declare const CLIENT_REFERENCE: unique symbol;
78
+ declare const SERVER_REFERENCE: unique symbol;
79
+ /**
80
+ * Detecta si un archivo tiene la directiva 'use client'
81
+ */
82
+ declare function hasUseClientDirective(source: string): boolean;
83
+ /**
84
+ * Detecta si un archivo tiene la directiva 'use server' a nivel de archivo
85
+ */
86
+ declare function hasUseServerDirective(source: string): boolean;
87
+ /**
88
+ * Detecta el tipo de componente basado en directivas
89
+ */
90
+ declare function detectBoundaryType(source: string): BoundaryType;
91
+ /**
92
+ * Detecta Server Actions inline en el código
93
+ * Busca funciones que contienen 'use server' dentro de su cuerpo
94
+ */
95
+ declare function detectInlineServerActions(source: string): string[];
96
+ /**
97
+ * Detecta componentes async (Server Components potenciales)
98
+ */
99
+ declare function detectAsyncComponents(source: string): string[];
100
+ /**
101
+ * Análisis completo de un módulo
102
+ */
103
+ declare function analyzeModule(source: string, moduleId: string): ModuleAnalysis;
104
+ /**
105
+ * Crea una referencia a un Client Component
106
+ * Para uso en build-time (transformación de código)
107
+ */
108
+ declare function createClientReference<T>(moduleId: string, exportName: string, isAsync?: boolean): ClientReference<T>;
109
+ /**
110
+ * Crea una referencia a una Server Function (Action)
111
+ * Para uso en build-time (transformación de código)
112
+ */
113
+ declare function createServerReference<T extends (...args: unknown[]) => unknown>(actionId: string, boundArgs?: unknown[]): ServerReference<T>;
114
+ /**
115
+ * Verifica si un valor es una Client Reference
116
+ */
117
+ declare function isClientReference(value: unknown): value is ClientReference;
118
+ /**
119
+ * Verifica si un valor es una Server Reference
120
+ */
121
+ declare function isServerReference(value: unknown): value is ServerReference;
122
+ /**
123
+ * Obtiene el ID de una referencia
124
+ */
125
+ declare function getReferenceId(ref: ClientReference | ServerReference): string;
126
+ /**
127
+ * Registry de boundaries para uso en runtime
128
+ */
129
+ declare class BoundaryRegistry {
130
+ private clientModules;
131
+ private serverActions;
132
+ /**
133
+ * Registra un Client Component
134
+ */
135
+ registerClient(id: string, loader: () => Promise<unknown>): void;
136
+ /**
137
+ * Registra una Server Action
138
+ */
139
+ registerServer(id: string, action: (...args: unknown[]) => Promise<unknown>): void;
140
+ /**
141
+ * Obtiene un Client Component loader
142
+ */
143
+ getClient(id: string): (() => Promise<unknown>) | undefined;
144
+ /**
145
+ * Obtiene una Server Action
146
+ */
147
+ getServer(id: string): ((...args: unknown[]) => Promise<unknown>) | undefined;
148
+ /**
149
+ * Verifica si un client module está registrado
150
+ */
151
+ hasClient(id: string): boolean;
152
+ /**
153
+ * Verifica si una server action está registrada
154
+ */
155
+ hasServer(id: string): boolean;
156
+ /**
157
+ * Obtiene todos los IDs de client modules
158
+ */
159
+ getClientIds(): string[];
160
+ /**
161
+ * Obtiene todos los IDs de server actions
162
+ */
163
+ getServerIds(): string[];
164
+ /**
165
+ * Limpia el registry
166
+ */
167
+ clear(): void;
168
+ }
169
+ /**
170
+ * Registry global (singleton)
171
+ */
172
+ declare const globalRegistry: BoundaryRegistry;
173
+ /**
174
+ * Registra un Client Component en el registry global
175
+ */
176
+ declare function registerClientComponent(id: string, loader: () => Promise<unknown>): void;
177
+ /**
178
+ * Registra una Server Action en el registry global
179
+ */
180
+ declare function registerServerAction(id: string, action: (...args: unknown[]) => Promise<unknown>): void;
181
+
182
+ export { BoundaryRegistry, type BoundaryType, CLIENT_REFERENCE, type ClientReference, type ComponentBoundary, type ModuleAnalysis, SERVER_REFERENCE, type ServerReference, analyzeModule, createClientReference, createServerReference, detectAsyncComponents, detectBoundaryType, detectInlineServerActions, getReferenceId, globalRegistry, hasUseClientDirective, hasUseServerDirective, isClientReference, isServerReference, registerClientComponent, registerServerAction };
@@ -0,0 +1,3 @@
1
+ export { BoundaryRegistry, CLIENT_REFERENCE, SERVER_REFERENCE, analyzeModule, createClientReference, createServerReference, detectAsyncComponents, detectBoundaryType, detectInlineServerActions, getReferenceId, globalRegistry, hasUseClientDirective, hasUseServerDirective, isClientReference, isServerReference, registerClientComponent, registerServerAction } from '../chunk-CLZSB5QD.js';
2
+ //# sourceMappingURL=boundaries.js.map
3
+ //# sourceMappingURL=boundaries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"boundaries.js"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @flight-framework/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 @flight-framework/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-62C7LX2E.js';
2
+ //# sourceMappingURL=context.js.map
3
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"context.js"}
@@ -1,131 +1,27 @@
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 { 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, withErrorBoundary } from './legacy.js';
11
+ import 'react';
12
+ import 'vite';
13
+
1
14
  /**
2
- * @flight-framework/core - React Server Components Support
3
- *
4
- * Framework-agnostic primitives for RSC-like patterns.
5
- * Enables async server components, client/server boundaries, and data fetching.
6
- *
7
- * Best Practices 2025/2026:
8
- * - Async components for server-side data fetching
9
- * - 'use client' / 'use server' directive detection
10
- * - Automatic component serialization
11
- * - Props passing between server and client
12
- */
13
- /**
14
- * Component rendering context
15
- */
16
- interface RenderContext {
17
- /** Current request */
18
- request: Request;
19
- /** Route params */
20
- params: Record<string, string>;
21
- /** Search params */
22
- searchParams: URLSearchParams;
23
- /** Request headers */
24
- headers: Headers;
25
- /** Cookies */
26
- cookies: Map<string, string>;
27
- }
28
- /**
29
- * Server component definition
30
- */
31
- interface ServerComponent<P = unknown> {
32
- (props: P, context: RenderContext): Promise<string> | string;
33
- /** Mark as server component */
34
- __flight_server?: true;
35
- /** Dependencies for hydration */
36
- __flight_deps?: string[];
37
- }
38
- /**
39
- * Client component definition
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
- * Check if a file has 'use client' directive
54
- */
55
- declare function hasUseClientDirective(source: string): boolean;
56
- /**
57
- * Check if a file has 'use server' directive
58
- */
59
- declare function hasUseServerDirective(source: string): boolean;
60
- /**
61
- * Detect component type from source
62
- */
63
- declare function detectComponentType(source: string): ComponentType;
64
- /**
65
- * Execute an async server component
66
- */
67
- declare function executeServerComponent<P>(component: ServerComponent<P>, props: P, context: RenderContext): Promise<string>;
68
- /**
69
- * Create a render context from a Request
70
- */
71
- declare function createRenderContext(request: Request, params?: Record<string, string>): RenderContext;
72
- /**
73
- * Server-side fetch with automatic caching (like Next.js fetch extensions)
74
- */
75
- declare function serverFetch<T>(url: string, options?: RequestInit & {
76
- revalidate?: number | false;
77
- tags?: string[];
78
- }): Promise<T>;
79
- /**
80
- * Invalidate cache by tag
81
- */
82
- declare function revalidateTag(tag: string): void;
83
- /**
84
- * Invalidate cache by path
85
- */
86
- declare function revalidatePath(path: string): void;
87
- /**
88
- * Serialize props for transmission to client
89
- */
90
- declare function serializeProps(props: unknown): string;
91
- /**
92
- * Deserialize props on client
93
- */
94
- declare function deserializeProps<T>(serialized: string): T;
95
- /**
96
- * Create a client boundary placeholder
97
- */
98
- declare function createClientBoundary(componentId: string, props: unknown, fallback?: string): string;
99
- /**
100
- * Helper to create an async server component
101
- */
102
- declare function createAsyncComponent<P, T>(fetcher: (props: P, context: RenderContext) => Promise<T>, renderer: (data: T, props: P) => string): ServerComponent<P>;
103
- /**
104
- * Compose multiple server components
105
- */
106
- declare function composeComponents(...components: Array<() => Promise<string> | string>): () => Promise<string>;
107
- /**
108
- * Wrap a server component with error handling
109
- */
110
- declare function withErrorBoundary<P>(component: ServerComponent<P>, errorFallback: (error: Error) => string): ServerComponent<P>;
111
- /**
112
- * Throw a not found error (like Next.js notFound())
113
- */
114
- declare function notFound(): never;
115
- /**
116
- * Check if error is not found
15
+ * Server Component function type
117
16
  */
118
- declare function isNotFoundError(error: unknown): boolean;
17
+ type ServerComponentFn<P = unknown, R = FlightElement> = (props: P, ctx: ServerContext) => R | Promise<R>;
119
18
  /**
120
- * Server-side redirect (like Next.js redirect())
19
+ * Server Action function type
121
20
  */
122
- declare function redirect(url: string, type?: 'replace' | 'push'): never;
21
+ type ServerActionFn<Args extends unknown[] = unknown[], R = unknown> = (...args: Args) => Promise<R>;
123
22
  /**
124
- * Check if error is redirect
23
+ * Props for a component
125
24
  */
126
- declare function isRedirectError(error: unknown): {
127
- url: string;
128
- type: string;
129
- } | null;
25
+ type ComponentProps<T> = T extends (props: infer P, ...args: unknown[]) => unknown ? P : never;
130
26
 
131
- export { type ClientComponent, type ComponentType, type RenderContext, type ServerComponent, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary };
27
+ export { type ComponentProps, FlightElement, type ServerActionFn, type ServerComponentFn, ServerContext };
package/dist/rsc/index.js CHANGED
@@ -1,3 +1,15 @@
1
- export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary } from '../chunk-5KF3QQWZ.js';
1
+ import '../chunk-63SCEXD7.js';
2
+ export { FlightStreamError, consumeFlightStream, createFlightResponse, createFlightStream, createFlightStreamFromArray, createHybridResponse, createStreamController, mergeFlightStreams, parseFlightStream, parseFlightStreamSync, prettyPrintChunks, transformFlightStream } from '../chunk-T3S5YC7L.js';
3
+ export { FlightRenderer, createRenderer, renderServerComponent, renderServerComponentStreaming } from '../chunk-4F77J5TY.js';
4
+ export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError as legacyIsNotFoundError, isRedirectError as legacyIsRedirectError, notFound as legacyNotFound, redirect as legacyRedirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary } from '../chunk-3AY23FZP.js';
5
+ export { flightRSC } from '../chunk-MRLCNFSD.js';
6
+ import '../chunk-Y22AMGTM.js';
7
+ import '../chunk-Q62ZQ6FM.js';
8
+ export { createReactAdapter, createReactConsumer, markAsClientComponent } from '../chunk-PSJPMEQK.js';
9
+ import '../chunk-BJIMTO2I.js';
10
+ import '../chunk-6CD5FIYI.js';
11
+ export { FlightPayloadError, FlightSerializationError, clientRef, createActionChunk, createClientChunk, createErrorChunk, createHintChunk, createServerChunk, deserialize, fragment, generateChunkId, h, isFlightElement, resetChunkIdCounter, serialize, suspense, text, toFlightElement } from '../chunk-K2CQZPCG.js';
12
+ export { BoundaryRegistry, CLIENT_REFERENCE, SERVER_REFERENCE, analyzeModule, createClientReference, createServerReference, detectAsyncComponents, detectBoundaryType, detectInlineServerActions, getReferenceId, globalRegistry, hasUseClientDirective, hasUseServerDirective, isClientReference, isServerReference, registerClientComponent, registerServerAction } from '../chunk-CLZSB5QD.js';
13
+ export { acceptsJson, createServerContext, deleteCookie, getHeader, getHeaders, getPreferredLanguage, getRedirectInfo, isAjaxRequest, isBotRequest, isMutationRequest, isNotFoundError, isRedirectError, notFound, redirect, setCacheControl, setCookie, supportsStreaming } from '../chunk-62C7LX2E.js';
2
14
  //# sourceMappingURL=index.js.map
3
15
  //# sourceMappingURL=index.js.map