@useavalon/avalon 0.1.13 → 0.1.14

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 (230) hide show
  1. package/dist/mod.js +1 -0
  2. package/dist/src/build/integration-bundler-plugin.js +1 -0
  3. package/dist/src/build/integration-config.js +1 -0
  4. package/dist/src/build/integration-detection-plugin.js +1 -0
  5. package/dist/src/build/integration-resolver-plugin.js +1 -0
  6. package/dist/src/build/island-manifest.js +1 -0
  7. package/dist/src/build/island-types-generator.js +5 -0
  8. package/dist/src/build/mdx-island-transform.js +2 -0
  9. package/dist/src/build/mdx-plugin.js +1 -0
  10. package/dist/src/build/page-island-transform.js +3 -0
  11. package/dist/src/build/prop-extractors/index.js +1 -0
  12. package/dist/src/build/prop-extractors/lit.js +1 -0
  13. package/dist/src/build/prop-extractors/qwik.js +1 -0
  14. package/dist/src/build/prop-extractors/solid.js +1 -0
  15. package/dist/src/build/prop-extractors/svelte.js +1 -0
  16. package/dist/src/build/prop-extractors/vue.js +1 -0
  17. package/dist/src/build/sidecar-file-manager.js +1 -0
  18. package/dist/src/build/sidecar-renderer.js +6 -0
  19. package/dist/src/client/adapters/index.js +1 -0
  20. package/dist/src/client/components.js +1 -0
  21. package/dist/src/client/css-hmr-handler.js +1 -0
  22. package/dist/src/client/framework-adapter.js +13 -0
  23. package/dist/src/client/hmr-coordinator.js +1 -0
  24. package/dist/src/client/hmr-error-overlay.js +214 -0
  25. package/dist/src/client/main.js +39 -0
  26. package/dist/src/components/Image.js +1 -0
  27. package/dist/src/components/IslandErrorBoundary.js +1 -0
  28. package/dist/src/components/LayoutDataErrorBoundary.js +1 -0
  29. package/dist/src/components/LayoutErrorBoundary.js +1 -0
  30. package/dist/src/components/PersistentIsland.js +1 -0
  31. package/dist/src/components/StreamingErrorBoundary.js +1 -0
  32. package/dist/src/components/StreamingLayout.js +29 -0
  33. package/dist/src/core/components/component-analyzer.js +1 -0
  34. package/dist/src/core/components/component-detection.js +5 -0
  35. package/dist/src/core/components/enhanced-framework-detector.js +1 -0
  36. package/dist/src/core/components/framework-registry.js +1 -0
  37. package/dist/src/core/content/mdx-processor.js +1 -0
  38. package/dist/src/core/integrations/index.js +1 -0
  39. package/dist/src/core/integrations/loader.js +1 -0
  40. package/dist/src/core/integrations/registry.js +1 -0
  41. package/dist/src/core/islands/island-persistence.js +1 -0
  42. package/dist/src/core/islands/island-state-serializer.js +1 -0
  43. package/dist/src/core/islands/persistent-island-context.js +1 -0
  44. package/dist/src/core/islands/use-persistent-state.js +1 -0
  45. package/dist/src/core/layout/enhanced-layout-resolver.js +1 -0
  46. package/dist/src/core/layout/layout-cache-manager.js +1 -0
  47. package/dist/src/core/layout/layout-composer.js +1 -0
  48. package/dist/src/core/layout/layout-data-loader.js +1 -0
  49. package/dist/src/core/layout/layout-discovery.js +1 -0
  50. package/dist/src/core/layout/layout-matcher.js +1 -0
  51. package/dist/src/core/layout/layout-types.js +1 -0
  52. package/dist/src/core/modules/framework-module-resolver.js +1 -0
  53. package/dist/src/islands/component-analysis.js +1 -0
  54. package/dist/src/islands/css-utils.js +17 -0
  55. package/dist/src/islands/discovery/index.js +1 -0
  56. package/dist/src/islands/discovery/registry.js +1 -0
  57. package/dist/src/islands/discovery/resolver.js +2 -0
  58. package/dist/src/islands/discovery/scanner.js +1 -0
  59. package/dist/src/islands/discovery/types.js +1 -0
  60. package/dist/src/islands/discovery/validator.js +18 -0
  61. package/dist/src/islands/discovery/watcher.js +1 -0
  62. package/dist/src/islands/framework-detection.js +1 -0
  63. package/dist/src/islands/integration-loader.js +1 -0
  64. package/dist/src/islands/island.js +1 -0
  65. package/dist/src/islands/render-cache.js +1 -0
  66. package/dist/src/islands/types.js +1 -0
  67. package/dist/src/islands/universal-css-collector.js +5 -0
  68. package/dist/src/islands/universal-head-collector.js +2 -0
  69. package/dist/src/layout-system.js +1 -0
  70. package/dist/src/middleware/discovery.js +1 -0
  71. package/dist/src/middleware/executor.js +1 -0
  72. package/dist/src/middleware/index.js +1 -0
  73. package/dist/src/middleware/types.js +1 -0
  74. package/dist/src/nitro/build-config.js +1 -0
  75. package/dist/src/nitro/config.js +1 -0
  76. package/dist/src/nitro/error-handler.js +198 -0
  77. package/dist/src/nitro/index.js +1 -0
  78. package/dist/src/nitro/island-manifest.js +2 -0
  79. package/dist/src/nitro/middleware-adapter.js +1 -0
  80. package/dist/src/nitro/renderer.js +183 -0
  81. package/dist/src/nitro/route-discovery.js +1 -0
  82. package/dist/src/nitro/types.js +1 -0
  83. package/dist/src/render/collect-css.js +3 -0
  84. package/dist/src/render/error-pages.js +48 -0
  85. package/dist/src/render/isolated-ssr-renderer.js +1 -0
  86. package/dist/src/render/ssr.js +90 -0
  87. package/dist/src/schemas/api.js +1 -0
  88. package/dist/src/schemas/core.js +1 -0
  89. package/dist/src/schemas/index.js +1 -0
  90. package/dist/src/schemas/layout.js +1 -0
  91. package/dist/src/schemas/routing/index.js +1 -0
  92. package/dist/src/schemas/routing.js +1 -0
  93. package/dist/src/types/as-island.js +1 -0
  94. package/dist/src/types/layout.js +1 -0
  95. package/dist/src/types/routing.js +1 -0
  96. package/dist/src/types/types.js +1 -0
  97. package/dist/src/utils/dev-logger.js +12 -0
  98. package/dist/src/utils/fs.js +1 -0
  99. package/dist/src/vite-plugin/auto-discover.js +1 -0
  100. package/dist/src/vite-plugin/config.js +1 -0
  101. package/dist/src/vite-plugin/errors.js +1 -0
  102. package/dist/src/vite-plugin/image-optimization.js +45 -0
  103. package/dist/src/vite-plugin/integration-activator.js +1 -0
  104. package/dist/src/vite-plugin/island-sidecar-plugin.js +1 -0
  105. package/dist/src/vite-plugin/module-discovery.js +1 -0
  106. package/dist/src/vite-plugin/nitro-integration.js +42 -0
  107. package/dist/src/vite-plugin/plugin.js +1 -0
  108. package/dist/src/vite-plugin/types.js +1 -0
  109. package/dist/src/vite-plugin/validation.js +2 -0
  110. package/package.json +14 -20
  111. package/mod.ts +0 -302
  112. package/src/build/integration-bundler-plugin.ts +0 -116
  113. package/src/build/integration-config.ts +0 -168
  114. package/src/build/integration-detection-plugin.ts +0 -117
  115. package/src/build/integration-resolver-plugin.ts +0 -90
  116. package/src/build/island-manifest.ts +0 -269
  117. package/src/build/island-types-generator.ts +0 -476
  118. package/src/build/mdx-island-transform.ts +0 -464
  119. package/src/build/mdx-plugin.ts +0 -98
  120. package/src/build/page-island-transform.ts +0 -598
  121. package/src/build/prop-extractors/index.ts +0 -21
  122. package/src/build/prop-extractors/lit.ts +0 -140
  123. package/src/build/prop-extractors/qwik.ts +0 -16
  124. package/src/build/prop-extractors/solid.ts +0 -125
  125. package/src/build/prop-extractors/svelte.ts +0 -194
  126. package/src/build/prop-extractors/vue.ts +0 -111
  127. package/src/build/sidecar-file-manager.ts +0 -104
  128. package/src/build/sidecar-renderer.ts +0 -30
  129. package/src/client/adapters/index.ts +0 -21
  130. package/src/client/components.ts +0 -35
  131. package/src/client/css-hmr-handler.ts +0 -344
  132. package/src/client/framework-adapter.ts +0 -462
  133. package/src/client/hmr-coordinator.ts +0 -396
  134. package/src/client/hmr-error-overlay.js +0 -533
  135. package/src/client/main.js +0 -824
  136. package/src/components/Image.tsx +0 -123
  137. package/src/components/IslandErrorBoundary.tsx +0 -145
  138. package/src/components/LayoutDataErrorBoundary.tsx +0 -141
  139. package/src/components/LayoutErrorBoundary.tsx +0 -127
  140. package/src/components/PersistentIsland.tsx +0 -52
  141. package/src/components/StreamingErrorBoundary.tsx +0 -233
  142. package/src/components/StreamingLayout.tsx +0 -538
  143. package/src/core/components/component-analyzer.ts +0 -192
  144. package/src/core/components/component-detection.ts +0 -508
  145. package/src/core/components/enhanced-framework-detector.ts +0 -500
  146. package/src/core/components/framework-registry.ts +0 -563
  147. package/src/core/content/mdx-processor.ts +0 -46
  148. package/src/core/integrations/index.ts +0 -19
  149. package/src/core/integrations/loader.ts +0 -125
  150. package/src/core/integrations/registry.ts +0 -175
  151. package/src/core/islands/island-persistence.ts +0 -325
  152. package/src/core/islands/island-state-serializer.ts +0 -258
  153. package/src/core/islands/persistent-island-context.tsx +0 -80
  154. package/src/core/islands/use-persistent-state.ts +0 -68
  155. package/src/core/layout/enhanced-layout-resolver.ts +0 -322
  156. package/src/core/layout/layout-cache-manager.ts +0 -485
  157. package/src/core/layout/layout-composer.ts +0 -357
  158. package/src/core/layout/layout-data-loader.ts +0 -516
  159. package/src/core/layout/layout-discovery.ts +0 -243
  160. package/src/core/layout/layout-matcher.ts +0 -299
  161. package/src/core/layout/layout-types.ts +0 -110
  162. package/src/core/modules/framework-module-resolver.ts +0 -273
  163. package/src/islands/component-analysis.ts +0 -213
  164. package/src/islands/css-utils.ts +0 -565
  165. package/src/islands/discovery/index.ts +0 -80
  166. package/src/islands/discovery/registry.ts +0 -340
  167. package/src/islands/discovery/resolver.ts +0 -477
  168. package/src/islands/discovery/scanner.ts +0 -386
  169. package/src/islands/discovery/types.ts +0 -117
  170. package/src/islands/discovery/validator.ts +0 -544
  171. package/src/islands/discovery/watcher.ts +0 -368
  172. package/src/islands/framework-detection.ts +0 -428
  173. package/src/islands/integration-loader.ts +0 -490
  174. package/src/islands/island.tsx +0 -565
  175. package/src/islands/render-cache.ts +0 -550
  176. package/src/islands/types.ts +0 -80
  177. package/src/islands/universal-css-collector.ts +0 -157
  178. package/src/islands/universal-head-collector.ts +0 -137
  179. package/src/layout-system.ts +0 -218
  180. package/src/middleware/discovery.ts +0 -268
  181. package/src/middleware/executor.ts +0 -315
  182. package/src/middleware/index.ts +0 -76
  183. package/src/middleware/types.ts +0 -99
  184. package/src/nitro/build-config.ts +0 -576
  185. package/src/nitro/config.ts +0 -483
  186. package/src/nitro/error-handler.ts +0 -636
  187. package/src/nitro/index.ts +0 -173
  188. package/src/nitro/island-manifest.ts +0 -584
  189. package/src/nitro/middleware-adapter.ts +0 -260
  190. package/src/nitro/renderer.ts +0 -1471
  191. package/src/nitro/route-discovery.ts +0 -439
  192. package/src/nitro/types.ts +0 -321
  193. package/src/render/collect-css.ts +0 -198
  194. package/src/render/error-pages.ts +0 -79
  195. package/src/render/isolated-ssr-renderer.ts +0 -654
  196. package/src/render/ssr.ts +0 -1030
  197. package/src/schemas/api.ts +0 -30
  198. package/src/schemas/core.ts +0 -64
  199. package/src/schemas/index.ts +0 -212
  200. package/src/schemas/layout.ts +0 -279
  201. package/src/schemas/routing/index.ts +0 -38
  202. package/src/schemas/routing.ts +0 -376
  203. package/src/types/as-island.ts +0 -20
  204. package/src/types/layout.ts +0 -285
  205. package/src/types/routing.ts +0 -555
  206. package/src/types/types.ts +0 -5
  207. package/src/utils/dev-logger.ts +0 -299
  208. package/src/utils/fs.ts +0 -151
  209. package/src/vite-plugin/auto-discover.ts +0 -551
  210. package/src/vite-plugin/config.ts +0 -266
  211. package/src/vite-plugin/errors.ts +0 -127
  212. package/src/vite-plugin/image-optimization.ts +0 -156
  213. package/src/vite-plugin/integration-activator.ts +0 -126
  214. package/src/vite-plugin/island-sidecar-plugin.ts +0 -176
  215. package/src/vite-plugin/module-discovery.ts +0 -189
  216. package/src/vite-plugin/nitro-integration.ts +0 -1354
  217. package/src/vite-plugin/plugin.ts +0 -403
  218. package/src/vite-plugin/types.ts +0 -327
  219. package/src/vite-plugin/validation.ts +0 -228
  220. /package/{src → dist/src}/client/types/framework-runtime.d.ts +0 -0
  221. /package/{src → dist/src}/client/types/vite-hmr.d.ts +0 -0
  222. /package/{src → dist/src}/client/types/vite-virtual-modules.d.ts +0 -0
  223. /package/{src → dist/src}/layout-system.d.ts +0 -0
  224. /package/{src → dist/src}/types/image.d.ts +0 -0
  225. /package/{src → dist/src}/types/index.d.ts +0 -0
  226. /package/{src → dist/src}/types/island-jsx.d.ts +0 -0
  227. /package/{src → dist/src}/types/island-prop.d.ts +0 -0
  228. /package/{src → dist/src}/types/mdx.d.ts +0 -0
  229. /package/{src → dist/src}/types/urlpattern.d.ts +0 -0
  230. /package/{src → dist/src}/types/vite-env.d.ts +0 -0
