@useavalon/avalon 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mod.ts CHANGED
@@ -164,12 +164,13 @@ export { asIsland } from './src/types/as-island.ts';
164
164
  export { generateIslandTypes, watchAndGenerateTypes } from './src/build/island-types-generator.ts';
165
165
  export type { IslandTypeGeneratorOptions, TypeGenerationResult } from './src/build/island-types-generator.ts';
166
166
 
167
- // Build command (batteries included)
168
- // Note: This is exported as a function that dynamically imports the build module
169
- // to avoid top-level await issues when SSR loading modules that import from @useavalon/avalon
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
170
  export async function build(_options?: Record<string, unknown>) {
171
- const { build: buildFn } = await import('../../scripts/build.ts');
172
- return buildFn();
171
+ throw new Error(
172
+ 'avalon build() is not available in the published package. Use `vite build` or the Avalon CLI instead.',
173
+ );
173
174
  }
174
175
 
175
176
  // Middleware system (Nitro-aligned)
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "repository": "github:useAvalon/Avalon",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/useAvalon/Avalon.git",
10
+ "directory": "packages/avalon"
11
+ },
8
12
  "homepage": "https://useavalon.dev",
9
13
  "keywords": ["avalon", "islands", "ssr", "vite", "preact", "multi-framework", "hydration"],
10
14
  "exports": {
@@ -44,6 +44,8 @@ import {
44
44
  discoverErrorPages,
45
45
  type ErrorHandlerOptions,
46
46
  } from './error-handler.ts';
47
+ import { h } from 'preact';
48
+ import preactRenderToString from 'preact-render-to-string';
47
49
 
48
50
  /**
49
51
  * Resolved page route information
@@ -626,17 +628,27 @@ async function renderPageComponent(
626
628
  context: NitroRenderContext,
627
629
  _options: SSRRenderOptions,
628
630
  ): Promise<string> {
629
- // This would integrate with the existing renderToHtml function
630
- // For now, return a basic structure showing the integration point
631
+ const Component = pageModule.default as (props?: Record<string, unknown>) => unknown;
632
+ const metadata = pageModule.metadata || {};
631
633
 
632
- // In the real implementation, this would:
633
- // 1. Import and use renderToHtml from '../render/ssr.ts'
634
- // 2. Create a RouteConfig from the pageModule
635
- // 3. Apply layouts using the layout resolver
636
- // 4. Return the fully rendered HTML
634
+ // Call the page component (supports async components)
635
+ let vnode: unknown;
636
+ try {
637
+ const result = Component(pageProps);
638
+ vnode = result instanceof Promise ? await result : result;
639
+ } catch (err) {
640
+ console.error('[renderer] Error calling page component:', err);
641
+ vnode = h('div', null, 'Error rendering page');
642
+ }
637
643
 
638
- const componentName = (pageModule.default as { name?: string })?.name || 'Page';
639
- const metadata = pageModule.metadata || {};
644
+ // Render the vnode to HTML string using Preact SSR
645
+ let pageHtml: string;
646
+ try {
647
+ pageHtml = preactRenderToString(vnode as any);
648
+ } catch (err) {
649
+ console.error('[renderer] Error in preactRenderToString:', err);
650
+ pageHtml = '<div>Error rendering page</div>';
651
+ }
640
652
 
641
653
  return `<!DOCTYPE html>
642
654
  <html lang="en">
@@ -647,9 +659,10 @@ async function renderPageComponent(
647
659
  ${metadata.description ? `<meta name="description" content="${escapeHtml(String(metadata.description))}">` : ''}
648
660
  </head>
649
661
  <body>
650
- <div id="app" data-page="${escapeHtml(String(componentName))}" data-props='${escapeHtml(JSON.stringify(pageProps))}'>
651
- <!-- Page content rendered by Avalon SSR pipeline -->
662
+ <div id="app">
663
+ ${pageHtml}
652
664
  </div>
665
+ <script type="module" src="/src/client/main.js"></script>
653
666
  </body>
654
667
  </html>`;
655
668
  }