@useavalon/avalon 0.1.10 → 0.1.12

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 (250) hide show
  1. package/README.md +54 -54
  2. package/dist/mod.js +1 -0
  3. package/dist/src/build/integration-bundler-plugin.js +1 -0
  4. package/dist/src/build/integration-config.js +1 -0
  5. package/dist/src/build/integration-detection-plugin.js +1 -0
  6. package/dist/src/build/integration-resolver-plugin.js +1 -0
  7. package/dist/src/build/island-manifest.js +1 -0
  8. package/dist/src/build/island-types-generator.js +5 -0
  9. package/dist/src/build/mdx-island-transform.js +2 -0
  10. package/dist/src/build/mdx-plugin.js +1 -0
  11. package/dist/src/build/page-island-transform.js +3 -0
  12. package/dist/src/build/prop-extractors/index.js +1 -0
  13. package/dist/src/build/prop-extractors/lit.js +1 -0
  14. package/dist/src/build/prop-extractors/qwik.js +1 -0
  15. package/dist/src/build/prop-extractors/solid.js +1 -0
  16. package/dist/src/build/prop-extractors/svelte.js +1 -0
  17. package/dist/src/build/prop-extractors/vue.js +1 -0
  18. package/dist/src/build/sidecar-file-manager.js +1 -0
  19. package/dist/src/build/sidecar-renderer.js +6 -0
  20. package/dist/src/client/adapters/index.js +1 -0
  21. package/dist/src/client/components.js +1 -0
  22. package/dist/src/client/css-hmr-handler.js +1 -0
  23. package/dist/src/client/framework-adapter.js +13 -0
  24. package/dist/src/client/hmr-coordinator.js +1 -0
  25. package/dist/src/client/hmr-error-overlay.js +214 -0
  26. package/dist/src/client/main.js +39 -0
  27. package/{src → dist/src}/client/types/framework-runtime.d.ts +68 -68
  28. package/{src → dist/src}/client/types/vite-hmr.d.ts +46 -46
  29. package/dist/src/client/types/vite-virtual-modules.d.ts +70 -0
  30. package/dist/src/components/Image.js +1 -0
  31. package/dist/src/components/IslandErrorBoundary.js +1 -0
  32. package/dist/src/components/LayoutDataErrorBoundary.js +1 -0
  33. package/dist/src/components/LayoutErrorBoundary.js +1 -0
  34. package/dist/src/components/PersistentIsland.js +1 -0
  35. package/dist/src/components/StreamingErrorBoundary.js +1 -0
  36. package/dist/src/components/StreamingLayout.js +29 -0
  37. package/dist/src/core/components/component-analyzer.js +1 -0
  38. package/dist/src/core/components/component-detection.js +5 -0
  39. package/dist/src/core/components/enhanced-framework-detector.js +1 -0
  40. package/dist/src/core/components/framework-registry.js +1 -0
  41. package/dist/src/core/content/mdx-processor.js +1 -0
  42. package/dist/src/core/integrations/index.js +1 -0
  43. package/dist/src/core/integrations/loader.js +1 -0
  44. package/dist/src/core/integrations/registry.js +1 -0
  45. package/dist/src/core/islands/island-persistence.js +1 -0
  46. package/dist/src/core/islands/island-state-serializer.js +1 -0
  47. package/dist/src/core/islands/persistent-island-context.js +1 -0
  48. package/dist/src/core/islands/use-persistent-state.js +1 -0
  49. package/dist/src/core/layout/enhanced-layout-resolver.js +1 -0
  50. package/dist/src/core/layout/layout-cache-manager.js +1 -0
  51. package/dist/src/core/layout/layout-composer.js +1 -0
  52. package/dist/src/core/layout/layout-data-loader.js +1 -0
  53. package/dist/src/core/layout/layout-discovery.js +1 -0
  54. package/dist/src/core/layout/layout-matcher.js +1 -0
  55. package/dist/src/core/layout/layout-types.js +1 -0
  56. package/dist/src/core/modules/framework-module-resolver.js +1 -0
  57. package/dist/src/islands/component-analysis.js +1 -0
  58. package/dist/src/islands/css-utils.js +17 -0
  59. package/dist/src/islands/discovery/index.js +1 -0
  60. package/dist/src/islands/discovery/registry.js +1 -0
  61. package/dist/src/islands/discovery/resolver.js +2 -0
  62. package/dist/src/islands/discovery/scanner.js +1 -0
  63. package/dist/src/islands/discovery/types.js +1 -0
  64. package/dist/src/islands/discovery/validator.js +18 -0
  65. package/dist/src/islands/discovery/watcher.js +1 -0
  66. package/dist/src/islands/framework-detection.js +1 -0
  67. package/dist/src/islands/integration-loader.js +1 -0
  68. package/dist/src/islands/island.js +1 -0
  69. package/dist/src/islands/render-cache.js +1 -0
  70. package/dist/src/islands/types.js +1 -0
  71. package/dist/src/islands/universal-css-collector.js +5 -0
  72. package/dist/src/islands/universal-head-collector.js +2 -0
  73. package/{src → dist/src}/layout-system.d.ts +592 -592
  74. package/dist/src/layout-system.js +1 -0
  75. package/dist/src/middleware/discovery.js +1 -0
  76. package/dist/src/middleware/executor.js +1 -0
  77. package/dist/src/middleware/index.js +1 -0
  78. package/dist/src/middleware/types.js +1 -0
  79. package/dist/src/nitro/build-config.js +1 -0
  80. package/dist/src/nitro/config.js +1 -0
  81. package/dist/src/nitro/error-handler.js +198 -0
  82. package/dist/src/nitro/index.js +1 -0
  83. package/dist/src/nitro/island-manifest.js +2 -0
  84. package/dist/src/nitro/middleware-adapter.js +1 -0
  85. package/dist/src/nitro/renderer.js +183 -0
  86. package/dist/src/nitro/route-discovery.js +1 -0
  87. package/dist/src/nitro/types.js +1 -0
  88. package/dist/src/render/collect-css.js +3 -0
  89. package/{src/render/error-pages.ts → dist/src/render/error-pages.js} +7 -38
  90. package/dist/src/render/isolated-ssr-renderer.js +1 -0
  91. package/dist/src/render/ssr.js +90 -0
  92. package/dist/src/schemas/api.js +1 -0
  93. package/dist/src/schemas/core.js +1 -0
  94. package/dist/src/schemas/index.js +1 -0
  95. package/dist/src/schemas/layout.js +1 -0
  96. package/dist/src/schemas/routing/index.js +1 -0
  97. package/dist/src/schemas/routing.js +1 -0
  98. package/dist/src/types/as-island.js +1 -0
  99. package/{src → dist/src}/types/image.d.ts +106 -106
  100. package/{src → dist/src}/types/index.d.ts +22 -22
  101. package/{src → dist/src}/types/island-jsx.d.ts +33 -33
  102. package/{src → dist/src}/types/island-prop.d.ts +20 -20
  103. package/dist/src/types/layout.js +1 -0
  104. package/{src → dist/src}/types/mdx.d.ts +6 -6
  105. package/dist/src/types/routing.js +1 -0
  106. package/dist/src/types/types.js +1 -0
  107. package/{src → dist/src}/types/urlpattern.d.ts +49 -49
  108. package/{src → dist/src}/types/vite-env.d.ts +11 -11
  109. package/dist/src/utils/dev-logger.js +12 -0
  110. package/dist/src/utils/fs.js +1 -0
  111. package/dist/src/vite-plugin/auto-discover.js +1 -0
  112. package/dist/src/vite-plugin/config.js +1 -0
  113. package/dist/src/vite-plugin/errors.js +1 -0
  114. package/dist/src/vite-plugin/image-optimization.js +45 -0
  115. package/dist/src/vite-plugin/integration-activator.js +1 -0
  116. package/dist/src/vite-plugin/island-sidecar-plugin.js +1 -0
  117. package/dist/src/vite-plugin/module-discovery.js +1 -0
  118. package/dist/src/vite-plugin/nitro-integration.js +42 -0
  119. package/dist/src/vite-plugin/plugin.js +1 -0
  120. package/dist/src/vite-plugin/types.js +1 -0
  121. package/dist/src/vite-plugin/validation.js +2 -0
  122. package/package.json +57 -26
  123. package/mod.ts +0 -302
  124. package/src/build/integration-bundler-plugin.ts +0 -116
  125. package/src/build/integration-config.ts +0 -168
  126. package/src/build/integration-detection-plugin.ts +0 -117
  127. package/src/build/integration-resolver-plugin.ts +0 -90
  128. package/src/build/island-manifest.ts +0 -269
  129. package/src/build/island-types-generator.ts +0 -476
  130. package/src/build/mdx-island-transform.ts +0 -464
  131. package/src/build/mdx-plugin.ts +0 -98
  132. package/src/build/page-island-transform.ts +0 -598
  133. package/src/build/prop-extractors/index.ts +0 -21
  134. package/src/build/prop-extractors/lit.ts +0 -140
  135. package/src/build/prop-extractors/qwik.ts +0 -16
  136. package/src/build/prop-extractors/solid.ts +0 -125
  137. package/src/build/prop-extractors/svelte.ts +0 -194
  138. package/src/build/prop-extractors/vue.ts +0 -111
  139. package/src/build/sidecar-file-manager.ts +0 -104
  140. package/src/build/sidecar-renderer.ts +0 -30
  141. package/src/client/adapters/index.js +0 -12
  142. package/src/client/adapters/index.ts +0 -13
  143. package/src/client/adapters/lit-adapter.js +0 -467
  144. package/src/client/adapters/lit-adapter.ts +0 -654
  145. package/src/client/adapters/preact-adapter.js +0 -223
  146. package/src/client/adapters/preact-adapter.ts +0 -331
  147. package/src/client/adapters/qwik-adapter.js +0 -259
  148. package/src/client/adapters/qwik-adapter.ts +0 -345
  149. package/src/client/adapters/react-adapter.js +0 -220
  150. package/src/client/adapters/react-adapter.ts +0 -353
  151. package/src/client/adapters/solid-adapter.js +0 -295
  152. package/src/client/adapters/solid-adapter.ts +0 -451
  153. package/src/client/adapters/svelte-adapter.js +0 -368
  154. package/src/client/adapters/svelte-adapter.ts +0 -524
  155. package/src/client/adapters/vue-adapter.js +0 -278
  156. package/src/client/adapters/vue-adapter.ts +0 -467
  157. package/src/client/components.js +0 -23
  158. package/src/client/components.ts +0 -35
  159. package/src/client/css-hmr-handler.js +0 -263
  160. package/src/client/css-hmr-handler.ts +0 -344
  161. package/src/client/framework-adapter.js +0 -283
  162. package/src/client/framework-adapter.ts +0 -462
  163. package/src/client/hmr-coordinator.js +0 -274
  164. package/src/client/hmr-coordinator.ts +0 -396
  165. package/src/client/hmr-error-overlay.js +0 -533
  166. package/src/client/main.js +0 -816
  167. package/src/client/types/vite-virtual-modules.d.ts +0 -60
  168. package/src/components/Image.tsx +0 -123
  169. package/src/components/IslandErrorBoundary.tsx +0 -145
  170. package/src/components/LayoutDataErrorBoundary.tsx +0 -141
  171. package/src/components/LayoutErrorBoundary.tsx +0 -127
  172. package/src/components/PersistentIsland.tsx +0 -52
  173. package/src/components/StreamingErrorBoundary.tsx +0 -233
  174. package/src/components/StreamingLayout.tsx +0 -538
  175. package/src/core/components/component-analyzer.ts +0 -192
  176. package/src/core/components/component-detection.ts +0 -508
  177. package/src/core/components/enhanced-framework-detector.ts +0 -500
  178. package/src/core/components/framework-registry.ts +0 -563
  179. package/src/core/content/mdx-processor.ts +0 -46
  180. package/src/core/integrations/index.ts +0 -19
  181. package/src/core/integrations/loader.ts +0 -125
  182. package/src/core/integrations/registry.ts +0 -175
  183. package/src/core/islands/island-persistence.ts +0 -325
  184. package/src/core/islands/island-state-serializer.ts +0 -258
  185. package/src/core/islands/persistent-island-context.tsx +0 -80
  186. package/src/core/islands/use-persistent-state.ts +0 -68
  187. package/src/core/layout/enhanced-layout-resolver.ts +0 -322
  188. package/src/core/layout/layout-cache-manager.ts +0 -485
  189. package/src/core/layout/layout-composer.ts +0 -357
  190. package/src/core/layout/layout-data-loader.ts +0 -516
  191. package/src/core/layout/layout-discovery.ts +0 -243
  192. package/src/core/layout/layout-matcher.ts +0 -299
  193. package/src/core/layout/layout-types.ts +0 -110
  194. package/src/core/modules/framework-module-resolver.ts +0 -273
  195. package/src/islands/component-analysis.ts +0 -213
  196. package/src/islands/css-utils.ts +0 -565
  197. package/src/islands/discovery/index.ts +0 -80
  198. package/src/islands/discovery/registry.ts +0 -340
  199. package/src/islands/discovery/resolver.ts +0 -477
  200. package/src/islands/discovery/scanner.ts +0 -386
  201. package/src/islands/discovery/types.ts +0 -117
  202. package/src/islands/discovery/validator.ts +0 -544
  203. package/src/islands/discovery/watcher.ts +0 -368
  204. package/src/islands/framework-detection.ts +0 -428
  205. package/src/islands/integration-loader.ts +0 -490
  206. package/src/islands/island.tsx +0 -565
  207. package/src/islands/render-cache.ts +0 -550
  208. package/src/islands/types.ts +0 -80
  209. package/src/islands/universal-css-collector.ts +0 -157
  210. package/src/islands/universal-head-collector.ts +0 -137
  211. package/src/layout-system.ts +0 -218
  212. package/src/middleware/discovery.ts +0 -268
  213. package/src/middleware/executor.ts +0 -315
  214. package/src/middleware/index.ts +0 -76
  215. package/src/middleware/types.ts +0 -99
  216. package/src/nitro/build-config.ts +0 -576
  217. package/src/nitro/config.ts +0 -483
  218. package/src/nitro/error-handler.ts +0 -636
  219. package/src/nitro/index.ts +0 -173
  220. package/src/nitro/island-manifest.ts +0 -584
  221. package/src/nitro/middleware-adapter.ts +0 -260
  222. package/src/nitro/renderer.ts +0 -1471
  223. package/src/nitro/route-discovery.ts +0 -439
  224. package/src/nitro/types.ts +0 -321
  225. package/src/render/collect-css.ts +0 -198
  226. package/src/render/isolated-ssr-renderer.ts +0 -654
  227. package/src/render/ssr.ts +0 -1030
  228. package/src/schemas/api.ts +0 -30
  229. package/src/schemas/core.ts +0 -64
  230. package/src/schemas/index.ts +0 -212
  231. package/src/schemas/layout.ts +0 -279
  232. package/src/schemas/routing/index.ts +0 -38
  233. package/src/schemas/routing.ts +0 -376
  234. package/src/types/as-island.ts +0 -20
  235. package/src/types/layout.ts +0 -285
  236. package/src/types/routing.ts +0 -555
  237. package/src/types/types.ts +0 -5
  238. package/src/utils/dev-logger.ts +0 -299
  239. package/src/utils/fs.ts +0 -151
  240. package/src/vite-plugin/auto-discover.ts +0 -551
  241. package/src/vite-plugin/config.ts +0 -266
  242. package/src/vite-plugin/errors.ts +0 -127
  243. package/src/vite-plugin/image-optimization.ts +0 -156
  244. package/src/vite-plugin/integration-activator.ts +0 -126
  245. package/src/vite-plugin/island-sidecar-plugin.ts +0 -176
  246. package/src/vite-plugin/module-discovery.ts +0 -189
  247. package/src/vite-plugin/nitro-integration.ts +0 -1354
  248. package/src/vite-plugin/plugin.ts +0 -401
  249. package/src/vite-plugin/types.ts +0 -327
  250. package/src/vite-plugin/validation.ts +0 -228