@@ -1,376 +0,0 @@
1
- import { z } from 'zod';
2
- import type { ComponentType } from 'preact/compat';
3
-
4
- /**
5
- * Route Type Schema - Defines the different types of routes supported
6
- */
7
- export const RouteTypeSchema = z.enum(['static', 'dynamic', 'catch-all', 'index', 'group']);
8
-
9
- /**
10
- * File System Route Schema - Represents a discovered route from the file system
11
- */
12
- export const FileSystemRouteSchema = z.object({
13
- /** URL pattern for matching requests */
14
- pattern: z.any(), // URLPattern object - can't validate with Zod
15
- /** File path to the page component */
16
- filePath: z.string().min(1),
17
- /** Type of route (static, dynamic, etc.) */
18
- routeType: RouteTypeSchema,
19
- /** Dynamic segments extracted from the file path */
20
- dynamicSegments: z.array(z.string()),
21
- /** Route priority for conflict resolution (lower = higher priority) */
22
- priority: z.number().int().min(0),
23
- /** Whether this route is in a private folder */
24
- isPrivate: z.boolean(),
25
- /** Route group name if the route is in a group */
26
- routeGroup: z.string().optional(),
27
- });
28
-
29
- /**
30
- * Route Page Module Schema - Represents the exports from a page file in routing context
31
- */
32
- export const RoutePageModuleSchema = z.object({
33
- /** Default export - the page component */
34
- default: z.any(), // ComponentType<PageProps> - can't validate function types with Zod
35
- /** Optional layout configuration for this page */
36
- layoutConfig: z.any().optional(), // LayoutConfig from layout system
37
- /** Optional metadata generator function */
38
- generateMetadata: z.any().optional(), // (params: RouteParams) => Promise<Metadata>
39
- /** Optional data loader function */
40
- loader: z.any().optional(), // (context: LoaderContext) => Promise<any>
41
- /** Optional frontmatter data from MDX files */
42
- frontmatter: z.record(z.string(), z.any()).optional(), // Frontmatter metadata from MDX files
43
- });
44
-
45
- /**
46
- * Route Parameters Schema - Parameters extracted from dynamic routes
47
- */
48
- export const RouteParamsSchema = z.record(z.string(), z.string());
49
-
50
- /**
51
- * Loader Context Schema - Context passed to page loaders
52
- */
53
- export const LoaderContextSchema = z.object({
54
- /** HTTP request object */
55
- request: z.instanceof(Request),
56
- /** URL object for easy access */
57
- url: z.instanceof(URL),
58
- /** Route parameters */
59
- params: RouteParamsSchema,
60
- /** Query parameters */
61
- query: z.instanceof(URLSearchParams),
62
- /** State from middleware */
63
- state: z.instanceof(Map),
64
- });
65
-
66
- /**
67
- * Page Props Schema - Props passed to page components
68
- */
69
- export const PagePropsSchema = z.object({
70
- /** Route parameters */
71
- params: RouteParamsSchema,
72
- /** Query parameters */
73
- query: z.instanceof(URLSearchParams),
74
- /** Data from loader function */
75
- data: z.unknown().optional(),
76
- });
77
-
78
- /**
79
- * Metadata Schema - SEO and meta information
80
- */
81
- export const MetadataSchema = z.object({
82
- /** Page title */
83
- title: z.string().optional(),
84
- /** Page description */
85
- description: z.string().optional(),
86
- /** Keywords for SEO */
87
- keywords: z.array(z.string()).optional(),
88
- /** Open Graph data */
89
- openGraph: z
90
- .object({
91
- title: z.string().optional(),
92
- description: z.string().optional(),
93
- image: z.url().optional(),
94
- url: z.url().optional(),
95
- type: z.string().optional(),
96
- siteName: z.string().optional(),
97
- })
98
- .optional(),
99
- /** Twitter Card data */
100
- twitter: z
101
- .object({
102
- card: z.enum(['summary', 'summary_large_image', 'app', 'player']).optional(),
103
- title: z.string().optional(),
104
- description: z.string().optional(),
105
- image: z.url().optional(),
106
- site: z.string().optional(),
107
- })
108
- .optional(),
109
- /** Schema.org structured data */
110
- schema: z.array(z.record(z.string(), z.unknown())).optional(),
111
- /** Canonical URL */
112
- canonical: z.url().optional(),
113
- /** Robots meta tag */
114
- robots: z.string().optional(),
115
- });
116
-
117
- /**
118
- * Resolved Metadata Schema - Final merged metadata for a route
119
- */
120
- export const ResolvedMetadataSchema = MetadataSchema.extend({
121
- /** Source chain for debugging */
122
- sources: z.array(z.string()).optional(),
123
- /** Resolution timestamp */
124
- resolvedAt: z.number().optional(),
125
- });
126
-
127
- /**
128
- * Metadata Chain Schema - Hierarchical metadata from multiple sources
129
- */
130
- export const MetadataChainSchema = z.object({
131
- /** Global metadata */
132
- global: MetadataSchema.optional(),
133
- /** Section-specific metadata */
134
- sections: z.array(
135
- z.object({
136
- path: z.string(),
137
- metadata: MetadataSchema,
138
- })
139
- ),
140
- /** Page-specific metadata */
141
- page: MetadataSchema.optional(),
142
- });
143
-
144
- /**
145
- * Route Discovery Options Schema - Configuration for route discovery
146
- */
147
- export const RouteDiscoveryOptionsSchema = z.object({
148
- /** Base directory to scan for pages */
149
- pagesDirectory: z.string().min(1).default('src/pages'),
150
- /** Base directory to scan for API routes */
151
- apiDirectory: z.string().min(1).default('src/api'),
152
- /** File extensions to include */
153
- extensions: z.array(z.string()).default(['.tsx', '.ts', '.jsx', '.js']),
154
- /** Directories to exclude from scanning */
155
- excludeDirectories: z.array(z.string()).default(['node_modules', '.git']),
156
- /** Enable file watching for development */
157
- enableWatching: z.boolean().default(false),
158
- /** Development mode features */
159
- developmentMode: z.boolean().default(false),
160
- /** Quiet mode - suppress verbose logging */
161
- quietMode: z.boolean().default(false),
162
- });
163
-
164
- /**
165
- * File System Router Configuration Schema
166
- */
167
- export const FileSystemRouterConfigSchema = z.object({
168
- /** Route discovery options */
169
- discovery: RouteDiscoveryOptionsSchema.optional(),
170
- /** Enable file-system routing */
171
- enabled: z.boolean().default(true),
172
- /** Fallback to manual routes when file-system routes fail */
173
- fallbackToManual: z.boolean().default(true),
174
- /** Cache discovered routes */
175
- enableCaching: z.boolean().default(true),
176
- /** Cache TTL in milliseconds */
177
- cacheTTL: z.number().positive().default(300000), // 5 minutes
178
- });
179
-
180
- /**
181
- * Page File Schema - Information about a discovered page file
182
- */
183
- export const PageFileSchema = z.object({
184
- /** Absolute file path */
185
- filePath: z.string().min(1),
186
- /** Relative path from pages directory */
187
- relativePath: z.string().min(1),
188
- /** File extension */
189
- extension: z.string().min(1),
190
- /** Whether file is in a private folder */
191
- isPrivate: z.boolean(),
192
- /** Route group if applicable */
193
- routeGroup: z.string().optional(),
194
- /** File modification time */
195
- mtime: z.number().optional(),
196
- });
197
-
198
- /**
199
- * Route Handler Schema - Complete route handler information
200
- */
201
- export const RouteHandlerSchema = z.object({
202
- /** Route pattern */
203
- pattern: z.any(), // URLPattern
204
- /** Handler function */
205
- handler: z.any(), // (request: Request, context: LoaderContext) => Promise<Response>
206
- /** Route metadata */
207
- metadata: z.object({
208
- filePath: z.string(),
209
- routeType: RouteTypeSchema,
210
- priority: z.number(),
211
- dynamicSegments: z.array(z.string()),
212
- }),
213
- });
214
-
215
- /**
216
- * Route Cache Entry Schema - Cached route information
217
- */
218
- export const RouteCacheEntrySchema = z.object({
219
- /** Cached routes */
220
- routes: z.array(FileSystemRouteSchema),
221
- /** Cache timestamp */
222
- timestamp: z.number(),
223
- /** File modification times for cache invalidation */
224
- fileMtimes: z.record(z.string(), z.number()),
225
- });
226
-
227
- /**
228
- * File System API Route Schema - Represents an API endpoint route discovered from file system
229
- */
230
- export const FileSystemApiRouteSchema = z.object({
231
- /** URL pattern for the API endpoint */
232
- pattern: z.any(), // URLPattern
233
- /** File path to the API handler */
234
- filePath: z.string().min(1),
235
- /** HTTP methods supported */
236
- methods: z.array(z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'])),
237
- /** Route priority */
238
- priority: z.number().int().min(0),
239
- /** Dynamic segments */
240
- dynamicSegments: z.array(z.string()),
241
- });
242
-
243
- /**
244
- * File System API Module Schema - Exports from an API route file
245
- */
246
- export const FileSystemApiModuleSchema = z.object({
247
- /** GET handler */
248
- GET: z.any().optional(), // (request: Request, context: any) => Promise<Response>
249
- /** POST handler */
250
- POST: z.any().optional(),
251
- /** PUT handler */
252
- PUT: z.any().optional(),
253
- /** DELETE handler */
254
- DELETE: z.any().optional(),
255
- /** PATCH handler */
256
- PATCH: z.any().optional(),
257
- /** HEAD handler */
258
- HEAD: z.any().optional(),
259
- /** OPTIONS handler */
260
- OPTIONS: z.any().optional(),
261
- });
262
-
263
- // === TypeScript Type Definitions ===
264
-
265
- export type RouteType = z.infer<typeof RouteTypeSchema>;
266
- export type FileSystemRoute = z.infer<typeof FileSystemRouteSchema>;
267
- export type RoutePageModule = z.infer<typeof RoutePageModuleSchema>;
268
- export type RouteParams = z.infer<typeof RouteParamsSchema>;
269
- export type LoaderContext = z.infer<typeof LoaderContextSchema>;
270
- export type PageProps = z.infer<typeof PagePropsSchema>;
271
- export type Metadata = z.infer<typeof MetadataSchema>;
272
- export type ResolvedMetadata = z.infer<typeof ResolvedMetadataSchema>;
273
- export type MetadataChain = z.infer<typeof MetadataChainSchema>;
274
- export type RouteDiscoveryOptions = z.infer<typeof RouteDiscoveryOptionsSchema>;
275
- export type FileSystemRouterConfig = z.infer<typeof FileSystemRouterConfigSchema>;
276
- export type PageFile = z.infer<typeof PageFileSchema>;
277
- export type RouteHandler = z.infer<typeof RouteHandlerSchema>;
278
- export type RouteCacheEntry = z.infer<typeof RouteCacheEntrySchema>;
279
- export type FileSystemApiRoute = z.infer<typeof FileSystemApiRouteSchema>;
280
- export type FileSystemApiModule = z.infer<typeof FileSystemApiModuleSchema>;
281
-
282
- // === Function Type Definitions ===
283
-
284
- /**
285
- * Page Component Type
286
- */
287
- export type PageComponent<P extends PageProps = PageProps> = ComponentType<P>;
288
-
289
- /**
290
- * Metadata Generator Function Type
291
- */
292
- export type MetadataGenerator = (params: RouteParams) => Promise<Metadata>;
293
-
294
- /**
295
- * Page Loader Function Type
296
- */
297
- export type PageLoader = (context: LoaderContext) => Promise<unknown>;
298
-
299
- /**
300
- * Route Handler Function Type
301
- */
302
- export type RouteHandlerFunction = (request: Request, context: LoaderContext) => Promise<Response>;
303
-
304
- /**
305
- * File System API Handler Function Type
306
- */
307
- export type FileSystemApiHandler = (request: Request, context: LoaderContext) => Promise<Response>;
308
-
309
- // === Type Guards ===
310
-
311
- /**
312
- * Type guard for FileSystemRoute
313
- */
314
- export function isFileSystemRoute(data: unknown): data is FileSystemRoute {
315
- return FileSystemRouteSchema.safeParse(data).success;
316
- }
317
-
318
- /**
319
- * Type guard for RoutePageModule
320
- */
321
- export function isRoutePageModule(data: unknown): data is RoutePageModule {
322
- return RoutePageModuleSchema.safeParse(data).success;
323
- }
324
-
325
- /**
326
- * Type guard for Metadata
327
- */
328
- export function isMetadata(data: unknown): data is Metadata {
329
- return MetadataSchema.safeParse(data).success;
330
- }
331
-
332
- /**
333
- * Type guard for RouteParams
334
- */
335
- export function isRouteParams(data: unknown): data is RouteParams {
336
- return RouteParamsSchema.safeParse(data).success;
337
- }
338
-
339
- /**
340
- * Type guard for FileSystemApiModule
341
- */
342
- export function isFileSystemApiModule(data: unknown): data is FileSystemApiModule {
343
- return FileSystemApiModuleSchema.safeParse(data).success;
344
- }
345
-
346
- // === Re-exports from types/routing.ts (single source of truth) ===
347
-
348
- export type {
349
- ExtractRouteParams,
350
- ExtractOptionalParams,
351
- RouteParameters,
352
- TypedPageComponent,
353
- TypedPageComponentWithData,
354
- TypedMetadataGenerator,
355
- TypedPageLoader,
356
- TypedApiHandler,
357
- TypedApiModule,
358
- HasDynamicSegments,
359
- HasCatchAllSegments,
360
- HasOptionalSegments,
361
- CountDynamicSegments,
362
- ValidRoutePattern,
363
- ValidRouteExtension,
364
- PageComponentProps,
365
- } from '../types/routing.ts';
366
-
367
- export {
368
- isValidRouteParams,
369
- isValidPageProps,
370
- isValidRoutePattern,
371
- validatePageComponent,
372
- createTypedPageComponent,
373
- createTypedMetadataGenerator,
374
- createTypedPageLoader,
375
- createTypedApiHandler,
376
- } from '../types/routing.ts';
@@ -1,20 +0,0 @@
1
- import type { IslandDirective } from './island-prop.d.ts';
2
- import type { ComponentType } from 'preact';
3
-
4
- /**
5
- * Cast a cross-framework component (Vue, Svelte, Lit, Solid) to be usable
6
- * in Preact JSX with the `island` prop and correct prop types.
7
- *
8
- * The Vite transform handles these components at build time — this cast is
9
- * purely for TypeScript's benefit.
10
- *
11
- * @example
12
- * import _VueCounter from '../islands/VueCounter.vue';
13
- * const VueCounter = asIsland<{ initialCount?: number }>(_VueCounter);
14
- * // Now usable as: <VueCounter island={{ condition: 'on:visible' }} initialCount={0} />
15
- */
16
- export function asIsland<P extends Record<string, unknown> = Record<string, unknown>>(
17
- _component: unknown,
18
- ): ComponentType<P & { island?: IslandDirective }> {
19
- return _component as ComponentType<P & { island?: IslandDirective }>;
20
- }
@@ -1,285 +0,0 @@
1
- import type {
2
- LayoutContext,
3
- LayoutRoute,
4
- LayoutHandler,
5
- LayoutProps,
6
- LayoutDiscoveryOptions,
7
- RouteInfo,
8
- LayoutRule,
9
- LayoutConfig,
10
- IslandState,
11
- PersistentIslandProps,
12
- LayoutErrorInfo,
13
- LayoutErrorBoundaryProps,
14
- ErrorRecoveryStrategy,
15
- StreamingLayoutProps,
16
- StreamingComponent,
17
- ResolvedLayout,
18
- LayoutLoader,
19
- } from '../schemas/layout.ts';
20
- import type { ComponentType, ComponentChildren } from 'preact';
21
-
22
- export type {
23
- LayoutContext,
24
- LayoutData,
25
- LayoutRoute,
26
- LayoutHandler,
27
- LayoutProps,
28
- LayoutDiscoveryOptions,
29
- RouteInfo,
30
- LayoutRule,
31
- LayoutConfig,
32
- IslandState,
33
- PersistentIslandProps,
34
- PersistentIslandContext,
35
- LayoutErrorInfo,
36
- LayoutErrorBoundaryProps,
37
- ErrorRecoveryStrategy,
38
- StreamingLayoutProps,
39
- StreamingComponent,
40
- ResolvedLayout,
41
- LayoutCache,
42
- EnhancedLayoutContext,
43
- LayoutLoader,
44
- LayoutMatcherFunction,
45
- LayoutErrorHandler,
46
- LayoutRetryFunction,
47
- LayoutFallbackRenderer,
48
- IslandStateSaver,
49
- IslandStateLoader,
50
- IslandStateClearer,
51
- StreamingReadyCheck,
52
- } from '../schemas/layout.ts';
53
- export type { ComponentType, ComponentChildren } from 'preact';
54
-
55
- // Import concrete implementations
56
- export { LayoutDiscovery } from '../core/layout/layout-discovery.ts';
57
- export { LayoutDataLoader } from '../core/layout/layout-data-loader.ts';
58
- export { LayoutMatcher as LayoutMatcherClass } from '../core/layout/layout-matcher.ts';
59
- export { LayoutComposer } from '../core/layout/layout-composer.ts';
60
-
61
- // Export persistent islands functionality
62
- export { IslandPersistence, defaultIslandPersistence } from '../core/islands/island-persistence.ts';
63
- export { IslandStateSerializer } from '../core/islands/island-state-serializer.ts';
64
- export {
65
- createPersistentIslandContext,
66
- usePersistentIslandContext,
67
- PersistentIslandProvider,
68
- } from '../core/islands/persistent-island-context.tsx';
69
- export { PersistentIsland } from '../components/PersistentIsland.tsx';
70
-
71
- // Export error boundary functionality
72
- export { LayoutErrorBoundary } from '../components/LayoutErrorBoundary.tsx';
73
- export { LayoutDataErrorBoundary } from '../components/LayoutDataErrorBoundary.tsx';
74
- export { IslandErrorBoundary, withIslandErrorBoundary } from '../components/IslandErrorBoundary.tsx';
75
-
76
- // Export streaming functionality
77
- export {
78
- StreamingLayout,
79
- StreamingSuspense,
80
- withStreaming,
81
- useStreamingState,
82
- } from '../components/StreamingLayout.tsx';
83
-
84
- // Export enhanced layout resolver
85
- export {
86
- EnhancedLayoutResolver,
87
- createEnhancedLayoutResolver,
88
- EnhancedLayoutResolverUtils,
89
- type EnhancedLayoutResolverOptions,
90
- } from '../core/layout/enhanced-layout-resolver.ts';
91
-
92
- // Export only essential layout cache types (no debug/performance tooling)
93
- export {
94
- LayoutCacheManager,
95
- type CacheEntry,
96
- type CacheStats,
97
- type CacheConfig,
98
- } from '../core/layout/layout-cache-manager.ts';
99
-
100
- // === Enhanced Interface Definitions ===
101
-
102
- /**
103
- * Layout Discovery Interface
104
- */
105
- export interface ILayoutDiscovery {
106
- discoverLayouts(routePath: string): Promise<LayoutRoute[]>;
107
- buildLayoutChain(url: URL): Promise<LayoutHandler[]>;
108
- setWatching(enabled: boolean): void;
109
- getOptions(): LayoutDiscoveryOptions;
110
- }
111
-
112
- /**
113
- * Layout Matcher Interface
114
- */
115
- export interface ILayoutMatcher {
116
- addRule(rule: LayoutRule): void;
117
- removeRule(rule: LayoutRule): void;
118
- shouldApplyLayout(layoutPath: string, route: RouteInfo): boolean;
119
- getRules(): LayoutRule[];
120
- clearRules(): void;
121
- }
122
-
123
- /**
124
- * Layout Composer Interface
125
- */
126
- export interface ILayoutComposer {
127
- resolveLayouts(routePath: string, pageModule: PageModule): Promise<LayoutHandler[]>;
128
- applyConfiguration(layouts: LayoutHandler[], config: LayoutConfig): Promise<LayoutHandler[]>;
129
- validateLayoutConfig(config: LayoutConfig): { valid: boolean; errors: string[] };
130
- clearCache(): void;
131
- getCompositionStats(): {
132
- customLayoutCacheSize: number;
133
- discoveryStats: { layoutCount: number; routeCacheCount: number };
134
- };
135
- }
136
-
137
- /**
138
- * Island Persistence Interface
139
- */
140
- export interface IIslandPersistence {
141
- saveState(id: string, state: IslandState): void;
142
- loadState(id: string): IslandState | null;
143
- clearState(id: string): void;
144
- hasState(id: string): boolean;
145
- getStoredIds(): string[];
146
- clearAllStates(): void;
147
- }
148
-
149
- /**
150
- * Layout Error Recovery Interface
151
- */
152
- export interface ILayoutErrorRecovery {
153
- handleLayoutError(error: Error, context: LayoutContext): Promise<Response>;
154
- registerStrategy(errorType: string, strategy: ErrorRecoveryStrategy): void;
155
- getStrategy(error: Error): ErrorRecoveryStrategy | null;
156
- }
157
-
158
- /**
159
- * Layout Streaming Interface
160
- */
161
- export interface ILayoutStreaming {
162
- renderWithStreaming(layout: LayoutHandler, props: LayoutProps): Promise<ReadableStream>;
163
- isStreamingSupported(): boolean;
164
- createStreamingResponse(components: StreamingComponent[]): ReadableStream;
165
- generateSkeleton(component: StreamingComponent): string;
166
- }
167
-
168
- /**
169
- * Enhanced Layout Resolver Interface
170
- */
171
- export interface IEnhancedLayoutResolver {
172
- resolveAndRender(routePath: string, pageModule: PageModule, context: LayoutContext): Promise<ResolvedLayout>;
173
- getCachedResolution(routePath: string): ResolvedLayout | null;
174
- clearCache(): void;
175
- setCaching(enabled: boolean): void;
176
- }
177
-
178
- // === Component Interface Definitions ===
179
-
180
- export interface ILayoutComponent {
181
- props: LayoutProps;
182
- layoutLoader?: LayoutLoader;
183
- layoutConfig?: LayoutConfig;
184
- }
185
-
186
- export interface IPersistentIslandComponent {
187
- props: PersistentIslandProps;
188
- saveState(): void;
189
- loadState(): void;
190
- clearState(): void;
191
- hasState(): boolean;
192
- }
193
-
194
- export interface ILayoutErrorBoundaryComponent {
195
- props: LayoutErrorBoundaryProps;
196
- handleRetry(): void;
197
- getErrorState(): { hasError: boolean; error?: Error };
198
- resetErrorState(): void;
199
- }
200
-
201
- export interface IStreamingLayoutComponent {
202
- props: StreamingLayoutProps;
203
- isReady(): Promise<boolean>;
204
- renderFallback(): ComponentChildren;
205
- getPriority(): number;
206
- }
207
-
208
- // === Utility Type Definitions ===
209
-
210
- export interface LayoutModule {
211
- default: ComponentType<LayoutProps>;
212
- layoutLoader?: LayoutLoader;
213
- layoutConfig?: LayoutConfig;
214
- ErrorBoundary?: ComponentType<LayoutErrorBoundaryProps>;
215
- }
216
-
217
- export interface PageModule {
218
- default: ComponentType<Record<string, unknown>>;
219
- layoutConfig?: LayoutConfig;
220
- frontmatter?: Record<string, unknown>;
221
- loader?: (ctx: LayoutContext) => Promise<Record<string, unknown>>;
222
- }
223
-
224
- export interface LayoutResolutionContext {
225
- route: RouteInfo;
226
- pageModule: PageModule;
227
- layoutContext: LayoutContext;
228
- cachingEnabled: boolean;
229
- streamingEnabled: boolean;
230
- developmentMode: boolean;
231
- }
232
-
233
- export interface LayoutPerformanceMetrics {
234
- discoveryTime: number;
235
- dataLoadingTime: number;
236
- renderingTime: number;
237
- totalTime: number;
238
- layoutCount: number;
239
- cacheHit: boolean;
240
- memoryUsage?: number;
241
- }
242
-
243
- export interface LayoutDebugInfo {
244
- resolutionChain: string[];
245
- appliedRules: LayoutRule[];
246
- skippedLayouts: string[];
247
- errors: LayoutErrorInfo[];
248
- metrics: LayoutPerformanceMetrics;
249
- cacheInfo: {
250
- hit: boolean;
251
- key: string;
252
- size: number;
253
- };
254
- }
255
-
256
- // === Event Type Definitions ===
257
-
258
- export type LayoutEventType =
259
- | 'layout-discovered'
260
- | 'layout-loaded'
261
- | 'layout-rendered'
262
- | 'layout-error'
263
- | 'layout-cached'
264
- | 'island-state-saved'
265
- | 'island-state-loaded'
266
- | 'streaming-started'
267
- | 'streaming-completed';
268
-
269
- export interface LayoutEventData {
270
- type: LayoutEventType;
271
- timestamp: number;
272
- layoutPath?: string;
273
- error?: Error;
274
- metrics?: LayoutPerformanceMetrics;
275
- data?: Record<string, unknown>;
276
- }
277
-
278
- export type LayoutEventHandler = (event: LayoutEventData) => void;
279
-
280
- export interface ILayoutEventEmitter {
281
- on(event: LayoutEventType, handler: LayoutEventHandler): void;
282
- off(event: LayoutEventType, handler: LayoutEventHandler): void;
283
- emit(event: LayoutEventType, data?: Record<string, unknown>): void;
284
- removeAllListeners(): void;
285
- }