@flight-framework/core 0.2.6 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +346 -347
- package/dist/actions/index.js +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/{chunk-FSJNOPYE.js → chunk-2JVEH76V.js} +3 -3
- package/dist/chunk-2JVEH76V.js.map +1 -0
- package/dist/{chunk-3ZSSRE6M.js → chunk-2R23X5Z3.js} +2 -2
- package/dist/chunk-2R23X5Z3.js.map +1 -0
- package/dist/{chunk-VPFMHGEV.js → chunk-3N5ZBVZJ.js} +2 -2
- package/dist/chunk-3N5ZBVZJ.js.map +1 -0
- package/dist/{chunk-2F2QU6RC.js → chunk-3UQJE3XZ.js} +2 -2
- package/dist/chunk-3UQJE3XZ.js.map +1 -0
- package/dist/{chunk-PDW5WCMW.js → chunk-5XHOLZBJ.js} +2 -2
- package/dist/chunk-5XHOLZBJ.js.map +1 -0
- package/dist/{chunk-MDQNNIHH.js → chunk-65JYF3DJ.js} +2 -2
- package/dist/chunk-65JYF3DJ.js.map +1 -0
- package/dist/{chunk-K2CQZPCG.js → chunk-6GI6HFSQ.js} +2 -2
- package/dist/chunk-6GI6HFSQ.js.map +1 -0
- package/dist/{chunk-PVUMB632.js → chunk-A2QRUBVE.js} +2 -2
- package/dist/chunk-A2QRUBVE.js.map +1 -0
- package/dist/{chunk-W6D62JCI.js → chunk-A4TKWQBU.js} +2 -2
- package/dist/chunk-A4TKWQBU.js.map +1 -0
- package/dist/{chunk-GCQZ4FHI.js → chunk-ARBKF6VI.js} +2 -2
- package/dist/{chunk-GCQZ4FHI.js.map → chunk-ARBKF6VI.js.map} +1 -1
- package/dist/{chunk-ZVC3ZWLM.js → chunk-B2LPSCES.js} +2 -2
- package/dist/chunk-B2LPSCES.js.map +1 -0
- package/dist/{chunk-62C7LX2E.js → chunk-CKJHJPKQ.js} +2 -2
- package/dist/chunk-CKJHJPKQ.js.map +1 -0
- package/dist/{chunk-RSVA2EYO.js → chunk-CNY3ZUVG.js} +2 -2
- package/dist/chunk-CNY3ZUVG.js.map +1 -0
- package/dist/{chunk-IXMD5QH2.js → chunk-EHVUAFNH.js} +2 -2
- package/dist/chunk-EHVUAFNH.js.map +1 -0
- package/dist/{chunk-P6WSBVDT.js → chunk-FRAH5QNY.js} +4 -4
- package/dist/chunk-FRAH5QNY.js.map +1 -0
- package/dist/{chunk-MQQLYWZZ.js → chunk-GNS2FGPC.js} +2 -2
- package/dist/chunk-GNS2FGPC.js.map +1 -0
- package/dist/{chunk-TASAT7KB.js → chunk-HNPO6LFW.js} +2 -2
- package/dist/chunk-HNPO6LFW.js.map +1 -0
- package/dist/{chunk-KWFX6WHG.js → chunk-JFUKVWSO.js} +2 -2
- package/dist/chunk-JFUKVWSO.js.map +1 -0
- package/dist/{chunk-NWMJYTMB.js → chunk-LAKHYTHL.js} +3 -3
- package/dist/chunk-LAKHYTHL.js.map +1 -0
- package/dist/{chunk-R7SQAREQ.js → chunk-LKOPJ3GS.js} +2 -2
- package/dist/chunk-LKOPJ3GS.js.map +1 -0
- package/dist/{chunk-WOEIJWGJ.js → chunk-NZS2YJ43.js} +2 -2
- package/dist/chunk-NZS2YJ43.js.map +1 -0
- package/dist/{chunk-3QP3E7HS.js → chunk-OZ3EXPLE.js} +2 -2
- package/dist/chunk-OZ3EXPLE.js.map +1 -0
- package/dist/{chunk-YHEVHRLH.js → chunk-OZBPR27I.js} +2 -2
- package/dist/chunk-OZBPR27I.js.map +1 -0
- package/dist/{chunk-T4Z4HM4W.js → chunk-PAVI5W6M.js} +3 -3
- package/dist/chunk-PAVI5W6M.js.map +1 -0
- package/dist/{chunk-XSY5AAXT.js → chunk-PO7IHPFF.js} +2 -2
- package/dist/chunk-PO7IHPFF.js.map +1 -0
- package/dist/{chunk-SUILH4ID.js → chunk-QK6UEQ75.js} +2 -2
- package/dist/chunk-QK6UEQ75.js.map +1 -0
- package/dist/{chunk-WFAWAHJH.js → chunk-UFWGOJL7.js} +2 -2
- package/dist/chunk-UFWGOJL7.js.map +1 -0
- package/dist/{chunk-54HPVE7N.js → chunk-UGTETAJ2.js} +2 -2
- package/dist/chunk-UGTETAJ2.js.map +1 -0
- package/dist/{chunk-LBYDTULN.js → chunk-UL4Q5CIJ.js} +5 -5
- package/dist/chunk-UL4Q5CIJ.js.map +1 -0
- package/dist/{chunk-XOIYNY4I.js → chunk-VNO2YUVD.js} +2 -2
- package/dist/chunk-VNO2YUVD.js.map +1 -0
- package/dist/{chunk-ZIE56LCA.js → chunk-XU6MRYG2.js} +3 -3
- package/dist/chunk-XU6MRYG2.js.map +1 -0
- package/dist/{chunk-6BDCTUQY.js → chunk-YNTMYL36.js} +3 -3
- package/dist/chunk-YNTMYL36.js.map +1 -0
- package/dist/config/index.js +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/file-router/index.js +1 -1
- package/dist/file-router/streaming-hints.js +1 -1
- package/dist/handlers/index.js +1 -1
- package/dist/index.js +30 -30
- package/dist/index.js.map +1 -1
- package/dist/islands/index.js +1 -1
- package/dist/middleware/index.js +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/render/index.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/rsc/adapters/index.js +4 -4
- package/dist/rsc/adapters/preact.js +1 -1
- package/dist/rsc/adapters/react.js +1 -1
- package/dist/rsc/adapters/solid.js +1 -1
- package/dist/rsc/adapters/vue.js +1 -1
- package/dist/rsc/boundaries.js +1 -1
- package/dist/rsc/context.js +1 -1
- package/dist/rsc/index.js +11 -11
- package/dist/rsc/legacy.js +1 -1
- package/dist/rsc/payload.js +1 -1
- package/dist/rsc/plugins/esbuild.js +2 -2
- package/dist/rsc/plugins/index.js +4 -4
- package/dist/rsc/plugins/rollup.js +2 -2
- package/dist/rsc/renderer.js +3 -3
- package/dist/rsc/stream.js +1 -1
- package/dist/rsc/vite-plugin.js +2 -2
- package/dist/server/index.js +4 -4
- package/dist/streaming/adapters/index.js +1 -1
- package/dist/streaming/conditional.js +1 -1
- package/dist/streaming/index.js +1 -1
- package/dist/streaming/observability.js +2 -2
- package/dist/streaming/priority.js +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +207 -207
- package/dist/chunk-2F2QU6RC.js.map +0 -1
- package/dist/chunk-3QP3E7HS.js.map +0 -1
- package/dist/chunk-3ZSSRE6M.js.map +0 -1
- package/dist/chunk-54HPVE7N.js.map +0 -1
- package/dist/chunk-62C7LX2E.js.map +0 -1
- package/dist/chunk-6BDCTUQY.js.map +0 -1
- package/dist/chunk-FSJNOPYE.js.map +0 -1
- package/dist/chunk-IXMD5QH2.js.map +0 -1
- package/dist/chunk-K2CQZPCG.js.map +0 -1
- package/dist/chunk-KWFX6WHG.js.map +0 -1
- package/dist/chunk-LBYDTULN.js.map +0 -1
- package/dist/chunk-MDQNNIHH.js.map +0 -1
- package/dist/chunk-MQQLYWZZ.js.map +0 -1
- package/dist/chunk-NWMJYTMB.js.map +0 -1
- package/dist/chunk-P6WSBVDT.js.map +0 -1
- package/dist/chunk-PDW5WCMW.js.map +0 -1
- package/dist/chunk-PVUMB632.js.map +0 -1
- package/dist/chunk-R7SQAREQ.js.map +0 -1
- package/dist/chunk-RSVA2EYO.js.map +0 -1
- package/dist/chunk-SUILH4ID.js.map +0 -1
- package/dist/chunk-T4Z4HM4W.js.map +0 -1
- package/dist/chunk-TASAT7KB.js.map +0 -1
- package/dist/chunk-VPFMHGEV.js.map +0 -1
- package/dist/chunk-W6D62JCI.js.map +0 -1
- package/dist/chunk-WFAWAHJH.js.map +0 -1
- package/dist/chunk-WOEIJWGJ.js.map +0 -1
- package/dist/chunk-XOIYNY4I.js.map +0 -1
- package/dist/chunk-XSY5AAXT.js.map +0 -1
- package/dist/chunk-YHEVHRLH.js.map +0 -1
- package/dist/chunk-ZIE56LCA.js.map +0 -1
- package/dist/chunk-ZVC3ZWLM.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,347 +1,346 @@
|
|
|
1
|
-
# @flight-framework/core
|
|
2
|
-
|
|
3
|
-
Core primitives for Flight Framework
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{ path: '/', handler:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
// src/routes/
|
|
68
|
-
// src/routes/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{ id: '
|
|
144
|
-
{ id: '
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
throw
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
<
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
'/': {
|
|
263
|
-
'/
|
|
264
|
-
'/
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
await
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
| `@flight-framework/core` |
|
|
313
|
-
| `@flight-framework/core/
|
|
314
|
-
| `@flight-framework/core/
|
|
315
|
-
| `@flight-framework/core/
|
|
316
|
-
| `@flight-framework/core/
|
|
317
|
-
| `@flight-framework/core/
|
|
318
|
-
| `@flight-framework/core/
|
|
319
|
-
| `@flight-framework/core/
|
|
320
|
-
| `@flight-framework/core/
|
|
321
|
-
| `@flight-framework/core/
|
|
322
|
-
| `@flight-framework/core/
|
|
323
|
-
| `@flight-framework/core/
|
|
324
|
-
| `@flight-framework/core/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
MIT
|
|
1
|
+
# @flight-framework/core
|
|
2
|
+
|
|
3
|
+
Core primitives for Flight Framework, including configuration, routing, caching, streaming SSR, and server actions.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Multi-render mode: SSR, SSG, ISR, and streaming
|
|
8
|
+
- Framework support: React, Vue, Svelte, Solid, HTMX
|
|
9
|
+
- File-based routing with automatic route discovery
|
|
10
|
+
- Type-safe server actions with form support
|
|
11
|
+
- Streaming SSR with priority control
|
|
12
|
+
- Islands architecture for partial hydration
|
|
13
|
+
- Pluggable cache adapters with deduplication
|
|
14
|
+
- Structured error handling with type guards
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @flight-framework/core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Configuration
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// flight.config.ts
|
|
28
|
+
import { defineConfig } from '@flight-framework/core';
|
|
29
|
+
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
server: {
|
|
32
|
+
port: 3000,
|
|
33
|
+
},
|
|
34
|
+
render: {
|
|
35
|
+
defaultMode: 'ssr',
|
|
36
|
+
streaming: true,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Create a Server
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { createServer } from '@flight-framework/core';
|
|
45
|
+
|
|
46
|
+
const server = createServer({
|
|
47
|
+
port: 3000,
|
|
48
|
+
routes: [
|
|
49
|
+
{ path: '/', handler: homeHandler },
|
|
50
|
+
{ path: '/api/*', handler: apiHandler },
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await server.start();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### File-Based Routing
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { createFileRouter, scanRoutes } from '@flight-framework/core';
|
|
61
|
+
|
|
62
|
+
const routes = await scanRoutes('./src/routes');
|
|
63
|
+
const router = createFileRouter({ routes });
|
|
64
|
+
|
|
65
|
+
// Routes are discovered automatically:
|
|
66
|
+
// src/routes/index.page.tsx -> /
|
|
67
|
+
// src/routes/about.page.tsx -> /about
|
|
68
|
+
// src/routes/blog/[slug].page.tsx -> /blog/:slug
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Modules
|
|
72
|
+
|
|
73
|
+
### Router
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { createRouter } from '@flight-framework/core/router';
|
|
77
|
+
|
|
78
|
+
const router = createRouter();
|
|
79
|
+
router.add('GET', '/users/:id', userHandler);
|
|
80
|
+
|
|
81
|
+
const match = router.match('GET', '/users/123');
|
|
82
|
+
// { params: { id: '123' }, handler: userHandler }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Cache
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { createCache, memory, cached, dedupe } from '@flight-framework/core/cache';
|
|
89
|
+
|
|
90
|
+
// Create a cache with memory adapter
|
|
91
|
+
const cache = createCache({
|
|
92
|
+
adapter: memory(),
|
|
93
|
+
ttl: 60000,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Cache function results
|
|
97
|
+
const getUser = cached(
|
|
98
|
+
async (id: string) => fetchUser(id),
|
|
99
|
+
{ ttl: 5000, key: (id) => `user:${id}` }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Deduplicate concurrent requests
|
|
103
|
+
const getData = dedupe(fetchData);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Server Actions
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { registerAction, executeAction, cookies } from '@flight-framework/core/actions';
|
|
110
|
+
|
|
111
|
+
// Register a server action
|
|
112
|
+
registerAction('createUser', async (formData: FormData) => {
|
|
113
|
+
const name = formData.get('name');
|
|
114
|
+
const user = await db.users.create({ name });
|
|
115
|
+
|
|
116
|
+
cookies().set('user_id', user.id);
|
|
117
|
+
|
|
118
|
+
return { success: true, user };
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Execute from client
|
|
122
|
+
const result = await executeAction('createUser', formData);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Streaming SSR
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import {
|
|
129
|
+
createStreamingSSR,
|
|
130
|
+
streamWithPriority
|
|
131
|
+
} from '@flight-framework/core/streaming';
|
|
132
|
+
|
|
133
|
+
// Basic streaming
|
|
134
|
+
const stream = await createStreamingSSR({
|
|
135
|
+
component: App,
|
|
136
|
+
props: { data },
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Priority-based streaming (out-of-order)
|
|
140
|
+
const result = await streamWithPriority({
|
|
141
|
+
boundaries: [
|
|
142
|
+
{ id: 'header', priority: 100, render: Header },
|
|
143
|
+
{ id: 'sidebar', priority: 50, render: Sidebar },
|
|
144
|
+
{ id: 'content', priority: 75, render: Content },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Islands Architecture
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import {
|
|
153
|
+
defineIsland,
|
|
154
|
+
hydrateIslands,
|
|
155
|
+
createReactIslandAdapter
|
|
156
|
+
} from '@flight-framework/core/islands';
|
|
157
|
+
|
|
158
|
+
// Define an island component
|
|
159
|
+
const Counter = defineIsland({
|
|
160
|
+
name: 'counter',
|
|
161
|
+
component: CounterComponent,
|
|
162
|
+
hydrate: 'visible', // 'load' | 'visible' | 'idle' | 'interaction'
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Client-side hydration
|
|
166
|
+
hydrateIslands({
|
|
167
|
+
adapter: createReactIslandAdapter(),
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Middleware
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { createMiddlewareChain } from '@flight-framework/core/middleware';
|
|
175
|
+
|
|
176
|
+
const middleware = createMiddlewareChain([
|
|
177
|
+
async (ctx, next) => {
|
|
178
|
+
const start = Date.now();
|
|
179
|
+
await next();
|
|
180
|
+
console.log(`Request took ${Date.now() - start}ms`);
|
|
181
|
+
},
|
|
182
|
+
authMiddleware,
|
|
183
|
+
loggingMiddleware,
|
|
184
|
+
]);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Error Handling
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import {
|
|
191
|
+
FlightError,
|
|
192
|
+
createError,
|
|
193
|
+
isFlightError,
|
|
194
|
+
createNotFound,
|
|
195
|
+
createForbidden,
|
|
196
|
+
} from '@flight-framework/core/errors';
|
|
197
|
+
|
|
198
|
+
// Create typed errors
|
|
199
|
+
throw createNotFound('Page not found');
|
|
200
|
+
throw createForbidden('Access denied');
|
|
201
|
+
|
|
202
|
+
// Create custom errors
|
|
203
|
+
throw createError({
|
|
204
|
+
statusCode: 422,
|
|
205
|
+
message: 'Validation failed',
|
|
206
|
+
data: { field: 'email', error: 'Invalid format' },
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Type guards
|
|
210
|
+
if (isFlightError(error)) {
|
|
211
|
+
console.log(error.statusCode, error.digest);
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### React Integration
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { ErrorProvider, useError, useFlightError } from '@flight-framework/core/react';
|
|
219
|
+
|
|
220
|
+
// Wrap your app
|
|
221
|
+
<ErrorProvider onError={console.error}>
|
|
222
|
+
<App />
|
|
223
|
+
</ErrorProvider>
|
|
224
|
+
|
|
225
|
+
// Use in components
|
|
226
|
+
function MyComponent() {
|
|
227
|
+
const { error, clearError } = useFlightError();
|
|
228
|
+
|
|
229
|
+
if (error) {
|
|
230
|
+
return <ErrorDisplay error={error} onRetry={clearError} />;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return <Content />;
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Metadata (SEO)
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { renderMetadataToHead, type Metadata } from '@flight-framework/core';
|
|
241
|
+
|
|
242
|
+
const metadata: Metadata = {
|
|
243
|
+
title: 'My Page',
|
|
244
|
+
description: 'Page description',
|
|
245
|
+
openGraph: {
|
|
246
|
+
title: 'OG Title',
|
|
247
|
+
image: '/og-image.png',
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const headHtml = renderMetadataToHead(metadata);
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Route Rules (ISR/SSG)
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { defineConfig } from '@flight-framework/core';
|
|
258
|
+
|
|
259
|
+
export default defineConfig({
|
|
260
|
+
routeRules: {
|
|
261
|
+
'/': { prerender: true },
|
|
262
|
+
'/blog/**': { isr: 3600 },
|
|
263
|
+
'/api/**': { ssr: true },
|
|
264
|
+
'/static/**': { static: true },
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Revalidation
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
import {
|
|
273
|
+
revalidatePath,
|
|
274
|
+
revalidateTag,
|
|
275
|
+
createRevalidateHandler
|
|
276
|
+
} from '@flight-framework/core';
|
|
277
|
+
|
|
278
|
+
// On-demand revalidation
|
|
279
|
+
await revalidatePath('/blog/my-post');
|
|
280
|
+
await revalidateTag('blog-posts');
|
|
281
|
+
|
|
282
|
+
// Create revalidation API handler
|
|
283
|
+
const handler = createRevalidateHandler({
|
|
284
|
+
secret: process.env.REVALIDATE_SECRET,
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Environment Utilities
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import {
|
|
292
|
+
isServer,
|
|
293
|
+
isBrowser,
|
|
294
|
+
isProduction,
|
|
295
|
+
isDevelopment
|
|
296
|
+
} from '@flight-framework/core/utils';
|
|
297
|
+
|
|
298
|
+
if (isServer()) {
|
|
299
|
+
// Server-only code
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (isDevelopment()) {
|
|
303
|
+
console.log('Debug info');
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Module Exports
|
|
308
|
+
|
|
309
|
+
| Export | Description |
|
|
310
|
+
|--------|-------------|
|
|
311
|
+
| `@flight-framework/core` | Main entry with all primitives |
|
|
312
|
+
| `@flight-framework/core/router` | Routing utilities |
|
|
313
|
+
| `@flight-framework/core/cache` | Caching system |
|
|
314
|
+
| `@flight-framework/core/server` | HTTP server |
|
|
315
|
+
| `@flight-framework/core/render` | Rendering modes |
|
|
316
|
+
| `@flight-framework/core/middleware` | Middleware chain |
|
|
317
|
+
| `@flight-framework/core/actions` | Server actions |
|
|
318
|
+
| `@flight-framework/core/streaming` | Streaming SSR |
|
|
319
|
+
| `@flight-framework/core/islands` | Islands architecture |
|
|
320
|
+
| `@flight-framework/core/errors` | Error handling |
|
|
321
|
+
| `@flight-framework/core/react` | React integration |
|
|
322
|
+
| `@flight-framework/core/rsc` | React Server Components |
|
|
323
|
+
| `@flight-framework/core/config` | Configuration |
|
|
324
|
+
| `@flight-framework/core/utils` | Environment utilities |
|
|
325
|
+
|
|
326
|
+
## TypeScript
|
|
327
|
+
|
|
328
|
+
Full TypeScript support with exported types for all APIs:
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import type {
|
|
332
|
+
FlightConfig,
|
|
333
|
+
Route,
|
|
334
|
+
RouteMatch,
|
|
335
|
+
Cache,
|
|
336
|
+
CacheAdapter,
|
|
337
|
+
Middleware,
|
|
338
|
+
FlightError,
|
|
339
|
+
Metadata,
|
|
340
|
+
StreamingHints,
|
|
341
|
+
} from '@flight-framework/core';
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## License
|
|
345
|
+
|
|
346
|
+
MIT
|