@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,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flightdev/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 @flightdev/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-7CNW24MQ.js';
|
|
2
|
+
//# sourceMappingURL=payload.js.map
|
|
3
|
+
//# sourceMappingURL=payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"payload.js"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flightdev/core - esbuild Plugin for RSC
|
|
3
|
+
*
|
|
4
|
+
* esbuild plugin for Flight Server Components.
|
|
5
|
+
* Transforms 'use client' and 'use server' directives at build time.
|
|
6
|
+
*
|
|
7
|
+
* Philosophy: Zero lock-in - esbuild is optional, user decides bundler.
|
|
8
|
+
*
|
|
9
|
+
* @module @flightdev/core/rsc/plugins/esbuild
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* esbuild Plugin interface (minimal)
|
|
13
|
+
* We define our own to avoid requiring esbuild as dependency
|
|
14
|
+
*/
|
|
15
|
+
interface EsbuildPlugin {
|
|
16
|
+
name: string;
|
|
17
|
+
setup: (build: EsbuildBuild) => void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
interface EsbuildBuild {
|
|
20
|
+
initialOptions: EsbuildBuildOptions;
|
|
21
|
+
onStart: (callback: () => void | Promise<void>) => void;
|
|
22
|
+
onEnd: (callback: (result: EsbuildResult) => void | Promise<void>) => void;
|
|
23
|
+
onResolve: (options: {
|
|
24
|
+
filter: RegExp;
|
|
25
|
+
namespace?: string;
|
|
26
|
+
}, callback: (args: EsbuildResolveArgs) => EsbuildResolveResult | null | undefined | Promise<EsbuildResolveResult | null | undefined>) => void;
|
|
27
|
+
onLoad: (options: {
|
|
28
|
+
filter: RegExp;
|
|
29
|
+
namespace?: string;
|
|
30
|
+
}, callback: (args: EsbuildLoadArgs) => EsbuildLoadResult | null | undefined | Promise<EsbuildLoadResult | null | undefined>) => void;
|
|
31
|
+
}
|
|
32
|
+
interface EsbuildBuildOptions {
|
|
33
|
+
outdir?: string;
|
|
34
|
+
write?: boolean;
|
|
35
|
+
metafile?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface EsbuildResult {
|
|
38
|
+
errors: unknown[];
|
|
39
|
+
warnings: unknown[];
|
|
40
|
+
metafile?: unknown;
|
|
41
|
+
}
|
|
42
|
+
interface EsbuildResolveArgs {
|
|
43
|
+
path: string;
|
|
44
|
+
importer: string;
|
|
45
|
+
namespace: string;
|
|
46
|
+
resolveDir: string;
|
|
47
|
+
kind: string;
|
|
48
|
+
}
|
|
49
|
+
interface EsbuildResolveResult {
|
|
50
|
+
path?: string;
|
|
51
|
+
external?: boolean;
|
|
52
|
+
namespace?: string;
|
|
53
|
+
suffix?: string;
|
|
54
|
+
pluginData?: unknown;
|
|
55
|
+
errors?: unknown[];
|
|
56
|
+
warnings?: unknown[];
|
|
57
|
+
watchFiles?: string[];
|
|
58
|
+
watchDirs?: string[];
|
|
59
|
+
}
|
|
60
|
+
interface EsbuildLoadArgs {
|
|
61
|
+
path: string;
|
|
62
|
+
namespace: string;
|
|
63
|
+
suffix: string;
|
|
64
|
+
pluginData: unknown;
|
|
65
|
+
}
|
|
66
|
+
interface EsbuildLoadResult {
|
|
67
|
+
contents?: string;
|
|
68
|
+
loader?: 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'css';
|
|
69
|
+
resolveDir?: string;
|
|
70
|
+
errors?: unknown[];
|
|
71
|
+
warnings?: unknown[];
|
|
72
|
+
watchFiles?: string[];
|
|
73
|
+
watchDirs?: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Plugin configuration
|
|
77
|
+
*/
|
|
78
|
+
interface FlightEsbuildPluginOptions {
|
|
79
|
+
/** Include patterns (regex) */
|
|
80
|
+
include?: RegExp;
|
|
81
|
+
/** Exclude patterns (regex) */
|
|
82
|
+
exclude?: RegExp;
|
|
83
|
+
/** Server actions endpoint */
|
|
84
|
+
actionsEndpoint?: string;
|
|
85
|
+
/** Output directory for manifests */
|
|
86
|
+
manifestDir?: string;
|
|
87
|
+
/** Is this for SSR build? */
|
|
88
|
+
ssr?: boolean;
|
|
89
|
+
/** Dev mode (include extra debug info) */
|
|
90
|
+
dev?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Manifest entry
|
|
94
|
+
*/
|
|
95
|
+
interface ManifestEntry {
|
|
96
|
+
id: string;
|
|
97
|
+
file: string;
|
|
98
|
+
exports: string[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Flight RSC esbuild Plugin
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // build.js
|
|
106
|
+
* import * as esbuild from 'esbuild';
|
|
107
|
+
* import { flightRSCEsbuild } from '@flightdev/core/rsc/plugins/esbuild';
|
|
108
|
+
*
|
|
109
|
+
* await esbuild.build({
|
|
110
|
+
* entryPoints: ['src/index.tsx'],
|
|
111
|
+
* bundle: true,
|
|
112
|
+
* outdir: 'dist',
|
|
113
|
+
* plugins: [
|
|
114
|
+
* flightRSCEsbuild({
|
|
115
|
+
* actionsEndpoint: '/_flight/action',
|
|
116
|
+
* ssr: true,
|
|
117
|
+
* }),
|
|
118
|
+
* ],
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare function flightRSCEsbuild(options?: FlightEsbuildPluginOptions): EsbuildPlugin;
|
|
123
|
+
|
|
124
|
+
export { type EsbuildBuild, type EsbuildBuildOptions, type EsbuildLoadArgs, type EsbuildLoadResult, type EsbuildPlugin, type EsbuildResolveArgs, type EsbuildResolveResult, type EsbuildResult, type FlightEsbuildPluginOptions, type ManifestEntry, flightRSCEsbuild as default, flightRSCEsbuild };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"esbuild.js"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ClientManifestEntry, FlightRSCPluginOptions as FlightVitePluginOptions, ServerManifestEntry, default as flightRSCVite } from '../vite-plugin.js';
|
|
2
|
+
export { EsbuildBuild, EsbuildLoadArgs, EsbuildLoadResult, EsbuildPlugin, EsbuildResolveArgs, EsbuildResolveResult, FlightEsbuildPluginOptions, ManifestEntry, default as flightRSCEsbuild } from './esbuild.js';
|
|
3
|
+
export { FlightRollupPluginOptions, RollupPlugin, RollupPluginContext, default as flightRSCRollup } from './rollup.js';
|
|
4
|
+
import 'vite';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { flightRSCEsbuild } from '../../chunk-MCL2MCA2.js';
|
|
2
|
+
export { flightRSCRollup } from '../../chunk-7WIEAUJT.js';
|
|
3
|
+
export { flightRSC as flightRSCVite } from '../../chunk-63LWTEDQ.js';
|
|
4
|
+
import '../../chunk-AP5NLUSB.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flightdev/core - Rollup Plugin for RSC
|
|
3
|
+
*
|
|
4
|
+
* Rollup plugin for Flight Server Components.
|
|
5
|
+
* Transforms 'use client' and 'use server' directives at build time.
|
|
6
|
+
*
|
|
7
|
+
* Philosophy: Zero lock-in - Rollup is optional, user decides bundler.
|
|
8
|
+
*
|
|
9
|
+
* @module @flightdev/core/rsc/plugins/rollup
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Rollup Plugin interface (minimal)
|
|
13
|
+
* We define our own to avoid requiring rollup as dependency
|
|
14
|
+
*/
|
|
15
|
+
interface RollupPlugin {
|
|
16
|
+
name: string;
|
|
17
|
+
buildStart?: (options: unknown) => void | Promise<void>;
|
|
18
|
+
resolveId?: (source: string, importer: string | undefined, options: {
|
|
19
|
+
isEntry: boolean;
|
|
20
|
+
}) => string | null | undefined | {
|
|
21
|
+
id: string;
|
|
22
|
+
external?: boolean;
|
|
23
|
+
} | Promise<string | null | undefined | {
|
|
24
|
+
id: string;
|
|
25
|
+
external?: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
load?: (id: string) => string | null | undefined | {
|
|
28
|
+
code: string;
|
|
29
|
+
map?: unknown;
|
|
30
|
+
} | Promise<string | null | undefined | {
|
|
31
|
+
code: string;
|
|
32
|
+
map?: unknown;
|
|
33
|
+
}>;
|
|
34
|
+
transform?: (code: string, id: string) => string | null | undefined | {
|
|
35
|
+
code: string;
|
|
36
|
+
map?: unknown;
|
|
37
|
+
} | Promise<string | null | undefined | {
|
|
38
|
+
code: string;
|
|
39
|
+
map?: unknown;
|
|
40
|
+
}>;
|
|
41
|
+
generateBundle?: (options: unknown, bundle: Record<string, unknown>) => void | Promise<void>;
|
|
42
|
+
buildEnd?: (error?: Error) => void | Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
interface RollupPluginContext {
|
|
45
|
+
emitFile: (file: {
|
|
46
|
+
type: 'asset' | 'chunk';
|
|
47
|
+
fileName?: string;
|
|
48
|
+
source?: string;
|
|
49
|
+
id?: string;
|
|
50
|
+
}) => string;
|
|
51
|
+
warn: (message: string) => void;
|
|
52
|
+
error: (message: string) => never;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Plugin configuration
|
|
56
|
+
*/
|
|
57
|
+
interface FlightRollupPluginOptions {
|
|
58
|
+
/** Include patterns (regex or function) */
|
|
59
|
+
include?: RegExp | ((id: string) => boolean);
|
|
60
|
+
/** Exclude patterns (regex or function) */
|
|
61
|
+
exclude?: RegExp | ((id: string) => boolean);
|
|
62
|
+
/** Server actions endpoint */
|
|
63
|
+
actionsEndpoint?: string;
|
|
64
|
+
/** Client manifest filename */
|
|
65
|
+
clientManifest?: string;
|
|
66
|
+
/** Server manifest filename */
|
|
67
|
+
serverManifest?: string;
|
|
68
|
+
/** Is this for SSR build? */
|
|
69
|
+
ssr?: boolean;
|
|
70
|
+
/** Dev mode */
|
|
71
|
+
dev?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Manifest entry
|
|
75
|
+
*/
|
|
76
|
+
interface ManifestEntry {
|
|
77
|
+
id: string;
|
|
78
|
+
file: string;
|
|
79
|
+
exports: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Flight RSC Rollup Plugin
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // rollup.config.js
|
|
87
|
+
* import { flightRSCRollup } from '@flightdev/core/rsc/plugins/rollup';
|
|
88
|
+
*
|
|
89
|
+
* export default {
|
|
90
|
+
* input: 'src/index.tsx',
|
|
91
|
+
* output: { dir: 'dist', format: 'esm' },
|
|
92
|
+
* plugins: [
|
|
93
|
+
* flightRSCRollup({
|
|
94
|
+
* ssr: true,
|
|
95
|
+
* actionsEndpoint: '/_flight/action',
|
|
96
|
+
* }),
|
|
97
|
+
* ],
|
|
98
|
+
* };
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function flightRSCRollup(options?: FlightRollupPluginOptions): RollupPlugin;
|
|
102
|
+
|
|
103
|
+
export { type FlightRollupPluginOptions, type ManifestEntry, type RollupPlugin, type RollupPluginContext, flightRSCRollup as default, flightRSCRollup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"rollup.js"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { FlightChunk, ServerComponentChunk, ClientReferenceChunk } from './payload.js';
|
|
2
|
+
import { ServerContext } from './context.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @flightdev/core - Server Component Renderer
|
|
6
|
+
*
|
|
7
|
+
* Renders Server Components to FlightChunks.
|
|
8
|
+
* Framework-agnostic rendering engine that works with adapters.
|
|
9
|
+
*
|
|
10
|
+
* @module @flightdev/core/rsc/renderer
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* UI Framework adapter for rendering
|
|
15
|
+
*/
|
|
16
|
+
interface UIAdapter {
|
|
17
|
+
/** Adapter name */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Check if value is a framework element */
|
|
20
|
+
isElement(value: unknown): boolean;
|
|
21
|
+
/** Get element type info */
|
|
22
|
+
getElementType(element: unknown): ElementTypeInfo;
|
|
23
|
+
/** Get element props */
|
|
24
|
+
getProps(element: unknown): Record<string, unknown>;
|
|
25
|
+
/** Get element children */
|
|
26
|
+
getChildren(element: unknown): unknown[];
|
|
27
|
+
/** Get element key */
|
|
28
|
+
getKey(element: unknown): string | number | undefined;
|
|
29
|
+
/** Check if component is a client boundary */
|
|
30
|
+
isClientBoundary(component: unknown): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Create a framework-specific element
|
|
33
|
+
* This abstracts away React's Symbol.for('react.element'), Vue's VNode, etc.
|
|
34
|
+
*/
|
|
35
|
+
createElement(component: ComponentFn, props: Record<string, unknown>): unknown;
|
|
36
|
+
/** Render element to HTML string (for SSR fallback) */
|
|
37
|
+
renderToString?(element: unknown): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
type ElementTypeInfo = {
|
|
40
|
+
kind: 'host';
|
|
41
|
+
tag: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'component';
|
|
44
|
+
fn: ComponentFn;
|
|
45
|
+
name: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'fragment';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'suspense';
|
|
50
|
+
fallback?: unknown;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'provider';
|
|
53
|
+
value?: unknown;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'context';
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'text';
|
|
58
|
+
value: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'null';
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Component function type
|
|
64
|
+
*/
|
|
65
|
+
type ComponentFn = (props: Record<string, unknown>, ctx?: ServerContext) => unknown | Promise<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Render options
|
|
68
|
+
*/
|
|
69
|
+
interface RenderOptions {
|
|
70
|
+
/** Include SSR fallbacks for client components */
|
|
71
|
+
includeSSRFallbacks?: boolean;
|
|
72
|
+
/** Error handler */
|
|
73
|
+
onError?: (error: Error, componentName?: string) => void;
|
|
74
|
+
/** Dev mode (include extra debug info) */
|
|
75
|
+
dev?: boolean;
|
|
76
|
+
/** Max render depth to prevent infinite loops */
|
|
77
|
+
maxDepth?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Render result with metadata
|
|
81
|
+
*/
|
|
82
|
+
interface RenderResult {
|
|
83
|
+
/** All chunks generated */
|
|
84
|
+
chunks: FlightChunk[];
|
|
85
|
+
/** Root chunk */
|
|
86
|
+
root: ServerComponentChunk;
|
|
87
|
+
/** Client references found */
|
|
88
|
+
clientRefs: ClientReferenceChunk[];
|
|
89
|
+
/** Timing info */
|
|
90
|
+
timing: {
|
|
91
|
+
startTime: number;
|
|
92
|
+
endTime: number;
|
|
93
|
+
duration: number;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Flight Server Component Renderer
|
|
98
|
+
*/
|
|
99
|
+
declare class FlightRenderer {
|
|
100
|
+
private adapter;
|
|
101
|
+
private options;
|
|
102
|
+
private chunks;
|
|
103
|
+
private clientRefs;
|
|
104
|
+
private pendingPromises;
|
|
105
|
+
private depth;
|
|
106
|
+
constructor(adapter: UIAdapter, options?: RenderOptions);
|
|
107
|
+
/**
|
|
108
|
+
* Render a component tree to Flight chunks
|
|
109
|
+
*/
|
|
110
|
+
render(element: unknown, ctx: ServerContext): Promise<RenderResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Render as async generator (for streaming)
|
|
113
|
+
*/
|
|
114
|
+
renderStreaming(element: unknown, ctx: ServerContext): AsyncGenerator<FlightChunk>;
|
|
115
|
+
/**
|
|
116
|
+
* Render an element to FlightElement
|
|
117
|
+
*/
|
|
118
|
+
private renderElement;
|
|
119
|
+
/**
|
|
120
|
+
* Render a framework-specific element
|
|
121
|
+
*/
|
|
122
|
+
private renderFrameworkElement;
|
|
123
|
+
/**
|
|
124
|
+
* Render a host element (div, span, etc.)
|
|
125
|
+
*/
|
|
126
|
+
private renderHostElement;
|
|
127
|
+
/**
|
|
128
|
+
* Render a component (server or client)
|
|
129
|
+
*/
|
|
130
|
+
private renderComponent;
|
|
131
|
+
/**
|
|
132
|
+
* Render a client boundary
|
|
133
|
+
*/
|
|
134
|
+
private renderClientBoundary;
|
|
135
|
+
/**
|
|
136
|
+
* Render a Suspense boundary
|
|
137
|
+
*/
|
|
138
|
+
private renderSuspense;
|
|
139
|
+
/**
|
|
140
|
+
* Render an async boundary (promise thrown from component)
|
|
141
|
+
*/
|
|
142
|
+
private renderAsyncBoundary;
|
|
143
|
+
/**
|
|
144
|
+
* Render a Client Reference directly
|
|
145
|
+
*/
|
|
146
|
+
private renderClientReference;
|
|
147
|
+
/**
|
|
148
|
+
* Resolve all pending async chunks
|
|
149
|
+
*/
|
|
150
|
+
private resolvePendingChunks;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create a renderer with adapter
|
|
154
|
+
*/
|
|
155
|
+
declare function createRenderer(adapter: UIAdapter, options?: RenderOptions): FlightRenderer;
|
|
156
|
+
/**
|
|
157
|
+
* Render a server component tree
|
|
158
|
+
*/
|
|
159
|
+
declare function renderServerComponent<P>(component: ComponentFn, props: P, ctx: ServerContext, adapter: UIAdapter, options?: RenderOptions): Promise<RenderResult>;
|
|
160
|
+
declare function renderServerComponentStreaming<P>(component: ComponentFn, props: P, ctx: ServerContext, adapter: UIAdapter, options?: RenderOptions): AsyncGenerator<FlightChunk>;
|
|
161
|
+
|
|
162
|
+
export { type ComponentFn, type ElementTypeInfo, FlightRenderer, type RenderOptions, type RenderResult, type UIAdapter, createRenderer, renderServerComponent, renderServerComponentStreaming };
|