@flight-framework/core 0.0.1
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/dist/actions/index.d.ts +108 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/adapters/index.d.ts +243 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/cache/index.d.ts +76 -0
- package/dist/cache/index.js +3 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/chunk-3AIQVGTM.js +120 -0
- package/dist/chunk-3AIQVGTM.js.map +1 -0
- package/dist/chunk-AFSKXC6V.js +188 -0
- package/dist/chunk-AFSKXC6V.js.map +1 -0
- package/dist/chunk-AJ3IBYXT.js +47 -0
- package/dist/chunk-AJ3IBYXT.js.map +1 -0
- package/dist/chunk-GCQZ4FHI.js +245 -0
- package/dist/chunk-GCQZ4FHI.js.map +1 -0
- package/dist/chunk-I5RHYGX6.js +167 -0
- package/dist/chunk-I5RHYGX6.js.map +1 -0
- package/dist/chunk-KWFX6WHG.js +311 -0
- package/dist/chunk-KWFX6WHG.js.map +1 -0
- package/dist/chunk-Q4C5CCHK.js +13 -0
- package/dist/chunk-Q4C5CCHK.js.map +1 -0
- package/dist/chunk-QEFGUHYD.js +221 -0
- package/dist/chunk-QEFGUHYD.js.map +1 -0
- package/dist/chunk-TKXN7KGE.js +145 -0
- package/dist/chunk-TKXN7KGE.js.map +1 -0
- package/dist/chunk-WAGCTWGY.js +93 -0
- package/dist/chunk-WAGCTWGY.js.map +1 -0
- package/dist/chunk-Y22KEW2F.js +223 -0
- package/dist/chunk-Y22KEW2F.js.map +1 -0
- package/dist/chunk-ZVC3ZWLM.js +52 -0
- package/dist/chunk-ZVC3ZWLM.js.map +1 -0
- package/dist/config/index.d.ts +146 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/file-router/index.d.ts +71 -0
- package/dist/file-router/index.js +3 -0
- package/dist/file-router/index.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 +23 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/index.d.ts +152 -0
- package/dist/middleware/index.js +3 -0
- package/dist/middleware/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/index.d.ts +131 -0
- package/dist/rsc/index.js +3 -0
- package/dist/rsc/index.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/index.d.ts +169 -0
- package/dist/streaming/index.js +3 -0
- package/dist/streaming/index.js.map +1 -0
- package/package.json +100 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { FlightConfig, FlightUserConfig, defineConfig } from './config/index.js';
|
|
2
|
+
export { Route, RouteMatch, RouteParams, Router, createRouter } from './router/index.js';
|
|
3
|
+
export { FlightServer, RouteHandler, RouteHandlerContext, ServerOptions, ServerRoute, createServer } from './server/index.js';
|
|
4
|
+
export { RenderContext, RenderMode, RenderResult } from './render/index.js';
|
|
5
|
+
export { Cache, CacheOptions, createCache } from './cache/index.js';
|
|
6
|
+
export { Middleware, MiddlewareContext, MiddlewareNext, createMiddlewareChain } from './middleware/index.js';
|
|
7
|
+
export { AdapterBuilder, FlightAdapter } from './adapters/index.js';
|
|
8
|
+
export { FileRoute, FileRouter, FileRouterOptions, ScanResult, createFileRouter, loadRoutes, scanRoutes } from './file-router/index.js';
|
|
9
|
+
export { HttpMethod as FileHttpMethod, RouteHandler as FileRouteHandler, RouteHandlerContext as FileRouteHandlerContext, createRouteContext, error, json, parseBody, redirect } from './handlers/index.js';
|
|
10
|
+
export { ActionResult, CookieOptions, RedirectError, ServerAction, redirect as actionRedirect, cookies, executeAction, executeFormAction, getAction, handleActionRequest, isRedirectError, parseFormData, registerAction } from './actions/index.js';
|
|
11
|
+
export { StreamingRenderOptions, StreamingRenderResult, SuspenseBoundaryConfig, createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from './streaming/index.js';
|
|
12
|
+
export { ClientComponent, ComponentType as RSCComponentType, RenderContext as RSCRenderContext, ServerComponent, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError as isRscRedirectError, notFound, revalidatePath, revalidateTag, redirect as rscRedirect, serializeProps, serverFetch, withErrorBoundary } from './rsc/index.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Flight Framework - Core
|
|
16
|
+
*
|
|
17
|
+
* The agnostic full-stack framework primitives.
|
|
18
|
+
* Maximum flexibility, zero lock-in.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare const VERSION = "0.0.1";
|
|
22
|
+
|
|
23
|
+
export { VERSION };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { createFileRouter, loadRoutes, scanRoutes } from './chunk-I5RHYGX6.js';
|
|
2
|
+
export { RedirectError, redirect as actionRedirect, cookies, executeAction, executeFormAction, getAction, handleActionRequest, isRedirectError, parseFormData, registerAction } from './chunk-TKXN7KGE.js';
|
|
3
|
+
export { createRouteContext, error, json, parseBody, redirect } from './chunk-AJ3IBYXT.js';
|
|
4
|
+
export { createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from './chunk-QEFGUHYD.js';
|
|
5
|
+
export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError as isRscRedirectError, notFound, revalidatePath, revalidateTag, redirect as rscRedirect, serializeProps, serverFetch, withErrorBoundary } from './chunk-AFSKXC6V.js';
|
|
6
|
+
import './chunk-ZVC3ZWLM.js';
|
|
7
|
+
export { createCache } from './chunk-3AIQVGTM.js';
|
|
8
|
+
import './chunk-Q4C5CCHK.js';
|
|
9
|
+
export { createServer } from './chunk-Y22KEW2F.js';
|
|
10
|
+
export { createRouter } from './chunk-GCQZ4FHI.js';
|
|
11
|
+
export { createMiddlewareChain } from './chunk-KWFX6WHG.js';
|
|
12
|
+
export { defineConfig } from './chunk-WAGCTWGY.js';
|
|
13
|
+
|
|
14
|
+
// src/index.ts
|
|
15
|
+
var VERSION = "0.0.1";
|
|
16
|
+
|
|
17
|
+
export { VERSION };
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAyIO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\r\n * Flight Framework - Core\r\n * \r\n * The agnostic full-stack framework primitives.\r\n * Maximum flexibility, zero lock-in.\r\n */\r\n\r\n// Configuration\r\nexport { defineConfig, type FlightConfig, type FlightUserConfig } from './config/index.js';\r\n\r\n// Router\r\nexport {\r\n createRouter,\r\n type Route,\r\n type RouteMatch,\r\n type Router,\r\n type RouteParams,\r\n} from './router/index.js';\r\n\r\n// Server\r\nexport {\r\n createServer,\r\n type FlightServer,\r\n type RouteHandler,\r\n type RouteHandlerContext,\r\n type ServerOptions,\r\n type ServerRoute,\r\n} from './server/index.js';\r\n\r\n// Render\r\nexport {\r\n type RenderMode,\r\n type RenderContext,\r\n type RenderResult,\r\n} from './render/index.js';\r\n\r\n// Cache\r\nexport {\r\n createCache,\r\n type Cache,\r\n type CacheOptions,\r\n} from './cache/index.js';\r\n\r\n// Middleware\r\nexport {\r\n createMiddlewareChain,\r\n type Middleware,\r\n type MiddlewareContext,\r\n type MiddlewareNext,\r\n} from './middleware/index.js';\r\n\r\n// Adapters\r\nexport {\r\n type FlightAdapter,\r\n type AdapterBuilder,\r\n} from './adapters/index.js';\r\n\r\n// File Router\r\nexport {\r\n createFileRouter,\r\n scanRoutes,\r\n loadRoutes,\r\n type FileRoute,\r\n type FileRouter,\r\n type FileRouterOptions,\r\n type ScanResult,\r\n} from './file-router/index.js';\r\n\r\n// Route Handlers (for file-based routing)\r\nexport {\r\n createRouteContext,\r\n json,\r\n redirect,\r\n error,\r\n parseBody,\r\n type RouteHandler as FileRouteHandler,\r\n type RouteHandlerContext as FileRouteHandlerContext,\r\n type HttpMethod as FileHttpMethod,\r\n} from './handlers/index.js';\r\n\r\n// Server Actions\r\nexport {\r\n registerAction,\r\n getAction,\r\n executeAction,\r\n executeFormAction,\r\n handleActionRequest,\r\n cookies,\r\n redirect as actionRedirect,\r\n parseFormData,\r\n RedirectError,\r\n isRedirectError,\r\n type ServerAction,\r\n type ActionResult,\r\n type CookieOptions,\r\n} from './actions/index.js';\r\n\r\n// Streaming SSR\r\nexport {\r\n createStreamingSSR,\r\n createStreamingResponse,\r\n renderWithStreaming,\r\n createLazyContent,\r\n streamParallel,\r\n streamSequential,\r\n type StreamingRenderOptions,\r\n type StreamingRenderResult,\r\n type SuspenseBoundaryConfig,\r\n} from './streaming/index.js';\r\n\r\n// React Server Components (RSC) Primitives\r\nexport {\r\n hasUseClientDirective,\r\n hasUseServerDirective,\r\n detectComponentType,\r\n createRenderContext,\r\n executeServerComponent,\r\n serverFetch,\r\n revalidateTag,\r\n revalidatePath,\r\n serializeProps,\r\n deserializeProps,\r\n createClientBoundary,\r\n createAsyncComponent,\r\n composeComponents,\r\n withErrorBoundary,\r\n notFound,\r\n isNotFoundError,\r\n redirect as rscRedirect,\r\n isRedirectError as isRscRedirectError,\r\n type RenderContext as RSCRenderContext,\r\n type ServerComponent,\r\n type ClientComponent,\r\n type ComponentType as RSCComponentType,\r\n} from './rsc/index.js';\r\n\r\n// Version\r\nexport const VERSION = '0.0.1';\r\n"]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flight Middleware - Composable request/response handlers
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic middleware system inspired by Koa/Hono.
|
|
5
|
+
*/
|
|
6
|
+
/** Request context passed through middleware chain */
|
|
7
|
+
interface MiddlewareContext {
|
|
8
|
+
/** Request URL */
|
|
9
|
+
url: URL;
|
|
10
|
+
/** Request method */
|
|
11
|
+
method: string;
|
|
12
|
+
/** Request headers */
|
|
13
|
+
headers: Headers;
|
|
14
|
+
/** URL parameters from routing */
|
|
15
|
+
params: Record<string, string | string[]>;
|
|
16
|
+
/** Query parameters */
|
|
17
|
+
query: URLSearchParams;
|
|
18
|
+
/** Parsed request body (if any) */
|
|
19
|
+
body?: unknown;
|
|
20
|
+
/** Local data shared between middleware */
|
|
21
|
+
locals: Record<string, unknown>;
|
|
22
|
+
/** Original request (platform-specific) */
|
|
23
|
+
request?: Request;
|
|
24
|
+
/** Response status code */
|
|
25
|
+
status: number;
|
|
26
|
+
/** Response headers */
|
|
27
|
+
responseHeaders: Headers;
|
|
28
|
+
/** Response body */
|
|
29
|
+
responseBody?: BodyInit | null;
|
|
30
|
+
}
|
|
31
|
+
/** Next function to call the next middleware */
|
|
32
|
+
type MiddlewareNext = () => Promise<void>;
|
|
33
|
+
/** Middleware function signature */
|
|
34
|
+
type Middleware = (ctx: MiddlewareContext, next: MiddlewareNext) => Promise<void> | void;
|
|
35
|
+
/** Middleware with optional path matching */
|
|
36
|
+
interface MiddlewareDefinition {
|
|
37
|
+
/** Path pattern to match (undefined = match all) */
|
|
38
|
+
path?: string | RegExp;
|
|
39
|
+
/** HTTP methods to match (undefined = match all) */
|
|
40
|
+
methods?: string[];
|
|
41
|
+
/** The middleware function */
|
|
42
|
+
handler: Middleware;
|
|
43
|
+
}
|
|
44
|
+
interface MiddlewareChain {
|
|
45
|
+
/** Add middleware to the chain */
|
|
46
|
+
use(middleware: Middleware): MiddlewareChain;
|
|
47
|
+
use(path: string, middleware: Middleware): MiddlewareChain;
|
|
48
|
+
use(definition: MiddlewareDefinition): MiddlewareChain;
|
|
49
|
+
/** Execute the middleware chain */
|
|
50
|
+
execute(ctx: MiddlewareContext): Promise<void>;
|
|
51
|
+
/** Get all middleware definitions */
|
|
52
|
+
middlewares(): MiddlewareDefinition[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a new middleware chain
|
|
56
|
+
*/
|
|
57
|
+
declare function createMiddlewareChain(): MiddlewareChain;
|
|
58
|
+
/**
|
|
59
|
+
* CORS middleware factory
|
|
60
|
+
*/
|
|
61
|
+
declare function cors(options?: {
|
|
62
|
+
origin?: string | string[] | ((origin: string) => boolean);
|
|
63
|
+
methods?: string[];
|
|
64
|
+
headers?: string[];
|
|
65
|
+
credentials?: boolean;
|
|
66
|
+
maxAge?: number;
|
|
67
|
+
}): Middleware;
|
|
68
|
+
/** Log levels in order of verbosity */
|
|
69
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
70
|
+
/** Log format types */
|
|
71
|
+
type LogFormat = 'pretty' | 'json' | 'combined' | 'common' | 'short' | 'tiny';
|
|
72
|
+
/** Log entry structure for JSON format */
|
|
73
|
+
interface LogEntry {
|
|
74
|
+
timestamp: string;
|
|
75
|
+
level: LogLevel;
|
|
76
|
+
method: string;
|
|
77
|
+
path: string;
|
|
78
|
+
status: number;
|
|
79
|
+
duration: number;
|
|
80
|
+
userAgent?: string;
|
|
81
|
+
ip?: string;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
/** Custom log writer function */
|
|
85
|
+
type LogWriter = (entry: LogEntry, formatted: string) => void;
|
|
86
|
+
/** Logger options */
|
|
87
|
+
interface LoggerOptions {
|
|
88
|
+
/** Minimum log level (default: 'info') */
|
|
89
|
+
level?: LogLevel;
|
|
90
|
+
/** Output format (default: 'pretty') */
|
|
91
|
+
format?: LogFormat;
|
|
92
|
+
/** Skip logging for certain requests */
|
|
93
|
+
skip?: (ctx: MiddlewareContext) => boolean;
|
|
94
|
+
/** Custom log writer (replaces console output) */
|
|
95
|
+
writer?: LogWriter;
|
|
96
|
+
/** Include request headers in logs */
|
|
97
|
+
includeHeaders?: boolean;
|
|
98
|
+
/** Colorize output (only for 'pretty' format, default: true) */
|
|
99
|
+
colorize?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Professional logger middleware with configurable levels
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // Basic usage
|
|
107
|
+
* server.use(logger());
|
|
108
|
+
*
|
|
109
|
+
* // With level control
|
|
110
|
+
* server.use(logger({ level: 'warn' })); // Only warn and error
|
|
111
|
+
*
|
|
112
|
+
* // JSON format for production/observability
|
|
113
|
+
* server.use(logger({ format: 'json', level: 'info' }));
|
|
114
|
+
*
|
|
115
|
+
* // Custom writer (e.g., for external logging service)
|
|
116
|
+
* server.use(logger({
|
|
117
|
+
* writer: (entry) => myLoggingService.log(entry)
|
|
118
|
+
* }));
|
|
119
|
+
*
|
|
120
|
+
* // Silent in production
|
|
121
|
+
* server.use(logger({ level: process.env.NODE_ENV === 'production' ? 'error' : 'debug' }));
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare function logger(options?: LoggerOptions): Middleware;
|
|
125
|
+
/**
|
|
126
|
+
* Security headers middleware
|
|
127
|
+
*/
|
|
128
|
+
declare function securityHeaders(options?: {
|
|
129
|
+
contentSecurityPolicy?: string | false;
|
|
130
|
+
xFrameOptions?: 'DENY' | 'SAMEORIGIN' | false;
|
|
131
|
+
xContentTypeOptions?: boolean;
|
|
132
|
+
referrerPolicy?: string;
|
|
133
|
+
permissionsPolicy?: string;
|
|
134
|
+
}): Middleware;
|
|
135
|
+
/**
|
|
136
|
+
* Compression middleware (requires implementation in adapter)
|
|
137
|
+
*/
|
|
138
|
+
declare function compress(): Middleware;
|
|
139
|
+
/**
|
|
140
|
+
* Create a middleware context from a Web Request
|
|
141
|
+
*/
|
|
142
|
+
declare function createContextFromRequest(request: Request, params?: Record<string, string | string[]>): MiddlewareContext;
|
|
143
|
+
/**
|
|
144
|
+
* Create a Web Response from middleware context
|
|
145
|
+
*/
|
|
146
|
+
declare function createResponseFromContext(ctx: MiddlewareContext): Response;
|
|
147
|
+
/**
|
|
148
|
+
* Compose multiple middleware into one
|
|
149
|
+
*/
|
|
150
|
+
declare function compose(...middlewares: Middleware[]): Middleware;
|
|
151
|
+
|
|
152
|
+
export { type LogEntry, type LogFormat, type LogLevel, type LogWriter, type LoggerOptions, type Middleware, type MiddlewareChain, type MiddlewareContext, type MiddlewareDefinition, type MiddlewareNext, compose, compress, cors, createContextFromRequest, createMiddlewareChain, createResponseFromContext, logger, securityHeaders };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flight Render Engine - Universal rendering primitives
|
|
3
|
+
*
|
|
4
|
+
* Supports SSR, SSG, CSR, and ISR - the user chooses per route.
|
|
5
|
+
*/
|
|
6
|
+
/** Rendering modes supported by Flight */
|
|
7
|
+
type RenderMode = 'ssr' | 'ssg' | 'csr' | 'isr';
|
|
8
|
+
/** Context passed to render functions */
|
|
9
|
+
interface RenderContext {
|
|
10
|
+
/** The URL being rendered */
|
|
11
|
+
url: URL;
|
|
12
|
+
/** Route parameters */
|
|
13
|
+
params: Record<string, string | string[]>;
|
|
14
|
+
/** Request headers (available in SSR/ISR) */
|
|
15
|
+
headers?: Headers;
|
|
16
|
+
/** Cookies (available in SSR/ISR) */
|
|
17
|
+
cookies?: Record<string, string>;
|
|
18
|
+
/** Request method */
|
|
19
|
+
method?: string;
|
|
20
|
+
/** Request body (for POST/PUT/etc) */
|
|
21
|
+
body?: unknown;
|
|
22
|
+
/** Custom context data */
|
|
23
|
+
locals?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** Result of a render operation */
|
|
26
|
+
interface RenderResult {
|
|
27
|
+
/** HTML content */
|
|
28
|
+
html: string;
|
|
29
|
+
/** HTTP status code */
|
|
30
|
+
status: number;
|
|
31
|
+
/** Response headers */
|
|
32
|
+
headers: Record<string, string>;
|
|
33
|
+
/** Head elements to inject */
|
|
34
|
+
head?: {
|
|
35
|
+
title?: string;
|
|
36
|
+
meta?: Array<{
|
|
37
|
+
name?: string;
|
|
38
|
+
property?: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}>;
|
|
41
|
+
links?: Array<{
|
|
42
|
+
rel: string;
|
|
43
|
+
href: string;
|
|
44
|
+
[key: string]: string;
|
|
45
|
+
}>;
|
|
46
|
+
scripts?: Array<{
|
|
47
|
+
src?: string;
|
|
48
|
+
content?: string;
|
|
49
|
+
type?: string;
|
|
50
|
+
}>;
|
|
51
|
+
styles?: Array<{
|
|
52
|
+
href?: string;
|
|
53
|
+
content?: string;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Configuration for SSG/ISR */
|
|
58
|
+
interface StaticRenderConfig {
|
|
59
|
+
/** Paths to pre-render */
|
|
60
|
+
paths: string[] | (() => Promise<string[]>);
|
|
61
|
+
/** Fallback behavior for non-pre-rendered paths */
|
|
62
|
+
fallback?: 'blocking' | 'prerender' | false;
|
|
63
|
+
}
|
|
64
|
+
/** Configuration for ISR */
|
|
65
|
+
interface ISRConfig extends StaticRenderConfig {
|
|
66
|
+
/** Revalidation time in seconds */
|
|
67
|
+
revalidate: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if a render mode requires server runtime
|
|
71
|
+
*/
|
|
72
|
+
declare function requiresServer(mode: RenderMode): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a render mode can be statically generated
|
|
75
|
+
*/
|
|
76
|
+
declare function canBeStatic(mode: RenderMode): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a render mode is purely client-side
|
|
79
|
+
*/
|
|
80
|
+
declare function isClientOnly(mode: RenderMode): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* UI Framework Integration Interface
|
|
83
|
+
*
|
|
84
|
+
* Each UI framework (React, Vue, Svelte, etc.) implements this interface
|
|
85
|
+
* to integrate with Flight's render engine.
|
|
86
|
+
*/
|
|
87
|
+
interface UIFrameworkAdapter<Component = unknown> {
|
|
88
|
+
/** Framework name */
|
|
89
|
+
name: string;
|
|
90
|
+
/**
|
|
91
|
+
* Render a component to HTML string (for SSR/SSG)
|
|
92
|
+
*/
|
|
93
|
+
renderToString(component: Component, context: RenderContext): Promise<RenderResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Render a component to a stream (for streaming SSR)
|
|
96
|
+
*/
|
|
97
|
+
renderToStream?(component: Component, context: RenderContext): Promise<ReadableStream<Uint8Array>>;
|
|
98
|
+
/**
|
|
99
|
+
* Generate client hydration script
|
|
100
|
+
*/
|
|
101
|
+
getHydrationScript?(component: Component): string;
|
|
102
|
+
/**
|
|
103
|
+
* File extensions this adapter handles
|
|
104
|
+
*/
|
|
105
|
+
extensions: string[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create a minimal HTML shell
|
|
109
|
+
*/
|
|
110
|
+
declare function createHTMLShell(options: {
|
|
111
|
+
head?: string;
|
|
112
|
+
body: string;
|
|
113
|
+
scripts?: string[];
|
|
114
|
+
styles?: string[];
|
|
115
|
+
htmlAttributes?: Record<string, string>;
|
|
116
|
+
bodyAttributes?: Record<string, string>;
|
|
117
|
+
}): string;
|
|
118
|
+
/**
|
|
119
|
+
* Escape HTML special characters
|
|
120
|
+
*/
|
|
121
|
+
declare function escapeHtml(str: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Create a CSR shell (minimal HTML that loads client bundle)
|
|
124
|
+
*/
|
|
125
|
+
declare function createCSRShell(options: {
|
|
126
|
+
title?: string;
|
|
127
|
+
entryScript: string;
|
|
128
|
+
rootId?: string;
|
|
129
|
+
}): RenderResult;
|
|
130
|
+
|
|
131
|
+
export { type ISRConfig, type RenderContext, type RenderMode, type RenderResult, type StaticRenderConfig, type UIFrameworkAdapter, canBeStatic, createCSRShell, createHTMLShell, escapeHtml, isClientOnly, requiresServer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flight Router - File-based routing with dynamic patterns
|
|
3
|
+
*/
|
|
4
|
+
interface RouteParams {
|
|
5
|
+
[key: string]: string | string[];
|
|
6
|
+
}
|
|
7
|
+
interface Route<T = unknown> {
|
|
8
|
+
/** Route path pattern (e.g., '/blog/[slug]', '/api/[...path]') */
|
|
9
|
+
path: string;
|
|
10
|
+
/** Handler or component for this route */
|
|
11
|
+
handler: T;
|
|
12
|
+
/** Rendering mode for this route */
|
|
13
|
+
mode?: 'ssr' | 'ssg' | 'csr' | 'isr';
|
|
14
|
+
/** Metadata for the route */
|
|
15
|
+
meta?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
interface RouteMatch<T = unknown> {
|
|
18
|
+
/** The matched route */
|
|
19
|
+
route: Route<T>;
|
|
20
|
+
/** Extracted parameters from the URL */
|
|
21
|
+
params: RouteParams;
|
|
22
|
+
/** The original path that was matched */
|
|
23
|
+
path: string;
|
|
24
|
+
}
|
|
25
|
+
interface Router<T = unknown> {
|
|
26
|
+
/** Add a route to the router */
|
|
27
|
+
add(route: Route<T>): void;
|
|
28
|
+
/** Add multiple routes */
|
|
29
|
+
addAll(routes: Route<T>[]): void;
|
|
30
|
+
/** Match a path against registered routes */
|
|
31
|
+
match(path: string): RouteMatch<T> | null;
|
|
32
|
+
/** Get all registered routes */
|
|
33
|
+
routes(): Route<T>[];
|
|
34
|
+
/** Remove a route by path */
|
|
35
|
+
remove(path: string): boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new Flight router instance
|
|
39
|
+
*/
|
|
40
|
+
declare function createRouter<T = unknown>(): Router<T>;
|
|
41
|
+
interface FileRoute {
|
|
42
|
+
/** File path relative to routes directory */
|
|
43
|
+
filePath: string;
|
|
44
|
+
/** Generated route path */
|
|
45
|
+
routePath: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Convert a file path to a route path
|
|
49
|
+
*
|
|
50
|
+
* Examples:
|
|
51
|
+
* - index.tsx -> /
|
|
52
|
+
* - about.tsx -> /about
|
|
53
|
+
* - blog/index.tsx -> /blog
|
|
54
|
+
* - blog/[slug].tsx -> /blog/[slug]
|
|
55
|
+
* - api/[...path].ts -> /api/[...path]
|
|
56
|
+
* - (group)/settings.tsx -> /settings (groups are ignored)
|
|
57
|
+
*/
|
|
58
|
+
declare function filePathToRoutePath(filePath: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Sort routes by specificity (most specific first)
|
|
61
|
+
* Static routes come before dynamic routes
|
|
62
|
+
*/
|
|
63
|
+
declare function sortRoutes<T>(routes: Route<T>[]): Route<T>[];
|
|
64
|
+
|
|
65
|
+
export { type FileRoute, type Route, type RouteMatch, type RouteParams, type Router, createRouter, filePathToRoutePath, sortRoutes };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flight/core - React Server Components Support
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic primitives for RSC-like patterns.
|
|
5
|
+
* Enables async server components, client/server boundaries, and data fetching.
|
|
6
|
+
*
|
|
7
|
+
* Best Practices 2025/2026:
|
|
8
|
+
* - Async components for server-side data fetching
|
|
9
|
+
* - 'use client' / 'use server' directive detection
|
|
10
|
+
* - Automatic component serialization
|
|
11
|
+
* - Props passing between server and client
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Component rendering context
|
|
15
|
+
*/
|
|
16
|
+
interface RenderContext {
|
|
17
|
+
/** Current request */
|
|
18
|
+
request: Request;
|
|
19
|
+
/** Route params */
|
|
20
|
+
params: Record<string, string>;
|
|
21
|
+
/** Search params */
|
|
22
|
+
searchParams: URLSearchParams;
|
|
23
|
+
/** Request headers */
|
|
24
|
+
headers: Headers;
|
|
25
|
+
/** Cookies */
|
|
26
|
+
cookies: Map<string, string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Server component definition
|
|
30
|
+
*/
|
|
31
|
+
interface ServerComponent<P = unknown> {
|
|
32
|
+
(props: P, context: RenderContext): Promise<string> | string;
|
|
33
|
+
/** Mark as server component */
|
|
34
|
+
__flight_server?: true;
|
|
35
|
+
/** Dependencies for hydration */
|
|
36
|
+
__flight_deps?: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Client component definition
|
|
40
|
+
*/
|
|
41
|
+
interface ClientComponent<P = unknown> {
|
|
42
|
+
(props: P): unknown;
|
|
43
|
+
/** Mark as client component */
|
|
44
|
+
__flight_client?: true;
|
|
45
|
+
/** Client bundle path */
|
|
46
|
+
__flight_bundle?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Component type detection
|
|
50
|
+
*/
|
|
51
|
+
type ComponentType = 'server' | 'client' | 'hybrid';
|
|
52
|
+
/**
|
|
53
|
+
* Check if a file has 'use client' directive
|
|
54
|
+
*/
|
|
55
|
+
declare function hasUseClientDirective(source: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a file has 'use server' directive
|
|
58
|
+
*/
|
|
59
|
+
declare function hasUseServerDirective(source: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Detect component type from source
|
|
62
|
+
*/
|
|
63
|
+
declare function detectComponentType(source: string): ComponentType;
|
|
64
|
+
/**
|
|
65
|
+
* Execute an async server component
|
|
66
|
+
*/
|
|
67
|
+
declare function executeServerComponent<P>(component: ServerComponent<P>, props: P, context: RenderContext): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a render context from a Request
|
|
70
|
+
*/
|
|
71
|
+
declare function createRenderContext(request: Request, params?: Record<string, string>): RenderContext;
|
|
72
|
+
/**
|
|
73
|
+
* Server-side fetch with automatic caching (like Next.js fetch extensions)
|
|
74
|
+
*/
|
|
75
|
+
declare function serverFetch<T>(url: string, options?: RequestInit & {
|
|
76
|
+
revalidate?: number | false;
|
|
77
|
+
tags?: string[];
|
|
78
|
+
}): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Invalidate cache by tag
|
|
81
|
+
*/
|
|
82
|
+
declare function revalidateTag(tag: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Invalidate cache by path
|
|
85
|
+
*/
|
|
86
|
+
declare function revalidatePath(path: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Serialize props for transmission to client
|
|
89
|
+
*/
|
|
90
|
+
declare function serializeProps(props: unknown): string;
|
|
91
|
+
/**
|
|
92
|
+
* Deserialize props on client
|
|
93
|
+
*/
|
|
94
|
+
declare function deserializeProps<T>(serialized: string): T;
|
|
95
|
+
/**
|
|
96
|
+
* Create a client boundary placeholder
|
|
97
|
+
*/
|
|
98
|
+
declare function createClientBoundary(componentId: string, props: unknown, fallback?: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Helper to create an async server component
|
|
101
|
+
*/
|
|
102
|
+
declare function createAsyncComponent<P, T>(fetcher: (props: P, context: RenderContext) => Promise<T>, renderer: (data: T, props: P) => string): ServerComponent<P>;
|
|
103
|
+
/**
|
|
104
|
+
* Compose multiple server components
|
|
105
|
+
*/
|
|
106
|
+
declare function composeComponents(...components: Array<() => Promise<string> | string>): () => Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Wrap a server component with error handling
|
|
109
|
+
*/
|
|
110
|
+
declare function withErrorBoundary<P>(component: ServerComponent<P>, errorFallback: (error: Error) => string): ServerComponent<P>;
|
|
111
|
+
/**
|
|
112
|
+
* Throw a not found error (like Next.js notFound())
|
|
113
|
+
*/
|
|
114
|
+
declare function notFound(): never;
|
|
115
|
+
/**
|
|
116
|
+
* Check if error is not found
|
|
117
|
+
*/
|
|
118
|
+
declare function isNotFoundError(error: unknown): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Server-side redirect (like Next.js redirect())
|
|
121
|
+
*/
|
|
122
|
+
declare function redirect(url: string, type?: 'replace' | 'push'): never;
|
|
123
|
+
/**
|
|
124
|
+
* Check if error is redirect
|
|
125
|
+
*/
|
|
126
|
+
declare function isRedirectError(error: unknown): {
|
|
127
|
+
url: string;
|
|
128
|
+
type: string;
|
|
129
|
+
} | null;
|
|
130
|
+
|
|
131
|
+
export { type ClientComponent, type ComponentType, type RenderContext, type ServerComponent, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError, notFound, redirect, revalidatePath, revalidateTag, serializeProps, serverFetch, withErrorBoundary } from '../chunk-AFSKXC6V.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|