package/mod.ts DELETED
@@ -1,302 +0,0 @@
1
- // === Core Avalon + Vite Architecture ===
2
-
3
- // Vite Plugin - unified configuration API
4
- export {
5
- avalon,
6
- getResolvedConfig,
7
- getPagesDir,
8
- getLayoutsDir,
9
- getNitroConfig,
10
- isNitroEnabled,
11
- } from './src/vite-plugin/plugin.ts';
12
- export type {
13
- AvalonPluginConfig,
14
- IntegrationName,
15
- ResolvedAvalonConfig,
16
- MDXConfig,
17
- ResolvedMDXConfig,
18
- AvalonNitroConfig,
19
- CacheOptions,
20
- RouteRule,
21
- NitroConfigOutput,
22
- AvalonRuntimeConfig,
23
- } from './src/vite-plugin/types.ts';
24
-
25
- // Nitro Integration - virtual modules and coordination
26
- export {
27
- createNitroIntegration,
28
- createNitroCoordinationPlugin,
29
- createVirtualModulesPlugin,
30
- getViteDevServer,
31
- getAvalonConfig,
32
- isDevelopmentMode,
33
- VIRTUAL_MODULE_IDS,
34
- RESOLVED_VIRTUAL_IDS,
35
- } from './src/vite-plugin/nitro-integration.ts';
36
- export type { NitroIntegrationResult, NitroCoordinationPluginOptions } from './src/vite-plugin/nitro-integration.ts';
37
-
38
- // Main exports
39
- export { renderToHtml } from './src/render/ssr.ts';
40
-
41
- // Universal Island component (single function auto-detects framework)
42
- export { default as Island, renderIsland, type IslandProps } from './src/islands/island.tsx';
43
-
44
- // Island utilities
45
- export {
46
- addSvelteSSRCSS,
47
- getSvelteSSRCSS,
48
- getSvelteSSRCSSForHead,
49
- getSvelteSSRCSSStats,
50
- getSvelteComponentCSS,
51
- clearSvelteComponentCSS,
52
- generateComponentScopeId,
53
- } from './src/islands/css-utils.ts';
54
- export { detectFramework, detectFrameworkFromSrc, resolveIslandPath } from './src/islands/framework-detection.ts';
55
- export { analyzeComponentFile, renderComponentSSROnly } from './src/islands/component-analysis.ts';
56
- export type { Framework, RenderParams, SvelteSSRCSSEntry } from './src/islands/types.ts';
57
-
58
- // Island render cache utilities
59
- export {
60
- clearCache,
61
- clearIslandCache,
62
- invalidateCacheForPath,
63
- invalidateCacheForFile,
64
- getCacheStats,
65
- logCacheStats,
66
- configureCache,
67
- getCacheConfig,
68
- } from './src/islands/render-cache.ts';
69
- export type { CacheConfig as IslandCacheConfig, CacheStats as IslandCacheStats } from './src/islands/render-cache.ts';
70
-
71
- // Island Discovery Utilities (optional - for advanced use cases)
72
- // Note: Islands are detected by usage (island prop), not by directory.
73
- // These utilities are provided for tooling that needs to scan component files.
74
- export {
75
- // Scanner functions
76
- discoverIslandDirectories,
77
- discoverIslandsInDirectory,
78
- discoverAllIslands,
79
- isIslandsDirectory,
80
- getDefaultIslandsPath,
81
- hasDefaultIslandsDirectory,
82
- getQualifiedIslandName,
83
- parseQualifiedIslandName,
84
- // Registry
85
- IslandRegistry,
86
- createIslandRegistry,
87
- // Resolver
88
- IslandResolver,
89
- createIslandResolver,
90
- // Validator
91
- IslandValidator,
92
- createIslandValidator,
93
- validateAllIslands,
94
- formatValidationError,
95
- formatValidationWarning,
96
- formatCircularDependency,
97
- formatValidationResult,
98
- // Watcher
99
- IslandWatcher,
100
- createIslandWatcher,
101
- // Type utilities
102
- ISLAND_FILE_EXTENSIONS,
103
- DEFAULT_DISCOVERY_CONFIG,
104
- isSupportedIslandExtension,
105
- } from './src/islands/discovery/index.ts';
106
-
107
- // Island Discovery Types
108
- export type {
109
- IslandDirectory,
110
- DiscoveredIsland,
111
- IslandCollision,
112
- IslandChangeEvent,
113
- IslandFileExtension,
114
- IslandDiscoveryConfig,
115
- ResolutionResult,
116
- ImportPathOptions,
117
- ValidationResult,
118
- ValidationError,
119
- ValidationWarning,
120
- CircularDependency,
121
- IslandChangeCallback,
122
- IslandWatcherOptions,
123
- } from './src/islands/discovery/index.ts';
124
-
125
- // Integration system
126
- export {
127
- loadIntegration,
128
- detectAndLoadIntegration,
129
- preloadIntegrations,
130
- detectFrameworksFromPageContent,
131
- DEFAULT_PRELOAD_FRAMEWORKS,
132
- } from './src/islands/integration-loader.ts';
133
- export type { PreloadIntegrationsOptions } from './src/islands/integration-loader.ts';
134
- export { registry as integrationRegistry } from './src/core/integrations/registry.ts';
135
- export type {
136
- Integration,
137
- RenderParams as IntegrationRenderParams,
138
- RenderResult,
139
- IntegrationConfig,
140
- } from '@useavalon/core';
141
-
142
- // Build utilities
143
- export { generateIslandManifest, loadIslandManifest, getIslandBundlePath } from './src/build/island-manifest.ts';
144
- export type {
145
- IslandManifest,
146
- IslandEntry,
147
- ExtendedIslandManifest,
148
- ExtendedIslandEntry,
149
- } from './src/build/island-manifest.ts';
150
-
151
- // MDX island transform (auto-wraps island imports in MDX with Island() calls)
152
- export { mdxIslandTransform } from './src/build/mdx-island-transform.ts';
153
- export type { MDXIslandTransformOptions } from './src/build/mdx-island-transform.ts';
154
-
155
- // Page island transform (auto-wraps island imports in TSX pages when using `island` prop)
156
- export { pageIslandTransform } from './src/build/page-island-transform.ts';
157
- export type { PageIslandTransformOptions } from './src/build/page-island-transform.ts';
158
-
159
- // Island directive type for the `island` prop
160
- export type { IslandDirective } from './src/types/island-prop.d.ts';
161
- export { asIsland } from './src/types/as-island.ts';
162
-
163
- // Island type generation
164
- export { generateIslandTypes, watchAndGenerateTypes } from './src/build/island-types-generator.ts';
165
- export type { IslandTypeGeneratorOptions, TypeGenerationResult } from './src/build/island-types-generator.ts';
166
-
167
- // Build command
168
- // Note: The build function is only available in the monorepo development environment.
169
- // End users should use the CLI or Vite build commands directly.
170
- export async function build(_options?: Record<string, unknown>) {
171
- throw new Error(
172
- 'avalon build() is not available in the published package. Use `vite build` or the Avalon CLI instead.',
173
- );
174
- }
175
-
176
- // Middleware system (Nitro-aligned)
177
- // Note: defineMiddleware removed — use defineHandler from 'nitro/h3' directly.
178
- // Scoped middleware discovery/execution is Avalon's value-add over Nitro.
179
- export {
180
- discoverScopedMiddleware,
181
- executeScopedMiddleware,
182
- clearMiddlewareCache,
183
- invalidateMiddleware,
184
- getMatchingMiddleware,
185
- clearDiscoveryCache,
186
- hasContextValue,
187
- getContextValue,
188
- setContextValue,
189
- getMiddlewareCacheSize,
190
- } from './src/middleware/index.ts';
191
-
192
- export type {
193
- MiddlewareHandler,
194
- MiddlewareFileExport,
195
- MiddlewareRoute,
196
- MiddlewareDiscoveryOptions,
197
- MiddlewareExecutorOptions,
198
- } from './src/middleware/types.ts';
199
-
200
- // Layout system - comprehensive export (all layout functionality)
201
- export * from './src/layout-system.ts';
202
-
203
- // Core types
204
- export type { RenderOptions, MetaTag, ScriptConfig } from './src/schemas/core.ts';
205
- export type { ApiRoute, ApiMethod } from './src/schemas/api.ts';
206
- export type { MiddlewareContext } from './src/nitro/middleware-adapter.ts';
207
-
208
- // Layout data loading types
209
- export type { LayoutDataLoadingResult, LayoutDataLoadingOptions } from './src/core/layout/layout-data-loader.ts';
210
-
211
- // Enhanced layout resolver types
212
- export type { EnhancedLayoutResolverOptions } from './src/core/layout/enhanced-layout-resolver.ts';
213
-
214
- // Layout cache types (essential only)
215
- export type { CacheEntry, CacheStats, CacheConfig } from './src/core/layout/layout-cache-manager.ts';
216
-
217
- // Layout system types - comprehensive export
218
- export type {
219
- // Core layout types (from hand-written interfaces — proper types, no Zod inference)
220
- LayoutProps,
221
- LayoutContext,
222
- LayoutData,
223
- LayoutRoute,
224
- LayoutHandler,
225
- LayoutDiscoveryOptions,
226
- LayoutConfig,
227
- RouteInfo,
228
- LayoutRule,
229
- LayoutLoader,
230
- ResolvedLayout,
231
- LayoutCache,
232
- LayoutErrorInfo
233
- } from './src/core/layout/layout-types.ts';
234
-
235
- export type {
236
- // Zod-inferred types for schemas that don't have hand-written equivalents
237
- EnhancedLayoutContext,
238
-
239
- // Persistent islands types
240
- IslandState,
241
- PersistentIslandProps,
242
- PersistentIslandContext,
243
- IslandStateSaver,
244
- IslandStateLoader,
245
- IslandStateClearer,
246
-
247
- // Error boundary types
248
- LayoutErrorBoundaryProps,
249
- ErrorRecoveryStrategy,
250
- LayoutErrorHandler,
251
- LayoutRetryFunction,
252
- LayoutFallbackRenderer,
253
-
254
- // Streaming types
255
- StreamingLayoutProps,
256
- StreamingComponent,
257
- StreamingReadyCheck,
258
-
259
- // Function types
260
- LayoutMatcherFunction,
261
- } from './src/schemas/layout.ts';
262
-
263
- // Persistent islands system
264
- export { IslandPersistence, defaultIslandPersistence } from './src/core/islands/island-persistence.ts';
265
- export { IslandStateSerializer } from './src/core/islands/island-state-serializer.ts';
266
- export {
267
- createPersistentIslandContext,
268
- usePersistentIslandContext,
269
- PersistentIslandProvider,
270
- } from './src/core/islands/persistent-island-context.tsx';
271
- export { PersistentIsland } from './src/components/PersistentIsland.tsx';
272
- export { usePersistentState } from './src/core/islands/use-persistent-state.ts';
273
-
274
- // Error boundary system
275
- export { LayoutErrorBoundary } from './src/components/LayoutErrorBoundary.tsx';
276
- export { LayoutDataErrorBoundary } from './src/components/LayoutDataErrorBoundary.tsx';
277
- export { IslandErrorBoundary, withIslandErrorBoundary } from './src/components/IslandErrorBoundary.tsx';
278
- export { StreamingErrorBoundary, withStreamingErrorBoundary } from './src/components/StreamingErrorBoundary.tsx';
279
-
280
- // Layout system interfaces
281
- export type {
282
- ILayoutDiscovery,
283
- ILayoutMatcher,
284
- ILayoutComposer,
285
- IIslandPersistence,
286
- ILayoutErrorRecovery,
287
- ILayoutStreaming,
288
- IEnhancedLayoutResolver,
289
- ILayoutComponent,
290
- IPersistentIslandComponent,
291
- ILayoutErrorBoundaryComponent,
292
- IStreamingLayoutComponent,
293
- LayoutModule,
294
- PageModule,
295
- LayoutResolutionContext,
296
- LayoutPerformanceMetrics,
297
- LayoutDebugInfo,
298
- LayoutEventType,
299
- LayoutEventData,
300
- LayoutEventHandler,
301
- ILayoutEventEmitter,
302
- } from './src/types/layout.ts';
@@ -1,116 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- import { resolve } from 'node:path';
3
- import { getOptimizeDepsForIntegrations, getSSRNoExternalForIntegrations } from './integration-config.ts';
4
-
5
- export interface IntegrationBundlerOptions {
6
- /** Integrations to include in the build */
7
- integrations: string[];
8
- /** Whether to bundle for SSR */
9
- ssr?: boolean;
10
- }
11
-
12
- /**
13
- * Vite plugin to bundle integration packages
14
- * Ensures integration server and client code is properly bundled
15
- */
16
- export function integrationBundlerPlugin(options: IntegrationBundlerOptions): Plugin {
17
- const { integrations, ssr = false } = options;
18
- const cwd = process.cwd();
19
-
20
- return {
21
- name: 'avalon:integration-bundler',
22
- enforce: 'post',
23
-
24
- config(config) {
25
- // Add integration entry points to the build
26
- const entries: Record<string, string> = {};
27
-
28
- for (const framework of integrations) {
29
- if (ssr) {
30
- // SSR build: include server-side integration code
31
- entries[`integrations/${framework}/server`] = resolve(
32
- cwd,
33
- `packages/integrations/${framework}/server/renderer.ts`
34
- );
35
- } else {
36
- // Client build: include client-side integration code
37
- entries[`integrations/${framework}/client`] = resolve(
38
- cwd,
39
- `packages/integrations/${framework}/client/index.ts`
40
- );
41
- }
42
- }
43
-
44
- // Merge with existing rolldown input
45
- const existingInput = config.build?.rolldownOptions?.input || {};
46
- const mergedInput = typeof existingInput === 'string'
47
- ? { main: existingInput, ...entries }
48
- : { ...existingInput, ...entries };
49
-
50
- return {
51
- build: {
52
- rolldownOptions: {
53
- input: mergedInput,
54
- },
55
- },
56
- };
57
- },
58
-
59
-
60
- };
61
- }
62
-
63
- /**
64
- * Get external dependencies for integration bundling
65
- * These should not be bundled but loaded from node_modules
66
- */
67
- export function getIntegrationExternals(framework: string, ssr: boolean) {
68
- const externals: string[] = [];
69
-
70
- // Framework-specific externals
71
- switch (framework) {
72
- case 'preact':
73
- if (!ssr) {
74
- // Client-side: preact should be bundled for hydration
75
- return [];
76
- }
77
- // SSR: keep preact external if needed
78
- externals.push('preact', 'preact/hooks', 'preact-render-to-string');
79
- break;
80
-
81
- case 'vue':
82
- if (ssr) {
83
- // SSR: Vue server renderer should be external
84
- externals.push('vue', 'vue/server-renderer', '@vue/server-renderer', '@vue/shared');
85
- }
86
- break;
87
-
88
- case 'solid':
89
- if (ssr) {
90
- externals.push('solid-js', 'solid-js/web');
91
- }
92
- break;
93
-
94
- case 'svelte':
95
- if (ssr) {
96
- externals.push('svelte', 'svelte/server', 'svelte/compiler', 'svelte/internal');
97
- }
98
- break;
99
- }
100
-
101
- return externals;
102
- }
103
-
104
- /**
105
- * Configure optimization for integration dependencies
106
- */
107
- export function getIntegrationOptimizeDeps(integrations: string[]) {
108
- return getOptimizeDepsForIntegrations(integrations);
109
- }
110
-
111
- /**
112
- * Get SSR noExternal packages for integrations
113
- */
114
- export function getIntegrationSSRNoExternal(integrations: string[]) {
115
- return getSSRNoExternalForIntegrations(integrations);
116
- }
@@ -1,168 +0,0 @@
1
- /**
2
- * Integration configuration for build system
3
- * Defines how each integration should be bundled and optimized
4
- */
5
-
6
- export interface IntegrationBuildConfig {
7
- /** Framework name */
8
- name: string;
9
- /** File extensions this integration handles */
10
- extensions: string[];
11
- /** NPM packages that should be optimized for this integration */
12
- optimizeDeps: string[];
13
- /** NPM packages that should be external in SSR builds */
14
- ssrExternal: string[];
15
- /** NPM packages that should NOT be external in SSR builds */
16
- ssrNoExternal: string[];
17
- /** Whether this integration requires a Vite plugin */
18
- requiresPlugin: boolean;
19
- /** Plugin package name (if requiresPlugin is true) */
20
- pluginPackage?: string;
21
- }
22
-
23
- /**
24
- * Build configuration for all supported integrations
25
- */
26
- export const INTEGRATION_BUILD_CONFIGS: Record<string, IntegrationBuildConfig> = {
27
- preact: {
28
- name: 'preact',
29
- extensions: ['.tsx', '.jsx'],
30
- optimizeDeps: [
31
- 'preact',
32
- 'preact/hooks',
33
- 'preact/jsx-runtime',
34
- 'preact/jsx-dev-runtime',
35
- ],
36
- ssrExternal: [],
37
- ssrNoExternal: ['preact', 'preact-render-to-string'],
38
- requiresPlugin: false,
39
- },
40
-
41
- vue: {
42
- name: 'vue',
43
- extensions: ['.vue'],
44
- optimizeDeps: ['vue'],
45
- ssrExternal: [],
46
- ssrNoExternal: ['vue', '@vue/server-renderer', '@vue/shared'],
47
- requiresPlugin: true,
48
- pluginPackage: '@vitejs/plugin-vue',
49
- },
50
-
51
- solid: {
52
- name: 'solid',
53
- extensions: ['.tsx', '.jsx'],
54
- optimizeDeps: [
55
- 'solid-js',
56
- 'solid-js/web',
57
- 'solid-js/store',
58
- ],
59
- ssrExternal: [],
60
- ssrNoExternal: ['solid-js', 'solid-js/web', 'solid-js/store'],
61
- requiresPlugin: true,
62
- pluginPackage: 'vite-plugin-solid',
63
- },
64
-
65
- svelte: {
66
- name: 'svelte',
67
- extensions: ['.svelte'],
68
- optimizeDeps: [
69
- 'svelte',
70
- 'svelte/internal',
71
- 'svelte/store',
72
- 'svelte/animate',
73
- 'svelte/easing',
74
- 'svelte/motion',
75
- 'svelte/transition',
76
- ],
77
- ssrExternal: [],
78
- ssrNoExternal: ['svelte', 'svelte/server', 'svelte/internal', 'svelte/store'],
79
- requiresPlugin: true,
80
- pluginPackage: '@sveltejs/vite-plugin-svelte',
81
- },
82
-
83
- react: {
84
- name: 'react',
85
- extensions: ['.jsx', '.tsx'],
86
- optimizeDeps: [
87
- 'react',
88
- 'react/jsx-runtime',
89
- 'react/jsx-dev-runtime',
90
- 'react-dom',
91
- 'react-dom/client',
92
- ],
93
- ssrExternal: [],
94
- ssrNoExternal: ['react', 'react-dom', 'react-dom/server'],
95
- requiresPlugin: true,
96
- pluginPackage: '@vitejs/plugin-react',
97
- },
98
-
99
- lit: {
100
- name: 'lit',
101
- extensions: ['.ts', '.js'],
102
- optimizeDeps: [
103
- 'lit',
104
- 'lit/decorators.js',
105
- 'lit/directives/class-map.js',
106
- 'lit/directives/style-map.js',
107
- '@lit/reactive-element',
108
- ],
109
- ssrExternal: [],
110
- ssrNoExternal: ['lit', '@lit-labs/ssr', '@lit/reactive-element', 'lit-html'],
111
- requiresPlugin: false,
112
- },
113
- };
114
-
115
- /**
116
- * Get build configuration for a specific integration
117
- */
118
- export function getIntegrationBuildConfig(framework: string) {
119
- return INTEGRATION_BUILD_CONFIGS[framework];
120
- }
121
-
122
- /**
123
- * Get all optimize deps for given integrations
124
- */
125
- export function getOptimizeDepsForIntegrations(integrations: string[]) {
126
- const deps = new Set<string>();
127
-
128
- for (const integration of integrations) {
129
- const config = INTEGRATION_BUILD_CONFIGS[integration];
130
- if (config) {
131
- config.optimizeDeps.forEach(dep => deps.add(dep));
132
- }
133
- }
134
-
135
- return Array.from(deps);
136
- }
137
-
138
- /**
139
- * Get SSR noExternal packages for given integrations
140
- */
141
- export function getSSRNoExternalForIntegrations(integrations: string[]) {
142
- const packages = new Set<string>();
143
-
144
- for (const integration of integrations) {
145
- const config = INTEGRATION_BUILD_CONFIGS[integration];
146
- if (config) {
147
- config.ssrNoExternal.forEach(pkg => packages.add(pkg));
148
- }
149
- }
150
-
151
- return Array.from(packages);
152
- }
153
-
154
- /**
155
- * Check if an integration requires a Vite plugin
156
- */
157
- export function integrationRequiresPlugin(framework: string) {
158
- const config = INTEGRATION_BUILD_CONFIGS[framework];
159
- return config?.requiresPlugin ?? false;
160
- }
161
-
162
- /**
163
- * Get plugin package name for an integration
164
- */
165
- export function getIntegrationPluginPackage(framework: string) {
166
- const config = INTEGRATION_BUILD_CONFIGS[framework];
167
- return config?.pluginPackage;
168
- }
@@ -1,117 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- import { resolve } from 'node:path';
3
- import { readdir, readFile } from 'node:fs/promises';
4
-
5
- export interface IntegrationDetectionResult {
6
- preact: boolean;
7
- vue: boolean;
8
- solid: boolean;
9
- svelte: boolean;
10
- }
11
-
12
- /**
13
- * Vite plugin to detect which framework integrations are used in the project
14
- * This enables tree-shaking of unused integrations
15
- */
16
- export function integrationDetectionPlugin(): Plugin {
17
- let detectedIntegrations: IntegrationDetectionResult | null = null;
18
-
19
- return {
20
- name: 'avalon:integration-detection',
21
- enforce: 'pre',
22
-
23
- async buildStart() {
24
- // Detect integrations during build start
25
- detectedIntegrations = await detectUsedIntegrations();
26
- },
27
-
28
- resolveId(id: string) {
29
- // Handle integration imports
30
- if (id.startsWith('@useavalon/integration-')) {
31
- const framework = id.replace('@useavalon/integration-', '').split('/')[0];
32
-
33
- // Check if this integration is used
34
- if (detectedIntegrations && !detectedIntegrations[framework as keyof IntegrationDetectionResult]) {
35
- console.warn(`⚠️ Integration ${framework} is imported but not detected in project files`);
36
- }
37
-
38
- // Resolve to the actual integration path
39
- const integrationPath = resolve(process.cwd(), `packages/integrations/${framework}/mod.ts`);
40
- return integrationPath;
41
- }
42
-
43
- return null;
44
- },
45
-
46
- transform(_code: string, id: string) {
47
- // Track integration usage in island files
48
- if (id.includes('/islands/') || id.includes('/components/')) {
49
- // This helps with dynamic detection during development
50
- return null;
51
- }
52
-
53
- return null;
54
- },
55
- };
56
- }
57
-
58
- /**
59
- * Detect which framework integrations are actually used in the project
60
- */
61
- export async function detectUsedIntegrations() {
62
- const result: IntegrationDetectionResult = {
63
- preact: false,
64
- vue: false,
65
- solid: false,
66
- svelte: false,
67
- };
68
-
69
- const searchDirs = ['islands', 'components', 'src/islands', 'src/components'];
70
- const cwd = process.cwd();
71
-
72
- for (const dir of searchDirs) {
73
- try {
74
- const dirPath = resolve(cwd, dir);
75
- const entries = await readdir(dirPath, { withFileTypes: true });
76
- for (const entry of entries) {
77
- if (!entry.isFile()) continue;
78
-
79
- // Check file extensions
80
- if (entry.name.endsWith('.vue')) {
81
- result.vue = true;
82
- } else if (entry.name.endsWith('.svelte')) {
83
- result.svelte = true;
84
- } else if (entry.name.endsWith('.tsx') || entry.name.endsWith('.jsx')) {
85
- // Read file content to detect framework
86
- const filePath = resolve(dirPath, entry.name);
87
- const content = await readFile(filePath, 'utf-8');
88
-
89
- if (content.includes('solid-js')) {
90
- result.solid = true;
91
- } else {
92
- // Default to Preact for JSX/TSX files
93
- result.preact = true;
94
- }
95
- }
96
- }
97
- } catch {
98
- // Directory doesn't exist, continue
99
- }
100
- }
101
-
102
- return result;
103
- }
104
-
105
- /**
106
- * Get list of integration packages that should be included in the build
107
- */
108
- export function getRequiredIntegrations(detected: IntegrationDetectionResult) {
109
- const integrations: string[] = [];
110
-
111
- if (detected.preact) integrations.push('preact');
112
- if (detected.vue) integrations.push('vue');
113
- if (detected.solid) integrations.push('solid');
114
- if (detected.svelte) integrations.push('svelte');
115
-
116
- return integrations;
117
- }