@flight-framework/core 0.1.0 → 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 (99) 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-5GUCB2CG.js +300 -0
  7. package/dist/chunk-5GUCB2CG.js.map +1 -0
  8. package/dist/chunk-62C7LX2E.js +205 -0
  9. package/dist/chunk-62C7LX2E.js.map +1 -0
  10. package/dist/chunk-63SCEXD7.js +3 -0
  11. package/dist/chunk-63SCEXD7.js.map +1 -0
  12. package/dist/{chunk-YIOQC3DC.js → chunk-6BDCTUQY.js} +3 -3
  13. package/dist/{chunk-YIOQC3DC.js.map → chunk-6BDCTUQY.js.map} +1 -1
  14. package/dist/chunk-6CD5FIYI.js +252 -0
  15. package/dist/chunk-6CD5FIYI.js.map +1 -0
  16. package/dist/chunk-6XZQPPYC.js +285 -0
  17. package/dist/chunk-6XZQPPYC.js.map +1 -0
  18. package/dist/chunk-BJIMTO2I.js +213 -0
  19. package/dist/chunk-BJIMTO2I.js.map +1 -0
  20. package/dist/chunk-CLZSB5QD.js +258 -0
  21. package/dist/chunk-CLZSB5QD.js.map +1 -0
  22. package/dist/chunk-K2CQZPCG.js +257 -0
  23. package/dist/chunk-K2CQZPCG.js.map +1 -0
  24. package/dist/chunk-MRLCNFSD.js +341 -0
  25. package/dist/chunk-MRLCNFSD.js.map +1 -0
  26. package/dist/chunk-PSJPMEQK.js +212 -0
  27. package/dist/chunk-PSJPMEQK.js.map +1 -0
  28. package/dist/chunk-Q62ZQ6FM.js +218 -0
  29. package/dist/chunk-Q62ZQ6FM.js.map +1 -0
  30. package/dist/{chunk-6WSPUG5L.js → chunk-RSVA2EYO.js} +2 -2
  31. package/dist/chunk-RSVA2EYO.js.map +1 -0
  32. package/dist/chunk-T3S5YC7L.js +256 -0
  33. package/dist/chunk-T3S5YC7L.js.map +1 -0
  34. package/dist/{chunk-OBNYNJB5.js → chunk-WOEIJWGJ.js} +6 -8
  35. package/dist/chunk-WOEIJWGJ.js.map +1 -0
  36. package/dist/{chunk-I2B4WSHC.js → chunk-XSY5AAXT.js} +3 -4
  37. package/dist/chunk-XSY5AAXT.js.map +1 -0
  38. package/dist/chunk-Y22AMGTM.js +3 -0
  39. package/dist/chunk-Y22AMGTM.js.map +1 -0
  40. package/dist/file-router/streaming-hints.d.ts +1 -1
  41. package/dist/file-router/streaming-hints.js +1 -1
  42. package/dist/index.d.ts +3 -1
  43. package/dist/index.js +19 -7
  44. package/dist/index.js.map +1 -1
  45. package/dist/rsc/adapters/index.d.ts +8 -0
  46. package/dist/rsc/adapters/index.js +7 -0
  47. package/dist/rsc/adapters/index.js.map +1 -0
  48. package/dist/rsc/adapters/preact.d.ts +97 -0
  49. package/dist/rsc/adapters/preact.js +3 -0
  50. package/dist/rsc/adapters/preact.js.map +1 -0
  51. package/dist/rsc/adapters/react.d.ts +82 -0
  52. package/dist/rsc/adapters/react.js +3 -0
  53. package/dist/rsc/adapters/react.js.map +1 -0
  54. package/dist/rsc/adapters/solid.d.ts +84 -0
  55. package/dist/rsc/adapters/solid.js +3 -0
  56. package/dist/rsc/adapters/solid.js.map +1 -0
  57. package/dist/rsc/adapters/vue.d.ts +80 -0
  58. package/dist/rsc/adapters/vue.js +3 -0
  59. package/dist/rsc/adapters/vue.js.map +1 -0
  60. package/dist/rsc/boundaries.d.ts +182 -0
  61. package/dist/rsc/boundaries.js +3 -0
  62. package/dist/rsc/boundaries.js.map +1 -0
  63. package/dist/rsc/context.d.ts +201 -0
  64. package/dist/rsc/context.js +3 -0
  65. package/dist/rsc/context.js.map +1 -0
  66. package/dist/rsc/index.d.ts +20 -124
  67. package/dist/rsc/index.js +13 -1
  68. package/dist/rsc/legacy.d.ts +131 -0
  69. package/dist/rsc/legacy.js +3 -0
  70. package/dist/rsc/legacy.js.map +1 -0
  71. package/dist/rsc/payload.d.ts +262 -0
  72. package/dist/rsc/payload.js +3 -0
  73. package/dist/rsc/payload.js.map +1 -0
  74. package/dist/rsc/plugins/esbuild.d.ts +124 -0
  75. package/dist/rsc/plugins/esbuild.js +4 -0
  76. package/dist/rsc/plugins/esbuild.js.map +1 -0
  77. package/dist/rsc/plugins/index.d.ts +4 -0
  78. package/dist/rsc/plugins/index.js +6 -0
  79. package/dist/rsc/plugins/index.js.map +1 -0
  80. package/dist/rsc/plugins/rollup.d.ts +103 -0
  81. package/dist/rsc/plugins/rollup.js +4 -0
  82. package/dist/rsc/plugins/rollup.js.map +1 -0
  83. package/dist/rsc/renderer.d.ts +160 -0
  84. package/dist/rsc/renderer.js +5 -0
  85. package/dist/rsc/renderer.js.map +1 -0
  86. package/dist/rsc/stream.d.ts +129 -0
  87. package/dist/rsc/stream.js +3 -0
  88. package/dist/rsc/stream.js.map +1 -0
  89. package/dist/rsc/vite-plugin.d.ts +78 -0
  90. package/dist/rsc/vite-plugin.js +4 -0
  91. package/dist/rsc/vite-plugin.js.map +1 -0
  92. package/dist/streaming/index.js +1 -1
  93. package/dist/streaming/observability.js +2 -2
  94. package/dist/streaming/priority.js +1 -1
  95. package/package.json +180 -124
  96. package/dist/chunk-5KF3QQWZ.js.map +0 -1
  97. package/dist/chunk-6WSPUG5L.js.map +0 -1
  98. package/dist/chunk-I2B4WSHC.js.map +0 -1
  99. package/dist/chunk-OBNYNJB5.js.map +0 -1
