@flightdev/core 0.6.7 → 0.6.8
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/README.md +38 -38
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @flightdev/core
|
|
2
2
|
|
|
3
3
|
Core primitives for Flight Framework, including configuration, routing, caching, streaming SSR, and server actions.
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ Core primitives for Flight Framework, including configuration, routing, caching,
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install @
|
|
19
|
+
npm install @flightdev/core
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Quick Start
|
|
@@ -25,7 +25,7 @@ npm install @flight-framework/core
|
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
27
|
// flight.config.ts
|
|
28
|
-
import { defineConfig } from '@
|
|
28
|
+
import { defineConfig } from '@flightdev/core';
|
|
29
29
|
|
|
30
30
|
export default defineConfig({
|
|
31
31
|
server: {
|
|
@@ -41,7 +41,7 @@ export default defineConfig({
|
|
|
41
41
|
### Create a Server
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
|
-
import { createServer } from '@
|
|
44
|
+
import { createServer } from '@flightdev/core';
|
|
45
45
|
|
|
46
46
|
const server = createServer({
|
|
47
47
|
port: 3000,
|
|
@@ -57,7 +57,7 @@ await server.start();
|
|
|
57
57
|
### File-Based Routing
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
|
-
import { createFileRouter, scanRoutes } from '@
|
|
60
|
+
import { createFileRouter, scanRoutes } from '@flightdev/core';
|
|
61
61
|
|
|
62
62
|
const routes = await scanRoutes('./src/routes');
|
|
63
63
|
const router = createFileRouter({ routes });
|
|
@@ -73,7 +73,7 @@ const router = createFileRouter({ routes });
|
|
|
73
73
|
### Router
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
|
-
import { createRouter } from '@
|
|
76
|
+
import { createRouter } from '@flightdev/core/router';
|
|
77
77
|
|
|
78
78
|
const router = createRouter();
|
|
79
79
|
router.add('GET', '/users/:id', userHandler);
|
|
@@ -85,7 +85,7 @@ const match = router.match('GET', '/users/123');
|
|
|
85
85
|
### Cache
|
|
86
86
|
|
|
87
87
|
```typescript
|
|
88
|
-
import { createCache, memory, cached, dedupe } from '@
|
|
88
|
+
import { createCache, memory, cached, dedupe } from '@flightdev/core/cache';
|
|
89
89
|
|
|
90
90
|
// Create a cache with memory adapter
|
|
91
91
|
const cache = createCache({
|
|
@@ -106,7 +106,7 @@ const getData = dedupe(fetchData);
|
|
|
106
106
|
### Server Actions
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
|
-
import { registerAction, executeAction, cookies } from '@
|
|
109
|
+
import { registerAction, executeAction, cookies } from '@flightdev/core/actions';
|
|
110
110
|
|
|
111
111
|
// Register a server action
|
|
112
112
|
registerAction('createUser', async (formData: FormData) => {
|
|
@@ -128,7 +128,7 @@ const result = await executeAction('createUser', formData);
|
|
|
128
128
|
import {
|
|
129
129
|
createStreamingSSR,
|
|
130
130
|
streamWithPriority
|
|
131
|
-
} from '@
|
|
131
|
+
} from '@flightdev/core/streaming';
|
|
132
132
|
|
|
133
133
|
// Basic streaming
|
|
134
134
|
const stream = await createStreamingSSR({
|
|
@@ -153,7 +153,7 @@ import {
|
|
|
153
153
|
defineIsland,
|
|
154
154
|
hydrateIslands,
|
|
155
155
|
createReactIslandAdapter
|
|
156
|
-
} from '@
|
|
156
|
+
} from '@flightdev/core/islands';
|
|
157
157
|
|
|
158
158
|
// Define an island component
|
|
159
159
|
const Counter = defineIsland({
|
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
cors,
|
|
181
181
|
logger,
|
|
182
182
|
securityHeaders
|
|
183
|
-
} from '@
|
|
183
|
+
} from '@flightdev/core/middleware';
|
|
184
184
|
|
|
185
185
|
const chain = createMiddlewareChain();
|
|
186
186
|
|
|
@@ -200,7 +200,7 @@ chain
|
|
|
200
200
|
Centralized error handling with the `errorHandler` factory:
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
|
-
import { createMiddlewareChain, errorHandler } from '@
|
|
203
|
+
import { createMiddlewareChain, errorHandler } from '@flightdev/core/middleware';
|
|
204
204
|
|
|
205
205
|
const chain = createMiddlewareChain();
|
|
206
206
|
|
|
@@ -237,7 +237,7 @@ chain.use(errorHandler({
|
|
|
237
237
|
Middleware context supports generics for type-safe data sharing:
|
|
238
238
|
|
|
239
239
|
```typescript
|
|
240
|
-
import type { Middleware, MiddlewareContext } from '@
|
|
240
|
+
import type { Middleware, MiddlewareContext } from '@flightdev/core/middleware';
|
|
241
241
|
|
|
242
242
|
interface AppLocals {
|
|
243
243
|
user: { id: string; role: string };
|
|
@@ -271,7 +271,7 @@ const roleGuard: Middleware<AppLocals> = async (ctx, next) => {
|
|
|
271
271
|
CORS middleware with dynamic origin validation and CDN compatibility:
|
|
272
272
|
|
|
273
273
|
```typescript
|
|
274
|
-
import { cors } from '@
|
|
274
|
+
import { cors } from '@flightdev/core/middleware';
|
|
275
275
|
|
|
276
276
|
// Static origins
|
|
277
277
|
chain.use(cors({
|
|
@@ -304,7 +304,7 @@ Dynamic origins automatically set `Vary: Origin` for CDN/cache compatibility.
|
|
|
304
304
|
#### Logger Configuration
|
|
305
305
|
|
|
306
306
|
```typescript
|
|
307
|
-
import { logger } from '@
|
|
307
|
+
import { logger } from '@flightdev/core/middleware';
|
|
308
308
|
|
|
309
309
|
chain.use(logger({
|
|
310
310
|
level: 'info', // 'debug' | 'info' | 'warn' | 'error' | 'silent'
|
|
@@ -326,7 +326,7 @@ import {
|
|
|
326
326
|
isFlightError,
|
|
327
327
|
createNotFound,
|
|
328
328
|
createForbidden,
|
|
329
|
-
} from '@
|
|
329
|
+
} from '@flightdev/core/errors';
|
|
330
330
|
|
|
331
331
|
// Create typed errors
|
|
332
332
|
throw createNotFound('Page not found');
|
|
@@ -348,7 +348,7 @@ if (isFlightError(error)) {
|
|
|
348
348
|
### React Integration
|
|
349
349
|
|
|
350
350
|
```typescript
|
|
351
|
-
import { ErrorProvider, useError, useFlightError } from '@
|
|
351
|
+
import { ErrorProvider, useError, useFlightError } from '@flightdev/core/react';
|
|
352
352
|
|
|
353
353
|
// Wrap your app
|
|
354
354
|
<ErrorProvider onError={console.error}>
|
|
@@ -370,7 +370,7 @@ function MyComponent() {
|
|
|
370
370
|
### Metadata (SEO)
|
|
371
371
|
|
|
372
372
|
```typescript
|
|
373
|
-
import { renderMetadataToHead, type Metadata } from '@
|
|
373
|
+
import { renderMetadataToHead, type Metadata } from '@flightdev/core';
|
|
374
374
|
|
|
375
375
|
const metadata: Metadata = {
|
|
376
376
|
title: 'My Page',
|
|
@@ -387,7 +387,7 @@ const headHtml = renderMetadataToHead(metadata);
|
|
|
387
387
|
### Route Rules (ISR/SSG)
|
|
388
388
|
|
|
389
389
|
```typescript
|
|
390
|
-
import { defineConfig } from '@
|
|
390
|
+
import { defineConfig } from '@flightdev/core';
|
|
391
391
|
|
|
392
392
|
export default defineConfig({
|
|
393
393
|
routeRules: {
|
|
@@ -406,7 +406,7 @@ import {
|
|
|
406
406
|
revalidatePath,
|
|
407
407
|
revalidateTag,
|
|
408
408
|
createRevalidateHandler
|
|
409
|
-
} from '@
|
|
409
|
+
} from '@flightdev/core';
|
|
410
410
|
|
|
411
411
|
// On-demand revalidation
|
|
412
412
|
await revalidatePath('/blog/my-post');
|
|
@@ -426,7 +426,7 @@ import {
|
|
|
426
426
|
isBrowser,
|
|
427
427
|
isProduction,
|
|
428
428
|
isDevelopment
|
|
429
|
-
} from '@
|
|
429
|
+
} from '@flightdev/core/utils';
|
|
430
430
|
|
|
431
431
|
if (isServer()) {
|
|
432
432
|
// Server-only code
|
|
@@ -441,20 +441,20 @@ if (isDevelopment()) {
|
|
|
441
441
|
|
|
442
442
|
| Export | Description |
|
|
443
443
|
|--------|-------------|
|
|
444
|
-
| `@
|
|
445
|
-
| `@
|
|
446
|
-
| `@
|
|
447
|
-
| `@
|
|
448
|
-
| `@
|
|
449
|
-
| `@
|
|
450
|
-
| `@
|
|
451
|
-
| `@
|
|
452
|
-
| `@
|
|
453
|
-
| `@
|
|
454
|
-
| `@
|
|
455
|
-
| `@
|
|
456
|
-
| `@
|
|
457
|
-
| `@
|
|
444
|
+
| `@flightdev/core` | Main entry with all primitives |
|
|
445
|
+
| `@flightdev/core/router` | Routing utilities |
|
|
446
|
+
| `@flightdev/core/cache` | Caching system |
|
|
447
|
+
| `@flightdev/core/server` | HTTP server |
|
|
448
|
+
| `@flightdev/core/render` | Rendering modes |
|
|
449
|
+
| `@flightdev/core/middleware` | Middleware chain |
|
|
450
|
+
| `@flightdev/core/actions` | Server actions |
|
|
451
|
+
| `@flightdev/core/streaming` | Streaming SSR |
|
|
452
|
+
| `@flightdev/core/islands` | Islands architecture |
|
|
453
|
+
| `@flightdev/core/errors` | Error handling |
|
|
454
|
+
| `@flightdev/core/react` | React integration |
|
|
455
|
+
| `@flightdev/core/rsc` | React Server Components |
|
|
456
|
+
| `@flightdev/core/config` | Configuration |
|
|
457
|
+
| `@flightdev/core/utils` | Environment utilities |
|
|
458
458
|
|
|
459
459
|
## TypeScript
|
|
460
460
|
|
|
@@ -471,7 +471,7 @@ import type {
|
|
|
471
471
|
FlightError,
|
|
472
472
|
Metadata,
|
|
473
473
|
StreamingHints,
|
|
474
|
-
} from '@
|
|
474
|
+
} from '@flightdev/core';
|
|
475
475
|
```
|
|
476
476
|
|
|
477
477
|
## Build Plugins
|
|
@@ -486,7 +486,7 @@ npm install critters
|
|
|
486
486
|
|
|
487
487
|
```typescript
|
|
488
488
|
// vite.config.ts
|
|
489
|
-
import { criticalCSS } from '@
|
|
489
|
+
import { criticalCSS } from '@flightdev/core/plugins';
|
|
490
490
|
|
|
491
491
|
export default defineConfig({
|
|
492
492
|
plugins: [
|
|
@@ -524,7 +524,7 @@ import {
|
|
|
524
524
|
mergeCSS,
|
|
525
525
|
generatePreloadLink,
|
|
526
526
|
generateNoscriptFallback,
|
|
527
|
-
} from '@
|
|
527
|
+
} from '@flightdev/core/plugins/critical-css';
|
|
528
528
|
|
|
529
529
|
// Extract styles from HTML
|
|
530
530
|
const { html, styles } = extractInlineStyles(htmlString);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightdev/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "Core primitives for Flight Framework - routing, rendering, caching",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"flight",
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": "Flight Contributors",
|
|
14
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
18
|
+
"directory": "packages/core"
|
|
19
|
+
},
|
|
14
20
|
"type": "module",
|
|
15
21
|
"exports": {
|
|
16
22
|
".": {
|