@useavalon/avalon 0.1.23 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/mod.d.ts +50 -0
  2. package/dist/src/build/integration-bundler-plugin.d.ts +25 -0
  3. package/dist/src/build/integration-config.d.ts +44 -0
  4. package/dist/src/build/integration-detection-plugin.d.ts +20 -0
  5. package/dist/src/build/integration-resolver-plugin.d.ts +10 -0
  6. package/dist/src/build/island-manifest.d.ts +57 -0
  7. package/dist/src/build/island-types-generator.d.ts +49 -0
  8. package/dist/src/build/mdx-island-transform.d.ts +23 -0
  9. package/dist/src/build/mdx-plugin.d.ts +36 -0
  10. package/dist/src/build/page-island-transform.d.ts +41 -0
  11. package/dist/src/build/prop-extractors/index.d.ts +8 -0
  12. package/dist/src/build/prop-extractors/lit.d.ts +11 -0
  13. package/dist/src/build/prop-extractors/qwik.d.ts +9 -0
  14. package/dist/src/build/prop-extractors/solid.d.ts +12 -0
  15. package/dist/src/build/prop-extractors/svelte.d.ts +13 -0
  16. package/dist/src/build/prop-extractors/vue.d.ts +19 -0
  17. package/dist/src/build/sidecar-file-manager.d.ts +23 -0
  18. package/dist/src/build/sidecar-renderer.d.ts +22 -0
  19. package/dist/src/client/adapters/index.d.ts +15 -0
  20. package/dist/src/client/components.d.ts +21 -0
  21. package/dist/src/client/css-hmr-handler.d.ts +94 -0
  22. package/dist/src/client/framework-adapter.d.ts +225 -0
  23. package/dist/src/client/hmr-coordinator.d.ts +88 -0
  24. package/dist/src/components/Image.d.ts +61 -0
  25. package/dist/src/components/IslandErrorBoundary.d.ts +37 -0
  26. package/dist/src/components/IslandErrorBoundary.js +1 -1
  27. package/dist/src/components/LayoutDataErrorBoundary.d.ts +34 -0
  28. package/dist/src/components/LayoutDataErrorBoundary.js +1 -1
  29. package/dist/src/components/LayoutErrorBoundary.d.ts +25 -0
  30. package/dist/src/components/LayoutErrorBoundary.js +1 -1
  31. package/dist/src/components/PersistentIsland.d.ts +36 -0
  32. package/dist/src/components/StreamingErrorBoundary.d.ts +42 -0
  33. package/dist/src/components/StreamingErrorBoundary.js +1 -1
  34. package/dist/src/components/StreamingLayout.d.ts +83 -0
  35. package/dist/src/components/StreamingLayout.js +1 -1
  36. package/dist/src/core/components/component-analyzer.d.ts +48 -0
  37. package/dist/src/core/components/component-detection.d.ts +72 -0
  38. package/dist/src/core/components/enhanced-framework-detector.d.ts +78 -0
  39. package/dist/src/core/components/framework-registry.d.ts +114 -0
  40. package/dist/src/core/content/mdx-processor.d.ts +14 -0
  41. package/dist/src/core/integrations/index.d.ts +6 -0
  42. package/dist/src/core/integrations/loader.d.ts +35 -0
  43. package/dist/src/core/integrations/registry.d.ts +51 -0
  44. package/dist/src/core/islands/island-persistence.d.ts +74 -0
  45. package/dist/src/core/islands/island-state-serializer.d.ts +53 -0
  46. package/dist/src/core/islands/persistent-island-context.d.ts +36 -0
  47. package/dist/src/core/islands/use-persistent-state.d.ts +17 -0
  48. package/dist/src/core/layout/enhanced-layout-resolver.d.ts +73 -0
  49. package/dist/src/core/layout/layout-cache-manager.d.ts +66 -0
  50. package/dist/src/core/layout/layout-composer.d.ts +63 -0
  51. package/dist/src/core/layout/layout-data-loader.d.ts +146 -0
  52. package/dist/src/core/layout/layout-discovery.d.ts +51 -0
  53. package/dist/src/core/layout/layout-matcher.d.ts +77 -0
  54. package/dist/src/core/layout/layout-types.d.ts +94 -0
  55. package/dist/src/core/modules/framework-module-resolver.d.ts +85 -0
  56. package/dist/src/islands/component-analysis.d.ts +38 -0
  57. package/dist/src/islands/css-utils.d.ts +81 -0
  58. package/dist/src/islands/discovery/index.d.ts +16 -0
  59. package/dist/src/islands/discovery/registry.d.ts +141 -0
  60. package/dist/src/islands/discovery/resolver.d.ts +190 -0
  61. package/dist/src/islands/discovery/scanner.d.ts +55 -0
  62. package/dist/src/islands/discovery/types.d.ts +92 -0
  63. package/dist/src/islands/discovery/validator.d.ts +89 -0
  64. package/dist/src/islands/discovery/watcher.d.ts +95 -0
  65. package/dist/src/islands/framework-detection.d.ts +53 -0
  66. package/dist/src/islands/integration-loader.d.ts +139 -0
  67. package/dist/src/islands/island.d.ts +55 -0
  68. package/dist/src/islands/render-cache.d.ts +203 -0
  69. package/dist/src/islands/types.d.ts +63 -0
  70. package/dist/src/islands/universal-css-collector.d.ts +41 -0
  71. package/dist/src/islands/universal-head-collector.d.ts +42 -0
  72. package/dist/src/layout-system.d.ts +92 -592
  73. package/dist/src/middleware/discovery.d.ts +70 -0
  74. package/dist/src/middleware/executor.d.ts +52 -0
  75. package/dist/src/middleware/index.d.ts +43 -0
  76. package/dist/src/middleware/types.d.ts +89 -0
  77. package/dist/src/nitro/build-config.d.ts +163 -0
  78. package/dist/src/nitro/config.d.ts +268 -0
  79. package/dist/src/nitro/error-handler.d.ts +151 -0
  80. package/dist/src/nitro/index.d.ts +15 -0
  81. package/dist/src/nitro/island-manifest.d.ts +191 -0
  82. package/dist/src/nitro/middleware-adapter.d.ts +151 -0
  83. package/dist/src/nitro/renderer.d.ts +342 -0
  84. package/dist/src/nitro/route-discovery.d.ts +142 -0
  85. package/dist/src/nitro/types.d.ts +278 -0
  86. package/dist/src/render/collect-css.d.ts +28 -0
  87. package/dist/src/render/error-pages.d.ts +14 -0
  88. package/dist/src/render/isolated-ssr-renderer.d.ts +127 -0
  89. package/dist/src/render/ssr.d.ts +56 -0
  90. package/dist/src/schemas/api.d.ts +27 -0
  91. package/dist/src/schemas/core.d.ts +75 -0
  92. package/dist/src/schemas/index.d.ts +79 -0
  93. package/dist/src/schemas/index.js +1 -1
  94. package/dist/src/schemas/layout.d.ts +282 -0
  95. package/dist/src/schemas/routing/index.d.ts +181 -0
  96. package/dist/src/schemas/routing.d.ts +388 -0
  97. package/dist/src/types/as-island.d.ts +17 -0
  98. package/dist/src/types/layout.d.ts +177 -0
  99. package/dist/src/types/routing.d.ts +297 -0
  100. package/dist/src/types/types.d.ts +6 -0
  101. package/dist/src/utils/dev-logger.d.ts +84 -0
  102. package/dist/src/utils/fs.d.ts +41 -0
  103. package/dist/src/vite-plugin/auto-discover.d.ts +72 -0
  104. package/dist/src/vite-plugin/config.d.ts +82 -0
  105. package/dist/src/vite-plugin/errors.d.ts +62 -0
  106. package/dist/src/vite-plugin/image-optimization.d.ts +36 -0
  107. package/dist/src/vite-plugin/integration-activator.d.ts +48 -0
  108. package/dist/src/vite-plugin/island-sidecar-plugin.d.ts +17 -0
  109. package/dist/src/vite-plugin/module-discovery.d.ts +66 -0
  110. package/dist/src/vite-plugin/nitro-integration.d.ts +56 -0
  111. package/dist/src/vite-plugin/plugin.d.ts +51 -0
  112. package/dist/src/vite-plugin/types.d.ts +281 -0
  113. package/dist/src/vite-plugin/validation.d.ts +93 -0
  114. package/package.json +33 -9
