@useavalon/avalon 0.1.14 → 0.1.16

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.
@@ -1,106 +1,106 @@
1
- /**
2
- * Type declarations for image imports with vite-imagetools
3
- *
4
- * These types enable TypeScript support for optimized image imports.
5
- * Include this in your tsconfig.json `types` array:
6
- *
7
- * ```json
8
- * {
9
- * "compilerOptions": {
10
- * "types": ["@useavalon/avalon/types"]
11
- * }
12
- * }
13
- * ```
14
- */
15
-
16
- declare module "*.jpg" {
17
- const src: string;
18
- export default src;
19
- }
20
-
21
- declare module "*.jpeg" {
22
- const src: string;
23
- export default src;
24
- }
25
-
26
- declare module "*.png" {
27
- const src: string;
28
- export default src;
29
- }
30
-
31
- declare module "*.webp" {
32
- const src: string;
33
- export default src;
34
- }
35
-
36
- declare module "*.avif" {
37
- const src: string;
38
- export default src;
39
- }
40
-
41
- declare module "*.gif" {
42
- const src: string;
43
- export default src;
44
- }
45
-
46
- declare module "*.tiff" {
47
- const src: string;
48
- export default src;
49
- }
50
-
51
- declare module "*.svg" {
52
- const src: string;
53
- export default src;
54
- }
55
-
56
- // vite-imagetools srcset output
57
- interface ImageToolsSrcset {
58
- src: string;
59
- srcset: string;
60
- width: number;
61
- height: number;
62
- }
63
-
64
- declare module "*&as=srcset" {
65
- const srcset: ImageToolsSrcset;
66
- export default srcset;
67
- }
68
-
69
- declare module "*?as=srcset" {
70
- const srcset: ImageToolsSrcset;
71
- export default srcset;
72
- }
73
-
74
- // vite-imagetools picture output (multiple formats)
75
- interface ImageToolsPicture {
76
- sources: Record<string, ImageToolsSrcset>;
77
- img: ImageToolsSrcset;
78
- }
79
-
80
- declare module "*&as=picture" {
81
- const picture: ImageToolsPicture;
82
- export default picture;
83
- }
84
-
85
- declare module "*?as=picture" {
86
- const picture: ImageToolsPicture;
87
- export default picture;
88
- }
89
-
90
- // vite-imagetools metadata output
91
- interface ImageToolsMetadata {
92
- src: string;
93
- width: number;
94
- height: number;
95
- format: string;
96
- }
97
-
98
- declare module "*&as=metadata" {
99
- const metadata: ImageToolsMetadata;
100
- export default metadata;
101
- }
102
-
103
- declare module "*?as=metadata" {
104
- const metadata: ImageToolsMetadata;
105
- export default metadata;
106
- }
1
+ /**
2
+ * Type declarations for image imports with vite-imagetools
3
+ *
4
+ * These types enable TypeScript support for optimized image imports.
5
+ * Include this in your tsconfig.json `types` array:
6
+ *
7
+ * ```json
8
+ * {
9
+ * "compilerOptions": {
10
+ * "types": ["@useavalon/avalon/types"]
11
+ * }
12
+ * }
13
+ * ```
14
+ */
15
+
16
+ declare module "*.jpg" {
17
+ const src: string;
18
+ export default src;
19
+ }
20
+
21
+ declare module "*.jpeg" {
22
+ const src: string;
23
+ export default src;
24
+ }
25
+
26
+ declare module "*.png" {
27
+ const src: string;
28
+ export default src;
29
+ }
30
+
31
+ declare module "*.webp" {
32
+ const src: string;
33
+ export default src;
34
+ }
35
+
36
+ declare module "*.avif" {
37
+ const src: string;
38
+ export default src;
39
+ }
40
+
41
+ declare module "*.gif" {
42
+ const src: string;
43
+ export default src;
44
+ }
45
+
46
+ declare module "*.tiff" {
47
+ const src: string;
48
+ export default src;
49
+ }
50
+
51
+ declare module "*.svg" {
52
+ const src: string;
53
+ export default src;
54
+ }
55
+
56
+ // vite-imagetools srcset output
57
+ interface ImageToolsSrcset {
58
+ src: string;
59
+ srcset: string;
60
+ width: number;
61
+ height: number;
62
+ }
63
+
64
+ declare module "*&as=srcset" {
65
+ const srcset: ImageToolsSrcset;
66
+ export default srcset;
67
+ }
68
+
69
+ declare module "*?as=srcset" {
70
+ const srcset: ImageToolsSrcset;
71
+ export default srcset;
72
+ }
73
+
74
+ // vite-imagetools picture output (multiple formats)
75
+ interface ImageToolsPicture {
76
+ sources: Record<string, ImageToolsSrcset>;
77
+ img: ImageToolsSrcset;
78
+ }
79
+
80
+ declare module "*&as=picture" {
81
+ const picture: ImageToolsPicture;
82
+ export default picture;
83
+ }
84
+
85
+ declare module "*?as=picture" {
86
+ const picture: ImageToolsPicture;
87
+ export default picture;
88
+ }
89
+
90
+ // vite-imagetools metadata output
91
+ interface ImageToolsMetadata {
92
+ src: string;
93
+ width: number;
94
+ height: number;
95
+ format: string;
96
+ }
97
+
98
+ declare module "*&as=metadata" {
99
+ const metadata: ImageToolsMetadata;
100
+ export default metadata;
101
+ }
102
+
103
+ declare module "*?as=metadata" {
104
+ const metadata: ImageToolsMetadata;
105
+ export default metadata;
106
+ }
@@ -1,22 +1,22 @@
1
- /**
2
- * Avalon type definitions.
3
- *
4
- * Include this in your tsconfig.json `types` array to get island prop support:
5
- *
6
- * ```json
7
- * {
8
- * "compilerOptions": {
9
- * "types": ["@useavalon/avalon/types"]
10
- * }
11
- * }
12
- * ```
13
- */
14
-
15
- // Re-export island prop types
16
- export * from './island-prop.d.ts';
17
-
18
- // Import JSX augmentations (side-effect import for type augmentation)
19
- import './island-jsx.d.ts';
20
-
21
- // Import image type declarations
22
- import './image.d.ts';
1
+ /**
2
+ * Avalon type definitions.
3
+ *
4
+ * Include this in your tsconfig.json `types` array to get island prop support:
5
+ *
6
+ * ```json
7
+ * {
8
+ * "compilerOptions": {
9
+ * "types": ["@useavalon/avalon/types"]
10
+ * }
11
+ * }
12
+ * ```
13
+ */
14
+
15
+ // Re-export island prop types
16
+ export * from './island-prop.d.ts';
17
+
18
+ // Import JSX augmentations (side-effect import for type augmentation)
19
+ import './island-jsx.d.ts';
20
+
21
+ // Import image type declarations
22
+ import './image.d.ts';
@@ -1,33 +1,33 @@
1
- /**
2
- * JSX augmentation for the `island` prop.
3
- *
4
- * Automatically included via tsconfig.json `compilerOptions.types`.
5
- */
6
-
7
- import type { IslandDirective } from './island-prop.d.ts';
8
-
9
- declare module 'preact' {
10
- namespace JSX {
11
- interface IntrinsicAttributes {
12
- island?: IslandDirective;
13
- }
14
- }
15
- }
16
-
17
- // Augment the global JSX namespace so the `island` prop is accepted on
18
- // non-Preact components (Svelte, Solid) when used in a Preact JSX context.
19
- declare global {
20
- namespace JSX {
21
- interface IntrinsicAttributes {
22
- island?: IslandDirective;
23
- }
24
- }
25
- }
26
-
27
- // Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
28
- declare module '@vue/runtime-core' {
29
- interface ComponentCustomProps {
30
- island?: IslandDirective;
31
- }
32
- }
33
-
1
+ /**
2
+ * JSX augmentation for the `island` prop.
3
+ *
4
+ * Automatically included via tsconfig.json `compilerOptions.types`.
5
+ */
6
+
7
+ import type { IslandDirective } from './island-prop.d.ts';
8
+
9
+ declare module 'preact' {
10
+ namespace JSX {
11
+ interface IntrinsicAttributes {
12
+ island?: IslandDirective;
13
+ }
14
+ }
15
+ }
16
+
17
+ // Augment the global JSX namespace so the `island` prop is accepted on
18
+ // non-Preact components (Svelte, Solid) when used in a Preact JSX context.
19
+ declare global {
20
+ namespace JSX {
21
+ interface IntrinsicAttributes {
22
+ island?: IslandDirective;
23
+ }
24
+ }
25
+ }
26
+
27
+ // Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
28
+ declare module '@vue/runtime-core' {
29
+ interface ComponentCustomProps {
30
+ island?: IslandDirective;
31
+ }
32
+ }
33
+
@@ -1,20 +1,20 @@
1
- /**
2
- * Type augmentation for the `island` prop on island components.
3
- *
4
- * When importing a component from the islands directory and using it in a page,
5
- * you can pass an `island` prop to control hydration behavior. The Vite transform
6
- * plugin intercepts this at build time and converts it to a renderIsland() call.
7
- *
8
- * Usage:
9
- * import Counter from '../islands/Counter.tsx';
10
- * <Counter island={{ condition: 'on:interaction' }} someProp={42} />
11
- */
12
-
13
- export interface IslandDirective {
14
- /** Hydration condition */
15
- condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
16
- /** Force SSR-only rendering without client hydration */
17
- ssrOnly?: boolean;
18
- /** Whether to render server-side (default: true) */
19
- ssr?: boolean;
20
- }
1
+ /**
2
+ * Type augmentation for the `island` prop on island components.
3
+ *
4
+ * When importing a component from the islands directory and using it in a page,
5
+ * you can pass an `island` prop to control hydration behavior. The Vite transform
6
+ * plugin intercepts this at build time and converts it to a renderIsland() call.
7
+ *
8
+ * Usage:
9
+ * import Counter from '../islands/Counter.tsx';
10
+ * <Counter island={{ condition: 'on:interaction' }} someProp={42} />
11
+ */
12
+
13
+ export interface IslandDirective {
14
+ /** Hydration condition */
15
+ condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
16
+ /** Force SSR-only rendering without client hydration */
17
+ ssrOnly?: boolean;
18
+ /** Whether to render server-side (default: true) */
19
+ ssr?: boolean;
20
+ }
@@ -1,6 +1,6 @@
1
- import type { ComponentType } from 'preact';
2
-
3
- declare module '*.mdx' {
4
- const MDXComponent: ComponentType<Record<string, unknown>>;
5
- export default MDXComponent;
6
- }
1
+ import type { ComponentType } from 'preact';
2
+
3
+ declare module '*.mdx' {
4
+ const MDXComponent: ComponentType<Record<string, unknown>>;
5
+ export default MDXComponent;
6
+ }
@@ -1,49 +1,49 @@
1
- /**
2
- * Global URLPattern type declaration.
3
- * URLPattern is available at runtime in Node 22+, Bun, and Deno,
4
- * but TypeScript's lib.dom.d.ts may not include it in all configurations.
5
- */
6
- declare class URLPattern {
7
- constructor(init?: URLPatternInit | string, baseURL?: string);
8
- readonly protocol: string;
9
- readonly username: string;
10
- readonly password: string;
11
- readonly hostname: string;
12
- readonly port: string;
13
- readonly pathname: string;
14
- readonly search: string;
15
- readonly hash: string;
16
- test(input?: URLPatternInput, baseURL?: string): boolean;
17
- exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null;
18
- }
19
-
20
- interface URLPatternInit {
21
- baseURL?: string;
22
- username?: string;
23
- password?: string;
24
- hostname?: string;
25
- port?: string;
26
- pathname?: string;
27
- search?: string;
28
- hash?: string;
29
- protocol?: string;
30
- }
31
-
32
- type URLPatternInput = URLPatternInit | string;
33
-
34
- interface URLPatternComponentResult {
35
- input: string;
36
- groups: Record<string, string | undefined>;
37
- }
38
-
39
- interface URLPatternResult {
40
- inputs: [URLPatternInput, string?];
41
- protocol: URLPatternComponentResult;
42
- username: URLPatternComponentResult;
43
- password: URLPatternComponentResult;
44
- hostname: URLPatternComponentResult;
45
- port: URLPatternComponentResult;
46
- pathname: URLPatternComponentResult;
47
- search: URLPatternComponentResult;
48
- hash: URLPatternComponentResult;
49
- }
1
+ /**
2
+ * Global URLPattern type declaration.
3
+ * URLPattern is available at runtime in Node 22+, Bun, and Deno,
4
+ * but TypeScript's lib.dom.d.ts may not include it in all configurations.
5
+ */
6
+ declare class URLPattern {
7
+ constructor(init?: URLPatternInit | string, baseURL?: string);
8
+ readonly protocol: string;
9
+ readonly username: string;
10
+ readonly password: string;
11
+ readonly hostname: string;
12
+ readonly port: string;
13
+ readonly pathname: string;
14
+ readonly search: string;
15
+ readonly hash: string;
16
+ test(input?: URLPatternInput, baseURL?: string): boolean;
17
+ exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null;
18
+ }
19
+
20
+ interface URLPatternInit {
21
+ baseURL?: string;
22
+ username?: string;
23
+ password?: string;
24
+ hostname?: string;
25
+ port?: string;
26
+ pathname?: string;
27
+ search?: string;
28
+ hash?: string;
29
+ protocol?: string;
30
+ }
31
+
32
+ type URLPatternInput = URLPatternInit | string;
33
+
34
+ interface URLPatternComponentResult {
35
+ input: string;
36
+ groups: Record<string, string | undefined>;
37
+ }
38
+
39
+ interface URLPatternResult {
40
+ inputs: [URLPatternInput, string?];
41
+ protocol: URLPatternComponentResult;
42
+ username: URLPatternComponentResult;
43
+ password: URLPatternComponentResult;
44
+ hostname: URLPatternComponentResult;
45
+ port: URLPatternComponentResult;
46
+ pathname: URLPatternComponentResult;
47
+ search: URLPatternComponentResult;
48
+ hash: URLPatternComponentResult;
49
+ }
@@ -1,11 +1,11 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_APP_TITLE: string;
5
- // more env variables...
6
- }
7
-
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv;
10
- readonly hot?: import('vite/types/hot').ViteHotContext;
11
- }
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_TITLE: string;
5
+ // more env variables...
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv;
10
+ readonly hot?: import('vite/types/hot').ViteHotContext;
11
+ }
@@ -1,13 +1,13 @@
1
- import{nitro as e}from"nitro/vite";import{stat as t}from"node:fs/promises";import{createRequire as n}from"node:module";import{dirname as r,join as i}from"node:path";import{createNitroConfig as a}from"../nitro/config.js";import{createNitroBuildPlugin as o,createIslandManifestPlugin as s,createSourceMapPlugin as c,createSourceMapConfig as l}from"../nitro/index.js";import{discoverScopedMiddleware as u,executeScopedMiddleware as d,clearMiddlewareCache as f}from"../middleware/index.js";import{generateErrorPage as p,generateFallback404 as m}from"../render/error-pages.js";import{collectCssFromModuleGraph as h,injectSsrCss as g}from"../render/collect-css.js";import{getUniversalCSSForHead as _}from"../islands/universal-css-collector.js";import{getUniversalHeadForInjection as v}from"../islands/universal-head-collector.js";function y(e){return i(r(n(import.meta.url).resolve(`@useavalon/avalon`)),e)}function b(e,t){return i(r(n(i(process.cwd(),`package.json`)).resolve(`@useavalon/${e}`)),t)}export const VIRTUAL_MODULE_IDS={PAGE_ROUTES:`virtual:avalon/page-routes`,ISLAND_MANIFEST:`virtual:avalon/island-manifest`,RUNTIME_CONFIG:`virtual:avalon/runtime-config`,CONFIG:`virtual:avalon/config`};export const RESOLVED_VIRTUAL_IDS={PAGE_ROUTES:`\0`+VIRTUAL_MODULE_IDS.PAGE_ROUTES,ISLAND_MANIFEST:`\0`+VIRTUAL_MODULE_IDS.ISLAND_MANIFEST,RUNTIME_CONFIG:`\0`+VIRTUAL_MODULE_IDS.RUNTIME_CONFIG,CONFIG:`\0`+VIRTUAL_MODULE_IDS.CONFIG};export function createNitroIntegration(t,n={}){let r=a(n,t),i={preset:r.preset,serverDir:n.serverDir??r.serverDir??`./server`,routeRules:r.routeRules,runtimeConfig:r.runtimeConfig,renderer:n.renderer===!1?!1:r.renderer,compatibilityDate:r.compatibilityDate,scanDirs:[`.`]};r.publicRuntimeConfig&&(i.publicRuntimeConfig=r.publicRuntimeConfig),r.publicAssets&&(i.publicAssets=r.publicAssets),r.compressPublicAssets&&(i.compressPublicAssets=r.compressPublicAssets),r.serverEntry&&(i.serverEntry=r.serverEntry);let u=e(i),d=createNitroCoordinationPlugin({avalonConfig:t,nitroConfig:n,verbose:t.verbose}),f=createVirtualModulesPlugin({avalonConfig:t,nitroConfig:n,verbose:t.verbose}),p=o(t,n),m=s(t,{verbose:t.verbose,generatePreloadHints:!0}),h=c(l(n.preset??`node_server`,t.isDev));return{nitroOptions:r,plugins:[...Array.isArray(u)?u:[u],d,f,p,m,h]}}export function createNitroCoordinationPlugin(e){let{avalonConfig:t,verbose:n}=e;return{name:`avalon:nitro-coordination`,enforce:`pre`,configResolved(e){globalThis.__avalonConfig=t},configureServer(e){globalThis.__viteDevServer=e;let r=null;async function i(){return r||=await u({baseDir:`${e.config.root||process.cwd()}/src`,devMode:!1}),r}function a(){r=null}k(e,t,n,a),i().catch(e=>{console.warn(`[middleware] Failed to discover middleware:`,e)}),D(e,n).catch(e=>{console.error(`[prewarm] Core modules pre-warm failed:`,e)}),e.middlewares.use(async(r,a,o)=>{let s=r.url||`/`;if(s.endsWith(`.html`)&&(s=s.slice(0,-5)||`/`),s===`/index`&&(s=`/`),s.startsWith(`/@`)||s.startsWith(`/__`)||s.startsWith(`/node_modules/`)||s.startsWith(`/src/client/`)||s.startsWith(`/packages/`)||s.includes(`.`)&&!s.endsWith(`/`)||s.startsWith(`/api/`))return o();try{if(await T(e,s,r,a,i,n)||await L(e,s,t,a))return;let o=await R(e,s,t);if(o){a.statusCode=200,a.setHeader(`Content-Type`,`text/html`),a.end(o);return}await E(e,s,a,t)}catch(e){console.error(`[SSR Error]`,e),a.statusCode=500,a.setHeader(`Content-Type`,`text/html`),a.end(p(e))}})},buildStart(){}}}async function T(e,t,n,r,i,a){let o=performance.now(),s=await i();if(s.length===0)return!1;let c={};for(let[e,t]of Object.entries(n.headers))typeof t==`string`?c[e]=t:Array.isArray(t)&&(c[e]=t.join(`, `));let l=`http://${n.headers.host||`localhost`}${t}`,u=await d({url:l,method:n.method||`GET`,path:t,node:{req:n,res:r},req:new Request(l,{method:n.method||`GET`,headers:c}),context:{}},s,{devMode:!1}),f=performance.now()-o;return f>100&&console.warn(`⚠️ Slow middleware: ${f.toFixed(0)}ms for ${t}`),u?(r.statusCode=u.status,u.headers.forEach((e,t)=>{r.setHeader(t,e)}),r.end(await u.text()),!0):!1}async function E(e,t,n,r){try{let{discoverErrorPages:i,getErrorPageModule:a,generateDefaultErrorPage:o}=await import(`../nitro/error-handler.js`),s=a(404,await i({isDev:r.isDev,pagesDir:r.pagesDir,loadPageModule:async t=>await e.ssrLoadModule(t)}));if(s?.default&&typeof s.default==`function`){let{renderToHtml:e}=await import(`../render/ssr.js`),r=s.default,i=await e({component:()=>r({statusCode:404,message:`Page not found: ${t}`,url:t})},{});n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(i);return}let c=o(404,`Page not found: ${t}`,r.isDev);n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(c)}catch{n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(m(t))}}async function D(e,t){let n=performance.now(),r=[{path:y(`src/render/ssr.ts`),assignTo:`ssr`},{path:y(`src/core/layout/enhanced-layout-resolver.ts`),assignTo:`layout`},{path:y(`src/middleware/index.ts`),assignTo:null},...[`react`,`vue`,`solid`,`svelte`,`lit`,`preact`].map(e=>({path:b(e,`server/renderer.ts`),assignTo:null}))],i=(await Promise.allSettled(r.map(async({path:t,assignTo:n})=>{let r=await e.ssrLoadModule(t);n===`ssr`&&(F=r),n===`layout`&&(I=r)}))).filter(e=>e.status===`fulfilled`).length,a=performance.now()-n;t&&i>0&&console.log(`🔥 SSR ready in ${a.toFixed(0)}ms (${i}/${r.length} core modules)`)}export function createVirtualModulesPlugin(e){let{avalonConfig:t,nitroConfig:n,verbose:r}=e;return{name:`avalon:nitro-virtual-modules`,enforce:`pre`,resolveId(e){return e===VIRTUAL_MODULE_IDS.PAGE_ROUTES?RESOLVED_VIRTUAL_IDS.PAGE_ROUTES:e===VIRTUAL_MODULE_IDS.ISLAND_MANIFEST?RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST:e===VIRTUAL_MODULE_IDS.RUNTIME_CONFIG?RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG:e===VIRTUAL_MODULE_IDS.CONFIG?RESOLVED_VIRTUAL_IDS.CONFIG:null},async load(e){return e===RESOLVED_VIRTUAL_IDS.PAGE_ROUTES?await A(t,r):e===RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST?j():e===RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG?M(t,n):e===RESOLVED_VIRTUAL_IDS.CONFIG?generateConfigModule(t,n):null},handleHotUpdate({file:e,server:n}){if(e.includes(t.pagesDir)){let e=n.moduleGraph.getModuleById(RESOLVED_VIRTUAL_IDS.PAGE_ROUTES);e&&n.moduleGraph.invalidateModule(e)}if(e.includes(`vite.config`)||e.includes(`avalon.config`)||e.includes(`nitro.config`)){let e=n.moduleGraph.getModuleById(RESOLVED_VIRTUAL_IDS.CONFIG);e&&n.moduleGraph.invalidateModule(e)}}}}function k(e,t,n,r){e.watcher.on(`change`,e=>{e.includes(`_middleware`)&&(f(),r?.()),(e.includes(`/render/`)||e.includes(`/layout/`)||e.includes(`/islands/`))&&(F=null,I=null),(e.includes(`/layouts/`)||e.includes(`_layout`))&&globalThis.__avalonLayoutResolver?.clearCache?.()}),e.watcher.on(`add`,e=>{e.includes(`_middleware`)&&(f(),r?.())}),e.watcher.on(`unlink`,e=>{e.includes(`_middleware`)&&(f(),r?.())})}async function A(e,t){try{let{getAllPageDirs:t}=await import(`./module-discovery.js`),{discoverPageRoutesFromMultipleDirs:n}=await import(`../nitro/route-discovery.js`),r=await n(await t(e.pagesDir,e.modules,process.cwd()),{developmentMode:e.isDev});return`export const pageRoutes = ${JSON.stringify(r,null,2)};\nexport default pageRoutes;\n`}catch{return`export const pageRoutes = [];
1
+ import{nitro as e}from"nitro/vite";import{stat as t}from"node:fs/promises";import{existsSync as n}from"node:fs";import{createRequire as r}from"node:module";import{dirname as i,join as a}from"node:path";import{createNitroConfig as o}from"../nitro/config.js";import{createNitroBuildPlugin as s,createIslandManifestPlugin as c,createSourceMapPlugin as l,createSourceMapConfig as u}from"../nitro/index.js";import{discoverScopedMiddleware as d,executeScopedMiddleware as f,clearMiddlewareCache as p}from"../middleware/index.js";import{generateErrorPage as m,generateFallback404 as h}from"../render/error-pages.js";import{collectCssFromModuleGraph as g,injectSsrCss as _}from"../render/collect-css.js";import{getUniversalCSSForHead as v}from"../islands/universal-css-collector.js";import{getUniversalHeadForInjection as y}from"../islands/universal-head-collector.js";function b(e){let t=a(i(r(import.meta.url).resolve(`@useavalon/avalon`)),e);if(e.endsWith(`.ts`)&&!n(t)){let e=t.replace(/\.ts$/,`.js`);if(n(e))return e}return t}function x(e,t){let o=a(i(r(a(process.cwd(),`package.json`)).resolve(`@useavalon/${e}`)),t);if(t.endsWith(`.ts`)&&!n(o)){let e=o.replace(/\.ts$/,`.js`);if(n(e))return e}return o}export const VIRTUAL_MODULE_IDS={PAGE_ROUTES:`virtual:avalon/page-routes`,ISLAND_MANIFEST:`virtual:avalon/island-manifest`,RUNTIME_CONFIG:`virtual:avalon/runtime-config`,CONFIG:`virtual:avalon/config`};export const RESOLVED_VIRTUAL_IDS={PAGE_ROUTES:`\0`+VIRTUAL_MODULE_IDS.PAGE_ROUTES,ISLAND_MANIFEST:`\0`+VIRTUAL_MODULE_IDS.ISLAND_MANIFEST,RUNTIME_CONFIG:`\0`+VIRTUAL_MODULE_IDS.RUNTIME_CONFIG,CONFIG:`\0`+VIRTUAL_MODULE_IDS.CONFIG};export function createNitroIntegration(t,n={}){let r=o(n,t),i={preset:r.preset,serverDir:n.serverDir??r.serverDir??`./server`,routeRules:r.routeRules,runtimeConfig:r.runtimeConfig,renderer:n.renderer===!1?!1:r.renderer,compatibilityDate:r.compatibilityDate,scanDirs:[`.`]};r.publicRuntimeConfig&&(i.publicRuntimeConfig=r.publicRuntimeConfig),r.publicAssets&&(i.publicAssets=r.publicAssets),r.compressPublicAssets&&(i.compressPublicAssets=r.compressPublicAssets),r.serverEntry&&(i.serverEntry=r.serverEntry);let a=e(i),d=createNitroCoordinationPlugin({avalonConfig:t,nitroConfig:n,verbose:t.verbose}),f=createVirtualModulesPlugin({avalonConfig:t,nitroConfig:n,verbose:t.verbose}),p=s(t,n),m=c(t,{verbose:t.verbose,generatePreloadHints:!0}),h=l(u(n.preset??`node_server`,t.isDev));return{nitroOptions:r,plugins:[...Array.isArray(a)?a:[a],d,f,p,m,h]}}export function createNitroCoordinationPlugin(e){let{avalonConfig:t,verbose:n}=e;return{name:`avalon:nitro-coordination`,enforce:`pre`,configResolved(e){globalThis.__avalonConfig=t},configureServer(e){globalThis.__viteDevServer=e;let r=null;async function i(){return r||=await d({baseDir:`${e.config.root||process.cwd()}/src`,devMode:!1}),r}function a(){r=null}A(e,t,n,a),i().catch(e=>{console.warn(`[middleware] Failed to discover middleware:`,e)}),O(e,n).catch(e=>{console.error(`[prewarm] Core modules pre-warm failed:`,e)}),e.middlewares.use(async(r,a,o)=>{let s=r.url||`/`;if(s.endsWith(`.html`)&&(s=s.slice(0,-5)||`/`),s===`/index`&&(s=`/`),s.startsWith(`/@`)||s.startsWith(`/__`)||s.startsWith(`/node_modules/`)||s.startsWith(`/src/client/`)||s.startsWith(`/packages/`)||s.includes(`.`)&&!s.endsWith(`/`)||s.startsWith(`/api/`))return o();try{if(await E(e,s,r,a,i,n)||await L(e,s,t,a))return;let o=await R(e,s,t);if(o){a.statusCode=200,a.setHeader(`Content-Type`,`text/html`),a.end(o);return}await D(e,s,a,t)}catch(e){console.error(`[SSR Error]`,e),a.statusCode=500,a.setHeader(`Content-Type`,`text/html`),a.end(m(e))}})},buildStart(){}}}async function E(e,t,n,r,i,a){let o=performance.now(),s=await i();if(s.length===0)return!1;let c={};for(let[e,t]of Object.entries(n.headers))typeof t==`string`?c[e]=t:Array.isArray(t)&&(c[e]=t.join(`, `));let l=`http://${n.headers.host||`localhost`}${t}`,u=await f({url:l,method:n.method||`GET`,path:t,node:{req:n,res:r},req:new Request(l,{method:n.method||`GET`,headers:c}),context:{}},s,{devMode:!1}),d=performance.now()-o;return d>100&&console.warn(`⚠️ Slow middleware: ${d.toFixed(0)}ms for ${t}`),u?(r.statusCode=u.status,u.headers.forEach((e,t)=>{r.setHeader(t,e)}),r.end(await u.text()),!0):!1}async function D(e,t,n,r){try{let{discoverErrorPages:i,getErrorPageModule:a,generateDefaultErrorPage:o}=await import(`../nitro/error-handler.js`),s=a(404,await i({isDev:r.isDev,pagesDir:r.pagesDir,loadPageModule:async t=>await e.ssrLoadModule(t)}));if(s?.default&&typeof s.default==`function`){let{renderToHtml:e}=await import(`../render/ssr.js`),r=s.default,i=await e({component:()=>r({statusCode:404,message:`Page not found: ${t}`,url:t})},{});n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(i);return}let c=o(404,`Page not found: ${t}`,r.isDev);n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(c)}catch{n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(h(t))}}async function O(e,t){let n=performance.now(),r=[{path:b(`src/render/ssr.ts`),assignTo:`ssr`},{path:b(`src/core/layout/enhanced-layout-resolver.ts`),assignTo:`layout`},{path:b(`src/middleware/index.ts`),assignTo:null},...[`react`,`vue`,`solid`,`svelte`,`lit`,`preact`].map(e=>({path:x(e,`server/renderer.ts`),assignTo:null}))],i=(await Promise.allSettled(r.map(async({path:t,assignTo:n})=>{let r=await e.ssrLoadModule(t);n===`ssr`&&(F=r),n===`layout`&&(I=r)}))).filter(e=>e.status===`fulfilled`).length,a=performance.now()-n;t&&i>0&&console.log(`🔥 SSR ready in ${a.toFixed(0)}ms (${i}/${r.length} core modules)`)}export function createVirtualModulesPlugin(e){let{avalonConfig:t,nitroConfig:n,verbose:r}=e;return{name:`avalon:nitro-virtual-modules`,enforce:`pre`,resolveId(e){return e===VIRTUAL_MODULE_IDS.PAGE_ROUTES?RESOLVED_VIRTUAL_IDS.PAGE_ROUTES:e===VIRTUAL_MODULE_IDS.ISLAND_MANIFEST?RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST:e===VIRTUAL_MODULE_IDS.RUNTIME_CONFIG?RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG:e===VIRTUAL_MODULE_IDS.CONFIG?RESOLVED_VIRTUAL_IDS.CONFIG:null},async load(e){return e===RESOLVED_VIRTUAL_IDS.PAGE_ROUTES?await j(t,r):e===RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST?M():e===RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG?N(t,n):e===RESOLVED_VIRTUAL_IDS.CONFIG?generateConfigModule(t,n):null},handleHotUpdate({file:e,server:n}){if(e.includes(t.pagesDir)){let e=n.moduleGraph.getModuleById(RESOLVED_VIRTUAL_IDS.PAGE_ROUTES);e&&n.moduleGraph.invalidateModule(e)}if(e.includes(`vite.config`)||e.includes(`avalon.config`)||e.includes(`nitro.config`)){let e=n.moduleGraph.getModuleById(RESOLVED_VIRTUAL_IDS.CONFIG);e&&n.moduleGraph.invalidateModule(e)}}}}function A(e,t,n,r){e.watcher.on(`change`,e=>{e.includes(`_middleware`)&&(p(),r?.()),(e.includes(`/render/`)||e.includes(`/layout/`)||e.includes(`/islands/`))&&(F=null,I=null),(e.includes(`/layouts/`)||e.includes(`_layout`))&&globalThis.__avalonLayoutResolver?.clearCache?.()}),e.watcher.on(`add`,e=>{e.includes(`_middleware`)&&(p(),r?.())}),e.watcher.on(`unlink`,e=>{e.includes(`_middleware`)&&(p(),r?.())})}async function j(e,t){try{let{getAllPageDirs:t}=await import(`./module-discovery.js`),{discoverPageRoutesFromMultipleDirs:n}=await import(`../nitro/route-discovery.js`),r=await n(await t(e.pagesDir,e.modules,process.cwd()),{developmentMode:e.isDev});return`export const pageRoutes = ${JSON.stringify(r,null,2)};\nexport default pageRoutes;\n`}catch{return`export const pageRoutes = [];
2
2
  export default pageRoutes;
3
- `}}function j(){return`export const islandManifest = { islands: {}, clientEntry: "", css: [] };
3
+ `}}function M(){return`export const islandManifest = { islands: {}, clientEntry: "", css: [] };
4
4
  export default islandManifest;
5
- `}function M(e,t){let n={avalon:{streaming:t.streaming??!0,pagesDir:e.pagesDir,layoutsDir:e.layoutsDir,isDev:e.isDev},...t.runtimeConfig};return`export const runtimeConfig = ${JSON.stringify(n,null,2)};\nexport function useRuntimeConfig() { return runtimeConfig; }\nexport default runtimeConfig;\n`}export function generateConfigModule(e,t){let n={streaming:t.streaming??!0,pagesDir:e.pagesDir,layoutsDir:e.layoutsDir,isDev:e.isDev,...t.runtimeConfig};return`const config = ${JSON.stringify(n,null,2)};\nexport function useAvalonConfig() { return config; }\nexport default config;\n`}export function getViteDevServer(){return globalThis.__viteDevServer}export function getAvalonConfig(){return globalThis.__avalonConfig}export function isDevelopmentMode(){return globalThis.__avalonConfig?.isDev??!0}const P=`<!--AVALON_STREAM_BOUNDARY-->`;let F=null,I=null;async function L(e,t,n,r){if(!n.modules)return!1;let i=t.split(`?`)[0],a=await H(i,n,e);if(!a)return!1;try{let t=await e.ssrLoadModule(a),n=t.default;if(!n)return!1;let o=t.layoutConfig,s=await h(e,a),c=await V(i,e),l=[];for(let t of c){let n=await e.ssrLoadModule(t);l.push({file:t,module:n})}for(let t of c){let n=await h(e,t);s.push(...n)}if(l.length===0)return!1;let{render:u}=await e.ssrLoadModule(`preact-render-to-string`),{h:d}=await e.ssrLoadModule(`preact`),f=o?.skipLayouts||[],p=l.filter(({file:e})=>{let t=e.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``;return!f.includes(t)}),m=t.frontmatter,g=t.metadata,y={children:null,frontmatter:{...m,...g,currentPath:i},params:{},url:i},b=[],x=[];for(let e of p){let t=e.module.default;if(!(!t||typeof t!=`function`))try{let n=t({...y,children:d(`div`,null,`test`)}),r=u(n instanceof Promise?await n:n);r.trim().startsWith(`<html`)||r.includes(`<!DOCTYPE`)?b.push(e):x.push(e)}catch{x.push(e)}}if(b.length===0)return!1;let{module:S}=b[b.length-1],C=S.default;if(!C||typeof C!=`function`)return!1;let w;try{let e=C({...y,children:d(`div`,{dangerouslySetInnerHTML:{__html:P}})});w=u(e instanceof Promise?await e:e)}catch{return!1}let T=w.indexOf(P);if(T===-1)return!1;let E=w.slice(0,T),D=w.slice(T+29),O=E;if(s.length>0){let e=`<style data-avalon-ssr-css>${s.join(`
5
+ `}function N(e,t){let n={avalon:{streaming:t.streaming??!0,pagesDir:e.pagesDir,layoutsDir:e.layoutsDir,isDev:e.isDev},...t.runtimeConfig};return`export const runtimeConfig = ${JSON.stringify(n,null,2)};\nexport function useRuntimeConfig() { return runtimeConfig; }\nexport default runtimeConfig;\n`}export function generateConfigModule(e,t){let n={streaming:t.streaming??!0,pagesDir:e.pagesDir,layoutsDir:e.layoutsDir,isDev:e.isDev,...t.runtimeConfig};return`const config = ${JSON.stringify(n,null,2)};\nexport function useAvalonConfig() { return config; }\nexport default config;\n`}export function getViteDevServer(){return globalThis.__viteDevServer}export function getAvalonConfig(){return globalThis.__avalonConfig}export function isDevelopmentMode(){return globalThis.__avalonConfig?.isDev??!0}const P=`<!--AVALON_STREAM_BOUNDARY-->`;let F=null,I=null;async function L(e,t,n,r){if(!n.modules)return!1;let i=t.split(`?`)[0],a=await H(i,n,e);if(!a)return!1;try{let t=await e.ssrLoadModule(a),n=t.default;if(!n)return!1;let o=t.layoutConfig,s=await g(e,a),c=await V(i,e),l=[];for(let t of c){let n=await e.ssrLoadModule(t);l.push({file:t,module:n})}for(let t of c){let n=await g(e,t);s.push(...n)}if(l.length===0)return!1;let{render:u}=await e.ssrLoadModule(`preact-render-to-string`),{h:d}=await e.ssrLoadModule(`preact`),f=o?.skipLayouts||[],p=l.filter(({file:e})=>{let t=e.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``;return!f.includes(t)}),m=t.frontmatter,h=t.metadata,_={children:null,frontmatter:{...m,...h,currentPath:i},params:{},url:i},b=[],x=[];for(let e of p){let t=e.module.default;if(!(!t||typeof t!=`function`))try{let n=t({..._,children:d(`div`,null,`test`)}),r=u(n instanceof Promise?await n:n);r.trim().startsWith(`<html`)||r.includes(`<!DOCTYPE`)?b.push(e):x.push(e)}catch{x.push(e)}}if(b.length===0)return!1;let{module:S}=b[b.length-1],C=S.default;if(!C||typeof C!=`function`)return!1;let w;try{let e=C({..._,children:d(`div`,{dangerouslySetInnerHTML:{__html:P}})});w=u(e instanceof Promise?await e:e)}catch{return!1}let T=w.indexOf(P);if(T===-1)return!1;let E=w.slice(0,T),D=w.slice(T+29),O=E;if(s.length>0){let e=`<style data-avalon-ssr-css>${s.join(`
6
6
  `)}</style>`;O=E.includes(`</head>`)?E.replace(`</head>`,`${e}\n</head>`):E+e}O.trim().toLowerCase().startsWith(`<!doctype`)||(O=`<!DOCTYPE html>
7
- `+O);let k=_(!0);k&&O.includes(`</head>`)&&(O=O.replace(`</head>`,`${k}\n</head>`));let A=v(!0);A&&O.includes(`</head>`)&&(O=O.replace(`</head>`,`${A}\n</head>`)),r.statusCode=200,r.setHeader(`Content-Type`,`text/html; charset=utf-8`),r.setHeader(`Transfer-Encoding`,`chunked`),r.setHeader(`X-Avalon-Streaming`,`1`),r.flushHeaders(),r.write(O);let j;try{let e=typeof n==`function`?n():n;j=u(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR Streaming] Error rendering page component:`,e),j=`<div>Error rendering page</div>`}if(j.trim().startsWith(`<!DOCTYPE html>`)||j.trim().startsWith(`<html`))return r.end(j),!0;let M=j;for(let{module:e}of x){let t=e.default;if(!(!t||typeof t!=`function`))try{let e=t({...y,children:d(`div`,{dangerouslySetInnerHTML:{__html:M}})});M=u(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR Streaming] Error rendering wrapper layout:`,e)}}let N=M+D;if(!N.includes(`/src/client/main.js`)&&!N.includes(`/@vite/client`)){let e=N.lastIndexOf(`</body>`);e!==-1&&(N=N.slice(0,e)+`
7
+ `+O);let k=v(!0);k&&O.includes(`</head>`)&&(O=O.replace(`</head>`,`${k}\n</head>`));let A=y(!0);A&&O.includes(`</head>`)&&(O=O.replace(`</head>`,`${A}\n</head>`)),r.statusCode=200,r.setHeader(`Content-Type`,`text/html; charset=utf-8`),r.setHeader(`Transfer-Encoding`,`chunked`),r.setHeader(`X-Avalon-Streaming`,`1`),r.flushHeaders(),r.write(O);let j;try{let e=typeof n==`function`?n():n;j=u(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR Streaming] Error rendering page component:`,e),j=`<div>Error rendering page</div>`}if(j.trim().startsWith(`<!DOCTYPE html>`)||j.trim().startsWith(`<html`))return r.end(j),!0;let M=j;for(let{module:e}of x){let t=e.default;if(!(!t||typeof t!=`function`))try{let e=t({..._,children:d(`div`,{dangerouslySetInnerHTML:{__html:M}})});M=u(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR Streaming] Error rendering wrapper layout:`,e)}}let N=M+D;if(!N.includes(`/src/client/main.js`)&&!N.includes(`/@vite/client`)){let e=N.lastIndexOf(`</body>`);e!==-1&&(N=N.slice(0,e)+`
8
8
  <script type="module" src="/@vite/client"><\/script>
9
9
  <script type="module" src="/src/client/main.js"><\/script>
10
- `+N.slice(e))}return r.end(N),!0}catch(e){return r.headersSent?(r.end(`<div>Streaming SSR error: ${e.message}</div></body></html>`),!0):!1}}async function R(e,t,n){let r=t.split(`?`)[0],i=await H(r,n,e);if(!i)return null;try{let t=await e.ssrLoadModule(i),a=t.default;if(!a)return console.warn(`[SSR] Page ${i} has no default export`),null;let o=await h(e,i),s=await V(r,e),c=[];for(let t of s){let n=await e.ssrLoadModule(t);c.push({file:t,module:n})}for(let t of s){let n=await h(e,t);o.push(...n)}let l;return l=n.modules&&c.length>0?await z(a,t,c,r,n,e):await U(a,t,r,n,e),o.length>0&&(l=g(l,o)),l}catch(e){throw console.error(`[SSR] Error rendering ${i}:`,e),e}}async function z(e,t,n,r,i,a){let{render:o}=await a.ssrLoadModule(`preact-render-to-string`),{h:s}=await a.ssrLoadModule(`preact`),c=t.layoutConfig?.skipLayouts||[],l=n.filter(({file:e})=>{let t=e.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``;return!c.includes(t)}),u;try{let t=typeof e==`function`?e():e;u=o(t instanceof Promise?await t:t)}catch(e){console.error(`[SSR] Error rendering page component:`,e),u=`<div>Error rendering page</div>`}if(u.trim().startsWith(`<!DOCTYPE html>`)||u.trim().startsWith(`<html`))return B(u);let d=t.frontmatter,f=t.metadata,p={children:null,frontmatter:{...d,...f,currentPath:r},params:{},url:r},m=[],h=[];for(let e of l){let t=e.module.default;if(!(!t||typeof t!=`function`))try{let n=t({...p,children:s(`div`,null,`test`)}),r=o(n instanceof Promise?await n:n);r.trim().startsWith(`<html`)||r.includes(`<!DOCTYPE`)?m.push(e):h.push(e)}catch{h.push(e)}}let g=u;for(let{module:e}of h){let t=e.default;if(!(!t||typeof t!=`function`))try{let e=t({...p,children:s(`div`,{dangerouslySetInnerHTML:{__html:g}})});g=o(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR] Error rendering wrapper layout:`,e)}}if(m.length>0){let{module:e}=m[m.length-1],t=e.default;if(t&&typeof t==`function`)try{let e=t({...p,children:s(`div`,{dangerouslySetInnerHTML:{__html:g}})});g=o(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR] Error rendering shell layout:`,e)}}if(g.trim().startsWith(`<!DOCTYPE html>`)||g.trim().startsWith(`<html`))return B(g);let _=t.metadata||{},v=_.title||`Avalon App`,y=_.description||``;return`<!DOCTYPE html>
10
+ `+N.slice(e))}return r.end(N),!0}catch(e){return r.headersSent?(r.end(`<div>Streaming SSR error: ${e.message}</div></body></html>`),!0):!1}}async function R(e,t,n){let r=t.split(`?`)[0],i=await H(r,n,e);if(!i)return null;try{let t=await e.ssrLoadModule(i),a=t.default;if(!a)return console.warn(`[SSR] Page ${i} has no default export`),null;let o=await g(e,i),s=await V(r,e),c=[];for(let t of s){let n=await e.ssrLoadModule(t);c.push({file:t,module:n})}for(let t of s){let n=await g(e,t);o.push(...n)}let l;return l=n.modules&&c.length>0?await z(a,t,c,r,n,e):await U(a,t,r,n,e),o.length>0&&(l=_(l,o)),l}catch(e){throw console.error(`[SSR] Error rendering ${i}:`,e),e}}async function z(e,t,n,r,i,a){let{render:o}=await a.ssrLoadModule(`preact-render-to-string`),{h:s}=await a.ssrLoadModule(`preact`),c=t.layoutConfig?.skipLayouts||[],l=n.filter(({file:e})=>{let t=e.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``;return!c.includes(t)}),u;try{let t=typeof e==`function`?e():e;u=o(t instanceof Promise?await t:t)}catch(e){console.error(`[SSR] Error rendering page component:`,e),u=`<div>Error rendering page</div>`}if(u.trim().startsWith(`<!DOCTYPE html>`)||u.trim().startsWith(`<html`))return B(u);let d=t.frontmatter,f=t.metadata,p={children:null,frontmatter:{...d,...f,currentPath:r},params:{},url:r},m=[],h=[];for(let e of l){let t=e.module.default;if(!(!t||typeof t!=`function`))try{let n=t({...p,children:s(`div`,null,`test`)}),r=o(n instanceof Promise?await n:n);r.trim().startsWith(`<html`)||r.includes(`<!DOCTYPE`)?m.push(e):h.push(e)}catch{h.push(e)}}let g=u;for(let{module:e}of h){let t=e.default;if(!(!t||typeof t!=`function`))try{let e=t({...p,children:s(`div`,{dangerouslySetInnerHTML:{__html:g}})});g=o(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR] Error rendering wrapper layout:`,e)}}if(m.length>0){let{module:e}=m[m.length-1],t=e.default;if(t&&typeof t==`function`)try{let e=t({...p,children:s(`div`,{dangerouslySetInnerHTML:{__html:g}})});g=o(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR] Error rendering shell layout:`,e)}}if(g.trim().startsWith(`<!DOCTYPE html>`)||g.trim().startsWith(`<html`))return B(g);let _=t.metadata||{},v=_.title||`Avalon App`,y=_.description||``;return`<!DOCTYPE html>
11
11
  <html lang="en">
12
12
  <head>
13
13
  <meta charset="utf-8">
@@ -21,12 +21,12 @@ export default islandManifest;
21
21
  <script type="module" src="/src/client/main.js"><\/script>
22
22
  </body>
23
23
  </html>`}function B(e){let t=e;if(t.trim().toLowerCase().startsWith(`<!doctype`)||(t=`<!DOCTYPE html>
24
- `+t),!t.includes(`data-universal-ssr="true"`)){let e=_(!0);e&&t.includes(`</head>`)&&(t=t.replace(`</head>`,`${e}\n</head>`))}let n=v(!0);if(n&&t.includes(`</head>`)&&(t=t.replace(`</head>`,`${n}\n</head>`)),t.includes(`/src/client/main.js`)||t.includes(`/@vite/client`))return t;let r=t.lastIndexOf(`</body>`);return r===-1?t+`
24
+ `+t),!t.includes(`data-universal-ssr="true"`)){let e=v(!0);e&&t.includes(`</head>`)&&(t=t.replace(`</head>`,`${e}\n</head>`))}let n=y(!0);if(n&&t.includes(`</head>`)&&(t=t.replace(`</head>`,`${n}\n</head>`)),t.includes(`/src/client/main.js`)||t.includes(`/@vite/client`))return t;let r=t.lastIndexOf(`</body>`);return r===-1?t+`
25
25
  <script type="module" src="/@vite/client"><\/script>
26
26
  <script type="module" src="/src/client/main.js"><\/script>`:t.slice(0,r)+`
27
27
  <script type="module" src="/@vite/client"><\/script>
28
28
  <script type="module" src="/src/client/main.js"><\/script>
29
- `+t.slice(r)}async function V(e,n){let r=n.config.root||process.cwd(),i=globalThis.__avalonConfig,a=`_layout.tsx`,o=[],s=e.split(`/`).filter(Boolean),c=[``];for(let e=0;e<s.length;e++)c.push(`/`+s.slice(0,e+1).join(`/`));async function l(e){try{if((await t(e)).isFile()){let t=e.slice(r.length);o.includes(t)||o.push(t)}}catch{}}if(i?.layoutsDir&&await l(`${`${r}/${i.layoutsDir}`}/${a}`),i?.modules){let e=`${r}/${i.modules.dir}`,t=i.modules.layoutsDirName,n=s[0]||``,o=[`home`,`root`,`main`,`index`];if(!n||o.includes(n.toLowerCase()))for(let n of o)await l(`${e}/${n}/${t}/${a}`);else await l(`${e}/${n}/${t}/${a}`)}let u=`${r}/src/layouts`;for(let e of c)await l(e===``?`${u}/${a}`:`${u}${e}/${a}`);return o}async function H(e,n,r){let i=e;i.endsWith(`/`)&&i!==`/`&&(i=i.slice(0,-1)),i===`/`&&(i=`/index`);let a=[`.tsx`,`.ts`,`.jsx`,`.js`,`.mdx`,`.md`],o=r.config.root||process.cwd();async function s(e){try{if((await t(`${o}/${e}`)).isFile())return`/${e}`}catch{}return null}if(n.modules){let t=n.modules.dir,r=n.modules.pagesDirName,o=e.split(`/`).filter(Boolean),c=o[0]||``,l=[`home`,`root`,`main`,`index`],u,d;if(!c||l.includes(c.toLowerCase()))u=`home`,d=i;else{u=c;let e=o.slice(1);d=e.length>0?`/`+e.join(`/`):`/index`}for(let e of a){let n=await s(`${t}/${u}/${r}${d}${e}`);if(n)return n}if(!d.endsWith(`/index`))for(let e of a){let n=await s(`${t}/${u}/${r}${d}/index${e}`);if(n)return n}}let c=n.pagesDir;for(let e of a){let t=await s(`${c}${i}${e}`);if(t)return t}if(!i.endsWith(`/index`))for(let e of a){let t=await s(`${c}${i}/index${e}`);if(t)return t}return null}async function U(e,t,n,r,i){let a=t.metadata||{};try{F||=await i.ssrLoadModule(y(`src/render/ssr.ts`));let o=F;I||=await i.ssrLoadModule(y(`src/core/layout/enhanced-layout-resolver.ts`));let s=I,c={component:()=>typeof e==`function`?e():e,options:{title:a.title||`Avalon App`},frontmatter:t.frontmatter};if(o.renderToHtmlWithLayouts&&s.EnhancedLayoutResolver&&s.EnhancedLayoutResolverUtils)try{let e=i.config.root||process.cwd();if(!globalThis.__avalonLayoutResolver){let t=s.EnhancedLayoutResolver,n=r.layoutsDir||`src/layouts`;globalThis.__avalonLayoutResolver=new t({baseDirectory:`${e}/${n}`,filePattern:`_layout.tsx`,excludeDirectories:[`node_modules`,`.git`,`dist`,`build`],enableWatching:!0,developmentMode:!1,enableCaching:!0,cacheTTL:60*1e3,maxCacheSize:100,enableStreaming:!0,enableErrorBoundaries:!0,enableMetrics:!1,enableDebugInfo:!1,modulesDir:r.modules?`${e}/${r.modules.dir}`:void 0,modulesLayoutsDirName:r.modules?.layoutsDirName})}let t=`http://localhost${n}`,l={params:{},query:{},url:t,request:{method:`GET`,url:t,headers:new Headers}};return await o.renderToHtmlWithLayouts(c,globalThis.__avalonLayoutResolver,l,n,{title:a.title||`Avalon App`},void 0,{suppressWarnings:!0})}catch{}if(o.renderToHtml)return await o.renderToHtml(c,{title:a.title||`Avalon App`},void 0,{suppressWarnings:!0})}catch{}let o=a.title||`Avalon App`,s=a.description||``,c=``;try{let t=await i.ssrLoadModule(`preact-render-to-string`);t.render&&typeof e==`function`&&(c=t.render(e()))}catch{c=`<p>Loading page: ${W(n)}</p>`}return`<!DOCTYPE html>
29
+ `+t.slice(r)}async function V(e,n){let r=n.config.root||process.cwd(),i=globalThis.__avalonConfig,a=`_layout.tsx`,o=[],s=e.split(`/`).filter(Boolean),c=[``];for(let e=0;e<s.length;e++)c.push(`/`+s.slice(0,e+1).join(`/`));async function l(e){try{if((await t(e)).isFile()){let t=e.slice(r.length);o.includes(t)||o.push(t)}}catch{}}if(i?.layoutsDir&&await l(`${`${r}/${i.layoutsDir}`}/${a}`),i?.modules){let e=`${r}/${i.modules.dir}`,t=i.modules.layoutsDirName,n=s[0]||``,o=[`home`,`root`,`main`,`index`];if(!n||o.includes(n.toLowerCase()))for(let n of o)await l(`${e}/${n}/${t}/${a}`);else await l(`${e}/${n}/${t}/${a}`)}let u=`${r}/src/layouts`;for(let e of c)await l(e===``?`${u}/${a}`:`${u}${e}/${a}`);return o}async function H(e,n,r){let i=e;i.endsWith(`/`)&&i!==`/`&&(i=i.slice(0,-1)),i===`/`&&(i=`/index`);let a=[`.tsx`,`.ts`,`.jsx`,`.js`,`.mdx`,`.md`],o=r.config.root||process.cwd();async function s(e){try{if((await t(`${o}/${e}`)).isFile())return`/${e}`}catch{}return null}if(n.modules){let t=n.modules.dir,r=n.modules.pagesDirName,o=e.split(`/`).filter(Boolean),c=o[0]||``,l=[`home`,`root`,`main`,`index`],u,d;if(!c||l.includes(c.toLowerCase()))u=`home`,d=i;else{u=c;let e=o.slice(1);d=e.length>0?`/`+e.join(`/`):`/index`}for(let e of a){let n=await s(`${t}/${u}/${r}${d}${e}`);if(n)return n}if(!d.endsWith(`/index`))for(let e of a){let n=await s(`${t}/${u}/${r}${d}/index${e}`);if(n)return n}}let c=n.pagesDir;for(let e of a){let t=await s(`${c}${i}${e}`);if(t)return t}if(!i.endsWith(`/index`))for(let e of a){let t=await s(`${c}${i}/index${e}`);if(t)return t}return null}async function U(e,t,n,r,i){let a=t.metadata||{};try{F||=await i.ssrLoadModule(b(`src/render/ssr.ts`));let o=F;I||=await i.ssrLoadModule(b(`src/core/layout/enhanced-layout-resolver.ts`));let s=I,c={component:()=>typeof e==`function`?e():e,options:{title:a.title||`Avalon App`},frontmatter:t.frontmatter};if(o.renderToHtmlWithLayouts&&s.EnhancedLayoutResolver&&s.EnhancedLayoutResolverUtils)try{let e=i.config.root||process.cwd();if(!globalThis.__avalonLayoutResolver){let t=s.EnhancedLayoutResolver,n=r.layoutsDir||`src/layouts`;globalThis.__avalonLayoutResolver=new t({baseDirectory:`${e}/${n}`,filePattern:`_layout.tsx`,excludeDirectories:[`node_modules`,`.git`,`dist`,`build`],enableWatching:!0,developmentMode:!1,enableCaching:!0,cacheTTL:60*1e3,maxCacheSize:100,enableStreaming:!0,enableErrorBoundaries:!0,enableMetrics:!1,enableDebugInfo:!1,modulesDir:r.modules?`${e}/${r.modules.dir}`:void 0,modulesLayoutsDirName:r.modules?.layoutsDirName})}let t=`http://localhost${n}`,l={params:{},query:{},url:t,request:{method:`GET`,url:t,headers:new Headers}};return await o.renderToHtmlWithLayouts(c,globalThis.__avalonLayoutResolver,l,n,{title:a.title||`Avalon App`},void 0,{suppressWarnings:!0})}catch{}if(o.renderToHtml)return await o.renderToHtml(c,{title:a.title||`Avalon App`},void 0,{suppressWarnings:!0})}catch{}let o=a.title||`Avalon App`,s=a.description||``,c=``;try{let t=await i.ssrLoadModule(`preact-render-to-string`);t.render&&typeof e==`function`&&(c=t.render(e()))}catch{c=`<p>Loading page: ${W(n)}</p>`}return`<!DOCTYPE html>
30
30
  <html lang="en">
31
31
  <head>
32
32
  <meta charset="utf-8">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",