@flight-framework/core 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +347 -0
- package/dist/chunk-FSJNOPYE.js +197 -0
- package/dist/chunk-FSJNOPYE.js.map +1 -0
- package/dist/{chunk-VOBQDQKX.js → chunk-LBYDTULN.js} +3 -3
- package/dist/{chunk-VOBQDQKX.js.map → chunk-LBYDTULN.js.map} +1 -1
- package/dist/chunk-PL37KFRJ.js +3 -0
- package/dist/chunk-PL37KFRJ.js.map +1 -0
- package/dist/chunk-YHEVHRLH.js +46 -0
- package/dist/chunk-YHEVHRLH.js.map +1 -0
- package/dist/errors/index.d.ts +267 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +3 -308
- package/dist/index.js +15 -247
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +73 -0
- package/dist/react/index.js +52 -0
- package/dist/react/index.js.map +1 -0
- package/dist/rsc/adapters/index.js +1 -1
- package/dist/rsc/index.js +4 -4
- package/dist/server/index.js +2 -2
- package/dist/utils/index.d.ts +42 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export { DEFAULT_STREAMING_HINTS, GetStreamingConfig, ResolvedStreamingConfig, S
|
|
|
19
19
|
export { ServerContext as RSCServerContext, createServerContext, isNotFoundError, isRedirectError as isRscRedirectError, notFound, redirect as rscRedirect } from './rsc/context.js';
|
|
20
20
|
export { BoundaryType as RSCBoundaryType, detectBoundaryType, hasUseClientDirective, hasUseServerDirective } from './rsc/boundaries.js';
|
|
21
21
|
export { ClientComponent, ComponentType as RSCComponentType, RenderContext as RSCRenderContext, ServerComponent, composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, revalidatePath as rscRevalidatePath, revalidateTag as rscRevalidateTag, serializeProps, serverFetch, withErrorBoundary } from './rsc/legacy.js';
|
|
22
|
+
export { BadRequestError, ErrorBoundaryOptions, FlightError, FlightErrorOptions, FlightErrorProps, ForbiddenError, InternalError, NotFoundError, ResetDetails, UnauthorizedError, clearError, createError, createErrorResponse, forbidden as createForbidden, notFound as createNotFound, unauthorized as createUnauthorized, getError, getErrorStatusCode, isFlightError, isForbiddenError as isForbidden, isNotFoundError as isNotFound, isUnauthorizedError as isUnauthorized, showError, wrapWithDigest } from './errors/index.js';
|
|
23
|
+
export { getEnvironment, isBrowser, isDevelopment, isProduction, isServer, isTest } from './utils/index.js';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* @flight-framework/core - Route Rules Configuration
|
|
@@ -574,313 +576,6 @@ declare function isDevToolsEnabled(): boolean;
|
|
|
574
576
|
*/
|
|
575
577
|
declare function createDevToolsData(startTime: number, options?: Partial<DevToolsOptions>): DevToolsOptions;
|
|
576
578
|
|
|
577
|
-
/**
|
|
578
|
-
* @flight-framework/core - Error Handling
|
|
579
|
-
*
|
|
580
|
-
* Comprehensive error handling utilities for Flight applications.
|
|
581
|
-
* All utilities are OPTIONAL - developers can use their own error handling.
|
|
582
|
-
*
|
|
583
|
-
* Philosophy: Flight OFFERS these utilities, but never IMPOSES them.
|
|
584
|
-
* Using throw new Error() works perfectly fine - this is your choice.
|
|
585
|
-
*/
|
|
586
|
-
/**
|
|
587
|
-
* Options for creating a Flight error
|
|
588
|
-
*/
|
|
589
|
-
interface FlightErrorOptions {
|
|
590
|
-
/** HTTP status code */
|
|
591
|
-
statusCode: number;
|
|
592
|
-
/** Short status message (e.g., "Not Found") */
|
|
593
|
-
statusMessage?: string;
|
|
594
|
-
/** Detailed error message */
|
|
595
|
-
message?: string;
|
|
596
|
-
/** Additional data to include with the error */
|
|
597
|
-
data?: Record<string, unknown>;
|
|
598
|
-
/** If true, shows full-screen error page instead of error boundary */
|
|
599
|
-
fatal?: boolean;
|
|
600
|
-
/** Original error that caused this error */
|
|
601
|
-
cause?: Error;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Extended error props with digest for production error correlation
|
|
605
|
-
*/
|
|
606
|
-
interface FlightErrorProps {
|
|
607
|
-
/** The error object */
|
|
608
|
-
error: Error & {
|
|
609
|
-
digest?: string;
|
|
610
|
-
};
|
|
611
|
-
/** Function to attempt recovery by re-rendering */
|
|
612
|
-
reset: () => void;
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* Reset details provided to onReset callback
|
|
616
|
-
*/
|
|
617
|
-
interface ResetDetails {
|
|
618
|
-
/** Reason for the reset */
|
|
619
|
-
reason: 'imperative-api' | 'keys';
|
|
620
|
-
/** Arguments passed to resetErrorBoundary (if imperative) */
|
|
621
|
-
args?: unknown[];
|
|
622
|
-
/** Previous resetKeys values (if keys changed) */
|
|
623
|
-
prev?: unknown[];
|
|
624
|
-
/** New resetKeys values (if keys changed) */
|
|
625
|
-
next?: unknown[];
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Options for error boundary behavior
|
|
629
|
-
*/
|
|
630
|
-
interface ErrorBoundaryOptions {
|
|
631
|
-
/** Keys that trigger automatic reset when changed */
|
|
632
|
-
resetKeys?: unknown[];
|
|
633
|
-
/** Callback when error boundary resets */
|
|
634
|
-
onReset?: (details: ResetDetails) => void;
|
|
635
|
-
/** Callback when error is caught */
|
|
636
|
-
onError?: (error: Error, info: {
|
|
637
|
-
componentStack?: string;
|
|
638
|
-
}) => void;
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Custom error class with status code and metadata support.
|
|
642
|
-
*
|
|
643
|
-
* You can use this class or regular Error - Flight handles both.
|
|
644
|
-
*
|
|
645
|
-
* @example
|
|
646
|
-
* ```typescript
|
|
647
|
-
* throw new FlightError({
|
|
648
|
-
* statusCode: 404,
|
|
649
|
-
* message: 'User not found',
|
|
650
|
-
* data: { userId: '123' }
|
|
651
|
-
* });
|
|
652
|
-
* ```
|
|
653
|
-
*/
|
|
654
|
-
declare class FlightError extends Error {
|
|
655
|
-
/** HTTP status code */
|
|
656
|
-
readonly statusCode: number;
|
|
657
|
-
/** Short status message */
|
|
658
|
-
readonly statusMessage: string;
|
|
659
|
-
/** Additional error data */
|
|
660
|
-
readonly data?: Record<string, unknown>;
|
|
661
|
-
/** Whether this is a fatal error (shows full-screen) */
|
|
662
|
-
readonly fatal: boolean;
|
|
663
|
-
/** Unique digest for production error correlation */
|
|
664
|
-
readonly digest?: string;
|
|
665
|
-
constructor(options: FlightErrorOptions);
|
|
666
|
-
/**
|
|
667
|
-
* Convert to plain object for serialization
|
|
668
|
-
*/
|
|
669
|
-
toJSON(): Record<string, unknown>;
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* 400 Bad Request error
|
|
673
|
-
*/
|
|
674
|
-
declare class BadRequestError extends FlightError {
|
|
675
|
-
constructor(message?: string, data?: Record<string, unknown>);
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* 401 Unauthorized error
|
|
679
|
-
*/
|
|
680
|
-
declare class UnauthorizedError extends FlightError {
|
|
681
|
-
constructor(message?: string, data?: Record<string, unknown>);
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* 403 Forbidden error
|
|
685
|
-
*/
|
|
686
|
-
declare class ForbiddenError extends FlightError {
|
|
687
|
-
constructor(message?: string, data?: Record<string, unknown>);
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* 404 Not Found error
|
|
691
|
-
*/
|
|
692
|
-
declare class NotFoundError extends FlightError {
|
|
693
|
-
constructor(message?: string, data?: Record<string, unknown>);
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* 500 Internal Server Error
|
|
697
|
-
*/
|
|
698
|
-
declare class InternalError extends FlightError {
|
|
699
|
-
constructor(message?: string, data?: Record<string, unknown>);
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Create a FlightError with the specified options.
|
|
703
|
-
*
|
|
704
|
-
* This is a convenience function - you can also use `new FlightError()` directly
|
|
705
|
-
* or just `throw new Error()` - Flight handles all cases.
|
|
706
|
-
*
|
|
707
|
-
* @example
|
|
708
|
-
* ```typescript
|
|
709
|
-
* // With full options
|
|
710
|
-
* throw createError({
|
|
711
|
-
* statusCode: 404,
|
|
712
|
-
* message: 'Product not found',
|
|
713
|
-
* data: { productId: 'abc123' }
|
|
714
|
-
* });
|
|
715
|
-
*
|
|
716
|
-
* // Simple string shorthand (becomes 500 error)
|
|
717
|
-
* throw createError('Something went wrong');
|
|
718
|
-
* ```
|
|
719
|
-
*/
|
|
720
|
-
declare function createError(options: FlightErrorOptions | string): FlightError;
|
|
721
|
-
/**
|
|
722
|
-
* Create a 404 Not Found error.
|
|
723
|
-
* Convenience function equivalent to `createError({ statusCode: 404, ... })`.
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* ```typescript
|
|
727
|
-
* if (!user) {
|
|
728
|
-
* throw notFound('User not found');
|
|
729
|
-
* }
|
|
730
|
-
* ```
|
|
731
|
-
*/
|
|
732
|
-
declare function notFound(message?: string, data?: Record<string, unknown>): never;
|
|
733
|
-
/**
|
|
734
|
-
* Create a 403 Forbidden error.
|
|
735
|
-
*
|
|
736
|
-
* @example
|
|
737
|
-
* ```typescript
|
|
738
|
-
* if (!user.isAdmin) {
|
|
739
|
-
* throw forbidden('Admin access required');
|
|
740
|
-
* }
|
|
741
|
-
* ```
|
|
742
|
-
*/
|
|
743
|
-
declare function forbidden(message?: string, data?: Record<string, unknown>): never;
|
|
744
|
-
/**
|
|
745
|
-
* Create a 401 Unauthorized error.
|
|
746
|
-
*
|
|
747
|
-
* @example
|
|
748
|
-
* ```typescript
|
|
749
|
-
* if (!session) {
|
|
750
|
-
* throw unauthorized('Please log in to continue');
|
|
751
|
-
* }
|
|
752
|
-
* ```
|
|
753
|
-
*/
|
|
754
|
-
declare function unauthorized(message?: string, data?: Record<string, unknown>): never;
|
|
755
|
-
declare global {
|
|
756
|
-
interface Window {
|
|
757
|
-
__FLIGHT_ERROR__?: FlightError | null;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Programmatically show an error page.
|
|
762
|
-
*
|
|
763
|
-
* This triggers the nearest error boundary or navigates to the error page.
|
|
764
|
-
* Only works on the client side.
|
|
765
|
-
*
|
|
766
|
-
* @example
|
|
767
|
-
* ```typescript
|
|
768
|
-
* // Show error with full options
|
|
769
|
-
* showError({
|
|
770
|
-
* statusCode: 500,
|
|
771
|
-
* message: 'Connection lost'
|
|
772
|
-
* });
|
|
773
|
-
*
|
|
774
|
-
* // Simple string shorthand
|
|
775
|
-
* showError('Something went wrong');
|
|
776
|
-
* ```
|
|
777
|
-
*/
|
|
778
|
-
declare function showError(error: FlightErrorOptions | FlightError | string): void;
|
|
779
|
-
/**
|
|
780
|
-
* Clear the current error state and optionally redirect.
|
|
781
|
-
*
|
|
782
|
-
* Use this to dismiss an error and return to normal state.
|
|
783
|
-
*
|
|
784
|
-
* @example
|
|
785
|
-
* ```typescript
|
|
786
|
-
* // Just clear the error
|
|
787
|
-
* clearError();
|
|
788
|
-
*
|
|
789
|
-
* // Clear and redirect to home
|
|
790
|
-
* clearError({ redirect: '/' });
|
|
791
|
-
* ```
|
|
792
|
-
*/
|
|
793
|
-
declare function clearError(options?: {
|
|
794
|
-
redirect?: string;
|
|
795
|
-
}): void;
|
|
796
|
-
/**
|
|
797
|
-
* Get the current error from global state.
|
|
798
|
-
* Returns null if no error is active.
|
|
799
|
-
*/
|
|
800
|
-
declare function getError(): FlightError | null;
|
|
801
|
-
/**
|
|
802
|
-
* Check if an error is a FlightError
|
|
803
|
-
*/
|
|
804
|
-
declare function isFlightError(error: unknown): error is FlightError;
|
|
805
|
-
/**
|
|
806
|
-
* Check if an error is a NotFoundError (404)
|
|
807
|
-
*/
|
|
808
|
-
declare function isNotFoundError(error: unknown): error is NotFoundError;
|
|
809
|
-
/**
|
|
810
|
-
* Check if an error is a ForbiddenError (403)
|
|
811
|
-
*/
|
|
812
|
-
declare function isForbiddenError(error: unknown): error is ForbiddenError;
|
|
813
|
-
/**
|
|
814
|
-
* Check if an error is an UnauthorizedError (401)
|
|
815
|
-
*/
|
|
816
|
-
declare function isUnauthorizedError(error: unknown): error is UnauthorizedError;
|
|
817
|
-
/**
|
|
818
|
-
* Get the status code from any error.
|
|
819
|
-
* Returns 500 for non-FlightError errors.
|
|
820
|
-
*/
|
|
821
|
-
declare function getErrorStatusCode(error: unknown): number;
|
|
822
|
-
/**
|
|
823
|
-
* Create an error Response from a FlightError.
|
|
824
|
-
*
|
|
825
|
-
* @example
|
|
826
|
-
* ```typescript
|
|
827
|
-
* try {
|
|
828
|
-
* // ... some operation
|
|
829
|
-
* } catch (error) {
|
|
830
|
-
* return createErrorResponse(error);
|
|
831
|
-
* }
|
|
832
|
-
* ```
|
|
833
|
-
*/
|
|
834
|
-
declare function createErrorResponse(error: unknown): Response;
|
|
835
|
-
/**
|
|
836
|
-
* Wrap an error with a digest if it doesn't have one.
|
|
837
|
-
* Useful for adding correlation IDs to third-party errors.
|
|
838
|
-
*/
|
|
839
|
-
declare function wrapWithDigest<T extends Error>(error: T): T & {
|
|
840
|
-
digest: string;
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* @flight-framework/core - Environment Utilities
|
|
845
|
-
*
|
|
846
|
-
* Environment detection utilities that work across Node.js, browsers, and edge runtimes.
|
|
847
|
-
* No hardcoded values - detects environment dynamically.
|
|
848
|
-
*/
|
|
849
|
-
/**
|
|
850
|
-
* Check if running in production environment.
|
|
851
|
-
*
|
|
852
|
-
* Detection order:
|
|
853
|
-
* 1. Node.js process.env.NODE_ENV
|
|
854
|
-
* 2. Vite/modern bundlers import.meta.env.MODE or import.meta.env.PROD
|
|
855
|
-
* 3. Default: false (not production)
|
|
856
|
-
*/
|
|
857
|
-
declare function isProduction(): boolean;
|
|
858
|
-
/**
|
|
859
|
-
* Check if running in development environment.
|
|
860
|
-
*
|
|
861
|
-
* Detection order:
|
|
862
|
-
* 1. Node.js process.env.NODE_ENV
|
|
863
|
-
* 2. Vite/modern bundlers import.meta.env.MODE or import.meta.env.DEV
|
|
864
|
-
* 3. Default: true (assume development if unknown)
|
|
865
|
-
*/
|
|
866
|
-
declare function isDevelopment(): boolean;
|
|
867
|
-
/**
|
|
868
|
-
* Check if running in test environment.
|
|
869
|
-
*/
|
|
870
|
-
declare function isTest(): boolean;
|
|
871
|
-
/**
|
|
872
|
-
* Check if running on the server (not browser).
|
|
873
|
-
*/
|
|
874
|
-
declare function isServer(): boolean;
|
|
875
|
-
/**
|
|
876
|
-
* Check if running in the browser.
|
|
877
|
-
*/
|
|
878
|
-
declare function isBrowser(): boolean;
|
|
879
|
-
/**
|
|
880
|
-
* Get the current environment name.
|
|
881
|
-
*/
|
|
882
|
-
declare function getEnvironment(): 'production' | 'development' | 'test' | 'unknown';
|
|
883
|
-
|
|
884
579
|
/**
|
|
885
580
|
* Flight Framework - Core
|
|
886
581
|
*
|
|
@@ -890,4 +585,4 @@ declare function getEnvironment(): 'production' | 'development' | 'test' | 'unkn
|
|
|
890
585
|
|
|
891
586
|
declare const VERSION = "0.0.1";
|
|
892
587
|
|
|
893
|
-
export {
|
|
588
|
+
export { Cache, CacheOptions, type DevToolsOptions, type GenerateMetadataFn, type GenerateMetadataFunction, type GenerateStaticParamsFunction, type ISRCacheAdapter, type ISRCacheEntry, type Metadata, type PageMetadata, type PageModule, type PrerenderError, type PrerenderOptions, type PrerenderProgress, type PrerenderResult, type PrerenderSummary, type RevalidateHandlerOptions, type RevalidationResult, type RouteRule, type RouteRules, type StaticParams, VERSION, buildCacheControlHeader, createDefaultRouteRules, createDevToolsData, createHtmlStream, createISRCacheFromFlightCache, createMemoryISRCache, createRevalidateHandler, createStreamingResponse as createStaticStreamingResponse, expandDynamicRoutes, extractLinks, generateAllStaticPaths, getCacheOptionsFromRule, getISRCache, getOrGeneratePage, getRenderModeFromRule, getRevalidateTime, injectDevTools, isDevToolsEnabled, matchRouteRule, mergeMetadata, mergeRouteRules, prerenderRoutes, purgeAllPages, purgePage, renderMetadataToHead, resolveMetadata, revalidatePath, revalidatePaths, revalidateTag, setISRCache, shouldDynamicallyRender };
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
export { createIslandRegistry, createPreactIslandAdapter, createReactIslandAdapter, createSolidIslandAdapter, createVueIslandAdapter, defineIsland, hydrateIslands, registerFlightIslandElement, registerIsland, renderIsland, renderIslands, setIslandAdapter } from './chunk-WFAWAHJH.js';
|
|
2
|
-
export { DEFAULT_STREAMING_HINTS, createStreamingController, generateCacheKey, getStreamingCacheHeaders, hasStreamingConfig, isValidStreamingHints, loadRouteWithStreaming, resolveStreamingConfig, shouldStream } from './chunk-XSY5AAXT.js';
|
|
3
|
-
export { streamWithPriority, validateDependencies } from './chunk-WOEIJWGJ.js';
|
|
4
1
|
export { MetricsAggregator, createHttpObserver, createInstrumentedStream, createLoggerObserver } from './chunk-6BDCTUQY.js';
|
|
5
2
|
export { DEFAULT_BOT_PATTERNS, addStreamingHeaders, createConditionalStreamer, createStreamingResponse as createConditionalStreamingResponse, createStaticResponse, isBot, isSlowConnection, prefersNoStream, streamIf, supportsStreaming } from './chunk-XOIYNY4I.js';
|
|
6
3
|
export { createHTMXStreamAdapter, createReactStreamAdapter, createSolidStreamAdapter, createStreamAdapter, createSvelteStreamAdapter, createVueStreamAdapter } from './chunk-MQQLYWZZ.js';
|
|
4
|
+
export { createIslandRegistry, createPreactIslandAdapter, createReactIslandAdapter, createSolidIslandAdapter, createVueIslandAdapter, defineIsland, hydrateIslands, registerFlightIslandElement, registerIsland, renderIsland, renderIslands, setIslandAdapter } from './chunk-WFAWAHJH.js';
|
|
5
|
+
export { DEFAULT_STREAMING_HINTS, createStreamingController, generateCacheKey, getStreamingCacheHeaders, hasStreamingConfig, isValidStreamingHints, loadRouteWithStreaming, resolveStreamingConfig, shouldStream } from './chunk-XSY5AAXT.js';
|
|
6
|
+
export { streamWithPriority, validateDependencies } from './chunk-WOEIJWGJ.js';
|
|
7
|
+
import './chunk-SUILH4ID.js';
|
|
8
|
+
export { createServer } from './chunk-LBYDTULN.js';
|
|
9
|
+
export { defineConfig } from './chunk-IXMD5QH2.js';
|
|
7
10
|
export { createFileRouter, loadRoutes, scanRoutes } from './chunk-54HPVE7N.js';
|
|
8
11
|
export { RedirectError, redirect as actionRedirect, cookies, executeAction, executeFormAction, getAction, handleActionRequest, isRedirectError, parseFormData, registerAction } from './chunk-3QP3E7HS.js';
|
|
9
12
|
export { createRouteContext, error, json, parseBody, redirect } from './chunk-W6D62JCI.js';
|
|
10
13
|
export { createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from './chunk-RSVA2EYO.js';
|
|
11
14
|
import './chunk-63SCEXD7.js';
|
|
15
|
+
export { createServerContext, isNotFoundError, isRedirectError as isRscRedirectError, notFound, redirect as rscRedirect } from './chunk-62C7LX2E.js';
|
|
12
16
|
import './chunk-PVUMB632.js';
|
|
13
17
|
import './chunk-P6WSBVDT.js';
|
|
18
|
+
import './chunk-K2CQZPCG.js';
|
|
14
19
|
export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, executeServerComponent, revalidatePath as rscRevalidatePath, revalidateTag as rscRevalidateTag, serializeProps, serverFetch, withErrorBoundary } from './chunk-3ZSSRE6M.js';
|
|
15
20
|
import './chunk-ZIE56LCA.js';
|
|
21
|
+
export { detectBoundaryType, hasUseClientDirective, hasUseServerDirective } from './chunk-PDW5WCMW.js';
|
|
16
22
|
import './chunk-Y22AMGTM.js';
|
|
17
|
-
import './chunk-MDQNNIHH.js';
|
|
18
23
|
import './chunk-TASAT7KB.js';
|
|
19
24
|
import './chunk-2F2QU6RC.js';
|
|
20
25
|
import './chunk-VPFMHGEV.js';
|
|
21
|
-
import './chunk-
|
|
22
|
-
export {
|
|
23
|
-
|
|
26
|
+
import './chunk-MDQNNIHH.js';
|
|
27
|
+
export { BadRequestError, FlightError, ForbiddenError, InternalError, NotFoundError, UnauthorizedError, clearError, createError, createErrorResponse, forbidden as createForbidden, notFound as createNotFound, unauthorized as createUnauthorized, getError, getErrorStatusCode, isFlightError, isForbiddenError as isForbidden, isNotFoundError as isNotFound, isUnauthorizedError as isUnauthorized, showError, wrapWithDigest } from './chunk-FSJNOPYE.js';
|
|
28
|
+
import './chunk-PL37KFRJ.js';
|
|
29
|
+
export { getEnvironment, isBrowser, isDevelopment, isProduction, isServer, isTest } from './chunk-YHEVHRLH.js';
|
|
30
|
+
export { createRouter } from './chunk-GCQZ4FHI.js';
|
|
24
31
|
import './chunk-ZVC3ZWLM.js';
|
|
25
32
|
export { cacheKey, cached, createCache, dedupe, jsonSerializer, memory } from './chunk-R7SQAREQ.js';
|
|
26
|
-
import './chunk-SUILH4ID.js';
|
|
27
|
-
export { createServer } from './chunk-VOBQDQKX.js';
|
|
28
|
-
export { createRouter } from './chunk-GCQZ4FHI.js';
|
|
29
33
|
export { createMiddlewareChain } from './chunk-KWFX6WHG.js';
|
|
30
|
-
export { defineConfig } from './chunk-IXMD5QH2.js';
|
|
31
34
|
import { promises } from 'fs';
|
|
32
35
|
import { dirname, join } from 'path';
|
|
33
36
|
|
|
@@ -875,244 +878,9 @@ function createDevToolsData(startTime, options = {}) {
|
|
|
875
878
|
};
|
|
876
879
|
}
|
|
877
880
|
|
|
878
|
-
// src/utils/env.ts
|
|
879
|
-
function isProduction() {
|
|
880
|
-
if (typeof globalThis !== "undefined" && "process" in globalThis) {
|
|
881
|
-
const proc = globalThis.process;
|
|
882
|
-
return proc?.env?.NODE_ENV === "production";
|
|
883
|
-
}
|
|
884
|
-
if (typeof import.meta !== "undefined" && "env" in import.meta) {
|
|
885
|
-
const env = import.meta.env;
|
|
886
|
-
return env?.MODE === "production" || env?.PROD === true;
|
|
887
|
-
}
|
|
888
|
-
return false;
|
|
889
|
-
}
|
|
890
|
-
function isDevelopment() {
|
|
891
|
-
if (typeof globalThis !== "undefined" && "process" in globalThis) {
|
|
892
|
-
const proc = globalThis.process;
|
|
893
|
-
return proc?.env?.NODE_ENV === "development";
|
|
894
|
-
}
|
|
895
|
-
if (typeof import.meta !== "undefined" && "env" in import.meta) {
|
|
896
|
-
const env = import.meta.env;
|
|
897
|
-
return env?.MODE === "development" || env?.DEV === true;
|
|
898
|
-
}
|
|
899
|
-
return true;
|
|
900
|
-
}
|
|
901
|
-
function isTest() {
|
|
902
|
-
if (typeof globalThis !== "undefined" && "process" in globalThis) {
|
|
903
|
-
const proc = globalThis.process;
|
|
904
|
-
return proc?.env?.NODE_ENV === "test";
|
|
905
|
-
}
|
|
906
|
-
return false;
|
|
907
|
-
}
|
|
908
|
-
function isServer() {
|
|
909
|
-
return typeof window === "undefined";
|
|
910
|
-
}
|
|
911
|
-
function isBrowser() {
|
|
912
|
-
return typeof window !== "undefined";
|
|
913
|
-
}
|
|
914
|
-
function getEnvironment() {
|
|
915
|
-
if (isProduction()) return "production";
|
|
916
|
-
if (isDevelopment()) return "development";
|
|
917
|
-
if (isTest()) return "test";
|
|
918
|
-
return "unknown";
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
// src/errors/index.ts
|
|
922
|
-
var FlightError = class extends Error {
|
|
923
|
-
/** HTTP status code */
|
|
924
|
-
statusCode;
|
|
925
|
-
/** Short status message */
|
|
926
|
-
statusMessage;
|
|
927
|
-
/** Additional error data */
|
|
928
|
-
data;
|
|
929
|
-
/** Whether this is a fatal error (shows full-screen) */
|
|
930
|
-
fatal;
|
|
931
|
-
/** Unique digest for production error correlation */
|
|
932
|
-
digest;
|
|
933
|
-
constructor(options) {
|
|
934
|
-
super(options.message || options.statusMessage || "An error occurred");
|
|
935
|
-
this.name = "FlightError";
|
|
936
|
-
this.statusCode = options.statusCode;
|
|
937
|
-
this.statusMessage = options.statusMessage || getDefaultStatusMessage(options.statusCode);
|
|
938
|
-
this.data = options.data;
|
|
939
|
-
this.fatal = options.fatal ?? false;
|
|
940
|
-
if (isProduction()) {
|
|
941
|
-
this.digest = generateDigest();
|
|
942
|
-
}
|
|
943
|
-
if (options.cause) {
|
|
944
|
-
this.cause = options.cause;
|
|
945
|
-
if (options.cause.stack) {
|
|
946
|
-
this.stack = `${this.stack}
|
|
947
|
-
Caused by: ${options.cause.stack}`;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* Convert to plain object for serialization
|
|
953
|
-
*/
|
|
954
|
-
toJSON() {
|
|
955
|
-
return {
|
|
956
|
-
name: this.name,
|
|
957
|
-
message: this.message,
|
|
958
|
-
statusCode: this.statusCode,
|
|
959
|
-
statusMessage: this.statusMessage,
|
|
960
|
-
data: this.data,
|
|
961
|
-
fatal: this.fatal,
|
|
962
|
-
digest: this.digest
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
};
|
|
966
|
-
var BadRequestError = class extends FlightError {
|
|
967
|
-
constructor(message, data) {
|
|
968
|
-
super({ statusCode: 400, message, data });
|
|
969
|
-
this.name = "BadRequestError";
|
|
970
|
-
}
|
|
971
|
-
};
|
|
972
|
-
var UnauthorizedError = class extends FlightError {
|
|
973
|
-
constructor(message, data) {
|
|
974
|
-
super({ statusCode: 401, message: message || "Unauthorized", data });
|
|
975
|
-
this.name = "UnauthorizedError";
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
var ForbiddenError = class extends FlightError {
|
|
979
|
-
constructor(message, data) {
|
|
980
|
-
super({ statusCode: 403, message: message || "Forbidden", data });
|
|
981
|
-
this.name = "ForbiddenError";
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
var NotFoundError = class extends FlightError {
|
|
985
|
-
constructor(message, data) {
|
|
986
|
-
super({ statusCode: 404, message: message || "Not Found", data });
|
|
987
|
-
this.name = "NotFoundError";
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
var InternalError = class extends FlightError {
|
|
991
|
-
constructor(message, data) {
|
|
992
|
-
super({ statusCode: 500, message: message || "Internal Server Error", data });
|
|
993
|
-
this.name = "InternalError";
|
|
994
|
-
}
|
|
995
|
-
};
|
|
996
|
-
function createError(options) {
|
|
997
|
-
if (typeof options === "string") {
|
|
998
|
-
return new FlightError({ statusCode: 500, message: options });
|
|
999
|
-
}
|
|
1000
|
-
return new FlightError(options);
|
|
1001
|
-
}
|
|
1002
|
-
function notFound2(message, data) {
|
|
1003
|
-
throw new NotFoundError(message, data);
|
|
1004
|
-
}
|
|
1005
|
-
function forbidden(message, data) {
|
|
1006
|
-
throw new ForbiddenError(message, data);
|
|
1007
|
-
}
|
|
1008
|
-
function unauthorized(message, data) {
|
|
1009
|
-
throw new UnauthorizedError(message, data);
|
|
1010
|
-
}
|
|
1011
|
-
function showError(error2) {
|
|
1012
|
-
let flightError;
|
|
1013
|
-
if (typeof error2 === "string") {
|
|
1014
|
-
flightError = new FlightError({ statusCode: 500, message: error2 });
|
|
1015
|
-
} else if (error2 instanceof FlightError) {
|
|
1016
|
-
flightError = error2;
|
|
1017
|
-
} else {
|
|
1018
|
-
flightError = new FlightError(error2);
|
|
1019
|
-
}
|
|
1020
|
-
if (typeof window !== "undefined") {
|
|
1021
|
-
window.__FLIGHT_ERROR__ = flightError;
|
|
1022
|
-
window.dispatchEvent(new CustomEvent("flight:error", {
|
|
1023
|
-
detail: flightError,
|
|
1024
|
-
bubbles: true
|
|
1025
|
-
}));
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
function clearError(options) {
|
|
1029
|
-
if (typeof window !== "undefined") {
|
|
1030
|
-
window.__FLIGHT_ERROR__ = null;
|
|
1031
|
-
window.dispatchEvent(new CustomEvent("flight:error-clear", { bubbles: true }));
|
|
1032
|
-
if (options?.redirect) {
|
|
1033
|
-
window.location.href = options.redirect;
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
function getError() {
|
|
1038
|
-
if (typeof window !== "undefined") {
|
|
1039
|
-
return window.__FLIGHT_ERROR__ ?? null;
|
|
1040
|
-
}
|
|
1041
|
-
return null;
|
|
1042
|
-
}
|
|
1043
|
-
function isFlightError(error2) {
|
|
1044
|
-
return error2 instanceof FlightError;
|
|
1045
|
-
}
|
|
1046
|
-
function isNotFoundError2(error2) {
|
|
1047
|
-
return error2 instanceof NotFoundError || isFlightError(error2) && error2.statusCode === 404;
|
|
1048
|
-
}
|
|
1049
|
-
function isForbiddenError(error2) {
|
|
1050
|
-
return error2 instanceof ForbiddenError || isFlightError(error2) && error2.statusCode === 403;
|
|
1051
|
-
}
|
|
1052
|
-
function isUnauthorizedError(error2) {
|
|
1053
|
-
return error2 instanceof UnauthorizedError || isFlightError(error2) && error2.statusCode === 401;
|
|
1054
|
-
}
|
|
1055
|
-
function getErrorStatusCode(error2) {
|
|
1056
|
-
if (isFlightError(error2)) {
|
|
1057
|
-
return error2.statusCode;
|
|
1058
|
-
}
|
|
1059
|
-
return 500;
|
|
1060
|
-
}
|
|
1061
|
-
function createErrorResponse(error2) {
|
|
1062
|
-
const flightError = isFlightError(error2) ? error2 : new InternalError(error2 instanceof Error ? error2.message : "Unknown error");
|
|
1063
|
-
return new Response(
|
|
1064
|
-
JSON.stringify({
|
|
1065
|
-
error: flightError.statusMessage,
|
|
1066
|
-
message: flightError.message,
|
|
1067
|
-
statusCode: flightError.statusCode,
|
|
1068
|
-
digest: flightError.digest,
|
|
1069
|
-
...isDevelopment() && flightError.data ? { data: flightError.data } : {}
|
|
1070
|
-
}),
|
|
1071
|
-
{
|
|
1072
|
-
status: flightError.statusCode,
|
|
1073
|
-
headers: {
|
|
1074
|
-
"Content-Type": "application/json"
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1079
|
-
function getDefaultStatusMessage(statusCode) {
|
|
1080
|
-
const messages = {
|
|
1081
|
-
400: "Bad Request",
|
|
1082
|
-
401: "Unauthorized",
|
|
1083
|
-
403: "Forbidden",
|
|
1084
|
-
404: "Not Found",
|
|
1085
|
-
405: "Method Not Allowed",
|
|
1086
|
-
408: "Request Timeout",
|
|
1087
|
-
409: "Conflict",
|
|
1088
|
-
410: "Gone",
|
|
1089
|
-
422: "Unprocessable Entity",
|
|
1090
|
-
429: "Too Many Requests",
|
|
1091
|
-
500: "Internal Server Error",
|
|
1092
|
-
501: "Not Implemented",
|
|
1093
|
-
502: "Bad Gateway",
|
|
1094
|
-
503: "Service Unavailable",
|
|
1095
|
-
504: "Gateway Timeout"
|
|
1096
|
-
};
|
|
1097
|
-
return messages[statusCode] || "Error";
|
|
1098
|
-
}
|
|
1099
|
-
function generateDigest() {
|
|
1100
|
-
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
1101
|
-
return crypto.randomUUID().slice(0, 8);
|
|
1102
|
-
}
|
|
1103
|
-
return Math.random().toString(36).slice(2, 10);
|
|
1104
|
-
}
|
|
1105
|
-
function wrapWithDigest(error2) {
|
|
1106
|
-
const wrapped = error2;
|
|
1107
|
-
if (!wrapped.digest) {
|
|
1108
|
-
wrapped.digest = generateDigest();
|
|
1109
|
-
}
|
|
1110
|
-
return wrapped;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
881
|
// src/index.ts
|
|
1114
882
|
var VERSION = "0.0.1";
|
|
1115
883
|
|
|
1116
|
-
export {
|
|
884
|
+
export { VERSION, buildCacheControlHeader, createDefaultRouteRules, createDevToolsData, createHtmlStream, createISRCacheFromFlightCache, createMemoryISRCache, createRevalidateHandler, createStreamingResponse3 as createStaticStreamingResponse, expandDynamicRoutes, extractLinks, generateAllStaticPaths, getCacheOptionsFromRule, getISRCache, getOrGeneratePage, getRenderModeFromRule, getRevalidateTime, injectDevTools, isDevToolsEnabled, matchRouteRule, mergeMetadata, mergeRouteRules, prerenderRoutes, purgeAllPages, purgePage, renderMetadataToHead, resolveMetadata, revalidatePath2 as revalidatePath, revalidatePaths, revalidateTag2 as revalidateTag, setISRCache, shouldDynamicallyRender };
|
|
1117
885
|
//# sourceMappingURL=index.js.map
|
|
1118
886
|
//# sourceMappingURL=index.js.map
|