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