@@ -0,0 +1,278 @@
1
+ /**
2
+ * Nitro Types and Interfaces for Avalon
3
+ *
4
+ * This module defines the core types used throughout the Nitro integration,
5
+ * including render context, runtime configuration, and route definitions.
6
+ *
7
+ * In Nitro v3, canonical types should be imported from `nitro/types`.
8
+ * Avalon-specific types that extend or complement Nitro's types are defined here.
9
+ */
10
+ import type { MiddlewareContext } from '../nitro/middleware-adapter.ts';
11
+ import type { ApiMethod } from '../schemas/api.ts';
12
+ /**
13
+ * ServerRequest type reference from Nitro v3 (`nitro/types`).
14
+ * Re-exported here for convenience within Avalon's Nitro integration.
15
+ *
16
+ * Represents the server-side request object in Nitro v3's type system.
17
+ * When the full `nitro/types` package is available, prefer importing directly.
18
+ */
19
+ export interface ServerRequest {
20
+ /** HTTP method */
21
+ method: string;
22
+ /** Request URL */
23
+ url: string;
24
+ /** Request headers */
25
+ headers: Record<string, string | string[] | undefined>;
26
+ /** Request body (if applicable) */
27
+ body?: unknown;
28
+ }
29
+ /**
30
+ * H3 Event type placeholder
31
+ * This represents the H3 event object from Nitro's h3 library
32
+ */
33
+ export interface H3Event {
34
+ /** HTTP method */
35
+ method: string;
36
+ /** Node.js request object */
37
+ node?: {
38
+ req: unknown;
39
+ res?: unknown;
40
+ };
41
+ /** Event context for storing data */
42
+ context: Record<string, unknown>;
43
+ /** Request path */
44
+ path: string;
45
+ }
46
+ /**
47
+ * Avalon-specific runtime configuration stored in Nitro's runtimeConfig
48
+ * This is accessed via useRuntimeConfig().avalon in handlers
49
+ */
50
+ export interface AvalonRuntimeConfig {
51
+ /** Enable streaming SSR responses */
52
+ streaming: boolean;
53
+ /** Pages directory path relative to project root */
54
+ pagesDir: string;
55
+ /** Layouts directory path relative to project root */
56
+ layoutsDir: string;
57
+ /** Source directory path relative to project root */
58
+ srcDir?: string;
59
+ }
60
+ /**
61
+ * Render context provided to the SSR renderer
62
+ * Contains all information needed to render a page
63
+ */
64
+ export interface NitroRenderContext {
65
+ /** Request URL */
66
+ url: URL;
67
+ /** Route parameters extracted from dynamic segments */
68
+ params: Record<string, string>;
69
+ /** Query parameters from URL search string */
70
+ query: Record<string, string | string[]>;
71
+ /** Original HTTP request */
72
+ request: Request;
73
+ /** H3 event for advanced use cases */
74
+ event: H3Event;
75
+ /** Middleware context if middleware was executed */
76
+ middlewareContext?: MiddlewareContext;
77
+ /** Layout context for rendering */
78
+ layoutContext?: LayoutContext;
79
+ }
80
+ /**
81
+ * Layout context for page rendering
82
+ */
83
+ export interface LayoutContext {
84
+ /** Layout component paths in nesting order (outermost first) */
85
+ layouts: string[];
86
+ /** Layout data loaded from layout modules */
87
+ layoutData?: Record<string, unknown>;
88
+ }
89
+ /**
90
+ * Discovered route information
91
+ */
92
+ export interface DiscoveredRoute {
93
+ /** Route type: page or API */
94
+ type: 'page' | 'api';
95
+ /** Absolute file path to the route handler */
96
+ filePath: string;
97
+ /** Route pattern for matching (e.g., /users/:id) */
98
+ pattern: string;
99
+ /** Extracted parameter names from dynamic segments */
100
+ params: string[];
101
+ /** HTTP method for API routes with method suffix */
102
+ method?: ApiMethod;
103
+ }
104
+ /**
105
+ * Nitro route configuration
106
+ */
107
+ export interface NitroRouteConfig {
108
+ /** Route pattern (e.g., /users/:id) */
109
+ pattern: string;
110
+ /** Route handler type */
111
+ type: 'page' | 'api' | 'middleware';
112
+ /** File path to the handler */
113
+ filePath: string;
114
+ /** Extracted parameter names */
115
+ params: string[];
116
+ /** HTTP method (for API routes) */
117
+ method?: ApiMethod;
118
+ /** Layout chain for pages */
119
+ layouts?: string[];
120
+ }
121
+ /**
122
+ * SSR render options
123
+ */
124
+ export interface SSRRenderOptions {
125
+ /** Enable streaming SSR */
126
+ streaming?: boolean;
127
+ /** Callback when shell is ready (for streaming) */
128
+ onShellReady?: () => void;
129
+ /** Callback when all content is ready */
130
+ onAllReady?: () => void;
131
+ /** Callback on render error */
132
+ onError?: (error: Error) => void;
133
+ }
134
+ /**
135
+ * SSR render result
136
+ */
137
+ export interface SSRRenderResult {
138
+ /** Rendered HTML string or stream */
139
+ html: string | ReadableStream<Uint8Array>;
140
+ /** HTTP status code */
141
+ statusCode: number;
142
+ /** Response headers */
143
+ headers: Record<string, string>;
144
+ }
145
+ /**
146
+ * Island manifest entry for a single island
147
+ */
148
+ export interface IslandEntry {
149
+ /** Compiled JavaScript path */
150
+ src: string;
151
+ /** Framework identifier (react, vue, svelte, etc.) */
152
+ framework: string;
153
+ /** CSS dependencies */
154
+ css?: string[];
155
+ /** Preload dependencies */
156
+ preload?: string[];
157
+ }
158
+ /**
159
+ * Island manifest for production builds
160
+ */
161
+ export interface IslandManifest {
162
+ /** Map of island ID to compiled asset information */
163
+ islands: Record<string, IslandEntry>;
164
+ /** Client entry script path */
165
+ clientEntry: string;
166
+ /** CSS assets to inject */
167
+ css: string[];
168
+ }
169
+ /**
170
+ * Page module export interface
171
+ */
172
+ export interface PageModule {
173
+ /** Default export - the page component */
174
+ default: unknown;
175
+ /** Optional page metadata */
176
+ metadata?: PageMetadata;
177
+ /** Optional getStaticProps for static generation */
178
+ getStaticProps?: () => Promise<Record<string, unknown>>;
179
+ /** Optional getServerSideProps for SSR */
180
+ getServerSideProps?: (context: NitroRenderContext) => Promise<Record<string, unknown>>;
181
+ }
182
+ /**
183
+ * Page metadata for SEO and configuration
184
+ */
185
+ export interface PageMetadata {
186
+ /** Page title */
187
+ title?: string;
188
+ /** Page description */
189
+ description?: string;
190
+ /** Open Graph metadata */
191
+ openGraph?: {
192
+ title?: string;
193
+ description?: string;
194
+ image?: string;
195
+ };
196
+ /** Additional head elements */
197
+ head?: Array<{
198
+ tag: string;
199
+ attrs?: Record<string, string>;
200
+ content?: string;
201
+ }>;
202
+ }
203
+ /**
204
+ * Error response structure
205
+ */
206
+ export interface ErrorResponse {
207
+ /** HTTP status code */
208
+ statusCode: number;
209
+ /** Error message */
210
+ message: string;
211
+ /** Stack trace (development only) */
212
+ stack?: string;
213
+ /** Additional error data */
214
+ data?: Record<string, unknown>;
215
+ }
216
+ /**
217
+ * HTTP error class for typed error handling
218
+ */
219
+ export declare class HttpError extends Error {
220
+ /** HTTP status code */
221
+ statusCode: number;
222
+ /** Additional error data */
223
+ data?: Record<string, unknown>;
224
+ constructor(statusCode: number, message: string, data?: Record<string, unknown>);
225
+ }
226
+ /**
227
+ * Create a 404 Not Found error
228
+ */
229
+ export declare function createNotFoundError(message?: string): HttpError;
230
+ /**
231
+ * Create a 405 Method Not Allowed error
232
+ */
233
+ export declare function createMethodNotAllowedError(allowedMethods: string[]): HttpError;
234
+ /**
235
+ * Create a 500 Internal Server Error
236
+ */
237
+ export declare function createInternalError(message?: string): HttpError;
238
+ /**
239
+ * Type guard to check if an error is an HttpError
240
+ */
241
+ export declare function isHttpError(error: unknown): error is HttpError;
242
+ /**
243
+ * Avalon context stored in H3 event.context
244
+ */
245
+ export interface AvalonEventContext {
246
+ /** Middleware context after middleware execution */
247
+ middlewareContext?: MiddlewareContext;
248
+ /** Resolved route information */
249
+ route?: NitroRouteConfig;
250
+ /** Page props from getServerSideProps */
251
+ pageProps?: Record<string, unknown>;
252
+ }
253
+ /**
254
+ * Development server options
255
+ */
256
+ export interface DevServerOptions {
257
+ /** Port to listen on */
258
+ port?: number;
259
+ /** Host to bind to */
260
+ host?: string;
261
+ /** Enable HTTPS */
262
+ https?: boolean;
263
+ /** Open browser on start */
264
+ open?: boolean;
265
+ }
266
+ /**
267
+ * Build options for production
268
+ */
269
+ export interface BuildOptions {
270
+ /** Output directory */
271
+ outDir?: string;
272
+ /** Enable source maps */
273
+ sourcemap?: boolean;
274
+ /** Minify output */
275
+ minify?: boolean;
276
+ /** Target preset */
277
+ preset?: string;
278
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Collect CSS from Vite's module graph for SSR.
3
+ *
4
+ * After ssrLoadModule loads a page, Vite's module graph knows about all
5
+ * imported CSS files (including CSS modules). This utility walks the graph
6
+ * starting from the page module and collects all CSS content so it can be
7
+ * injected into the SSR HTML as <style> tags — preventing FOUC.
8
+ */
9
+ import type { ViteDevServer } from "vite";
10
+ /**
11
+ * Collect all CSS imported (directly or transitively) by a given module URL.
12
+ *
13
+ * Walks Vite's module graph breadth-first, collecting the transformed CSS
14
+ * source for every `.css` dependency (including `.module.css`).
15
+ *
16
+ * @param server - The Vite dev server instance
17
+ * @param moduleUrl - The module URL to start from (e.g. "/src/pages/frameworks.tsx")
18
+ * @returns Array of CSS strings ready to be injected as <style> tags
19
+ */
20
+ export declare function collectCssFromModuleGraph(server: ViteDevServer, moduleUrl: string): Promise<string[]>;
21
+ /**
22
+ * Inject collected CSS into an HTML string before </head>.
23
+ *
24
+ * Each CSS string is wrapped in a <style data-avalon-ssr-css> tag.
25
+ * CSS content is sanitized to prevent style tag breakout (XSS via </style> injection).
26
+ * If no </head> is found, styles are prepended to the HTML.
27
+ */
28
+ export declare function injectSsrCss(html: string, cssContents: string[]): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared error page HTML templates for development mode.
3
+ * Extracted from nitro-integration.ts to keep that file focused on coordination.
4
+ *
5
+ * @module render/error-pages
6
+ */
7
+ /**
8
+ * Generates a styled 500 error page for development with stack trace.
9
+ */
10
+ export declare function generateErrorPage(error: Error): string;
11
+ /**
12
+ * Generates a minimal fallback 404 page when the error handler itself fails.
13
+ */
14
+ export declare function generateFallback404(url: string): string;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Isolated SSR Renderer
3
+ *
4
+ * This module provides framework-specific SSR contexts to prevent cross-contamination
5
+ * between different frameworks during server-side rendering. Each framework gets its
6
+ * own isolated import context and rendering pipeline.
7
+ */
8
+ import type { JSX } from 'preact';
9
+ export interface FrameworkSSRContext {
10
+ framework: string;
11
+ imports: Map<string, unknown>;
12
+ renderFunction: (component: unknown, props: unknown) => Promise<string>;
13
+ cleanup: () => void;
14
+ isActive: boolean;
15
+ }
16
+ export interface SSRIsolationConfig {
17
+ enableStrictIsolation: boolean;
18
+ allowedCrossFrameworkImports: string[];
19
+ errorHandling: 'strict' | 'fallback' | 'ignore';
20
+ debugLogging: boolean;
21
+ }
22
+ export interface IsolatedRenderRequest {
23
+ componentPath: string;
24
+ component: () => JSX.Element | Promise<JSX.Element>;
25
+ framework?: string;
26
+ props?: Record<string, unknown>;
27
+ }
28
+ export interface IsolatedRenderResult {
29
+ html: string;
30
+ framework: string;
31
+ success: boolean;
32
+ errors: string[];
33
+ warnings: string[];
34
+ }
35
+ /**
36
+ * Isolated SSR Renderer with framework-specific contexts
37
+ */
38
+ export declare class IsolatedSSRRenderer {
39
+ private readonly contexts;
40
+ private readonly detector;
41
+ private config;
42
+ private activeContext;
43
+ constructor(config?: Partial<SSRIsolationConfig>);
44
+ /**
45
+ * Renders a component with framework isolation
46
+ */
47
+ renderWithIsolation(request: IsolatedRenderRequest): Promise<IsolatedRenderResult>;
48
+ private resolveFramework;
49
+ private renderInContext;
50
+ private tryFallbackRender;
51
+ /**
52
+ * Initializes framework-specific SSR contexts
53
+ */
54
+ private initializeFrameworkContexts;
55
+ /**
56
+ * Gets or creates a framework context
57
+ */
58
+ private getFrameworkContext;
59
+ /**
60
+ * Switches to a specific framework context with isolation
61
+ */
62
+ private switchToContext;
63
+ /**
64
+ * Cleans up a framework context
65
+ */
66
+ private cleanupContext;
67
+ /**
68
+ * Sets up framework-specific environment
69
+ */
70
+ private setupFrameworkEnvironment;
71
+ /**
72
+ * Imports a framework module with isolation
73
+ */
74
+ private importFrameworkModule;
75
+ /**
76
+ * Checks if an import is allowed for a specific framework
77
+ */
78
+ private isImportAllowed;
79
+ /**
80
+ * Clears framework-specific globals
81
+ */
82
+ private clearFrameworkGlobals;
83
+ /**
84
+ * Ensures Solid environment is properly set up
85
+ */
86
+ private ensureSolidEnvironment;
87
+ /**
88
+ * Ensures Vue environment is properly set up
89
+ */
90
+ private ensureVueEnvironment;
91
+ /**
92
+ * Ensures Svelte environment is properly set up
93
+ */
94
+ private ensureSvelteEnvironment;
95
+ /**
96
+ * Gets component content for framework detection
97
+ */
98
+ private getComponentContent;
99
+ /**
100
+ * Gets current active context
101
+ */
102
+ getActiveContext(): string | null;
103
+ /**
104
+ * Gets all framework contexts
105
+ */
106
+ getContexts(): Map<string, FrameworkSSRContext>;
107
+ /**
108
+ * Updates configuration
109
+ */
110
+ updateConfig(config: Partial<SSRIsolationConfig>): void;
111
+ /**
112
+ * Resets all contexts
113
+ */
114
+ resetAllContexts(): void;
115
+ /**
116
+ * Creates fallback rendering when framework modules are unavailable
117
+ */
118
+ renderWithFallback(component: () => JSX.Element | Promise<JSX.Element>, preferredFramework: string): Promise<IsolatedRenderResult>;
119
+ /**
120
+ * Validates that a framework context is properly set up
121
+ */
122
+ validateFrameworkContext(framework: string): Promise<boolean>;
123
+ /**
124
+ * Gets framework-specific error recovery strategies
125
+ */
126
+ getErrorRecoveryStrategies(framework: string): string[];
127
+ }
@@ -0,0 +1,56 @@
1
+ import { type JSX } from 'preact';
2
+ import type { RenderOptions } from '../schemas/core.ts';
3
+ import type { EnhancedLayoutResolver } from '../core/layout/enhanced-layout-resolver.ts';
4
+ import type { LayoutContext } from '../types/layout.ts';
5
+ export interface RouteConfig {
6
+ component: () => JSX.Element | Promise<JSX.Element>;
7
+ options?: Partial<RenderOptions>;
8
+ frontmatter?: Record<string, unknown>;
9
+ }
10
+ export interface RenderStrategy {
11
+ type: 'hydrate' | 'ssr-only';
12
+ reason: string;
13
+ warnings?: string[];
14
+ }
15
+ export interface ComponentRenderOptions {
16
+ forceSSROnly?: boolean;
17
+ detectScripts?: boolean;
18
+ suppressWarnings?: boolean;
19
+ logDecisions?: boolean;
20
+ }
21
+ export declare function renderToHtml(routeConfig: RouteConfig, defaultOptions?: Partial<RenderOptions>, viteHmrPort?: number, renderOptions?: ComponentRenderOptions): Promise<string>;
22
+ /**
23
+ * Render to HTML with layout system support
24
+ */
25
+ export declare function renderToHtmlWithLayouts(routeConfig: RouteConfig, layoutResolver: EnhancedLayoutResolver, layoutContext: LayoutContext, routePath: string, defaultOptions?: Partial<RenderOptions>, viteHmrPort?: number, renderOptions?: ComponentRenderOptions): Promise<string>;
26
+ /**
27
+ * Streaming render options
28
+ */
29
+ export interface StreamingRenderOptions extends ComponentRenderOptions {
30
+ /**
31
+ * Callback when the shell (initial HTML) is ready to stream
32
+ */
33
+ onShellReady?: () => void;
34
+ /**
35
+ * Callback when an error occurs before streaming starts
36
+ */
37
+ onShellError?: (error: Error) => void;
38
+ /**
39
+ * Callback when all content has been rendered
40
+ */
41
+ onAllReady?: () => void;
42
+ /**
43
+ * Callback for any error during rendering
44
+ */
45
+ onError?: (error: Error) => void;
46
+ }
47
+ /**
48
+ * Renders a route to a streaming HTML response
49
+ * This is the streaming equivalent of renderToHtml()
50
+ */
51
+ export declare function renderToHtmlStream(routeConfig: RouteConfig, defaultOptions?: Partial<RenderOptions>, viteHmrPort?: number, renderOptions?: StreamingRenderOptions): Promise<ReadableStream<Uint8Array>>;
52
+ /**
53
+ * Renders a route with layouts to a streaming HTML response
54
+ * This is the streaming equivalent of renderToHtmlWithLayouts()
55
+ */
56
+ export declare function renderToHtmlStreamWithLayouts(routeConfig: RouteConfig, layoutResolver: EnhancedLayoutResolver, layoutContext: LayoutContext, routePath: string, defaultOptions?: Partial<RenderOptions>, viteHmrPort?: number, renderOptions?: StreamingRenderOptions): Promise<ReadableStream<Uint8Array>>;
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Supported HTTP methods for API routes
4
+ */
5
+ export declare const ApiMethodSchema: z.ZodEnum<{
6
+ GET: "GET";
7
+ POST: "POST";
8
+ PUT: "PUT";
9
+ DELETE: "DELETE";
10
+ PATCH: "PATCH";
11
+ HEAD: "HEAD";
12
+ OPTIONS: "OPTIONS";
13
+ }>;
14
+ export type ApiMethod = z.infer<typeof ApiMethodSchema>;
15
+ /**
16
+ * Discovered API route with metadata
17
+ */
18
+ export interface ApiRoute {
19
+ /** URL pattern for matching requests */
20
+ pattern: URLPattern;
21
+ /** Route configuration with handlers */
22
+ config: unknown;
23
+ /** Original file path relative to src/api */
24
+ filePath: string;
25
+ /** Extracted dynamic parameter names */
26
+ paramNames: string[];
27
+ }
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Schema for meta tags
4
+ */
5
+ export declare const MetaTagSchema: z.ZodObject<{
6
+ name: z.ZodString;
7
+ content: z.ZodString;
8
+ }, z.core.$strip>;
9
+ /**
10
+ * Script configuration schema - supports both simple URLs and complex script objects
11
+ */
12
+ export declare const ScriptConfigSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
13
+ src: z.ZodOptional<z.ZodString>;
14
+ content: z.ZodOptional<z.ZodString>;
15
+ data: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>, z.ZodString]>>;
16
+ type: z.ZodOptional<z.ZodString>;
17
+ async: z.ZodOptional<z.ZodBoolean>;
18
+ defer: z.ZodOptional<z.ZodBoolean>;
19
+ crossorigin: z.ZodOptional<z.ZodEnum<{
20
+ anonymous: "anonymous";
21
+ "use-credentials": "use-credentials";
22
+ }>>;
23
+ integrity: z.ZodOptional<z.ZodString>;
24
+ nomodule: z.ZodOptional<z.ZodBoolean>;
25
+ referrerpolicy: z.ZodOptional<z.ZodEnum<{
26
+ "no-referrer": "no-referrer";
27
+ "no-referrer-when-downgrade": "no-referrer-when-downgrade";
28
+ origin: "origin";
29
+ "origin-when-cross-origin": "origin-when-cross-origin";
30
+ "same-origin": "same-origin";
31
+ "strict-origin": "strict-origin";
32
+ "strict-origin-when-cross-origin": "strict-origin-when-cross-origin";
33
+ "unsafe-url": "unsafe-url";
34
+ }>>;
35
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
36
+ }, z.core.$strip>]>;
37
+ /**
38
+ * Simplified render options for Vite-powered architecture
39
+ */
40
+ export declare const RenderOptionsSchema: z.ZodObject<{
41
+ title: z.ZodOptional<z.ZodString>;
42
+ scripts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
43
+ src: z.ZodOptional<z.ZodString>;
44
+ content: z.ZodOptional<z.ZodString>;
45
+ data: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>, z.ZodString]>>;
46
+ type: z.ZodOptional<z.ZodString>;
47
+ async: z.ZodOptional<z.ZodBoolean>;
48
+ defer: z.ZodOptional<z.ZodBoolean>;
49
+ crossorigin: z.ZodOptional<z.ZodEnum<{
50
+ anonymous: "anonymous";
51
+ "use-credentials": "use-credentials";
52
+ }>>;
53
+ integrity: z.ZodOptional<z.ZodString>;
54
+ nomodule: z.ZodOptional<z.ZodBoolean>;
55
+ referrerpolicy: z.ZodOptional<z.ZodEnum<{
56
+ "no-referrer": "no-referrer";
57
+ "no-referrer-when-downgrade": "no-referrer-when-downgrade";
58
+ origin: "origin";
59
+ "origin-when-cross-origin": "origin-when-cross-origin";
60
+ "same-origin": "same-origin";
61
+ "strict-origin": "strict-origin";
62
+ "strict-origin-when-cross-origin": "strict-origin-when-cross-origin";
63
+ "unsafe-url": "unsafe-url";
64
+ }>>;
65
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
66
+ }, z.core.$strip>]>>>;
67
+ styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ meta: z.ZodOptional<z.ZodArray<z.ZodObject<{
69
+ name: z.ZodString;
70
+ content: z.ZodString;
71
+ }, z.core.$strip>>>;
72
+ }, z.core.$strip>;
73
+ export type MetaTag = z.infer<typeof MetaTagSchema>;
74
+ export type ScriptConfig = z.infer<typeof ScriptConfigSchema>;
75
+ export type RenderOptions = z.infer<typeof RenderOptionsSchema>;
@@ -0,0 +1,79 @@
1
+ import { z } from 'zod';
2
+ import type { RenderOptions } from './core.ts';
3
+ import type { LayoutContext, LayoutData, LayoutHandler, LayoutDiscoveryOptions, LayoutConfig, ResolvedLayout } from './layout.ts';
4
+ import type { FileSystemRoute, RoutePageModule, RouteDiscoveryOptions, FileSystemRouterConfig, Metadata, ResolvedMetadata } from './routing.ts';
5
+ export * from './core.ts';
6
+ export * from './api.ts';
7
+ export * from './layout.ts';
8
+ export * from './routing.ts';
9
+ export interface ValidationSuccess<T> {
10
+ success: true;
11
+ data: T;
12
+ }
13
+ export interface ValidationFailure {
14
+ success: false;
15
+ error: ValidationError;
16
+ }
17
+ export type ValidationResult<T> = ValidationSuccess<T> | ValidationFailure;
18
+ export declare class ValidationError extends Error {
19
+ readonly zodError: z.ZodError;
20
+ constructor(message: string, zodError: z.ZodError);
21
+ getFormattedErrors(): string[];
22
+ getErrorMessage(): string;
23
+ }
24
+ export declare function createValidationError(message: string, zodError: z.ZodError): ValidationError;
25
+ export declare function safeValidate<TOutput>(schema: z.ZodType<TOutput>, data: unknown, errorMessage?: string): ValidationResult<TOutput>;
26
+ export declare function validate<TOutput>(schema: z.ZodType<TOutput>, data: unknown, errorMessage?: string): TOutput;
27
+ export declare const validators: {
28
+ readonly renderOptions: (data: unknown) => RenderOptions;
29
+ readonly layoutContext: (data: unknown) => LayoutContext;
30
+ readonly layoutData: (data: unknown) => LayoutData;
31
+ readonly layoutHandler: (data: unknown) => LayoutHandler;
32
+ readonly layoutDiscoveryOptions: (data: unknown) => LayoutDiscoveryOptions;
33
+ readonly layoutConfig: (data: unknown) => LayoutConfig;
34
+ readonly resolvedLayout: (data: unknown) => ResolvedLayout;
35
+ readonly fileSystemRoute: (data: unknown) => FileSystemRoute;
36
+ readonly routePageModule: (data: unknown) => RoutePageModule;
37
+ readonly routeDiscoveryOptions: (data: unknown) => RouteDiscoveryOptions;
38
+ readonly fileSystemRouterConfig: (data: unknown) => FileSystemRouterConfig;
39
+ readonly metadata: (data: unknown) => Metadata;
40
+ readonly resolvedMetadata: (data: unknown) => ResolvedMetadata;
41
+ };
42
+ export declare const safeValidators: {
43
+ readonly renderOptions: (data: unknown) => ValidationResult<RenderOptions>;
44
+ readonly layoutContext: (data: unknown) => ValidationResult<LayoutContext>;
45
+ readonly layoutData: (data: unknown) => ValidationResult<LayoutData>;
46
+ readonly layoutHandler: (data: unknown) => ValidationResult<LayoutHandler>;
47
+ readonly layoutDiscoveryOptions: (data: unknown) => ValidationResult<LayoutDiscoveryOptions>;
48
+ readonly layoutConfig: (data: unknown) => ValidationResult<LayoutConfig>;
49
+ readonly resolvedLayout: (data: unknown) => ValidationResult<ResolvedLayout>;
50
+ readonly fileSystemRoute: (data: unknown) => ValidationResult<FileSystemRoute>;
51
+ readonly routePageModule: (data: unknown) => ValidationResult<RoutePageModule>;
52
+ readonly routeDiscoveryOptions: (data: unknown) => ValidationResult<RouteDiscoveryOptions>;
53
+ readonly fileSystemRouterConfig: (data: unknown) => ValidationResult<FileSystemRouterConfig>;
54
+ readonly metadata: (data: unknown) => ValidationResult<Metadata>;
55
+ readonly resolvedMetadata: (data: unknown) => ValidationResult<ResolvedMetadata>;
56
+ };
57
+ export declare const devValidators: {
58
+ readonly renderOptionsSoft: (data: unknown, context?: string) => boolean;
59
+ };
60
+ export declare function isValidRenderOptions(data: unknown): data is RenderOptions;
61
+ export declare function isValidFileSystemRoute(data: unknown): data is FileSystemRoute;
62
+ export declare function isValidRoutePageModule(data: unknown): data is RoutePageModule;
63
+ export declare function isValidRouteDiscoveryOptions(data: unknown): data is RouteDiscoveryOptions;
64
+ export declare function isValidFileSystemRouterConfig(data: unknown): data is FileSystemRouterConfig;
65
+ export declare function isValidMetadata(data: unknown): data is Metadata;
66
+ export declare function isValidResolvedMetadata(data: unknown): data is ResolvedMetadata;
67
+ export declare function validateBatch<T extends Record<string, unknown>>(schemas: {
68
+ [K in keyof T]: z.ZodType<T[K]>;
69
+ }, data: {
70
+ [K in keyof T]: unknown;
71
+ }): T;
72
+ export declare function safeValidateBatch<T extends Record<string, unknown>>(schemas: {
73
+ [K in keyof T]: z.ZodType<T[K]>;
74
+ }, data: {
75
+ [K in keyof T]: unknown;
76
+ }): ValidationResult<T>;
77
+ export type ExtractValidationData<T> = T extends ValidationResult<infer U> ? U : never;
78
+ export type ExtractSchemaInput<T> = T extends z.ZodType<infer U> ? U : never;
79
+ export type ExtractSchemaOutput<T> = T extends z.ZodType<infer U> ? U : never;