@@ -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
@@ -0,0 +1,131 @@
1
+ /**
2
+ * @flight-framework/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 @flight-framework/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
+ * Wrap a server component with error handling
104
+ * @deprecated Use try/catch in async components
105
+ */
106
+ declare function withErrorBoundary<P>(component: ServerComponent<P>, errorFallback: (error: Error) => string): ServerComponent<P>;
107
+ /**
108
+ * Throw a not found error
109
+ * @deprecated Use notFound from './context.js' instead
110
+ */
111
+ declare function notFound(): never;
112
+ /**
113
+ * Check if error is not found
114
+ * @deprecated Use isNotFoundError from './context.js' instead
115
+ */
116
+ declare function isNotFoundError(error: unknown): boolean;
117
+ /**
118
+ * Server-side redirect
119
+ * @deprecated Use redirect from './context.js' instead
120
+ */
121
+ declare function redirect(url: string, type?: 'replace' | 'push'): never;
122
+ /**
123
+ * Check if error is redirect
124
+ * @deprecated Use isRedirectError from './context.js' instead
125
+ */
126
+ declare function isRedirectError(error: unknown): {
127
+ url: string;
128
+ type: string;
129
+ } | null;
130
+
131
+ export { type ClientComponent, type ComponentType, type RenderContext, type ServerComponent, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary };
@@ -0,0 +1,3 @@
1
+ export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary } from '../chunk-3AY23FZP.js';
2
+ //# sourceMappingURL=legacy.js.map
3
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"legacy.js"}
@@ -0,0 +1,262 @@
1
+ /**
2
+ * @flight-framework/core - Flight Payload System
3
+ *
4
+ * Formato de serialización agnóstico para Server Components.
5
+ * Diseñado para máxima debuggabilidad y compatibilidad multi-framework.
6
+ *
7
+ * Filosofía Flight:
8
+ * - Formato documentado y abierto (NDJSON)
9
+ * - No depende de internals de React
10
+ * - Extensible para cualquier UI framework
11
+ * - Zero vendor lock-in
12
+ *
13
+ * @module @flight-framework/core/rsc/payload
14
+ */
15
+ /**
16
+ * Union type de todos los chunks que pueden enviarse en un FlightStream
17
+ */
18
+ type FlightChunk = ServerComponentChunk | ClientReferenceChunk | ServerReferenceChunk | ErrorBoundaryChunk | HintChunk | MetaChunk;
19
+ /**
20
+ * Chunk de Server Component renderizado
21
+ * Contiene el árbol virtual de elementos
22
+ */
23
+ interface ServerComponentChunk {
24
+ /** Discriminator */
25
+ readonly type: 'S';
26
+ /** Unique chunk ID */
27
+ readonly id: string;
28
+ /** Virtual element tree */
29
+ readonly tree: FlightElement;
30
+ /** IDs de chunks que este depende (para streaming ordenado) */
31
+ readonly awaiting?: readonly string[];
32
+ /** Timestamp para debugging/observability */
33
+ readonly ts?: number;
34
+ }
35
+ /**
36
+ * Referencia a un Client Component
37
+ * El cliente cargará el módulo y lo hidratará
38
+ */
39
+ interface ClientReferenceChunk {
40
+ /** Discriminator */
41
+ readonly type: 'C';
42
+ /** Reference ID */
43
+ readonly id: string;
44
+ /** Module specifier (relativo al manifest) */
45
+ readonly module: string;
46
+ /** Export name */
47
+ readonly export: string;
48
+ /** Serialized props */
49
+ readonly props: SerializedValue;
50
+ /** Fallback HTML para SSR (opcional) */
51
+ readonly fallback?: string;
52
+ }
53
+ /**
54
+ * Referencia a una Server Function (Action)
55
+ * El cliente la invocará via RPC
56
+ */
57
+ interface ServerReferenceChunk {
58
+ /** Discriminator */
59
+ readonly type: 'A';
60
+ /** Action ID */
61
+ readonly id: string;
62
+ /** Bound arguments (pre-bound via .bind()) */
63
+ readonly bound?: readonly SerializedValue[];
64
+ }
65
+ /**
66
+ * Error en un boundary específico
67
+ */
68
+ interface ErrorBoundaryChunk {
69
+ /** Discriminator */
70
+ readonly type: 'E';
71
+ /** Boundary ID where error occurred */
72
+ readonly boundary: string;
73
+ /** Safe error message for client */
74
+ readonly message: string;
75
+ /** Error digest for server-side correlation */
76
+ readonly digest: string;
77
+ /** Component stack for development */
78
+ readonly stack?: string;
79
+ }
80
+ /**
81
+ * Hints para el cliente (preload, prefetch, etc.)
82
+ */
83
+ interface HintChunk {
84
+ /** Discriminator */
85
+ readonly type: 'H';
86
+ /** Hint type */
87
+ readonly hint: 'preload' | 'prefetch' | 'dns-prefetch' | 'preconnect' | 'modulepreload';
88
+ /** Resource URL */
89
+ readonly href: string;
90
+ /** Resource type (for preload) */
91
+ readonly as?: 'script' | 'style' | 'image' | 'font' | 'fetch';
92
+ /** Crossorigin attribute */
93
+ readonly crossorigin?: 'anonymous' | 'use-credentials';
94
+ }
95
+ /**
96
+ * Metadata chunk (para SSR head injection)
97
+ */
98
+ interface MetaChunk {
99
+ /** Discriminator */
100
+ readonly type: 'M';
101
+ /** Meta type */
102
+ readonly meta: 'title' | 'description' | 'og' | 'twitter' | 'link' | 'script';
103
+ /** Content */
104
+ readonly content: string | Record<string, string>;
105
+ }
106
+ /**
107
+ * Virtual element que puede representar cualquier UI framework
108
+ */
109
+ type FlightElement = FlightHostElement | FlightTextElement | FlightFragmentElement | FlightSuspenseElement | FlightClientElement | FlightLazyElement | FlightNullElement;
110
+ /**
111
+ * Host element (div, span, etc.)
112
+ */
113
+ interface FlightHostElement {
114
+ readonly $$type: 'host';
115
+ readonly tag: string;
116
+ readonly key?: string | number;
117
+ readonly props: Readonly<Record<string, SerializedValue>>;
118
+ readonly children: readonly FlightElement[];
119
+ }
120
+ /**
121
+ * Text node
122
+ */
123
+ interface FlightTextElement {
124
+ readonly $$type: 'text';
125
+ readonly value: string;
126
+ }
127
+ /**
128
+ * Fragment (multiple children, no wrapper)
129
+ */
130
+ interface FlightFragmentElement {
131
+ readonly $$type: 'fragment';
132
+ readonly children: readonly FlightElement[];
133
+ }
134
+ /**
135
+ * Suspense boundary
136
+ */
137
+ interface FlightSuspenseElement {
138
+ readonly $$type: 'suspense';
139
+ readonly id: string;
140
+ readonly fallback: FlightElement;
141
+ readonly children: readonly FlightElement[];
142
+ }
143
+ /**
144
+ * Client component reference
145
+ */
146
+ interface FlightClientElement {
147
+ readonly $$type: 'client';
148
+ /** Reference to ClientReferenceChunk ID */
149
+ readonly ref: string;
150
+ /** Pre-rendered fallback HTML */
151
+ readonly ssr?: string;
152
+ }
153
+ /**
154
+ * Lazy/async element (pending resolution)
155
+ */
156
+ interface FlightLazyElement {
157
+ readonly $$type: 'lazy';
158
+ readonly id: string;
159
+ readonly fallback?: FlightElement;
160
+ }
161
+ /**
162
+ * Null/empty element
163
+ */
164
+ interface FlightNullElement {
165
+ readonly $$type: 'null';
166
+ }
167
+ /**
168
+ * Valores que pueden cruzar el boundary server/client
169
+ */
170
+ type SerializedValue = string | number | boolean | null | undefined | readonly SerializedValue[] | {
171
+ readonly [key: string]: SerializedValue;
172
+ } | SerializedSpecialValue;
173
+ /**
174
+ * Tipos especiales que requieren serialización custom
175
+ */
176
+ interface SerializedSpecialValue {
177
+ readonly $$flight: SpecialValueType;
178
+ readonly value: string | readonly unknown[];
179
+ }
180
+ type SpecialValueType = 'date' | 'bigint' | 'map' | 'set' | 'undefined' | 'symbol' | 'regexp' | 'url' | 'error' | 'formdata' | 'blob' | 'arraybuffer';
181
+ /**
182
+ * Serializa un valor para transmisión a través de FlightStream
183
+ */
184
+ declare function serialize(value: unknown): SerializedValue;
185
+ /**
186
+ * Deserializa un valor recibido de FlightStream
187
+ */
188
+ declare function deserialize<T = unknown>(value: SerializedValue): T;
189
+ /**
190
+ * Create a host element
191
+ */
192
+ declare function h(tag: string, props: Record<string, unknown> | null, ...children: unknown[]): FlightHostElement;
193
+ /**
194
+ * Create a text element
195
+ */
196
+ declare function text(value: string): FlightTextElement;
197
+ /**
198
+ * Create a fragment
199
+ */
200
+ declare function fragment(...children: unknown[]): FlightFragmentElement;
201
+ /**
202
+ * Create a suspense boundary
203
+ */
204
+ declare function suspense(id: string, fallback: FlightElement, children: FlightElement[]): FlightSuspenseElement;
205
+ /**
206
+ * Create a client component reference
207
+ */
208
+ declare function clientRef(refId: string, ssrHtml?: string): FlightClientElement;
209
+ /**
210
+ * Convert any value to a FlightElement
211
+ */
212
+ declare function toFlightElement(value: unknown): FlightElement;
213
+ /**
214
+ * Type guard for FlightElement
215
+ */
216
+ declare function isFlightElement(value: unknown): value is FlightElement;
217
+ /**
218
+ * Generate unique chunk ID
219
+ */
220
+ declare function generateChunkId(prefix?: string): string;
221
+ /**
222
+ * Reset chunk ID counter (for testing)
223
+ */
224
+ declare function resetChunkIdCounter(): void;
225
+ /**
226
+ * Create a server component chunk
227
+ */
228
+ declare function createServerChunk(id: string, tree: FlightElement, awaiting?: string[]): ServerComponentChunk;
229
+ /**
230
+ * Create a client reference chunk
231
+ */
232
+ declare function createClientChunk(id: string, module: string, exportName: string, props: unknown, fallback?: string): ClientReferenceChunk;
233
+ /**
234
+ * Create a server reference (action) chunk
235
+ */
236
+ declare function createActionChunk(id: string, boundArgs?: unknown[]): ServerReferenceChunk;
237
+ /**
238
+ * Create an error chunk
239
+ */
240
+ declare function createErrorChunk(boundary: string, error: Error, includeStack?: boolean): ErrorBoundaryChunk;
241
+ /**
242
+ * Create a hint chunk
243
+ */
244
+ declare function createHintChunk(hint: HintChunk['hint'], href: string, options?: {
245
+ as?: HintChunk['as'];
246
+ crossorigin?: HintChunk['crossorigin'];
247
+ }): HintChunk;
248
+ /**
249
+ * Error thrown during serialization
250
+ */
251
+ declare class FlightSerializationError extends Error {
252
+ constructor(message: string);
253
+ }
254
+ /**
255
+ * Error thrown during payload processing
256
+ */
257
+ declare class FlightPayloadError extends Error {
258
+ readonly chunk?: FlightChunk | undefined;
259
+ constructor(message: string, chunk?: FlightChunk | undefined);
260
+ }
261
+
262
+ export { type ClientReferenceChunk, type ErrorBoundaryChunk, type FlightChunk, type FlightClientElement, type FlightElement, type FlightFragmentElement, type FlightHostElement, type FlightLazyElement, type FlightNullElement, FlightPayloadError, FlightSerializationError, type FlightSuspenseElement, type FlightTextElement, type HintChunk, type MetaChunk, type SerializedSpecialValue, type SerializedValue, type ServerComponentChunk, type ServerReferenceChunk, type SpecialValueType, clientRef, createActionChunk, createClientChunk, createErrorChunk, createHintChunk, createServerChunk, deserialize, fragment, generateChunkId, h, isFlightElement, resetChunkIdCounter, serialize, suspense, text, toFlightElement };
@@ -0,0 +1,3 @@
1
+ export { FlightPayloadError, FlightSerializationError, clientRef, createActionChunk, createClientChunk, createErrorChunk, createHintChunk, createServerChunk, deserialize, fragment, generateChunkId, h, isFlightElement, resetChunkIdCounter, serialize, suspense, text, toFlightElement } from '../chunk-K2CQZPCG.js';
2
+ //# sourceMappingURL=payload.js.map
3
+ //# sourceMappingURL=payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"payload.js"}