@flexireact/core 4.0.0 → 4.1.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.
@@ -0,0 +1,1978 @@
1
+ import React, { ReactNode } from 'react';
2
+ export { useActionState, useOptimistic } from 'react';
3
+ export { defaultConfig, loadConfig, resolvePaths } from './config.js';
4
+ import * as http from 'http';
5
+ import createServer from './server/index.js';
6
+ export { BuildMode, build, buildDev } from './build/index.js';
7
+ export { useFormStatus } from 'react-dom';
8
+ import 'zod';
9
+ import 'esbuild';
10
+
11
+ /**
12
+ * FlexiReact Core Types
13
+ */
14
+
15
+ interface FlexiConfig {
16
+ /** Stylesheets to include */
17
+ styles?: string[];
18
+ /** Favicon path */
19
+ favicon?: string;
20
+ /** Server configuration */
21
+ server?: {
22
+ port?: number;
23
+ host?: string;
24
+ };
25
+ /** Islands configuration */
26
+ islands?: {
27
+ enabled?: boolean;
28
+ };
29
+ /** Routing configuration */
30
+ routing?: {
31
+ type?: 'flexi' | 'app' | 'pages';
32
+ };
33
+ /** Pages directory */
34
+ pagesDir?: string;
35
+ /** Layouts directory */
36
+ layoutsDir?: string;
37
+ /** Public directory */
38
+ publicDir?: string;
39
+ }
40
+ type RouteType$1 = 'page' | 'api' | 'layout' | 'loading' | 'error' | 'not-found';
41
+ interface Route {
42
+ type: RouteType$1;
43
+ path: string;
44
+ filePath: string;
45
+ pattern: RegExp;
46
+ segments: string[];
47
+ layout?: string | null;
48
+ loading?: string | null;
49
+ error?: string | null;
50
+ notFound?: string | null;
51
+ template?: string | null;
52
+ isAppRouter?: boolean;
53
+ isFlexiRouter?: boolean;
54
+ isServerComponent?: boolean;
55
+ isClientComponent?: boolean;
56
+ isIsland?: boolean;
57
+ params?: Record<string, string>;
58
+ }
59
+ interface PageProps {
60
+ params?: Record<string, string>;
61
+ searchParams?: Record<string, string>;
62
+ }
63
+ interface LayoutProps {
64
+ children: ReactNode;
65
+ params?: Record<string, string>;
66
+ }
67
+
68
+ /**
69
+ * Creates a request context value
70
+ */
71
+ declare function createRequestContext(req: http.IncomingMessage, res: http.ServerResponse, params?: Record<string, string>, query?: Record<string, string>): {
72
+ req: http.IncomingMessage;
73
+ res: http.ServerResponse<http.IncomingMessage>;
74
+ params: Record<string, string>;
75
+ query: Record<string, string>;
76
+ url: string | undefined;
77
+ method: string | undefined;
78
+ headers: http.IncomingHttpHeaders;
79
+ cookies: Record<string, string>;
80
+ };
81
+ /**
82
+ * Hook to access request context (server-side only)
83
+ */
84
+ declare function useRequest(): any;
85
+ /**
86
+ * Hook to access route params
87
+ */
88
+ declare function useParams(): Record<string, string>;
89
+ /**
90
+ * Hook to access query parameters
91
+ */
92
+ declare function useQuery(): Record<string, string>;
93
+ /**
94
+ * Hook to access current pathname
95
+ */
96
+ declare function usePathname(): string;
97
+
98
+ /**
99
+ * FlexiReact Utility Functions
100
+ */
101
+ /**
102
+ * Generates a unique hash for cache busting
103
+ */
104
+ declare function generateHash(content: string): string;
105
+ /**
106
+ * Escapes HTML special characters
107
+ */
108
+ declare function escapeHtml(str: string): string;
109
+ /**
110
+ * Recursively finds all files matching a pattern
111
+ */
112
+ declare function findFiles(dir: string, pattern: RegExp, files?: string[]): string[];
113
+ /**
114
+ * Ensures a directory exists
115
+ */
116
+ declare function ensureDir(dir: string): void;
117
+ /**
118
+ * Cleans a directory
119
+ */
120
+ declare function cleanDir(dir: string): void;
121
+ /**
122
+ * Copies a directory recursively
123
+ */
124
+ declare function copyDir(src: string, dest: string): void;
125
+ /**
126
+ * Debounce function for file watching
127
+ */
128
+ declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
129
+ /**
130
+ * Formats bytes to human readable string
131
+ */
132
+ declare function formatBytes(bytes: number): string;
133
+ /**
134
+ * Formats milliseconds to human readable string
135
+ */
136
+ declare function formatTime(ms: number): string;
137
+ /**
138
+ * Creates a deferred promise
139
+ */
140
+ declare function createDeferred(): {
141
+ promise: Promise<unknown>;
142
+ resolve: any;
143
+ reject: any;
144
+ };
145
+ /**
146
+ * Sleep utility
147
+ */
148
+ declare function sleep(ms: number): Promise<void>;
149
+ /**
150
+ * Check if a file is a server component (has 'use server' directive)
151
+ */
152
+ declare function isServerComponent(filePath: string): boolean;
153
+ /**
154
+ * Check if a file is a client component (has 'use client' directive)
155
+ */
156
+ declare function isClientComponent(filePath: string): boolean;
157
+ /**
158
+ * Check if a component is an island (has 'use island' directive)
159
+ */
160
+ declare function isIsland(filePath: string): boolean;
161
+
162
+ /**
163
+ * FlexiReact Router v2
164
+ * Advanced file-based routing with nested routes, loading, and error boundaries
165
+ *
166
+ * Supports multiple routing conventions:
167
+ * - pages/ : Traditional file-based routing (index.tsx, about.tsx)
168
+ * - app/ : Next.js style App Router (page.tsx, layout.tsx)
169
+ * - routes/ : FlexiReact v4 routes directory (home.tsx → /, [slug].tsx → /:slug)
170
+ */
171
+ /**
172
+ * Route types
173
+ */
174
+ declare const RouteType: {
175
+ PAGE: string;
176
+ API: string;
177
+ LAYOUT: string;
178
+ LOADING: string;
179
+ ERROR: string;
180
+ NOT_FOUND: string;
181
+ };
182
+ /**
183
+ * Builds the complete route tree from all routing directories
184
+ */
185
+ declare function buildRouteTree(pagesDir: string, layoutsDir: string, appDir?: string | null, routesDir?: string | null): {
186
+ pages: any[];
187
+ api: any[];
188
+ layouts: Map<any, any>;
189
+ tree: Record<string, any>;
190
+ appRoutes: any[];
191
+ flexiRoutes: any[];
192
+ rootLayout?: string;
193
+ };
194
+ /**
195
+ * Matches URL path against routes
196
+ */
197
+ declare function matchRoute(urlPath: string, routes: any[]): any;
198
+ /**
199
+ * Finds all layouts that apply to a route
200
+ */
201
+ declare function findRouteLayouts(route: any, layoutsMap: Map<string, string>): Array<{
202
+ name: string;
203
+ filePath: string | undefined;
204
+ }>;
205
+
206
+ /**
207
+ * FlexiReact Render System v2
208
+ * SSR with layouts, loading states, error boundaries, and islands
209
+ */
210
+
211
+ /**
212
+ * Renders a page with all its layouts and wrappers
213
+ */
214
+ declare function renderPage(options: any): Promise<string>;
215
+ /**
216
+ * Streaming SSR with React 18
217
+ * Renders the page progressively, sending HTML chunks as they become ready
218
+ */
219
+ declare function renderPageStream(options: {
220
+ Component: React.ComponentType<any>;
221
+ props?: Record<string, any>;
222
+ layouts?: Array<{
223
+ Component: React.ComponentType<any>;
224
+ props?: Record<string, any>;
225
+ }>;
226
+ loading?: React.ComponentType | null;
227
+ error?: React.ComponentType<{
228
+ error: Error;
229
+ }> | null;
230
+ title?: string;
231
+ meta?: Record<string, string>;
232
+ scripts?: Array<string | {
233
+ src?: string;
234
+ content?: string;
235
+ type?: string;
236
+ }>;
237
+ styles?: Array<string | {
238
+ content: string;
239
+ }>;
240
+ favicon?: string | null;
241
+ route?: string;
242
+ onShellReady?: () => void;
243
+ onAllReady?: () => void;
244
+ onError?: (error: Error) => void;
245
+ }): Promise<{
246
+ stream: NodeJS.ReadableStream;
247
+ shellReady: Promise<void>;
248
+ }>;
249
+ /**
250
+ * Render to stream for HTTP response
251
+ * Use this in the server to stream HTML to the client
252
+ */
253
+ declare function streamToResponse(res: {
254
+ write: (chunk: string) => void;
255
+ end: () => void;
256
+ }, stream: NodeJS.ReadableStream, options?: {
257
+ onFinish?: () => void;
258
+ }): void;
259
+ /**
260
+ * Renders an error page with beautiful styling (FlexiReact v4)
261
+ */
262
+ declare function renderError(statusCode: number, message: string, stack?: string | null): string;
263
+ /**
264
+ * Renders a loading state
265
+ */
266
+ declare function renderLoading(LoadingComponent: React.ComponentType | null): string;
267
+
268
+ /**
269
+ * FlexiReact Static Site Generation (SSG)
270
+ *
271
+ * SSG pre-renders pages at build time, generating static HTML files.
272
+ * This provides the fastest possible page loads and enables CDN caching.
273
+ *
274
+ * Usage:
275
+ * - Export getStaticProps() from a page to fetch data at build time
276
+ * - Export getStaticPaths() for dynamic routes to specify which paths to pre-render
277
+ * - Pages without these exports are rendered as static HTML
278
+ */
279
+ /**
280
+ * SSG Build Result
281
+ */
282
+ interface SSGPage {
283
+ path: string;
284
+ file: string;
285
+ size: number;
286
+ }
287
+ interface SSGError {
288
+ path: string;
289
+ error: string;
290
+ }
291
+ declare class SSGResult {
292
+ pages: SSGPage[];
293
+ errors: SSGError[];
294
+ duration: number;
295
+ constructor();
296
+ addPage(pagePath: string, file: string, size: number): void;
297
+ addError(pagePath: string, error: Error): void;
298
+ get success(): boolean;
299
+ get totalSize(): number;
300
+ }
301
+ /**
302
+ * Generates static pages for all routes
303
+ */
304
+ declare function generateStaticSite(options: any): Promise<SSGResult>;
305
+ /**
306
+ * Incremental Static Regeneration (ISR) support
307
+ * Allows pages to be regenerated after a specified interval
308
+ */
309
+ interface ISRCacheEntry {
310
+ html: string;
311
+ generatedAt: number;
312
+ revalidateAfter: number | null;
313
+ }
314
+ declare class ISRManager {
315
+ cache: Map<string, ISRCacheEntry>;
316
+ revalidating: Set<string>;
317
+ defaultRevalidate: number;
318
+ constructor(options?: {
319
+ defaultRevalidate?: number;
320
+ });
321
+ /**
322
+ * Gets a cached page or regenerates it
323
+ */
324
+ getPage(routePath: string, generator: () => Promise<{
325
+ html: string;
326
+ revalidate?: number;
327
+ }>): Promise<string>;
328
+ /**
329
+ * Revalidates a page in the background
330
+ */
331
+ revalidateInBackground(routePath: string, generator: () => Promise<{
332
+ html: string;
333
+ revalidate?: number;
334
+ }>): Promise<void>;
335
+ /**
336
+ * Invalidates a cached page
337
+ */
338
+ invalidate(routePath: string): void;
339
+ /**
340
+ * Clears all cached pages
341
+ */
342
+ clear(): void;
343
+ }
344
+
345
+ /**
346
+ * FlexiReact React Server Components (RSC) System
347
+ *
348
+ * RSC allows components to run exclusively on the server, reducing client bundle size
349
+ * and enabling direct database/filesystem access in components.
350
+ *
351
+ * Usage:
352
+ * - Add 'use server' at the top of a component file to make it a Server Component
353
+ * - Add 'use client' at the top to make it a Client Component (hydrated on client)
354
+ * - Server Components can import Client Components, but not vice versa
355
+ */
356
+
357
+ /**
358
+ * RSC Payload format for streaming
359
+ */
360
+ declare const RSC_CONTENT_TYPE = "text/x-component";
361
+ /**
362
+ * Processes a component tree for RSC
363
+ * Server components are rendered to HTML, client components are serialized
364
+ */
365
+ declare function processServerComponent(Component: any, props: any, context: any): Promise<{
366
+ isServer: boolean;
367
+ rendered: string | null;
368
+ clientComponents: any[];
369
+ serverData: Record<string, any>;
370
+ }>;
371
+ /**
372
+ * Creates a client component reference for RSC payload
373
+ */
374
+ declare function createClientReference(componentPath: string, props: any): {
375
+ $$typeof: symbol;
376
+ $$id: string;
377
+ $$props: any;
378
+ };
379
+ /**
380
+ * Serializes RSC payload for streaming
381
+ */
382
+ declare function serializeRSCPayload(componentTree: any): string;
383
+ /**
384
+ * Server Actions support
385
+ * Allows calling server functions from client components
386
+ */
387
+ declare function createServerAction(fn: any, actionId: string): any;
388
+ /**
389
+ * Handles server action invocation
390
+ */
391
+ declare function handleServerAction(actionId: string, args: any[], context: any): Promise<any>;
392
+ /**
393
+ * RSC Boundary component
394
+ * Marks the boundary between server and client rendering
395
+ */
396
+ declare function ServerBoundary({ children, fallback }: {
397
+ children: React.ReactNode;
398
+ fallback?: React.ReactNode;
399
+ }): React.ReactNode;
400
+ /**
401
+ * Client Boundary component
402
+ * Marks components that should be hydrated on the client
403
+ */
404
+ declare function ClientBoundary({ children, fallback }: {
405
+ children: React.ReactNode;
406
+ fallback?: React.ReactNode;
407
+ }): React.DetailedReactHTMLElement<{
408
+ 'data-flexi-client': string;
409
+ children: React.ReactNode;
410
+ }, HTMLElement>;
411
+
412
+ /**
413
+ * FlexiReact Islands Architecture
414
+ *
415
+ * Islands allow partial hydration - only interactive components are hydrated on the client,
416
+ * while static content remains as HTML. This dramatically reduces JavaScript bundle size.
417
+ *
418
+ * Usage:
419
+ * - Add 'use island' at the top of a component file
420
+ * - The component will be rendered on server and hydrated on client
421
+ * - Non-island components are pure HTML (no JS)
422
+ */
423
+
424
+ /**
425
+ * Island wrapper component for server-side rendering
426
+ * Islands render a placeholder on the server and hydrate on the client
427
+ */
428
+ declare function Island({ component: Component, props, name, clientPath }: {
429
+ component: React.ComponentType<any>;
430
+ props?: any;
431
+ name: string;
432
+ clientPath: string;
433
+ }): React.DetailedReactHTMLElement<{
434
+ 'data-island': string;
435
+ 'data-island-name': string;
436
+ 'data-island-props': string;
437
+ dangerouslySetInnerHTML: {
438
+ __html: string;
439
+ };
440
+ }, HTMLElement>;
441
+ /**
442
+ * Gets all registered islands and clears the registry
443
+ */
444
+ declare function getRegisteredIslands(): any[];
445
+ /**
446
+ * Creates an island component wrapper
447
+ */
448
+ interface IslandOptions {
449
+ name?: string;
450
+ clientPath?: string;
451
+ }
452
+ declare function createIsland(Component: React.ComponentType<any>, options?: IslandOptions): {
453
+ (props: any): React.DetailedReactHTMLElement<{
454
+ 'data-island': string;
455
+ 'data-island-name': string;
456
+ 'data-island-props': string;
457
+ dangerouslySetInnerHTML: {
458
+ __html: string;
459
+ };
460
+ }, HTMLElement>;
461
+ displayName: string;
462
+ isIsland: boolean;
463
+ originalComponent: React.ComponentType<any>;
464
+ };
465
+ /**
466
+ * Generates the client-side hydration script
467
+ */
468
+ declare function generateHydrationScript(islands: any[]): string;
469
+ /**
470
+ * Island loading strategies
471
+ */
472
+ declare const LoadStrategy: {
473
+ IMMEDIATE: string;
474
+ VISIBLE: string;
475
+ IDLE: string;
476
+ MEDIA: string;
477
+ };
478
+ /**
479
+ * Creates a lazy island that hydrates based on strategy
480
+ */
481
+ interface LazyIslandOptions {
482
+ name?: string;
483
+ clientPath?: string;
484
+ strategy?: string;
485
+ media?: string | null;
486
+ }
487
+ declare function createLazyIsland(Component: React.ComponentType<any>, options?: LazyIslandOptions): {
488
+ (props: any): React.DetailedReactHTMLElement<{
489
+ 'data-island': string;
490
+ 'data-island-name': any;
491
+ 'data-island-strategy': string;
492
+ 'data-island-media': string | null;
493
+ 'data-island-props': string;
494
+ dangerouslySetInnerHTML: {
495
+ __html: string;
496
+ };
497
+ }, HTMLElement>;
498
+ displayName: string;
499
+ isIsland: boolean;
500
+ isLazy: boolean;
501
+ };
502
+ /**
503
+ * Generates advanced hydration script with loading strategies
504
+ */
505
+ declare function generateAdvancedHydrationScript(islands: any[]): string;
506
+
507
+ /**
508
+ * FlexiReact Middleware System
509
+ *
510
+ * Middlewares run before every request and can:
511
+ * - Modify the request/response
512
+ * - Redirect or rewrite URLs
513
+ * - Add headers
514
+ * - Authenticate users
515
+ * - Log requests
516
+ *
517
+ * Usage:
518
+ * Create a middleware.js file in your project root:
519
+ *
520
+ * export default function middleware(request) {
521
+ * // Return a response to short-circuit
522
+ * // Return NextResponse.next() to continue
523
+ * // Return NextResponse.redirect() to redirect
524
+ * }
525
+ *
526
+ * export const config = {
527
+ * matcher: ['/protected/:path*']
528
+ * };
529
+ */
530
+ /**
531
+ * Middleware response helpers
532
+ */
533
+ interface MiddlewareResponseOptions {
534
+ type?: string;
535
+ status?: number;
536
+ headers?: Record<string, string>;
537
+ body?: any;
538
+ url?: string | null;
539
+ }
540
+ declare class MiddlewareResponse {
541
+ type: string;
542
+ status: number;
543
+ headers: Map<string, string>;
544
+ body: any;
545
+ url: string | null;
546
+ constructor(options?: MiddlewareResponseOptions);
547
+ /**
548
+ * Continue to the next middleware/handler
549
+ */
550
+ static next(options?: {}): MiddlewareResponse;
551
+ /**
552
+ * Redirect to a different URL
553
+ */
554
+ static redirect(url: string, status?: number): MiddlewareResponse;
555
+ /**
556
+ * Rewrite the request to a different URL (internal)
557
+ */
558
+ static rewrite(url: string): MiddlewareResponse;
559
+ /**
560
+ * Return a JSON response
561
+ */
562
+ static json(data: any, options?: {
563
+ status?: number;
564
+ headers?: Record<string, string>;
565
+ }): MiddlewareResponse;
566
+ /**
567
+ * Return an HTML response
568
+ */
569
+ static html(content: string, options?: {
570
+ status?: number;
571
+ headers?: Record<string, string>;
572
+ }): MiddlewareResponse;
573
+ }
574
+ /**
575
+ * Middleware request wrapper
576
+ */
577
+ declare class MiddlewareRequest {
578
+ raw: any;
579
+ method: string;
580
+ url: string;
581
+ headers: Map<string, string>;
582
+ pathname: string;
583
+ searchParams: URLSearchParams;
584
+ query: Record<string, string>;
585
+ cookies: Map<string, string>;
586
+ constructor(req: any);
587
+ _parseCookies(cookieHeader: string): Map<string, string>;
588
+ /**
589
+ * Get a header value
590
+ */
591
+ header(name: string): string | undefined;
592
+ /**
593
+ * Get a cookie value
594
+ */
595
+ cookie(name: string): string | undefined;
596
+ /**
597
+ * Check if request matches a path pattern
598
+ */
599
+ matches(pattern: string): boolean;
600
+ }
601
+ /**
602
+ * Loads middleware from project
603
+ */
604
+ declare function loadMiddleware(projectRoot: string): Promise<{
605
+ handler: any;
606
+ config: any;
607
+ } | null>;
608
+ /**
609
+ * Runs middleware chain
610
+ */
611
+ declare function runMiddleware(req: any, res: any, middleware: any): Promise<{
612
+ continue: boolean;
613
+ rewritten?: undefined;
614
+ error?: undefined;
615
+ } | {
616
+ continue: boolean;
617
+ rewritten: boolean;
618
+ error?: undefined;
619
+ } | {
620
+ continue: boolean;
621
+ error: unknown;
622
+ rewritten?: undefined;
623
+ }>;
624
+ /**
625
+ * Compose multiple middleware functions
626
+ */
627
+ declare function composeMiddleware(...middlewares: Array<(request: MiddlewareRequest) => Promise<MiddlewareResponse | null>>): (request: MiddlewareRequest) => Promise<MiddlewareResponse>;
628
+ /**
629
+ * Built-in middleware helpers
630
+ */
631
+ declare const middlewares: {
632
+ /**
633
+ * CORS middleware
634
+ */
635
+ cors(options?: {
636
+ origin?: string;
637
+ methods?: string;
638
+ headers?: string;
639
+ credentials?: boolean;
640
+ }): (request: MiddlewareRequest) => MiddlewareResponse;
641
+ /**
642
+ * Basic auth middleware
643
+ */
644
+ basicAuth(options: {
645
+ username: string;
646
+ password: string;
647
+ realm?: string;
648
+ }): (request: MiddlewareRequest) => MiddlewareResponse;
649
+ /**
650
+ * Rate limiting middleware
651
+ */
652
+ rateLimit(options?: {
653
+ windowMs?: number;
654
+ max?: number;
655
+ }): (request: MiddlewareRequest) => MiddlewareResponse;
656
+ /**
657
+ * Logging middleware
658
+ */
659
+ logger(options?: {
660
+ format?: string;
661
+ }): (request: MiddlewareRequest) => MiddlewareResponse;
662
+ };
663
+
664
+ /**
665
+ * FlexiReact Plugin System
666
+ *
667
+ * Plugins can extend FlexiReact's functionality by hooking into various lifecycle events.
668
+ *
669
+ * Usage:
670
+ * Create a flexireact.plugin.js file:
671
+ *
672
+ * export default {
673
+ * name: 'my-plugin',
674
+ *
675
+ * // Called when the server starts
676
+ * onServerStart(server) {},
677
+ *
678
+ * // Called before each request
679
+ * onRequest(req, res) {},
680
+ *
681
+ * // Called before rendering a page
682
+ * onBeforeRender(page, props) {},
683
+ *
684
+ * // Called after rendering a page
685
+ * onAfterRender(html, page) {},
686
+ *
687
+ * // Called during build
688
+ * onBuild(config) {},
689
+ *
690
+ * // Modify esbuild config
691
+ * esbuildConfig(config) {},
692
+ * };
693
+ */
694
+ /**
695
+ * Plugin lifecycle hooks
696
+ */
697
+ declare const PluginHooks: {
698
+ SERVER_START: string;
699
+ SERVER_STOP: string;
700
+ REQUEST: string;
701
+ RESPONSE: string;
702
+ BEFORE_RENDER: string;
703
+ AFTER_RENDER: string;
704
+ BUILD_START: string;
705
+ BUILD_END: string;
706
+ ROUTES_LOADED: string;
707
+ CONFIG: string;
708
+ ESBUILD_CONFIG: string;
709
+ };
710
+ /**
711
+ * Plugin manager class
712
+ */
713
+ declare class PluginManager {
714
+ plugins: any[];
715
+ hooks: Map<string, any[]>;
716
+ constructor();
717
+ /**
718
+ * Registers a plugin
719
+ */
720
+ register(plugin: any): void;
721
+ /**
722
+ * Unregisters a plugin
723
+ */
724
+ unregister(pluginName: any): void;
725
+ /**
726
+ * Runs a hook with all registered handlers
727
+ */
728
+ runHook(hookName: string, ...args: unknown[]): Promise<Array<{
729
+ plugin: string;
730
+ result?: unknown;
731
+ error?: unknown;
732
+ }>>;
733
+ /**
734
+ * Runs a hook that can modify a value (waterfall)
735
+ */
736
+ runWaterfallHook(hookName: any, initialValue: any, ...args: any[]): Promise<any>;
737
+ /**
738
+ * Checks if any plugin handles a hook
739
+ */
740
+ hasHook(hookName: any): boolean;
741
+ /**
742
+ * Gets all registered plugins
743
+ */
744
+ getPlugins(): any[];
745
+ }
746
+ declare const pluginManager: PluginManager;
747
+ /**
748
+ * Loads plugins from project and config
749
+ */
750
+ declare function loadPlugins(projectRoot: any, config: any): Promise<PluginManager>;
751
+ /**
752
+ * Creates a plugin
753
+ */
754
+ declare function definePlugin(options: any): any;
755
+ /**
756
+ * Built-in plugins
757
+ */
758
+ declare const builtinPlugins: {
759
+ /**
760
+ * Analytics plugin
761
+ */
762
+ analytics(options?: {
763
+ trackingId?: string;
764
+ }): any;
765
+ /**
766
+ * PWA plugin
767
+ */
768
+ pwa(options?: {
769
+ manifest?: string;
770
+ serviceWorker?: string;
771
+ }): any;
772
+ /**
773
+ * SEO plugin
774
+ */
775
+ seo(options?: {
776
+ defaultTitle?: string;
777
+ titleTemplate?: string;
778
+ defaultDescription?: string;
779
+ }): any;
780
+ /**
781
+ * Compression plugin (for production)
782
+ */
783
+ compression(): any;
784
+ /**
785
+ * Security headers plugin
786
+ */
787
+ securityHeaders(options?: {
788
+ headers?: Record<string, string>;
789
+ }): any;
790
+ };
791
+
792
+ /**
793
+ * FlexiReact Universal Edge Runtime
794
+ *
795
+ * Works on:
796
+ * - Node.js
797
+ * - Bun
798
+ * - Deno
799
+ * - Cloudflare Workers
800
+ * - Vercel Edge
801
+ * - Any Web-standard runtime
802
+ */
803
+ type RuntimeEnvironment = 'node' | 'bun' | 'deno' | 'cloudflare' | 'vercel-edge' | 'netlify-edge' | 'fastly' | 'unknown';
804
+ declare function detectRuntime(): RuntimeEnvironment;
805
+ interface RuntimeCapabilities {
806
+ hasFileSystem: boolean;
807
+ hasWebCrypto: boolean;
808
+ hasWebStreams: boolean;
809
+ hasFetch: boolean;
810
+ hasWebSocket: boolean;
811
+ hasKV: boolean;
812
+ hasCache: boolean;
813
+ maxExecutionTime: number;
814
+ maxMemory: number;
815
+ }
816
+ declare function getRuntimeCapabilities(): RuntimeCapabilities;
817
+ declare const runtime: {
818
+ name: RuntimeEnvironment;
819
+ capabilities: RuntimeCapabilities;
820
+ readonly isEdge: boolean;
821
+ readonly isServer: boolean;
822
+ readonly supportsStreaming: boolean;
823
+ };
824
+
825
+ /**
826
+ * Fetch API Polyfill for Universal Compatibility
827
+ *
828
+ * Ensures Request, Response, Headers work everywhere
829
+ */
830
+ declare const GlobalRequest: {
831
+ new (input: RequestInfo | URL, init?: RequestInit): Request;
832
+ prototype: Request;
833
+ };
834
+ declare const GlobalResponse: {
835
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
836
+ prototype: Response;
837
+ error(): Response;
838
+ json(data: any, init?: ResponseInit): Response;
839
+ redirect(url: string | URL, status?: number): Response;
840
+ };
841
+ declare const GlobalHeaders: {
842
+ new (init?: HeadersInit): Headers;
843
+ prototype: Headers;
844
+ };
845
+ declare class FlexiRequest extends GlobalRequest {
846
+ private _parsedUrl?;
847
+ private _cookies?;
848
+ constructor(input: RequestInfo | URL, init?: RequestInit);
849
+ get pathname(): string;
850
+ get searchParams(): URLSearchParams;
851
+ get cookies(): Map<string, string>;
852
+ cookie(name: string): string | undefined;
853
+ jsonBody<T = any>(): Promise<T>;
854
+ formBody(): Promise<FormData>;
855
+ query(name: string): string | null;
856
+ queryAll(name: string): string[];
857
+ }
858
+ declare class FlexiResponse extends GlobalResponse {
859
+ static json(data: any, init?: ResponseInit): FlexiResponse;
860
+ static html(html: string, init?: ResponseInit): FlexiResponse;
861
+ static text(text: string, init?: ResponseInit): FlexiResponse;
862
+ static redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): FlexiResponse;
863
+ static notFound(message?: string): FlexiResponse;
864
+ static error(message?: string, status?: number): FlexiResponse;
865
+ static stream(stream: ReadableStream, init?: ResponseInit): FlexiResponse;
866
+ withCookie(name: string, value: string, options?: {
867
+ maxAge?: number;
868
+ expires?: Date;
869
+ path?: string;
870
+ domain?: string;
871
+ secure?: boolean;
872
+ httpOnly?: boolean;
873
+ sameSite?: 'Strict' | 'Lax' | 'None';
874
+ }): FlexiResponse;
875
+ withHeaders(newHeaders: Record<string, string>): FlexiResponse;
876
+ }
877
+ declare class FlexiHeaders extends GlobalHeaders {
878
+ getBearerToken(): string | null;
879
+ getBasicAuth(): {
880
+ username: string;
881
+ password: string;
882
+ } | null;
883
+ isJson(): boolean;
884
+ isFormData(): boolean;
885
+ isHtml(): boolean;
886
+ }
887
+
888
+ /**
889
+ * FlexiReact Universal Cache System
890
+ *
891
+ * Smart caching that works on:
892
+ * - Cloudflare Workers (Cache API + KV)
893
+ * - Vercel Edge (Edge Config + KV)
894
+ * - Deno (Deno KV)
895
+ * - Node.js/Bun (In-memory + File cache)
896
+ */
897
+ interface CacheEntry<T = any> {
898
+ value: T;
899
+ expires: number;
900
+ stale?: number;
901
+ tags?: string[];
902
+ etag?: string;
903
+ }
904
+ interface CacheOptions {
905
+ ttl?: number;
906
+ staleWhileRevalidate?: number;
907
+ tags?: string[];
908
+ key?: string;
909
+ revalidate?: number | false;
910
+ }
911
+ declare function initCache(options?: {
912
+ kv?: any;
913
+ }): void;
914
+ declare function cacheFunction<T extends (...args: any[]) => Promise<any>>(fn: T, options?: CacheOptions): T;
915
+ declare function unstable_cache<T extends (...args: any[]) => Promise<any>>(fn: T, keyParts?: string[], options?: {
916
+ revalidate?: number | false;
917
+ tags?: string[];
918
+ }): T;
919
+ declare function revalidateTag(tag: string): Promise<void>;
920
+ declare function revalidatePath(path: string): Promise<void>;
921
+ declare const cache: {
922
+ get: <T>(key: string) => Promise<CacheEntry<T> | null>;
923
+ set: <T>(key: string, value: T, options?: CacheOptions) => Promise<void>;
924
+ delete: (key: string) => Promise<void>;
925
+ deleteByTag: (tag: string) => Promise<void>;
926
+ clear: () => Promise<void>;
927
+ wrap: typeof cacheFunction;
928
+ unstable_cache: typeof unstable_cache;
929
+ revalidateTag: typeof revalidateTag;
930
+ revalidatePath: typeof revalidatePath;
931
+ };
932
+ declare function reactCache<T extends (...args: any[]) => any>(fn: T): T;
933
+
934
+ /**
935
+ * FlexiReact Universal Edge Handler
936
+ *
937
+ * Single handler that works on all platforms:
938
+ * - Node.js (http.createServer)
939
+ * - Bun (Bun.serve)
940
+ * - Deno (Deno.serve)
941
+ * - Cloudflare Workers (fetch handler)
942
+ * - Vercel Edge (edge function)
943
+ */
944
+
945
+ interface EdgeContext {
946
+ runtime: typeof runtime;
947
+ cache: typeof cache;
948
+ env: Record<string, string | undefined>;
949
+ waitUntil: (promise: Promise<any>) => void;
950
+ passThroughOnException?: () => void;
951
+ }
952
+ type EdgeHandler = (request: FlexiRequest, context: EdgeContext) => Promise<FlexiResponse> | FlexiResponse;
953
+ type EdgeMiddleware = (request: FlexiRequest, context: EdgeContext, next: () => Promise<FlexiResponse>) => Promise<FlexiResponse> | FlexiResponse;
954
+ interface EdgeAppConfig {
955
+ routes?: Map<string, EdgeHandler>;
956
+ middleware?: EdgeMiddleware[];
957
+ notFound?: EdgeHandler;
958
+ onError?: (error: Error, request: FlexiRequest) => FlexiResponse;
959
+ basePath?: string;
960
+ }
961
+ declare function createEdgeApp(config?: EdgeAppConfig): {
962
+ fetch: (request: Request, env?: Record<string, any>, executionContext?: {
963
+ waitUntil: (p: Promise<any>) => void;
964
+ passThroughOnException?: () => void;
965
+ }) => Promise<Response>;
966
+ scheduled(event: any, env: any, ctx: any): Promise<void>;
967
+ route(path: string, handler: EdgeHandler): /*elided*/ any;
968
+ use(mw: EdgeMiddleware): /*elided*/ any;
969
+ toNodeHandler(): (req: any, res: any) => Promise<void>;
970
+ toBunHandler(): {
971
+ fetch: (request: Request, env?: Record<string, any>, executionContext?: {
972
+ waitUntil: (p: Promise<any>) => void;
973
+ passThroughOnException?: () => void;
974
+ }) => Promise<Response>;
975
+ port: number;
976
+ };
977
+ toDenoHandler(): (request: Request, env?: Record<string, any>, executionContext?: {
978
+ waitUntil: (p: Promise<any>) => void;
979
+ passThroughOnException?: () => void;
980
+ }) => Promise<Response>;
981
+ listen(port?: number): Promise<any>;
982
+ };
983
+
984
+ /**
985
+ * FlexiReact Partial Prerendering (PPR)
986
+ *
987
+ * Combines static shell with dynamic content:
988
+ * - Static parts are prerendered at build time
989
+ * - Dynamic parts stream in at request time
990
+ * - Best of both SSG and SSR
991
+ */
992
+
993
+ interface PPRConfig {
994
+ shellCacheTTL?: number;
995
+ dynamicTimeout?: number;
996
+ fallback?: React.ReactNode;
997
+ }
998
+ declare function dynamic<T extends React.ComponentType<any>>(Component: T, options?: {
999
+ fallback?: React.ReactNode;
1000
+ }): T;
1001
+ declare function staticComponent<T extends React.ComponentType<any>>(Component: T): T;
1002
+ interface SuspenseBoundaryProps {
1003
+ children: React.ReactNode;
1004
+ fallback?: React.ReactNode;
1005
+ id?: string;
1006
+ }
1007
+ declare function PPRBoundary({ children, fallback, id }: SuspenseBoundaryProps): React.ReactElement;
1008
+ interface PPRShellProps {
1009
+ children: React.ReactNode;
1010
+ fallback?: React.ReactNode;
1011
+ }
1012
+ declare function PPRShell({ children, fallback }: PPRShellProps): React.ReactElement;
1013
+ interface PPRRenderResult {
1014
+ staticShell: string;
1015
+ dynamicParts: Map<string, () => Promise<string>>;
1016
+ fullHtml: string;
1017
+ }
1018
+ declare function prerenderWithPPR(Component: React.ComponentType<any>, props: any, config?: PPRConfig): Promise<PPRRenderResult>;
1019
+ declare function streamPPR(staticShell: string, dynamicParts: Map<string, () => Promise<string>>, options?: {
1020
+ onError?: (error: Error) => string;
1021
+ }): Promise<ReadableStream<Uint8Array>>;
1022
+ declare function pprFetch(input: RequestInfo | URL, init?: RequestInit & {
1023
+ cache?: 'force-cache' | 'no-store' | 'no-cache';
1024
+ next?: {
1025
+ revalidate?: number;
1026
+ tags?: string[];
1027
+ };
1028
+ }): Promise<Response>;
1029
+ declare const experimental_ppr = true;
1030
+ interface PPRPageConfig {
1031
+ experimental_ppr?: boolean;
1032
+ revalidate?: number | false;
1033
+ dynamic?: 'auto' | 'force-dynamic' | 'force-static' | 'error';
1034
+ dynamicParams?: boolean;
1035
+ fetchCache?: 'auto' | 'default-cache' | 'only-cache' | 'force-cache' | 'force-no-store' | 'default-no-store' | 'only-no-store';
1036
+ }
1037
+ type GenerateStaticParams<T = any> = () => Promise<T[]> | T[];
1038
+ declare function PPRLoading(): React.ReactElement;
1039
+
1040
+ /**
1041
+ * FlexiReact Font Optimization
1042
+ *
1043
+ * Optimized font loading with:
1044
+ * - Automatic font subsetting
1045
+ * - Preload hints generation
1046
+ * - Font-display: swap by default
1047
+ * - Self-hosted Google Fonts
1048
+ * - Variable font support
1049
+ * - CSS variable generation
1050
+ */
1051
+ interface FontConfig {
1052
+ family: string;
1053
+ weight?: string | number | (string | number)[];
1054
+ style?: 'normal' | 'italic' | 'oblique';
1055
+ subsets?: string[];
1056
+ display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
1057
+ preload?: boolean;
1058
+ fallback?: string[];
1059
+ variable?: string;
1060
+ adjustFontFallback?: boolean;
1061
+ }
1062
+ interface FontResult {
1063
+ className: string;
1064
+ style: {
1065
+ fontFamily: string;
1066
+ fontWeight?: number | string;
1067
+ fontStyle?: string;
1068
+ };
1069
+ variable?: string;
1070
+ }
1071
+ declare const googleFonts: {
1072
+ Inter: {
1073
+ weights: number[];
1074
+ variable: boolean;
1075
+ subsets: string[];
1076
+ };
1077
+ Roboto: {
1078
+ weights: number[];
1079
+ variable: boolean;
1080
+ subsets: string[];
1081
+ };
1082
+ 'Open Sans': {
1083
+ weights: number[];
1084
+ variable: boolean;
1085
+ subsets: string[];
1086
+ };
1087
+ Poppins: {
1088
+ weights: number[];
1089
+ variable: boolean;
1090
+ subsets: string[];
1091
+ };
1092
+ Montserrat: {
1093
+ weights: number[];
1094
+ variable: boolean;
1095
+ subsets: string[];
1096
+ };
1097
+ 'Fira Code': {
1098
+ weights: number[];
1099
+ variable: boolean;
1100
+ subsets: string[];
1101
+ };
1102
+ 'JetBrains Mono': {
1103
+ weights: number[];
1104
+ variable: boolean;
1105
+ subsets: string[];
1106
+ };
1107
+ Geist: {
1108
+ weights: number[];
1109
+ variable: boolean;
1110
+ subsets: string[];
1111
+ };
1112
+ 'Geist Mono': {
1113
+ weights: number[];
1114
+ variable: boolean;
1115
+ subsets: string[];
1116
+ };
1117
+ };
1118
+ declare function generateFontCSS(config: FontConfig): string;
1119
+ declare function generateFontPreloadTags(fonts: FontConfig[]): string;
1120
+ declare function createFont(config: FontConfig): FontResult;
1121
+ declare function googleFont(config: FontConfig): FontResult;
1122
+ declare function localFont(config: FontConfig & {
1123
+ src: string | {
1124
+ path: string;
1125
+ weight?: string | number;
1126
+ style?: string;
1127
+ }[];
1128
+ }): FontResult;
1129
+ declare function handleFontRequest(req: any, res: any): Promise<void>;
1130
+ declare const fonts: {
1131
+ inter: (config?: Partial<FontConfig>) => FontResult;
1132
+ roboto: (config?: Partial<FontConfig>) => FontResult;
1133
+ openSans: (config?: Partial<FontConfig>) => FontResult;
1134
+ poppins: (config?: Partial<FontConfig>) => FontResult;
1135
+ montserrat: (config?: Partial<FontConfig>) => FontResult;
1136
+ geist: (config?: Partial<FontConfig>) => FontResult;
1137
+ firaCode: (config?: Partial<FontConfig>) => FontResult;
1138
+ jetbrainsMono: (config?: Partial<FontConfig>) => FontResult;
1139
+ geistMono: (config?: Partial<FontConfig>) => FontResult;
1140
+ };
1141
+
1142
+ /**
1143
+ * FlexiReact Metadata API
1144
+ *
1145
+ * Complete metadata management like Next.js:
1146
+ * - Static and dynamic metadata
1147
+ * - Open Graph / Twitter Cards
1148
+ * - Robots / Sitemap
1149
+ * - JSON-LD structured data
1150
+ * - Viewport configuration
1151
+ * - Icons and manifest
1152
+ */
1153
+ interface Metadata {
1154
+ title?: string | {
1155
+ default: string;
1156
+ template?: string;
1157
+ absolute?: string;
1158
+ };
1159
+ description?: string;
1160
+ keywords?: string | string[];
1161
+ authors?: Author | Author[];
1162
+ creator?: string;
1163
+ publisher?: string;
1164
+ robots?: Robots | string;
1165
+ icons?: Icons;
1166
+ manifest?: string;
1167
+ openGraph?: OpenGraph;
1168
+ twitter?: Twitter;
1169
+ verification?: Verification;
1170
+ alternates?: Alternates;
1171
+ appLinks?: AppLinks;
1172
+ archives?: string | string[];
1173
+ assets?: string | string[];
1174
+ bookmarks?: string | string[];
1175
+ category?: string;
1176
+ classification?: string;
1177
+ other?: Record<string, string | string[]>;
1178
+ viewport?: Viewport | string;
1179
+ themeColor?: ThemeColor | ThemeColor[];
1180
+ colorScheme?: 'normal' | 'light' | 'dark' | 'light dark' | 'dark light';
1181
+ formatDetection?: FormatDetection;
1182
+ metadataBase?: URL | string;
1183
+ generator?: string;
1184
+ applicationName?: string;
1185
+ referrer?: 'no-referrer' | 'origin' | 'no-referrer-when-downgrade' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
1186
+ }
1187
+ interface Author {
1188
+ name?: string;
1189
+ url?: string;
1190
+ }
1191
+ interface Robots {
1192
+ index?: boolean;
1193
+ follow?: boolean;
1194
+ noarchive?: boolean;
1195
+ nosnippet?: boolean;
1196
+ noimageindex?: boolean;
1197
+ nocache?: boolean;
1198
+ googleBot?: Robots | string;
1199
+ }
1200
+ interface Icons {
1201
+ icon?: IconDescriptor | IconDescriptor[];
1202
+ shortcut?: IconDescriptor | IconDescriptor[];
1203
+ apple?: IconDescriptor | IconDescriptor[];
1204
+ other?: IconDescriptor[];
1205
+ }
1206
+ interface IconDescriptor {
1207
+ url: string;
1208
+ type?: string;
1209
+ sizes?: string;
1210
+ color?: string;
1211
+ rel?: string;
1212
+ media?: string;
1213
+ }
1214
+ interface OpenGraph {
1215
+ type?: 'website' | 'article' | 'book' | 'profile' | 'music.song' | 'music.album' | 'music.playlist' | 'music.radio_station' | 'video.movie' | 'video.episode' | 'video.tv_show' | 'video.other';
1216
+ url?: string;
1217
+ title?: string;
1218
+ description?: string;
1219
+ siteName?: string;
1220
+ locale?: string;
1221
+ images?: OGImage | OGImage[];
1222
+ videos?: OGVideo | OGVideo[];
1223
+ audio?: OGAudio | OGAudio[];
1224
+ determiner?: 'a' | 'an' | 'the' | 'auto' | '';
1225
+ publishedTime?: string;
1226
+ modifiedTime?: string;
1227
+ expirationTime?: string;
1228
+ authors?: string | string[];
1229
+ section?: string;
1230
+ tags?: string[];
1231
+ }
1232
+ interface OGImage {
1233
+ url: string;
1234
+ secureUrl?: string;
1235
+ type?: string;
1236
+ width?: number;
1237
+ height?: number;
1238
+ alt?: string;
1239
+ }
1240
+ interface OGVideo {
1241
+ url: string;
1242
+ secureUrl?: string;
1243
+ type?: string;
1244
+ width?: number;
1245
+ height?: number;
1246
+ }
1247
+ interface OGAudio {
1248
+ url: string;
1249
+ secureUrl?: string;
1250
+ type?: string;
1251
+ }
1252
+ interface Twitter {
1253
+ card?: 'summary' | 'summary_large_image' | 'app' | 'player';
1254
+ site?: string;
1255
+ siteId?: string;
1256
+ creator?: string;
1257
+ creatorId?: string;
1258
+ title?: string;
1259
+ description?: string;
1260
+ images?: string | TwitterImage | (string | TwitterImage)[];
1261
+ app?: TwitterApp;
1262
+ player?: TwitterPlayer;
1263
+ }
1264
+ interface TwitterImage {
1265
+ url: string;
1266
+ alt?: string;
1267
+ }
1268
+ interface TwitterApp {
1269
+ id?: {
1270
+ iphone?: string;
1271
+ ipad?: string;
1272
+ googleplay?: string;
1273
+ };
1274
+ name?: string;
1275
+ url?: {
1276
+ iphone?: string;
1277
+ ipad?: string;
1278
+ googleplay?: string;
1279
+ };
1280
+ }
1281
+ interface TwitterPlayer {
1282
+ url: string;
1283
+ width?: number;
1284
+ height?: number;
1285
+ stream?: string;
1286
+ }
1287
+ interface Verification {
1288
+ google?: string | string[];
1289
+ yahoo?: string | string[];
1290
+ yandex?: string | string[];
1291
+ me?: string | string[];
1292
+ other?: Record<string, string | string[]>;
1293
+ }
1294
+ interface Alternates {
1295
+ canonical?: string;
1296
+ languages?: Record<string, string>;
1297
+ media?: Record<string, string>;
1298
+ types?: Record<string, string>;
1299
+ }
1300
+ interface AppLinks {
1301
+ ios?: AppLink | AppLink[];
1302
+ iphone?: AppLink | AppLink[];
1303
+ ipad?: AppLink | AppLink[];
1304
+ android?: AppLink | AppLink[];
1305
+ windows_phone?: AppLink | AppLink[];
1306
+ windows?: AppLink | AppLink[];
1307
+ windows_universal?: AppLink | AppLink[];
1308
+ web?: AppLink | AppLink[];
1309
+ }
1310
+ interface AppLink {
1311
+ url: string;
1312
+ app_store_id?: string;
1313
+ app_name?: string;
1314
+ }
1315
+ interface Viewport {
1316
+ width?: number | 'device-width';
1317
+ height?: number | 'device-height';
1318
+ initialScale?: number;
1319
+ minimumScale?: number;
1320
+ maximumScale?: number;
1321
+ userScalable?: boolean;
1322
+ viewportFit?: 'auto' | 'cover' | 'contain';
1323
+ interactiveWidget?: 'resizes-visual' | 'resizes-content' | 'overlays-content';
1324
+ }
1325
+ interface ThemeColor {
1326
+ color: string;
1327
+ media?: string;
1328
+ }
1329
+ interface FormatDetection {
1330
+ telephone?: boolean;
1331
+ date?: boolean;
1332
+ address?: boolean;
1333
+ email?: boolean;
1334
+ url?: boolean;
1335
+ }
1336
+ declare function generateMetadataTags(metadata: Metadata, baseUrl?: string): string;
1337
+ declare function mergeMetadata(parent: Metadata, child: Metadata): Metadata;
1338
+ declare function generateJsonLd(data: Record<string, any>): string;
1339
+ declare const jsonLd: {
1340
+ website: (config: {
1341
+ name: string;
1342
+ url: string;
1343
+ description?: string;
1344
+ }) => {
1345
+ '@context': string;
1346
+ '@type': string;
1347
+ name: string;
1348
+ url: string;
1349
+ description: string | undefined;
1350
+ };
1351
+ article: (config: {
1352
+ headline: string;
1353
+ description?: string;
1354
+ image?: string | string[];
1355
+ datePublished: string;
1356
+ dateModified?: string;
1357
+ author: {
1358
+ name: string;
1359
+ url?: string;
1360
+ } | {
1361
+ name: string;
1362
+ url?: string;
1363
+ }[];
1364
+ }) => {
1365
+ '@context': string;
1366
+ '@type': string;
1367
+ headline: string;
1368
+ description: string | undefined;
1369
+ image: string | string[] | undefined;
1370
+ datePublished: string;
1371
+ dateModified: string;
1372
+ author: {
1373
+ name: string;
1374
+ url?: string;
1375
+ '@type': string;
1376
+ }[] | {
1377
+ name: string;
1378
+ url?: string;
1379
+ '@type': string;
1380
+ };
1381
+ };
1382
+ organization: (config: {
1383
+ name: string;
1384
+ url: string;
1385
+ logo?: string;
1386
+ sameAs?: string[];
1387
+ }) => {
1388
+ '@context': string;
1389
+ '@type': string;
1390
+ name: string;
1391
+ url: string;
1392
+ logo: string | undefined;
1393
+ sameAs: string[] | undefined;
1394
+ };
1395
+ product: (config: {
1396
+ name: string;
1397
+ description?: string;
1398
+ image?: string | string[];
1399
+ brand?: string;
1400
+ offers?: {
1401
+ price: number;
1402
+ priceCurrency: string;
1403
+ availability?: string;
1404
+ };
1405
+ }) => {
1406
+ '@context': string;
1407
+ '@type': string;
1408
+ name: string;
1409
+ description: string | undefined;
1410
+ image: string | string[] | undefined;
1411
+ brand: {
1412
+ '@type': string;
1413
+ name: string;
1414
+ } | undefined;
1415
+ offers: {
1416
+ '@type': string;
1417
+ price: number;
1418
+ priceCurrency: string;
1419
+ availability: string;
1420
+ } | undefined;
1421
+ };
1422
+ breadcrumb: (items: {
1423
+ name: string;
1424
+ url: string;
1425
+ }[]) => {
1426
+ '@context': string;
1427
+ '@type': string;
1428
+ itemListElement: {
1429
+ '@type': string;
1430
+ position: number;
1431
+ name: string;
1432
+ item: string;
1433
+ }[];
1434
+ };
1435
+ };
1436
+
1437
+ /**
1438
+ * FlexiReact Image Optimization
1439
+ *
1440
+ * Optimized image component with:
1441
+ * - Automatic WebP/AVIF conversion
1442
+ * - Responsive srcset generation
1443
+ * - Lazy loading with blur placeholder
1444
+ * - Priority loading for LCP images
1445
+ * - Automatic width/height to prevent CLS
1446
+ */
1447
+
1448
+ interface ImageConfig {
1449
+ domains: string[];
1450
+ deviceSizes: number[];
1451
+ imageSizes: number[];
1452
+ formats: ('webp' | 'avif' | 'png' | 'jpeg')[];
1453
+ minimumCacheTTL: number;
1454
+ dangerouslyAllowSVG: boolean;
1455
+ quality: number;
1456
+ cacheDir: string;
1457
+ }
1458
+ declare const defaultImageConfig: ImageConfig;
1459
+ interface ImageProps {
1460
+ src: string;
1461
+ alt: string;
1462
+ width?: number;
1463
+ height?: number;
1464
+ fill?: boolean;
1465
+ sizes?: string;
1466
+ quality?: number;
1467
+ priority?: boolean;
1468
+ placeholder?: 'blur' | 'empty' | 'data:image/...';
1469
+ blurDataURL?: string;
1470
+ loading?: 'lazy' | 'eager';
1471
+ className?: string;
1472
+ style?: React.CSSProperties;
1473
+ onLoad?: () => void;
1474
+ onError?: () => void;
1475
+ unoptimized?: boolean;
1476
+ }
1477
+ declare function generateBlurPlaceholder(imagePath: string): Promise<string>;
1478
+ declare function getImageDimensions(src: string): Promise<{
1479
+ width: number;
1480
+ height: number;
1481
+ } | null>;
1482
+ declare function generateSrcSet(src: string, widths: number[], quality?: number): string;
1483
+ declare function handleImageOptimization(req: any, res: any, config?: Partial<ImageConfig>): Promise<void>;
1484
+ declare function createImageComponent(config?: Partial<ImageConfig>): (props: ImageProps) => React.ReactElement;
1485
+ declare const Image: (props: ImageProps) => React.ReactElement;
1486
+ interface ImageLoader {
1487
+ (props: {
1488
+ src: string;
1489
+ width: number;
1490
+ quality?: number;
1491
+ }): string;
1492
+ }
1493
+ declare const imageLoaders: {
1494
+ default: ({ src, width, quality }: {
1495
+ src: string;
1496
+ width: number;
1497
+ quality?: number;
1498
+ }) => string;
1499
+ cloudinary: ({ src, width, quality }: {
1500
+ src: string;
1501
+ width: number;
1502
+ quality?: number;
1503
+ }) => string;
1504
+ imgix: ({ src, width, quality }: {
1505
+ src: string;
1506
+ width: number;
1507
+ quality?: number;
1508
+ }) => string;
1509
+ vercel: ({ src, width, quality }: {
1510
+ src: string;
1511
+ width: number;
1512
+ quality?: number;
1513
+ }) => string;
1514
+ cloudflare: ({ src, width, quality }: {
1515
+ src: string;
1516
+ width: number;
1517
+ quality?: number;
1518
+ }) => string;
1519
+ };
1520
+
1521
+ /**
1522
+ * FlexiReact Hooks - React 19 Native
1523
+ *
1524
+ * This module provides React 19 hooks re-exports and FlexiReact-specific
1525
+ * hook utilities for enhanced developer experience.
1526
+ */
1527
+
1528
+ /**
1529
+ * Async data fetching hook using React 19's use()
1530
+ *
1531
+ * @example
1532
+ * ```tsx
1533
+ * // In a Server Component or with Suspense boundary
1534
+ * function UserProfile({ userId }: { userId: string }) {
1535
+ * const user = useAsyncData(fetchUser(userId));
1536
+ * return <div>{user.name}</div>;
1537
+ * }
1538
+ * ```
1539
+ */
1540
+ declare function useAsyncData<T>(promise: Promise<T>): T;
1541
+ /**
1542
+ * Optimistic mutation helper with typed update function
1543
+ *
1544
+ * @example
1545
+ * ```tsx
1546
+ * function TodoList({ todos }: { todos: Todo[] }) {
1547
+ * const [optimisticTodos, addOptimistic] = useOptimisticMutation(
1548
+ * todos,
1549
+ * (state, newTodo: Todo) => [...state, { ...newTodo, pending: true }]
1550
+ * );
1551
+ *
1552
+ * async function addTodo(todo: Todo) {
1553
+ * addOptimistic(todo);
1554
+ * await saveTodo(todo);
1555
+ * }
1556
+ * }
1557
+ * ```
1558
+ */
1559
+ declare function useOptimisticMutation<T, M>(currentState: T, updateFn: (state: T, mutation: M) => T): [T, (mutation: M) => void];
1560
+ /**
1561
+ * Resource preloading for Suspense optimization
1562
+ *
1563
+ * @example
1564
+ * ```tsx
1565
+ * // Preload data before it's needed
1566
+ * const userResource = preloadResource(() => fetchUser(userId));
1567
+ *
1568
+ * // Later, use it with Suspense
1569
+ * function UserCard() {
1570
+ * const user = useAsyncData(userResource);
1571
+ * return <div>{user.name}</div>;
1572
+ * }
1573
+ * ```
1574
+ */
1575
+ declare function preloadResource<T>(fetcher: () => Promise<T>): Promise<T>;
1576
+
1577
+ /**
1578
+ * FlexiReact Server Helpers
1579
+ * Utility functions for server-side operations
1580
+ */
1581
+ /**
1582
+ * Custom error classes for control flow
1583
+ */
1584
+ declare class RedirectError extends Error {
1585
+ readonly url: string;
1586
+ readonly statusCode: number;
1587
+ readonly type: "redirect";
1588
+ constructor(url: string, statusCode?: number);
1589
+ }
1590
+ declare class NotFoundError extends Error {
1591
+ readonly type: "notFound";
1592
+ constructor(message?: string);
1593
+ }
1594
+ /**
1595
+ * Redirect to a different URL
1596
+ * @param url - The URL to redirect to
1597
+ * @param type - 'replace' (307) or 'push' (308) for permanent
1598
+ *
1599
+ * @example
1600
+ * ```tsx
1601
+ * import { redirect } from '@flexireact/core';
1602
+ *
1603
+ * export default function ProtectedPage() {
1604
+ * const user = getUser();
1605
+ * if (!user) {
1606
+ * redirect('/login');
1607
+ * }
1608
+ * return <Dashboard user={user} />;
1609
+ * }
1610
+ * ```
1611
+ */
1612
+ declare function redirect(url: string, type?: 'replace' | 'permanent'): never;
1613
+ /**
1614
+ * Trigger a 404 Not Found response
1615
+ *
1616
+ * @example
1617
+ * ```tsx
1618
+ * import { notFound } from '@flexireact/core';
1619
+ *
1620
+ * export default function ProductPage({ params }) {
1621
+ * const product = getProduct(params.id);
1622
+ * if (!product) {
1623
+ * notFound();
1624
+ * }
1625
+ * return <Product data={product} />;
1626
+ * }
1627
+ * ```
1628
+ */
1629
+ declare function notFound(message?: string): never;
1630
+ /**
1631
+ * Create a JSON response
1632
+ *
1633
+ * @example
1634
+ * ```ts
1635
+ * // In API route
1636
+ * export function GET() {
1637
+ * return json({ message: 'Hello' });
1638
+ * }
1639
+ *
1640
+ * export function POST() {
1641
+ * return json({ error: 'Bad request' }, { status: 400 });
1642
+ * }
1643
+ * ```
1644
+ */
1645
+ declare function json<T>(data: T, options?: {
1646
+ status?: number;
1647
+ headers?: Record<string, string>;
1648
+ }): Response;
1649
+ /**
1650
+ * Create an HTML response
1651
+ */
1652
+ declare function html(content: string, options?: {
1653
+ status?: number;
1654
+ headers?: Record<string, string>;
1655
+ }): Response;
1656
+ /**
1657
+ * Create a text response
1658
+ */
1659
+ declare function text(content: string, options?: {
1660
+ status?: number;
1661
+ headers?: Record<string, string>;
1662
+ }): Response;
1663
+ interface CookieOptions {
1664
+ /** Max age in seconds */
1665
+ maxAge?: number;
1666
+ /** Expiration date */
1667
+ expires?: Date;
1668
+ /** Cookie path */
1669
+ path?: string;
1670
+ /** Cookie domain */
1671
+ domain?: string;
1672
+ /** Secure flag (HTTPS only) */
1673
+ secure?: boolean;
1674
+ /** HttpOnly flag */
1675
+ httpOnly?: boolean;
1676
+ /** SameSite policy */
1677
+ sameSite?: 'strict' | 'lax' | 'none';
1678
+ }
1679
+ /**
1680
+ * Cookie utilities for server-side operations
1681
+ */
1682
+ declare const cookies: {
1683
+ /**
1684
+ * Parse cookies from a cookie header string
1685
+ */
1686
+ parse(cookieHeader: string): Record<string, string>;
1687
+ /**
1688
+ * Get a cookie value from request headers
1689
+ */
1690
+ get(request: Request, name: string): string | undefined;
1691
+ /**
1692
+ * Get all cookies from request
1693
+ */
1694
+ getAll(request: Request): Record<string, string>;
1695
+ /**
1696
+ * Serialize a cookie for Set-Cookie header
1697
+ */
1698
+ serialize(name: string, value: string, options?: CookieOptions): string;
1699
+ /**
1700
+ * Create a Set-Cookie header value
1701
+ */
1702
+ set(name: string, value: string, options?: CookieOptions): string;
1703
+ /**
1704
+ * Create a cookie deletion header
1705
+ */
1706
+ delete(name: string, options?: Omit<CookieOptions, "maxAge" | "expires">): string;
1707
+ };
1708
+ /**
1709
+ * Headers utilities for server-side operations
1710
+ */
1711
+ declare const headers: {
1712
+ /**
1713
+ * Create a new Headers object with common defaults
1714
+ */
1715
+ create(init?: HeadersInit): Headers;
1716
+ /**
1717
+ * Get a header value from request
1718
+ */
1719
+ get(request: Request, name: string): string | null;
1720
+ /**
1721
+ * Get all headers as an object
1722
+ */
1723
+ getAll(request: Request): Record<string, string>;
1724
+ /**
1725
+ * Check if request has a specific header
1726
+ */
1727
+ has(request: Request, name: string): boolean;
1728
+ /**
1729
+ * Get content type from request
1730
+ */
1731
+ contentType(request: Request): string | null;
1732
+ /**
1733
+ * Check if request accepts JSON
1734
+ */
1735
+ acceptsJson(request: Request): boolean;
1736
+ /**
1737
+ * Check if request is AJAX/fetch
1738
+ */
1739
+ isAjax(request: Request): boolean;
1740
+ /**
1741
+ * Get authorization header
1742
+ */
1743
+ authorization(request: Request): {
1744
+ type: string;
1745
+ credentials: string;
1746
+ } | null;
1747
+ /**
1748
+ * Get bearer token from authorization header
1749
+ */
1750
+ bearerToken(request: Request): string | null;
1751
+ /**
1752
+ * Common security headers
1753
+ */
1754
+ security(): Record<string, string>;
1755
+ /**
1756
+ * CORS headers
1757
+ */
1758
+ cors(options?: {
1759
+ origin?: string;
1760
+ methods?: string[];
1761
+ headers?: string[];
1762
+ credentials?: boolean;
1763
+ maxAge?: number;
1764
+ }): Record<string, string>;
1765
+ /**
1766
+ * Cache control headers
1767
+ */
1768
+ cache(options?: {
1769
+ maxAge?: number;
1770
+ sMaxAge?: number;
1771
+ staleWhileRevalidate?: number;
1772
+ private?: boolean;
1773
+ noStore?: boolean;
1774
+ }): Record<string, string>;
1775
+ };
1776
+ /**
1777
+ * Parse JSON body from request
1778
+ */
1779
+ declare function parseJson<T = unknown>(request: Request): Promise<T>;
1780
+ /**
1781
+ * Parse form data from request
1782
+ */
1783
+ declare function parseFormData(request: Request): Promise<FormData>;
1784
+ /**
1785
+ * Parse URL search params
1786
+ */
1787
+ declare function parseSearchParams(request: Request): URLSearchParams;
1788
+ /**
1789
+ * Get request method
1790
+ */
1791
+ declare function getMethod(request: Request): string;
1792
+ /**
1793
+ * Get request pathname
1794
+ */
1795
+ declare function getPathname(request: Request): string;
1796
+ /**
1797
+ * Check if request method matches
1798
+ */
1799
+ declare function isMethod(request: Request, method: string | string[]): boolean;
1800
+
1801
+ /**
1802
+ * FlexiReact Server Actions
1803
+ *
1804
+ * React 19 native actions with FlexiReact enhancements.
1805
+ *
1806
+ * Usage:
1807
+ * ```tsx
1808
+ * // In a server file (actions.ts)
1809
+ * 'use server';
1810
+ *
1811
+ * export async function createUser(prevState: any, formData: FormData) {
1812
+ * const name = formData.get('name');
1813
+ * // Save to database...
1814
+ * return { success: true, id: 123 };
1815
+ * }
1816
+ *
1817
+ * // In a client component - React 19 style
1818
+ * 'use client';
1819
+ * import { useActionState } from '@flexireact/core';
1820
+ * import { createUser } from './actions';
1821
+ *
1822
+ * function Form() {
1823
+ * const [state, formAction, isPending] = useActionState(createUser, null);
1824
+ * return (
1825
+ * <form action={formAction}>
1826
+ * <input name="name" />
1827
+ * <button type="submit" disabled={isPending}>Create</button>
1828
+ * </form>
1829
+ * );
1830
+ * }
1831
+ * ```
1832
+ */
1833
+
1834
+ declare global {
1835
+ var __FLEXI_ACTIONS__: Record<string, ServerActionFunction>;
1836
+ var __FLEXI_ACTION_CONTEXT__: ActionContext | null;
1837
+ }
1838
+ interface ActionContext {
1839
+ request: Request;
1840
+ cookies: typeof cookies;
1841
+ headers: typeof headers;
1842
+ redirect: typeof redirect;
1843
+ notFound: typeof notFound;
1844
+ }
1845
+ type ServerActionFunction = (...args: any[]) => Promise<any>;
1846
+ interface ActionResult<T = any> {
1847
+ success: boolean;
1848
+ data?: T;
1849
+ error?: string;
1850
+ redirect?: string;
1851
+ }
1852
+ /**
1853
+ * Decorator to mark a function as a server action
1854
+ */
1855
+ declare function serverAction<T extends ServerActionFunction>(fn: T, actionId?: string): T;
1856
+ /**
1857
+ * Register a server action
1858
+ */
1859
+ declare function registerAction(id: string, fn: ServerActionFunction): void;
1860
+ /**
1861
+ * Get a registered action
1862
+ */
1863
+ declare function getAction(id: string): ServerActionFunction | undefined;
1864
+ /**
1865
+ * Execute a server action on the server
1866
+ */
1867
+ declare function executeAction(actionId: string, args: any[], context?: Partial<ActionContext>): Promise<ActionResult>;
1868
+ /**
1869
+ * Call a server action from the client
1870
+ */
1871
+ declare function callServerAction(actionId: string, args: any[]): Promise<ActionResult>;
1872
+ /**
1873
+ * Hook to get the current action context
1874
+ */
1875
+ declare function useActionContext(): ActionContext | null;
1876
+ /**
1877
+ * Create a form action handler
1878
+ * Wraps a server action for use with HTML forms
1879
+ */
1880
+ declare function formAction<T>(action: (formData: FormData) => Promise<T>): (formData: FormData) => Promise<ActionResult<T>>;
1881
+ declare function useFlexiAction<State, Payload>(action: (state: Awaited<State>, payload: Payload) => State | Promise<State>, initialState: Awaited<State>, permalink?: string): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1882
+ /**
1883
+ * @deprecated Since v3.1 - Use `useActionState` from React 19 instead.
1884
+ * This function will be removed in v4.0.
1885
+ *
1886
+ * Migration:
1887
+ * ```tsx
1888
+ * // Before (React 18)
1889
+ * const formState = createFormState(submitAction, null);
1890
+ *
1891
+ * // After (React 19)
1892
+ * const [state, formAction, isPending] = useActionState(submitAction, null);
1893
+ * ```
1894
+ */
1895
+ declare function createFormState<T>(action: (formData: FormData) => Promise<ActionResult<T>>, initialState?: T | null): {
1896
+ action: (formData: FormData) => Promise<ActionResult<T>>;
1897
+ initialState: T | null;
1898
+ pending: boolean;
1899
+ error: string | null;
1900
+ data: T | null;
1901
+ };
1902
+ /**
1903
+ * Bind arguments to a server action
1904
+ * Creates a new action with pre-filled arguments
1905
+ */
1906
+ declare function bindArgs<T extends ServerActionFunction>(action: T, ...boundArgs: any[]): T;
1907
+
1908
+ /**
1909
+ * FlexiReact DevTools
1910
+ * Advanced development tools for debugging and performance monitoring
1911
+ */
1912
+
1913
+ interface RouteInfo {
1914
+ path: string;
1915
+ component: string;
1916
+ params: Record<string, string>;
1917
+ query: Record<string, string>;
1918
+ loadTime: number;
1919
+ }
1920
+ interface ComponentInfo {
1921
+ name: string;
1922
+ renderCount: number;
1923
+ lastRenderTime: number;
1924
+ props: Record<string, any>;
1925
+ isIsland: boolean;
1926
+ }
1927
+ interface NetworkRequest {
1928
+ id: string;
1929
+ url: string;
1930
+ method: string;
1931
+ status: number;
1932
+ duration: number;
1933
+ size: number;
1934
+ timestamp: number;
1935
+ type: 'fetch' | 'xhr' | 'ssr' | 'action';
1936
+ }
1937
+ interface PerformanceMetric {
1938
+ name: string;
1939
+ value: number;
1940
+ rating: 'good' | 'needs-improvement' | 'poor';
1941
+ }
1942
+ declare const devtools: {
1943
+ trackRoute(info: RouteInfo): void;
1944
+ trackComponent(name: string, info: Partial<ComponentInfo>): void;
1945
+ trackRequest(request: NetworkRequest): void;
1946
+ trackMetric(metric: PerformanceMetric): void;
1947
+ log(level: "info" | "warn" | "error" | "debug", message: string): void;
1948
+ getState(): {
1949
+ routes: RouteInfo[];
1950
+ components: ComponentInfo[];
1951
+ network: NetworkRequest[];
1952
+ performance: PerformanceMetric[];
1953
+ logs: {
1954
+ level: string;
1955
+ message: string;
1956
+ timestamp: number;
1957
+ }[];
1958
+ };
1959
+ subscribe(listener: () => void): () => void;
1960
+ notify(): void;
1961
+ clear(): void;
1962
+ };
1963
+ declare function initPerformanceMonitoring(): void;
1964
+ declare function initNetworkInterceptor(): void;
1965
+ declare function DevToolsOverlay(): React.ReactElement | null;
1966
+
1967
+ /**
1968
+ * FlexiReact v4 - Main Entry Point
1969
+ * A modern React framework with RSC, SSG, Islands, and more
1970
+ */
1971
+
1972
+ declare const VERSION = "4.0.0";
1973
+ declare const _default: {
1974
+ VERSION: string;
1975
+ createServer: typeof createServer;
1976
+ };
1977
+
1978
+ export { type ActionContext, type ActionResult, type Author, type CacheEntry, type CacheOptions, ClientBoundary, type CookieOptions, DevToolsOverlay, type EdgeAppConfig, type EdgeContext, type EdgeHandler, type EdgeMiddleware, type FlexiConfig, FlexiHeaders, FlexiRequest, FlexiResponse, type FontConfig, type FontResult, type GenerateStaticParams, ISRManager, type Icons, Image, type ImageConfig, type ImageLoader, type ImageProps, Island, type LayoutProps, LoadStrategy, type Metadata, MiddlewareRequest, MiddlewareResponse, NotFoundError, type OpenGraph, PPRBoundary, type PPRConfig, PPRLoading, type PPRPageConfig, type PPRRenderResult, PPRShell, type PageProps, PluginHooks, PluginManager, RSC_CONTENT_TYPE, RedirectError, type Robots, type Route, RouteType, type RouteType$1 as RouteTypeEnum, type RuntimeCapabilities, type RuntimeEnvironment, SSGResult, type ServerActionFunction, ServerBoundary, type Twitter, VERSION, type Viewport, bindArgs, buildRouteTree, builtinPlugins, cacheFunction, callServerAction, cleanDir, composeMiddleware, cookies, copyDir, createEdgeApp as createApp, createClientReference, createDeferred, createEdgeApp, createFont, createFormState, createImageComponent, createIsland, createLazyIsland, createRequestContext, createServer, createServerAction, debounce, _default as default, defaultImageConfig, definePlugin, detectRuntime, devtools, dynamic, runtime as edgeRuntimeInfo, ensureDir, escapeHtml, executeAction, experimental_ppr, findFiles, findRouteLayouts, fonts, formAction, formatBytes, formatTime, generateAdvancedHydrationScript, generateBlurPlaceholder, generateFontCSS, generateFontPreloadTags, generateHash, generateHydrationScript, generateJsonLd, generateMetadataTags, generateSrcSet, generateStaticSite, getAction, getImageDimensions, getMethod, getPathname, getRegisteredIslands, getRuntimeCapabilities, googleFont, googleFonts, handleFontRequest, handleImageOptimization, handleServerAction, headers, html, imageLoaders, initCache, initNetworkInterceptor, initPerformanceMonitoring, isClientComponent, isIsland, isMethod, isServerComponent, json, jsonLd, loadMiddleware, loadPlugins, localFont, matchRoute, mergeMetadata, middlewares, notFound, parseFormData, parseJson, parseSearchParams, pluginManager, pprFetch, preloadResource, prerenderWithPPR, processServerComponent, reactCache, redirect, registerAction, renderError, renderLoading, renderPage, renderPageStream, revalidatePath, revalidateTag, runMiddleware, serializeRSCPayload, serverAction, sleep, cache as smartCache, staticComponent, streamPPR, streamToResponse, text, unstable_cache, useActionContext, useAsyncData, useFlexiAction, useOptimisticMutation, useParams, usePathname, useQuery, useRequest };