@useavalon/avalon 0.1.41 → 0.1.43
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/dist/src/build/island-client-bundler.d.ts +17 -0
- package/dist/src/build/island-client-bundler.js +2 -0
- package/dist/src/build/island-manifest.d.ts +2 -2
- package/dist/src/build/island-manifest.js +1 -1
- package/dist/src/build/page-island-transform.js +3 -3
- package/dist/src/client/main.js +2 -2
- package/dist/src/islands/island.d.ts +3 -1
- package/dist/src/islands/island.js +1 -1
- package/dist/src/nitro/build-config.js +1 -1
- package/dist/src/schemas/routing/index.d.ts +4 -4
- package/dist/src/schemas/routing.d.ts +5 -5
- package/dist/src/vite-plugin/nitro-integration.js +2 -2
- package/dist/src/vite-plugin/plugin.js +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Island Client Bundler Plugin
|
|
3
|
+
*
|
|
4
|
+
* Discovers components used with the `island` prop in page/layout files and
|
|
5
|
+
* emits them as separate client-side chunks so the hydration runtime can
|
|
6
|
+
* dynamically import them in production.
|
|
7
|
+
*
|
|
8
|
+
* Note: Component CSS from these chunks is injected into the HTML by the
|
|
9
|
+
* post-build script (post-build.mjs), which patches the SSR bundle to
|
|
10
|
+
* include all CSS files from the client build output.
|
|
11
|
+
*/
|
|
12
|
+
import type { Plugin } from 'vite';
|
|
13
|
+
import type { ResolvedAvalonConfig } from '../vite-plugin/types.ts';
|
|
14
|
+
/**
|
|
15
|
+
* Creates a Vite plugin that emits island components as separate client chunks.
|
|
16
|
+
*/
|
|
17
|
+
export declare function islandClientBundlerPlugin(config: ResolvedAvalonConfig): Plugin;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFileSync as e,existsSync as t,readdirSync as n,statSync as r}from"node:fs";import{resolve as i,dirname as a,relative as o}from"node:path";export function islandClientBundlerPlugin(e){let t=process.cwd(),n=new Map,r=c(e,t);for(let e of r)l(e,t,n);let i=`\0avalon-island-entry:`;return{name:`avalon:island-client-bundler`,enforce:`pre`,resolveId(e){return e.startsWith(i)?e:null},load(e){if(!e.startsWith(i))return null;let t=e.slice(21);return[`import __C from ${JSON.stringify(t)};`,`var Component = __C;`,`export { Component as default, Component };`,`if(typeof globalThis<"u")globalThis.__avalonIsland=Component;`].join(`
|
|
2
|
+
`)},async buildStart(){let t=this.environment;if(!(t&&t.name!==`client`)&&n.size>0){for(let[,e]of n)this.emitFile({type:`chunk`,id:i+e.filePath,fileName:`islands/${e.bundleKey}.js`,preserveSignature:`exports-only`});e.verbose&&console.log(`🏝️ Emitting ${n.size} island client bundles`)}}}}function c(e,r){let a=[];if(e.pagesDir){let n=i(r,e.pagesDir);t(n)&&a.push(n)}if(e.layoutsDir){let n=i(r,e.layoutsDir);t(n)&&a.push(n)}if(e.modules){let o=i(r,e.modules.dir);if(t(o))try{for(let e of n(o,{withFileTypes:!0}))if(e.isDirectory())for(let n of[`pages`,`layouts`,`components`]){let r=i(o,e.name,n);t(r)&&a.push(r)}}catch{}}return a}function l(t,r,a){let o;try{o=n(t,{withFileTypes:!0})}catch{return}for(let n of o){let o=i(t,n.name);if(n.isDirectory()){l(o,r,a);continue}if(/\.(tsx?|jsx?|mdx?)$/.test(n.name))try{let t=e(o,`utf-8`);if(!t.includes(`island=`)&&!t.includes(`island `))continue;u(t,o,r,a)}catch{}}}function u(e,t,n,r){let i=/<([A-Z]\w*)\s+[^>]*\bisland\b/g,a=new Set,s;for(;(s=i.exec(e))!==null;)a.add(s[1]);if(a.size===0)return;let c=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;for(;(s=c.exec(e))!==null;){let[,e,i]=s;if(!a.has(e))continue;let c=d(i,t,n);if(!c)continue;let l=o(n,c).replaceAll(`\\`,`/`).replace(/\.(tsx?|jsx?|vue|svelte)$/,``);r.has(c)||r.set(c,{filePath:c,bundleKey:l})}}function d(e,n,o){let s;if(e.startsWith(`@shared/`))s=i(o,`app/shared`,e.slice(8));else if(e.startsWith(`@modules/`))s=i(o,`app/modules`,e.slice(9));else if(e.startsWith(`@/`))s=i(o,`app`,e.slice(2));else if(e.startsWith(`.`))s=i(a(n),e);else return null;if(t(s)&&r(s).isFile())return s;for(let e of[`.tsx`,`.ts`,`.jsx`,`.js`,`.vue`,`.svelte`])if(t(s+e))return s+e;return null}
|
|
@@ -20,8 +20,8 @@ export interface IslandEntry {
|
|
|
20
20
|
bundle: string;
|
|
21
21
|
/** Bundle hash for cache busting */
|
|
22
22
|
hash: string;
|
|
23
|
-
/** Framework type (preact, solid, vue, svelte,
|
|
24
|
-
framework: 'preact' | 'solid' | 'vue' | 'svelte' | '
|
|
23
|
+
/** Framework type (preact, solid, vue, svelte, qwik, lit, react) */
|
|
24
|
+
framework: 'preact' | 'solid' | 'vue' | 'svelte' | 'qwik' | 'lit' | 'react' | 'unknown';
|
|
25
25
|
/** Import dependencies */
|
|
26
26
|
deps: string[];
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as e}from"node:fs/promises";import{getQualifiedIslandName as t,createIslandRegistry as n}from"../islands/discovery/index.js";export async function generateIslandManifest(){let r={},s=process.cwd();try{let c=await n(s),l=c.getAllIslands(),u=c.directories,d=c.collisions;for(let n of l){let s=t(n),c=`/${n.relativePath}`,l=await e(n.filePath,`utf-8`),u=i(n.framework),d=a(l),f=await o(l);r[s]={src:c,bundle:n.namespace===``?`/
|
|
1
|
+
import{readFile as e}from"node:fs/promises";import{getQualifiedIslandName as t,createIslandRegistry as n}from"../islands/discovery/index.js";export async function generateIslandManifest(){let r={},s=process.cwd();try{let c=await n(s),l=c.getAllIslands(),u=c.directories,d=c.collisions;for(let n of l){let s=t(n),c=`/${n.relativePath}`,l=await e(n.filePath,`utf-8`),u=i(n.framework),d=a(l),f=await o(l);r[s]={src:c,bundle:n.namespace===``?`/islands/${n.name}.${f}.js`:`/islands/${s}.${f}.js`,hash:f,framework:u,deps:d,namespace:n.namespace,qualifiedName:s,sourceDirectory:n.directory.relativePath}}return{islands:r,directories:u,collisions:d,version:`1.0.0`,buildTime:Date.now()}}catch(e){return console.warn(`Failed to generate island manifest:`,e),{islands:{},directories:[],collisions:[],version:`1.0.0`,buildTime:Date.now()}}}function i(e){switch(e){case`preact`:return`preact`;case`react`:return`react`;case`solid`:return`solid`;case`vue`:return`vue`;case`svelte`:return`svelte`;case`lit`:return`lit`;case`qwik`:return`qwik`;default:return`unknown`}}function a(e){let t=[],n=/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];!e.startsWith(`.`)&&!e.startsWith(`/`)&&t.push(e)}return[...new Set(t)]}async function o(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,8)}export async function loadIslandManifest(){try{let t=await e(`dist/island-manifest.json`,`utf-8`);return JSON.parse(t)}catch(e){return console.warn(`Failed to load island manifest:`,e),null}}export function getIslandBundlePath(e,t){let n=process.env.NODE_ENV!==`production`;if(t){let n=l(e),r=t;if(r.islands[n])return r.islands[n].bundle;let i=e.replace(/^\/islands\//,``).replace(/\.(tsx?|jsx?|vue|svelte)$/,``),a=t.islands[i];if(a)return a.bundle}return n?e.startsWith(`/islands/`)?e.replaceAll(`/islands/`,`/src/islands/`):e.startsWith(`/src/`)||e.startsWith(`/app/`)||e.startsWith(`/`)?e:`/src/${e}`:`/islands/${l(e)}.js`}function l(e){let t=e.replace(/^\//,``);t=t.replace(/\.(tsx?|jsx?|vue|svelte)$/,``),t=t.replace(/\.(solid|react|lit|preact)$/,``);let n=new RegExp(/^src\/(.+)\/islands\/([^/]+)$/).exec(t);if(n){let[,e,t]=n;return`${e}/${t}`}let r=new RegExp(/^(?:src\/)?islands\/([^/]+)$/).exec(t);return r?r[1]:t}export function getIslandEntry(e,t){if(t.islands[e])return t.islands[e];if(t.directories){for(let[n,r]of Object.entries(t.islands))if(n.split(`/`).pop()===e)return r}return null}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{dirname as e}from"node:path";function t(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r;for(;(r=n.exec(e))!==null;)t.push({localName:r[1],importPath:r[2].slice(1,-1),fullMatch:r[0].trimStart()});return t}function n(t,n){if(t.startsWith(`/src/`)||t.startsWith(`/app/`)||t.startsWith(`/`))return t;if(t.startsWith(`@/`))return`/app/`+t.slice(2);if(t.startsWith(`@shared/`))return`/app/shared/`+t.slice(8);if(t.startsWith(`@modules/`))return`/app/modules/`+t.slice(9);if(t.startsWith(`$components/`))return`/src/components/`+t.slice(12);if(t.startsWith(`$islands/`))return`/src/islands/`+t.slice(9);if(t.startsWith(`~/`))return`/src/`+t.slice(2);if(t.startsWith(`.`)){let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i!==-1){let n=e(r.slice(i)).split(`/`),a=t.split(`/`);for(let e of a)e===`..`?n.pop():e!==`.`&&n.push(e);return n.join(`/`)}}return`/src/`+t.split(`/`).pop()}function r(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`}function i(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/`+i+`/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/`+e+`/[^/]+/`+n.pagesDirName+`/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}function a(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/`+i+`/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/`+e+`/[^/]+/`+n.layoutsDirName+`/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}const o=new Set([`qwik`]);function s(e){let t=r(e);return t!==void 0&&o.has(t)}function c(e,t){return t.some(t=>RegExp(`<`+t+String.raw`[\s][^>]*island[\s]*[={]`).test(e))}function l(e,t){return t.some(t=>s(t.importPath)?RegExp(`<`+t.localName+String.raw`[\s/>]`).test(e):!1)}function u(e,t,i){let a=new Map;for(let s of t){let t=n(s.importPath,i),c=r(t);if(RegExp(`<`+s.localName+String.raw`[\s][^>]*island[\s]*[={]`).test(e)){a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!1});continue}c&&o.has(c)&&RegExp(`<`+s.localName+String.raw`[\s/>]`).test(e)&&a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!0})}return a}function d(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function f(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function p(e,t){for(t++;t<e.length&&e[t]!=="`";){if(e[t]===`\\`){t+=2;continue}if(e[t]===`$`&&e[t+1]===`{`){t=m(t+1,e);continue}t++}return t<e.length?t+1:t}function m(e,t){let n=e+1,r=1;for(;n<t.length&&r>0;){let e=t[n];e===`{`?(r++,n++):e===`}`?(r--,r>0&&n++):e===`'`||e===`"`||e==="`"?n=f(t,n):n++}return n<t.length?n+1:n}function h(e,t){let n=t+1,r=m(t,e);return{value:e.slice(n,r-1),endIdx:r}}function g(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)e[r]===`\\`&&r++,r++;return{value:`"`+e.slice(t+1,r)+`"`,endIdx:r+1}}function _(e,t){let n=t,r=t;for(;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;let i=e.slice(n,r);if(!i)return null;if(r=d(e,r),e[r]!==`=`)return{name:i,value:null,endIdx:r};if(r=d(e,r+1),e[r]===`{`){let t=h(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}if(e[r]===`"`||e[r]===`'`){let t=g(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}return null}function v(e,t,n){if(e[t]===`/`&&e[t+1]===`>`)return{endIdx:t+2,selfClosing:!0};if(e[t]===`>`){let r=`</`+n+`>`,i=e.indexOf(r,t+1);return i===-1?null:{endIdx:i+r.length,selfClosing:!1}}return null}function y(e,t,n){let r=d(e,t+1+n.length),i=null,a=[];for(;r<e.length;){r=d(e,r);let t=v(e,r,n);if(t)return{endIdx:t.endIdx,islandProp:i,otherProps:a};let o=_(e,r);if(!o)return null;if(r=o.endIdx,o.name===`island`)i=o.value??`{}`;else{let e=o.value===null?o.name+`: true`:o.name+`: `+o.value;a.push(e)}}return null}function b(e,t,n,r){let
|
|
2
|
-
`,s),n=t===-1?e.length:t+1;o+=e.slice(s,n),s=n;continue}if(e[s]===`/`&&e[s+1]===`*`){let t=e.indexOf(`*/`,s+2),n=t===-1?e.length:t+2;o+=e.slice(s,n),s=n;continue}if(!x(e,s,a)){o+=e[s],s++;continue}let c=y(e,s,t);if(!c||!c.islandProp&&!i){let t=c?c.endIdx:s+1;o+=e.slice(s,t),s=t;continue}o+=b(c,n,r,i&&!c.islandProp),s=c.endIdx}return o}export function pageIslandTransform(e={}){let{pagesDir:n=`src/pages`,layoutsDir:r=`src/layouts`,modules:o=null}=e;return{name:`avalon:page-island-transform`,enforce:`pre`,transform(e,s){let d=a(s,r,o);if(!i(s,n,o)&&!d)return null;let f=t(e);if(f.length===0||!c(e,f.map(e=>e.localName))&&!l(e,f))return null;let p=u(e,f,s);if(p.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';
|
|
3
|
-
`+e;for(let[e,t]of p)m=S(m,e,t.srcPath,t.framework,t.autoIsland);
|
|
1
|
+
import{dirname as e}from"node:path";function t(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r;for(;(r=n.exec(e))!==null;)t.push({localName:r[1],importPath:r[2].slice(1,-1),fullMatch:r[0].trimStart()});return t}function n(t,n){if(t.startsWith(`/src/`)||t.startsWith(`/app/`)||t.startsWith(`/`))return t;if(t.startsWith(`@/`))return`/app/`+t.slice(2);if(t.startsWith(`@shared/`))return`/app/shared/`+t.slice(8);if(t.startsWith(`@modules/`))return`/app/modules/`+t.slice(9);if(t.startsWith(`$components/`))return`/src/components/`+t.slice(12);if(t.startsWith(`$islands/`))return`/src/islands/`+t.slice(9);if(t.startsWith(`~/`))return`/src/`+t.slice(2);if(t.startsWith(`.`)){let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i!==-1){let n=e(r.slice(i)).split(`/`),a=t.split(`/`);for(let e of a)e===`..`?n.pop():e!==`.`&&n.push(e);return n.join(`/`)}}return`/src/`+t.split(`/`).pop()}function r(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`}function i(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/`+i+`/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/`+e+`/[^/]+/`+n.pagesDirName+`/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}function a(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/`+i+`/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/`+e+`/[^/]+/`+n.layoutsDirName+`/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}const o=new Set([`qwik`]);function s(e){let t=r(e);return t!==void 0&&o.has(t)}function c(e,t){return t.some(t=>RegExp(`<`+t+String.raw`[\s][^>]*island[\s]*[={]`).test(e))}function l(e,t){return t.some(t=>s(t.importPath)?RegExp(`<`+t.localName+String.raw`[\s/>]`).test(e):!1)}function u(e,t,i){let a=new Map;for(let s of t){let t=n(s.importPath,i),c=r(t);if(RegExp(`<`+s.localName+String.raw`[\s][^>]*island[\s]*[={]`).test(e)){a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!1});continue}c&&o.has(c)&&RegExp(`<`+s.localName+String.raw`[\s/>]`).test(e)&&a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!0})}return a}function d(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function f(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function p(e,t){for(t++;t<e.length&&e[t]!=="`";){if(e[t]===`\\`){t+=2;continue}if(e[t]===`$`&&e[t+1]===`{`){t=m(t+1,e);continue}t++}return t<e.length?t+1:t}function m(e,t){let n=e+1,r=1;for(;n<t.length&&r>0;){let e=t[n];e===`{`?(r++,n++):e===`}`?(r--,r>0&&n++):e===`'`||e===`"`||e==="`"?n=f(t,n):n++}return n<t.length?n+1:n}function h(e,t){let n=t+1,r=m(t,e);return{value:e.slice(n,r-1),endIdx:r}}function g(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)e[r]===`\\`&&r++,r++;return{value:`"`+e.slice(t+1,r)+`"`,endIdx:r+1}}function _(e,t){let n=t,r=t;for(;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;let i=e.slice(n,r);if(!i)return null;if(r=d(e,r),e[r]!==`=`)return{name:i,value:null,endIdx:r};if(r=d(e,r+1),e[r]===`{`){let t=h(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}if(e[r]===`"`||e[r]===`'`){let t=g(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}return null}function v(e,t,n){if(e[t]===`/`&&e[t+1]===`>`)return{endIdx:t+2,selfClosing:!0};if(e[t]===`>`){let r=`</`+n+`>`,i=e.indexOf(r,t+1);return i===-1?null:{endIdx:i+r.length,selfClosing:!1}}return null}function y(e,t,n){let r=d(e,t+1+n.length),i=null,a=[];for(;r<e.length;){r=d(e,r);let t=v(e,r,n);if(t)return{endIdx:t.endIdx,islandProp:i,otherProps:a};let o=_(e,r);if(!o)return null;if(r=o.endIdx,o.name===`island`)i=o.value??`{}`;else{let e=o.value===null?o.name+`: true`:o.name+`: `+o.value;a.push(e)}}return null}function b(e,t,n,r,i){let a=n?`, framework: "`+n+`"`:``,o=e.otherProps.length>0?`, props: { `+e.otherProps.join(`, `)+` }`:``,s=`, component: `+i;if(r)return`{await __pageRenderIsland({ src: "`+t+`"`+a+s+o+`, ssr: true, ssrOnly: true })}`;let c=e.islandProp,l=n===`qwik`?`, ssrOnly: true`:``;return`{await __pageRenderIsland({ src: "`+t+`"`+a+s+`, ...(`+c+`)`+o+l+`, ssr: (`+c+`).ssr !== undefined ? (`+c+`).ssr : true })}`}function x(e,t,n){if(!e.startsWith(n,t))return!1;let r=t+n.length;return r>=e.length||!/[a-zA-Z0-9_$]/.test(e[r])}function S(e,t,n,r,i){let a=`<`+t,o=``,s=0;for(;s<e.length;){if(e[s]==="`"){let t=s;s=p(e,s),o+=e.slice(t,s);continue}if(e[s]===`{`&&e[s+1]===`/`&&e[s+2]===`*`){let t=e.indexOf(`*/`,s+3);if(t!==-1){let n=t+2;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]===`}`){o+=e.slice(s,n+1),s=n+1;continue}}}if(e[s]===`/`&&e[s+1]===`/`){let t=e.indexOf(`
|
|
2
|
+
`,s),n=t===-1?e.length:t+1;o+=e.slice(s,n),s=n;continue}if(e[s]===`/`&&e[s+1]===`*`){let t=e.indexOf(`*/`,s+2),n=t===-1?e.length:t+2;o+=e.slice(s,n),s=n;continue}if(!x(e,s,a)){o+=e[s],s++;continue}let c=y(e,s,t);if(!c||!c.islandProp&&!i){let t=c?c.endIdx:s+1;o+=e.slice(s,t),s=t;continue}o+=b(c,n,r,i&&!c.islandProp,t),s=c.endIdx}return o}export function pageIslandTransform(e={}){let{pagesDir:n=`src/pages`,layoutsDir:r=`src/layouts`,modules:o=null}=e;return{name:`avalon:page-island-transform`,enforce:`pre`,transform(e,s){let d=a(s,r,o);if(!i(s,n,o)&&!d)return null;let f=t(e);if(f.length===0||!c(e,f.map(e=>e.localName))&&!l(e,f))return null;let p=u(e,f,s);if(p.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';
|
|
3
|
+
`+e;for(let[e,t]of p)m=S(m,e,t.srcPath,t.framework,t.autoIsland);return{code:m,map:null}}}}
|
package/dist/src/client/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,e):e();function e(){let e=document.querySelectorAll(`[data-framework]`);e.length!==0&&e.forEach(e=>{try{let o=e.dataset.framework,s=e.dataset.condition||`on:client`;if(e.dataset.renderStrategy===`ssr-only`||!t(e,s))return;s===`on:client`?c(e,o):s===`on:visible`?n(e,o):s===`on:interaction`?r(e,o):s===`on:idle`?i(e,o):s.startsWith(`media:`)?a(e,o,s.slice(6)):c(e,o)}catch(t){console.error(`Error processing island:`,t),l(e,e.dataset.framework||`unknown`,e.dataset.src||`unknown`,t)}})}function t(e,t){if(!t||t===`on:client`)return!0;if(t.startsWith(`media:`)){let e=t.slice(6);try{return globalThis.matchMedia(e).matches}catch(t){return console.error(`Invalid media query:`,e,t),!0}}return t===`on:visible`||t===`on:interaction`||t===`on:idle`||console.warn(`Unknown hydration condition:`,t),!0}function n(e,t){try{let n=new IntersectionObserver(r=>{r[0].isIntersecting&&(c(e,t),n.disconnect())},{rootMargin:`50px`,threshold:0});n.observe(e)}catch(n){console.error(`Failed to setup intersection observer:`,n),c(e,t)}}function r(e,t){let n=[`click`,`touchstart`,`mouseenter`,`focusin`],r=!1,i=()=>{r||(r=!0,n.forEach(t=>{e.removeEventListener(t,i)}),c(e,t))};try{n.forEach(t=>{e.addEventListener(t,i,{once:!0,passive:!0})})}catch(n){console.error(`Failed to setup interaction observer:`,n),c(e,t)}}function i(e,t){try{`requestIdleCallback`in globalThis?globalThis.requestIdleCallback(()=>{c(e,t)},{timeout:5e3}):document.readyState===`complete`?setTimeout(()=>{c(e,t)},200):globalThis.addEventListener(`load`,()=>{setTimeout(()=>{c(e,t)},200)},{once:!0})}catch(n){console.error(`Failed to setup idle callback:`,n),c(e,t)}}function a(e,t,n){try{let r=globalThis.matchMedia(n);if(r.matches){c(e,t);return}let i=n=>{n.matches&&(c(e,t),r.removeEventListener(`change`,i))};r.addEventListener(`change`,i)}catch(r){console.error(`Failed to setup media query:`,n,r),c(e,t)}}async function o(e){if(![`preact`,`react`,`vue`,`svelte`,`solid`,`lit`,`qwik`].includes(e))throw Error(`Unknown framework: ${e}`);return import(`/@useavalon/${e}/client`)}function s(e,t){let n=e.default;if(!n){let t=Object.keys(e).filter(e=>e!==`default`);for(let r of t){let t=e[r];if(typeof t==`function`&&t.prototype){n=t;break}}n||=e}if(!n)throw Error(`Component ${t} has no default export`);return n}async function c(e,t){if(e.dataset.hydrated)return;let n=e.dataset.src,r=e.dataset.props;if(!n){console.warn(`Island missing data-src attribute`);return}try{let i=r?JSON.parse(r):{};t===`lit`&&await import(`/@useavalon
|
|
1
|
+
document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,e):e();function e(){let e=document.querySelectorAll(`[data-framework]`);e.length!==0&&e.forEach(e=>{try{let o=e.dataset.framework,s=e.dataset.condition||`on:client`;if(e.dataset.renderStrategy===`ssr-only`||!t(e,s))return;s===`on:client`?c(e,o):s===`on:visible`?n(e,o):s===`on:interaction`?r(e,o):s===`on:idle`?i(e,o):s.startsWith(`media:`)?a(e,o,s.slice(6)):c(e,o)}catch(t){console.error(`Error processing island:`,t),l(e,e.dataset.framework||`unknown`,e.dataset.src||`unknown`,t)}})}function t(e,t){if(!t||t===`on:client`)return!0;if(t.startsWith(`media:`)){let e=t.slice(6);try{return globalThis.matchMedia(e).matches}catch(t){return console.error(`Invalid media query:`,e,t),!0}}return t===`on:visible`||t===`on:interaction`||t===`on:idle`||console.warn(`Unknown hydration condition:`,t),!0}function n(e,t){try{let n=new IntersectionObserver(r=>{r[0].isIntersecting&&(c(e,t),n.disconnect())},{rootMargin:`50px`,threshold:0});n.observe(e)}catch(n){console.error(`Failed to setup intersection observer:`,n),c(e,t)}}function r(e,t){let n=[`click`,`touchstart`,`mouseenter`,`focusin`],r=!1,i=()=>{r||(r=!0,n.forEach(t=>{e.removeEventListener(t,i)}),c(e,t))};try{n.forEach(t=>{e.addEventListener(t,i,{once:!0,passive:!0})})}catch(n){console.error(`Failed to setup interaction observer:`,n),c(e,t)}}function i(e,t){try{`requestIdleCallback`in globalThis?globalThis.requestIdleCallback(()=>{c(e,t)},{timeout:5e3}):document.readyState===`complete`?setTimeout(()=>{c(e,t)},200):globalThis.addEventListener(`load`,()=>{setTimeout(()=>{c(e,t)},200)},{once:!0})}catch(n){console.error(`Failed to setup idle callback:`,n),c(e,t)}}function a(e,t,n){try{let r=globalThis.matchMedia(n);if(r.matches){c(e,t);return}let i=n=>{n.matches&&(c(e,t),r.removeEventListener(`change`,i))};r.addEventListener(`change`,i)}catch(r){console.error(`Failed to setup media query:`,n,r),c(e,t)}}async function o(e){if(![`preact`,`react`,`vue`,`svelte`,`solid`,`lit`,`qwik`].includes(e))throw Error(`Unknown framework: ${e}`);if(import.meta.env?.DEV)return import(`/@useavalon/${e}/client`);switch(e){case`preact`:case`react`:return import(`@useavalon/preact/client`);case`vue`:return import(`@useavalon/vue/client`);case`svelte`:return import(`@useavalon/svelte/client`);case`solid`:return import(`@useavalon/solid/client`);case`lit`:return import(`@useavalon/lit/client`);case`qwik`:return import(`@useavalon/qwik/client`);default:throw Error(`Unknown framework: ${e}`)}}function s(e,t){let n=e.default;if(!n){let t=Object.keys(e).filter(e=>e!==`default`);for(let r of t){let t=e[r];if(typeof t==`function`&&t.prototype){n=t;break}}n||=e}if(!n)throw Error(`Component ${t} has no default export`);return n}async function c(e,t){if(e.dataset.hydrated)return;let n=e.dataset.src,r=e.dataset.props;if(!n){console.warn(`Island missing data-src attribute`);return}try{let i=r?JSON.parse(r):{};t===`lit`&&(import.meta.env?.DEV?await import(`/@useavalon/lit/client`):await import(`@useavalon/lit/client`));let a=s(await import(n),n);try{let n=await o(t);if(!n.hydrate||typeof n.hydrate!=`function`)throw Error(`Integration ${t} does not export a hydrate function`);await n.hydrate(e,a,i),e.dataset.hydrated=`true`}catch(r){import.meta.env?.DEV&&console.error(`Integration hydration failed for ${t}: ${n}`,r),e.dataset.hydrationStatus=`failed`,e.dataset.hydrationError=r.message,e.dispatchEvent(new CustomEvent(`hydration-error`,{detail:{framework:t,src:n,error:r.message,timestamp:Date.now(),hydrationType:`integration-level`},bubbles:!0}))}}catch(r){console.error(`❌ Critical error hydrating ${t} island ${n}:`,r),l(e,t,n,r)}}function l(e,t,n,r){console.error(`Hydration error for ${t} island:`,{src:n,error:r.message,stack:r.stack}),e.dataset.hydrationStatus=`failed`,e.dataset.renderStrategy=`ssr-only`,e.classList.add(`hydration-failed`),e.dispatchEvent(new CustomEvent(`hydration-error`,{detail:{framework:t,src:n,error:r.message,timestamp:Date.now()},bubbles:!0})),d()&&u(e,t,n,r)}function u(e,t,n,r){let i=document.createElement(`div`);i.className=`hydration-error-indicator`,i.style.cssText=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 0;
|
|
4
4
|
right: 0;
|
|
@@ -11,7 +11,7 @@ document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,e):
|
|
|
11
11
|
z-index: 9999;
|
|
12
12
|
cursor: pointer;
|
|
13
13
|
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
14
|
-
`,i.textContent=`❌ ${t}`,i.title=`Hydration failed: ${n}\n${r.message}\nClick for details`,i.addEventListener(`click`,()=>{alert(`Hydration Error\n\nFramework: ${t}\nComponent: ${n}\n\nError: ${r.message}\n\nStack:\n${r.stack}`)}),globalThis.getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(i)}function d(){return import.meta.env?.DEV||import.meta.env?.MODE===`development`||globalThis.location?.hostname===`localhost`||globalThis.location?.hostname===`127.0.0.1`}function f(e){let t=e.dataset.framework,n=e.dataset.src;if(!n)return null;let r={framework:t,src:n,props:e.dataset.props,scrollPosition:{x:globalThis.scrollX,y:globalThis.scrollY},focusedElement:document.activeElement?.id||null};try{t===`vue`&&e.__vue__?r.vueData=structuredClone(e.__vue__.$data||{}):t===`svelte`&&e.__svelte__?r.svelteState=e.__svelte__:t===`lit`&&e.tagName?.includes(`-`)&&(e.querySelector(`[data-lit-element]`)||e)._$litElement$&&(r.litProperties={})}catch(e){console.warn(`Failed to preserve island state:`,e)}return r}function p(e,t){if(t)try{if(t.scrollPosition&&globalThis.scrollTo(t.scrollPosition.x,t.scrollPosition.y),t.focusedElement){let e=document.getElementById(t.focusedElement);e&&e.focus()}e.dataset.framework===`vue`&&t.vueData&&e.__vue__&&Object.assign(e.__vue__.$data,t.vueData)}catch(e){console.warn(`Failed to restore island state:`,e)}}async function m(e,t,n,r){let i=e.dataset.props,a=i?JSON.parse(i):{};t===`lit`&&await import(`/@useavalon
|
|
14
|
+
`,i.textContent=`❌ ${t}`,i.title=`Hydration failed: ${n}\n${r.message}\nClick for details`,i.addEventListener(`click`,()=>{alert(`Hydration Error\n\nFramework: ${t}\nComponent: ${n}\n\nError: ${r.message}\n\nStack:\n${r.stack}`)}),globalThis.getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(i)}function d(){return import.meta.env?.DEV||import.meta.env?.MODE===`development`||globalThis.location?.hostname===`localhost`||globalThis.location?.hostname===`127.0.0.1`}function f(e){let t=e.dataset.framework,n=e.dataset.src;if(!n)return null;let r={framework:t,src:n,props:e.dataset.props,scrollPosition:{x:globalThis.scrollX,y:globalThis.scrollY},focusedElement:document.activeElement?.id||null};try{t===`vue`&&e.__vue__?r.vueData=structuredClone(e.__vue__.$data||{}):t===`svelte`&&e.__svelte__?r.svelteState=e.__svelte__:t===`lit`&&e.tagName?.includes(`-`)&&(e.querySelector(`[data-lit-element]`)||e)._$litElement$&&(r.litProperties={})}catch(e){console.warn(`Failed to preserve island state:`,e)}return r}function p(e,t){if(t)try{if(t.scrollPosition&&globalThis.scrollTo(t.scrollPosition.x,t.scrollPosition.y),t.focusedElement){let e=document.getElementById(t.focusedElement);e&&e.focus()}e.dataset.framework===`vue`&&t.vueData&&e.__vue__&&Object.assign(e.__vue__.$data,t.vueData)}catch(e){console.warn(`Failed to restore island state:`,e)}}async function m(e,t,n,r){let i=e.dataset.props,a=i?JSON.parse(i):{};t===`lit`&&(import.meta.env?.DEV?await import(`/@useavalon/lit/client`):await import(`@useavalon/lit/client`));let c=s(await import(n),r),l=await o(t);if(!l.hydrate||typeof l.hydrate!=`function`)throw Error(`Integration ${t} does not export a hydrate function`);l.hydrate(e,c,a),e.dataset.hydrated=`true`}function h(e,t,n,r){let i=e.querySelector(`.hmr-error-indicator`);i&&i.remove();let a=document.createElement(`div`);a.className=`hmr-error-indicator`,a.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 0;
|
|
17
17
|
left: 0;
|
|
@@ -28,6 +28,8 @@ export interface IslandProps {
|
|
|
28
28
|
renderOptions?: AnalyzerOptions;
|
|
29
29
|
/** Hydration data from integration renderer */
|
|
30
30
|
hydrationData?: Record<string, unknown>;
|
|
31
|
+
/** Pre-imported component reference (avoids dynamic import in bundled SSR) */
|
|
32
|
+
component?: unknown;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Universal Island component – renders `<avalon-island>` custom elements for better DOM structure.
|
|
@@ -52,4 +54,4 @@ export default function Island({ src, condition, props, children, ssr, framework
|
|
|
52
54
|
* Error isolation: If SSR fails, returns an error placeholder instead of throwing,
|
|
53
55
|
* allowing the page to continue rendering other islands.
|
|
54
56
|
*/
|
|
55
|
-
export declare function renderIsland({ src, condition, props, children, ssr, framework, ssrOnly, renderOptions, }: IslandProps): Promise<JSX.Element>;
|
|
57
|
+
export declare function renderIsland({ src, condition, props, children, ssr, framework, ssrOnly, renderOptions, component: preloadedComponent, }: IslandProps): Promise<JSX.Element>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"preact";import{detectFramework as t}from"./framework-detection.js";import{analyzeComponentFile as n,renderComponentSSROnly as r}from"./component-analysis.js";import{loadIntegration as i,detectFrameworkFromPath as a}from"./integration-loader.js";import{addUniversalCSS as o}from"./universal-css-collector.js";import{addUniversalHead as s}from"./universal-head-collector.js";import{getIslandBundlePath as c}from"../build/island-manifest.js";import{isDev as l,devLog as u,devWarn as d,devError as f,logRenderTiming as p}from"../utils/dev-logger.js";function m(e){return`island-${e.replaceAll(/[^a-zA-Z0-9]/g,`-`)}`}function h(e){let t={};e.renderId&&(t[`data-solid-render-id`]=e.renderId);let n=e.metadata;return n?.tagName&&(t[`data-tag-name`]=n.tagName),t}function g(e,t,n,r){return{"data-condition":t,"data-src":c(e),"data-props":JSON.stringify(n),"data-render-strategy":`hydrate`,...h(r)}}function _(e){return e.startsWith(`<script`)?`script`:e.startsWith(`<style`)?`style`:e.startsWith(`<meta`)?`meta`:e.startsWith(`<link`)?`link`:e.includes(`window._$HY`)||e.includes(`_$HY=`)?`script`:`other`}function v(e){let t=e.match(/<style[^>]*>([\s\S]*?)<\/style>/i);return t?t[1].trim():null}function y(e,t,n,r){if(e.css&&o(e.css,t,n,e.scopeId),e.head){let i=e.head.trim(),a=_(i);if(a===`style`){let a=v(i);a&&(u(`${r} Extracting CSS from head <style> tag`),o(a,t,n,e.scopeId));return}s(e.head,t,n,a)}}function b(t){let{islandId:n,detectedFramework:r,shouldSkipHydration:i,src:a,condition:o,props:s,hydrationData:c,children:l}=t,d={id:n,"data-framework":r},f=i?{"data-render-strategy":`ssr-only`}:g(a,o,s,c);r===`lit`&&u(`🔍 [Island Component] ${a} - Lit hydration data:`,{hydrationDataKeys:Object.keys(c),metadata:c.metadata});let p={...d,...f};return typeof l==`string`?e(`avalon-island`,{...p,dangerouslySetInnerHTML:{__html:l}}):e(`avalon-island`,p,l)}function x(t,n,r,i,a,o,s){return r?e(`avalon-island`,{id:t,"data-render-strategy":`ssr-only`,"data-framework":n}):e(`avalon-island`,{id:t,"data-condition":a,"data-src":c(i),"data-props":JSON.stringify(o),"data-render-strategy":`hydrate`,"data-framework":n,...h(s)})}export default function S({src:e,condition:t=`on:client`,props:n={},children:r,ssr:i=t!==`on:client`,framework:o,ssrOnly:s=!1,renderOptions:c={},hydrationData:l={}}){let f=m(e),p=s||!!c.forceSSROnly,h=o||a(e),g=r!=null&&r!==``;return u(`🔍 [Island Component] ${e}`,{ssr:i,ssrOnly:s,hasChildren:g,framework:o,condition:t}),i&&g?b({islandId:f,detectedFramework:h,shouldSkipHydration:p,src:e,condition:t,props:n,hydrationData:l,children:r}):(i&&!g&&p&&d(`${e}: SSR-only component has no rendered content. This may indicate a rendering error.`),x(f,h,p,e,t,n,l))}function C(t,n){let r=n instanceof Error?n.message:String(n);return f(`🚨 Island SSR failed for ${t}:`,n),n instanceof Error&&n.stack&&f(`Stack trace:`,n.stack),e(`avalon-island`,{id:m(t),"data-src":c(t),"data-ssr-error":r,"data-render-strategy":`client-only`})}async function w({src:e,condition:t,props:n,children:r,ssr:a,framework:o,ssrOnly:s,renderOptions:c}){let
|
|
1
|
+
import{h as e}from"preact";import{detectFramework as t}from"./framework-detection.js";import{analyzeComponentFile as n,renderComponentSSROnly as r}from"./component-analysis.js";import{loadIntegration as i,detectFrameworkFromPath as a}from"./integration-loader.js";import{addUniversalCSS as o}from"./universal-css-collector.js";import{addUniversalHead as s}from"./universal-head-collector.js";import{getIslandBundlePath as c}from"../build/island-manifest.js";import{isDev as l,devLog as u,devWarn as d,devError as f,logRenderTiming as p}from"../utils/dev-logger.js";function m(e){return`island-${e.replaceAll(/[^a-zA-Z0-9]/g,`-`)}`}function h(e){let t={};e.renderId&&(t[`data-solid-render-id`]=e.renderId);let n=e.metadata;return n?.tagName&&(t[`data-tag-name`]=n.tagName),t}function g(e,t,n,r){return{"data-condition":t,"data-src":c(e),"data-props":JSON.stringify(n),"data-render-strategy":`hydrate`,...h(r)}}function _(e){return e.startsWith(`<script`)?`script`:e.startsWith(`<style`)?`style`:e.startsWith(`<meta`)?`meta`:e.startsWith(`<link`)?`link`:e.includes(`window._$HY`)||e.includes(`_$HY=`)?`script`:`other`}function v(e){let t=e.match(/<style[^>]*>([\s\S]*?)<\/style>/i);return t?t[1].trim():null}function y(e,t,n,r){if(e.css&&o(e.css,t,n,e.scopeId),e.head){let i=e.head.trim(),a=_(i);if(a===`style`){let a=v(i);a&&(u(`${r} Extracting CSS from head <style> tag`),o(a,t,n,e.scopeId));return}s(e.head,t,n,a)}}function b(t){let{islandId:n,detectedFramework:r,shouldSkipHydration:i,src:a,condition:o,props:s,hydrationData:c,children:l}=t,d={id:n,"data-framework":r},f=i?{"data-render-strategy":`ssr-only`}:g(a,o,s,c);r===`lit`&&u(`🔍 [Island Component] ${a} - Lit hydration data:`,{hydrationDataKeys:Object.keys(c),metadata:c.metadata});let p={...d,...f};return typeof l==`string`?e(`avalon-island`,{...p,dangerouslySetInnerHTML:{__html:l}}):e(`avalon-island`,p,l)}function x(t,n,r,i,a,o,s){return r?e(`avalon-island`,{id:t,"data-render-strategy":`ssr-only`,"data-framework":n}):e(`avalon-island`,{id:t,"data-condition":a,"data-src":c(i),"data-props":JSON.stringify(o),"data-render-strategy":`hydrate`,"data-framework":n,...h(s)})}export default function S({src:e,condition:t=`on:client`,props:n={},children:r,ssr:i=t!==`on:client`,framework:o,ssrOnly:s=!1,renderOptions:c={},hydrationData:l={}}){let f=m(e),p=s||!!c.forceSSROnly,h=o||a(e),g=r!=null&&r!==``;return u(`🔍 [Island Component] ${e}`,{ssr:i,ssrOnly:s,hasChildren:g,framework:o,condition:t}),i&&g?b({islandId:f,detectedFramework:h,shouldSkipHydration:p,src:e,condition:t,props:n,hydrationData:l,children:r}):(i&&!g&&p&&d(`${e}: SSR-only component has no rendered content. This may indicate a rendering error.`),x(f,h,p,e,t,n,l))}function C(t,n){let r=n instanceof Error?n.message:String(n);return f(`🚨 Island SSR failed for ${t}:`,n),n instanceof Error&&n.stack&&f(`Stack trace:`,n.stack),e(`avalon-island`,{id:m(t),"data-src":c(t),"data-ssr-error":r,"data-render-strategy":`client-only`})}async function w({src:e,condition:t,props:n,children:r,ssr:a,framework:o,ssrOnly:s,renderOptions:c,component:u}){let d=`🏝️ [${e}]`;if(!a||r)return S({src:e,condition:t,props:n,children:r,ssr:a,framework:o,ssrOnly:s,renderOptions:c});let p;try{p=await i(o)}catch(r){return f(`${d} Failed to load ${o} integration:`,r),S({src:e,condition:t,props:n,ssr:!1,framework:o,ssrOnly:s,renderOptions:c})}try{let r=await p.render({component:u??null,props:n,src:e,condition:t,ssrOnly:s,viteServer:globalThis.__viteDevServer,isDev:l()});return y(r,e,o,d),S({src:e,condition:t,props:n,children:r.html,ssr:!0,framework:o,ssrOnly:s,renderOptions:c,hydrationData:s?void 0:r.hydrationData})}catch(r){return f(`${d} Fast path SSR failed:`,r),S({src:e,condition:t,props:n,ssr:!1,framework:o,ssrOnly:s,renderOptions:c})}}async function T(e,t,r,i){if(t||r.detectScripts===!1)return t;try{let t=await n(e,r);if(t.decision.warnings?.length)for(let e of t.decision.warnings)d(`${i} Analysis warning: ${e}`);return!t.decision.shouldHydrate}catch(e){return d(`${i} Component analysis failed:`,e),t}}async function E(e){return e.endsWith(`.vue`)?`vue`:e.endsWith(`.svelte`)?`svelte`:e.endsWith(`.tsx`)||e.endsWith(`.jsx`)||e.endsWith(`.ts`)||e.endsWith(`.js`)?t(e):`unknown`}async function D(e,t,n,r,i,a,o){let s=await E(e),c=s,u=await(await O(s,a)).render({component:o??null,props:n,src:e,condition:t,ssrOnly:r,viteServer:globalThis.__viteDevServer,isDev:l()});return y(u,e,s,a),S({src:e,condition:t,props:n,children:u.html,ssr:!0,framework:c,ssrOnly:r,renderOptions:i,hydrationData:r?void 0:u.hydrationData})}async function O(e,t){try{u(`${t} Loading integration for framework: ${e}`);let n=await i(e);return u(`${t} ✅ Integration loaded successfully`),n}catch(n){throw f(`${t} Failed to load ${e} integration:`,n),Error(`Failed to load integration for framework '${e}'. Make sure @useavalon/${e} is installed.\nInstall it with: deno add @useavalon/${e}`,{cause:n})}}export async function renderIsland({src:e,condition:t=`on:client`,props:n={},children:r,ssr:i=t!==`on:client`,framework:a,ssrOnly:o=!1,renderOptions:s={},component:c}){let u=l()?performance.now():0,d=`🏝️ [${e}]`;try{return o&&!i&&(i=!0),a?await w({src:e,condition:t,props:n,children:r,ssr:i,framework:a,ssrOnly:o,renderOptions:s,component:c}):await k({src:e,condition:t,props:n,children:r,ssr:i,ssrOnly:o,renderOptions:s,logPrefix:d,component:c})}catch(t){return C(e,t)}finally{l()&&p(e,performance.now()-u)}}async function k(e){let{src:t,condition:n,props:r,children:i,ssr:a,ssrOnly:o,renderOptions:s,logPrefix:c,component:l}=e;if(u(`🔍 [renderIsland] ${t} - Starting render (slow path)`,{ssr:a,ssrOnly:o,hasChildren:!!i,condition:n}),await T(t,o,s,c))return A(t,n,r,i,a,s,c);if(!a||i)return S({src:t,condition:n,props:r,children:i,ssr:a,renderOptions:s});try{return await D(t,n,r,o,s,c,l)}catch(e){let i=await E(t);return f(`${c} Framework rendering failed:`,e),S({src:t,condition:n,props:r,ssr:!1,framework:i,renderOptions:s})}}function A(e,t,n,i,a,o,s){return a&&!i?r({src:e,condition:t,props:n,renderOptions:o}).catch(r=>(f(`${s} SSR failed for SSR-only component:`,r),S({src:e,condition:t,props:n,ssr:!1,ssrOnly:!0,renderOptions:o}))):S({src:e,condition:t,props:n,children:i,ssr:a,ssrOnly:!0,renderOptions:o})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_NITRO_CONFIG as e,VALID_V3_PRESETS as t}from"./config.js";export const DEFAULT_BUILD_CONFIG={mode:`both`,clientOutDir:`dist/client`,serverOutDir:`dist/server`,sourcemap:!0,minify:`oxc`,target:`es2020`,ssr:!0,preset:`node_server`,verbose:!1};export const PRESET_OUTPUT_CONFIGS={node_server:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!1},node_middleware:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!1},vercel:{outputDir:`.vercel/output`,serverEntry:`functions/render.func/index.mjs`,supportsStreaming:!0,bundleDependencies:!0,additionalFiles:[`config.json`]},cloudflare_module:{outputDir:`dist`,serverEntry:`server/index.mjs`,supportsStreaming:!1,bundleDependencies:!0},cloudflare_pages:{outputDir:`dist`,serverEntry:`_worker.js`,supportsStreaming:!1,bundleDependencies:!0,additionalFiles:[`_routes.json`]},deno_deploy:{outputDir:`.output`,serverEntry:`server/index.ts`,supportsStreaming:!0,bundleDependencies:!1},deno_server:{outputDir:`.output`,serverEntry:`server/index.ts`,supportsStreaming:!0,bundleDependencies:!1},netlify_functions:{outputDir:`.netlify`,serverEntry:`functions-internal/render.mjs`,supportsStreaming:!0,bundleDependencies:!0},netlify:{outputDir:`.netlify`,serverEntry:`functions-internal/server/index.mjs`,supportsStreaming:!0,bundleDependencies:!0},netlify_edge:{outputDir:`.netlify/edge-functions`,serverEntry:`render.js`,supportsStreaming:!0,bundleDependencies:!0},aws_lambda:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!1,bundleDependencies:!0},azure_swa:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!1,bundleDependencies:!0},firebase_functions:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!0},render_com:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!1},static:{outputDir:`dist`,serverEntry:``,supportsStreaming:!1,bundleDependencies:!1},browser:{outputDir:`dist`,serverEntry:``,supportsStreaming:!1,bundleDependencies:!0}};export function createClientBuildConfig(e,t={}){let r={...DEFAULT_BUILD_CONFIG,...t};return{outDir:r.clientOutDir,emptyOutDir:!0,sourcemap:r.sourcemap,minify:r.minify,target:r.target,rolldownOptions:{output:{entryFileNames:`[name].[hash].js`,chunkFileNames:`chunks/[name].[hash].js`,assetFileNames:`assets/[name].[hash].[ext]`,codeSplitting:{groups:[{name:`vendor-react`,test:/node_modules\/(react|react-dom)/},{name:`vendor-vue`,test:/node_modules\/(vue|@vue)/},{name:`vendor-svelte`,test:/node_modules\/svelte/},{name:`vendor-preact`,test:/node_modules\/preact/},{name:`vendor-solid`,test:/node_modules\/solid-js/},{name:`vendor-lit`,test:/node_modules\/(lit|@lit)/},{name:`vendor`,test:/node_modules/},{name:`islands`,test:/\/islands\//}]}}},reportCompressedSize:!e.isDev,cssCodeSplit:!0}}export function createServerBuildConfig(t,i,a={}){let s={...DEFAULT_BUILD_CONFIG,...a},c=i.preset??e.preset,l=PRESET_OUTPUT_CONFIGS[c]??PRESET_OUTPUT_CONFIGS.node_server;return{outDir:s.serverOutDir,emptyOutDir:!0,sourcemap:s.sourcemap,minify:s.minify,target:s.target,ssr:!0,rolldownOptions:{input:{index:`./server/index.ts`},output:{format:`esm`,entryFileNames:`[name].mjs`,chunkFileNames:`chunks/[name].[hash].mjs`,preserveModules:!l.bundleDependencies},external:l.bundleDependencies?[]:o(c)}}}function o(e){let t=[/^node:/,/^deno:/];switch(e){case`deno_deploy`:case`deno_server`:return[...t];case`node_server`:return[...t,/^[a-z@]/i];default:return t}}export function getPresetOutputConfig(e){return PRESET_OUTPUT_CONFIGS[e]??PRESET_OUTPUT_CONFIGS.node_server}export function presetSupportsStreaming(e){return getPresetOutputConfig(e).supportsStreaming}export function createCombinedBuildConfig(t,n,r={}){let a=n.preset??e.preset,o=getPresetOutputConfig(a);return{build:{...createClientBuildConfig(t,r),outDir:o.outputDir},define:{__DEV__:!1,__PROD__:!0,"process.env.NODE_ENV":JSON.stringify(`production`),...u(a,o)}}}function u(e,t){let n={__NITRO_PRESET__:JSON.stringify(e),__SUPPORTS_STREAMING__:JSON.stringify(t.supportsStreaming)};if(t.env)for(let[e,r]of Object.entries(t.env))n[`process.env.${e}`]=JSON.stringify(r);return n}
|
|
1
|
+
import{DEFAULT_NITRO_CONFIG as e,VALID_V3_PRESETS as t}from"./config.js";export const DEFAULT_BUILD_CONFIG={mode:`both`,clientOutDir:`dist/client`,serverOutDir:`dist/server`,sourcemap:!0,minify:`oxc`,target:`es2020`,ssr:!0,preset:`node_server`,verbose:!1};export const PRESET_OUTPUT_CONFIGS={node_server:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!1},node_middleware:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!1},vercel:{outputDir:`.vercel/output`,serverEntry:`functions/render.func/index.mjs`,supportsStreaming:!0,bundleDependencies:!0,additionalFiles:[`config.json`]},cloudflare_module:{outputDir:`dist`,serverEntry:`server/index.mjs`,supportsStreaming:!1,bundleDependencies:!0},cloudflare_pages:{outputDir:`dist`,serverEntry:`_worker.js`,supportsStreaming:!1,bundleDependencies:!0,additionalFiles:[`_routes.json`]},deno_deploy:{outputDir:`.output`,serverEntry:`server/index.ts`,supportsStreaming:!0,bundleDependencies:!1},deno_server:{outputDir:`.output`,serverEntry:`server/index.ts`,supportsStreaming:!0,bundleDependencies:!1},netlify_functions:{outputDir:`.netlify`,serverEntry:`functions-internal/render.mjs`,supportsStreaming:!0,bundleDependencies:!0},netlify:{outputDir:`.netlify`,serverEntry:`functions-internal/server/index.mjs`,supportsStreaming:!0,bundleDependencies:!0},netlify_edge:{outputDir:`.netlify/edge-functions`,serverEntry:`render.js`,supportsStreaming:!0,bundleDependencies:!0},aws_lambda:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!1,bundleDependencies:!0},azure_swa:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!1,bundleDependencies:!0},firebase_functions:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!0},render_com:{outputDir:`.output`,serverEntry:`server/index.mjs`,supportsStreaming:!0,bundleDependencies:!1},static:{outputDir:`dist`,serverEntry:``,supportsStreaming:!1,bundleDependencies:!1},browser:{outputDir:`dist`,serverEntry:``,supportsStreaming:!1,bundleDependencies:!0}};export function createClientBuildConfig(e,t={}){let r={...DEFAULT_BUILD_CONFIG,...t};return{outDir:r.clientOutDir,emptyOutDir:!0,sourcemap:r.sourcemap,minify:r.minify,target:r.target,rolldownOptions:{output:{entryFileNames:`[name].[hash].js`,chunkFileNames:`chunks/[name].[hash].js`,assetFileNames:`assets/[name].[hash].[ext]`,codeSplitting:{groups:[{name:`vendor-react`,test:/node_modules\/(react|react-dom)/},{name:`vendor-vue`,test:/node_modules\/(vue|@vue)/},{name:`vendor-svelte`,test:/node_modules\/svelte/},{name:`vendor-preact`,test:/node_modules\/preact/},{name:`vendor-solid`,test:/node_modules\/solid-js/},{name:`vendor-lit`,test:/node_modules\/(lit|@lit)/},{name:`vendor`,test:/node_modules/},{name:`islands`,test:/\/islands\//}]}}},reportCompressedSize:!e.isDev,cssCodeSplit:!0}}export function createServerBuildConfig(t,i,a={}){let s={...DEFAULT_BUILD_CONFIG,...a},c=i.preset??e.preset,l=PRESET_OUTPUT_CONFIGS[c]??PRESET_OUTPUT_CONFIGS.node_server;return{outDir:s.serverOutDir,emptyOutDir:!0,sourcemap:s.sourcemap,minify:s.minify,target:s.target,ssr:!0,rolldownOptions:{input:{index:`./server/index.ts`},output:{format:`esm`,entryFileNames:`[name].mjs`,chunkFileNames:`chunks/[name].[hash].mjs`,preserveModules:!l.bundleDependencies},external:l.bundleDependencies?[]:o(c)}}}function o(e){let t=[/^node:/,/^deno:/];switch(e){case`deno_deploy`:case`deno_server`:return[...t];case`node_server`:return[...t,/^[a-z@]/i];default:return t}}export function getPresetOutputConfig(e){return PRESET_OUTPUT_CONFIGS[e]??PRESET_OUTPUT_CONFIGS.node_server}export function presetSupportsStreaming(e){return getPresetOutputConfig(e).supportsStreaming}export function createCombinedBuildConfig(t,n,r={}){let a=n.preset??e.preset,o=getPresetOutputConfig(a);return{build:{...createClientBuildConfig(t,r),outDir:o.outputDir},define:{__DEV__:!1,__PROD__:!0,"process.env.NODE_ENV":JSON.stringify(`production`),...u(a,o)}}}function u(e,t){let n={__NITRO_PRESET__:JSON.stringify(e),__SUPPORTS_STREAMING__:JSON.stringify(t.supportsStreaming)};if(t.env)for(let[e,r]of Object.entries(t.env))n[`process.env.${e}`]=JSON.stringify(r);return n}export function createNitroBuildPlugin(t,n){let r=n.preset??e.preset,i=getPresetOutputConfig(r);return{name:`avalon:nitro-build`,enforce:`post`,config(e,{command:t}){if(t===`build`)return{define:{__DEV__:!1,__PROD__:!0,"process.env.NODE_ENV":JSON.stringify(`production`),...u(r,i)}}},buildStart(){t.verbose&&(console.log(`🚀 Avalon Nitro build starting...`),console.log(` Preset: ${r}`),console.log(` Output: ${i.outputDir}`),console.log(` Streaming: ${i.supportsStreaming}`))},writeBundle(){t.verbose&&console.log(`✅ Avalon client build complete`)},closeBundle(){t.verbose&&(console.log(`📦 Avalon build finished`),console.log(` Output directory: ${i.outputDir}`))}}}export function validateBuildConfig(e){let n=[];return e.preset&&(t.includes(e.preset)||n.push(`Unknown preset: ${e.preset}. Valid presets: ${t.join(`, `)}`)),e.mode&&![`client`,`server`,`both`].includes(e.mode)&&n.push(`Invalid build mode: ${e.mode}. Must be 'client', 'server', or 'both'`),e.sourcemap!==void 0&&typeof e.sourcemap!=`boolean`&&![`inline`,`hidden`].includes(e.sourcemap)&&n.push(`Invalid sourcemap option: ${e.sourcemap}`),{valid:n.length===0,errors:n}}export const DEFAULT_SOURCEMAP_CONFIG={enabled:!0,type:!0,includeContent:!0};export function createSourceMapConfig(e,t){return t?{enabled:!0,type:!0,includeContent:!0}:e.includes(`edge`)||e.includes(`cloudflare`)||e.includes(`lambda`)?{enabled:!0,type:`hidden`,includeContent:!1}:{enabled:!0,type:!0,includeContent:!0}}export function getViteSourceMapOption(e){return e.enabled?e.type:!1}export function createSourceMapPlugin(e){return{name:`avalon:sourcemap`,enforce:`post`,config(t,{command:n}){if(n===`build`)return{build:{sourcemap:getViteSourceMapOption(e)},...e.sourceRoot&&{rolldownOptions:{output:{sourcemapPathTransform:t=>`${e.sourceRoot}/${t}`}}}}},generateBundle(t,n){if(!e.enabled)return;let r=Object.keys(n).filter(e=>e.endsWith(`.map`)).length;r>0&&globalThis.__avalonConfig?.verbose&&console.log(`📍 Generated ${r} source map(s)`)}}}
|
|
@@ -53,7 +53,7 @@ export declare const routingValidators: {
|
|
|
53
53
|
siteName?: string;
|
|
54
54
|
};
|
|
55
55
|
twitter?: {
|
|
56
|
-
card?: "summary" | "
|
|
56
|
+
card?: "summary" | "app" | "summary_large_image" | "player";
|
|
57
57
|
title?: string;
|
|
58
58
|
description?: string;
|
|
59
59
|
image?: string;
|
|
@@ -76,7 +76,7 @@ export declare const routingValidators: {
|
|
|
76
76
|
siteName?: string;
|
|
77
77
|
};
|
|
78
78
|
twitter?: {
|
|
79
|
-
card?: "summary" | "
|
|
79
|
+
card?: "summary" | "app" | "summary_large_image" | "player";
|
|
80
80
|
title?: string;
|
|
81
81
|
description?: string;
|
|
82
82
|
image?: string;
|
|
@@ -143,7 +143,7 @@ export declare const safeRoutingValidators: {
|
|
|
143
143
|
siteName?: string;
|
|
144
144
|
};
|
|
145
145
|
twitter?: {
|
|
146
|
-
card?: "summary" | "
|
|
146
|
+
card?: "summary" | "app" | "summary_large_image" | "player";
|
|
147
147
|
title?: string;
|
|
148
148
|
description?: string;
|
|
149
149
|
image?: string;
|
|
@@ -166,7 +166,7 @@ export declare const safeRoutingValidators: {
|
|
|
166
166
|
siteName?: string;
|
|
167
167
|
};
|
|
168
168
|
twitter?: {
|
|
169
|
-
card?: "summary" | "
|
|
169
|
+
card?: "summary" | "app" | "summary_large_image" | "player";
|
|
170
170
|
title?: string;
|
|
171
171
|
description?: string;
|
|
172
172
|
image?: string;
|
|
@@ -78,8 +78,8 @@ export declare const MetadataSchema: z.ZodObject<{
|
|
|
78
78
|
twitter: z.ZodOptional<z.ZodObject<{
|
|
79
79
|
card: z.ZodOptional<z.ZodEnum<{
|
|
80
80
|
summary: "summary";
|
|
81
|
-
summary_large_image: "summary_large_image";
|
|
82
81
|
app: "app";
|
|
82
|
+
summary_large_image: "summary_large_image";
|
|
83
83
|
player: "player";
|
|
84
84
|
}>>;
|
|
85
85
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -109,8 +109,8 @@ export declare const ResolvedMetadataSchema: z.ZodObject<{
|
|
|
109
109
|
twitter: z.ZodOptional<z.ZodObject<{
|
|
110
110
|
card: z.ZodOptional<z.ZodEnum<{
|
|
111
111
|
summary: "summary";
|
|
112
|
-
summary_large_image: "summary_large_image";
|
|
113
112
|
app: "app";
|
|
113
|
+
summary_large_image: "summary_large_image";
|
|
114
114
|
player: "player";
|
|
115
115
|
}>>;
|
|
116
116
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -143,8 +143,8 @@ export declare const MetadataChainSchema: z.ZodObject<{
|
|
|
143
143
|
twitter: z.ZodOptional<z.ZodObject<{
|
|
144
144
|
card: z.ZodOptional<z.ZodEnum<{
|
|
145
145
|
summary: "summary";
|
|
146
|
-
summary_large_image: "summary_large_image";
|
|
147
146
|
app: "app";
|
|
147
|
+
summary_large_image: "summary_large_image";
|
|
148
148
|
player: "player";
|
|
149
149
|
}>>;
|
|
150
150
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -173,8 +173,8 @@ export declare const MetadataChainSchema: z.ZodObject<{
|
|
|
173
173
|
twitter: z.ZodOptional<z.ZodObject<{
|
|
174
174
|
card: z.ZodOptional<z.ZodEnum<{
|
|
175
175
|
summary: "summary";
|
|
176
|
-
summary_large_image: "summary_large_image";
|
|
177
176
|
app: "app";
|
|
177
|
+
summary_large_image: "summary_large_image";
|
|
178
178
|
player: "player";
|
|
179
179
|
}>>;
|
|
180
180
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -202,8 +202,8 @@ export declare const MetadataChainSchema: z.ZodObject<{
|
|
|
202
202
|
twitter: z.ZodOptional<z.ZodObject<{
|
|
203
203
|
card: z.ZodOptional<z.ZodEnum<{
|
|
204
204
|
summary: "summary";
|
|
205
|
-
summary_large_image: "summary_large_image";
|
|
206
205
|
app: "app";
|
|
206
|
+
summary_large_image: "summary_large_image";
|
|
207
207
|
player: "player";
|
|
208
208
|
}>>;
|
|
209
209
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -1,6 +1,6 @@
|
|
|
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`,PAGE_LOADER:`virtual:avalon/page-loader`,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,PAGE_LOADER:`\0`+VIRTUAL_MODULE_IDS.PAGE_LOADER,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,compatibilityDate:r.compatibilityDate,scanDirs:[`.`]};n.renderer===!1?i.renderer=!1:r.renderer&&(i.renderer=r.renderer),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,t.integrations,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 R(e,s,t,a))return;let o=await z(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,n){let r=performance.now(),i=[{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},...t.map(e=>({path:x(e,`server/renderer.ts`),assignTo:null}))],a=(await Promise.allSettled(i.map(async({path:t,assignTo:n})=>{let r=await e.ssrLoadModule(t);n===`ssr`&&(I=r),n===`layout`&&(L=r)}))).filter(e=>e.status===`fulfilled`).length,o=performance.now()-r;n&&a>0&&console.log(`🔥 SSR ready in ${o.toFixed(0)}ms (${a}/${i.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.PAGE_LOADER?RESOLVED_VIRTUAL_IDS.PAGE_LOADER: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.PAGE_LOADER?await M(t,r):e===RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST?N():e===RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG?P(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/`))&&(I=null,L=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 = [];
|
|
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`,PAGE_LOADER:`virtual:avalon/page-loader`,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,PAGE_LOADER:`\0`+VIRTUAL_MODULE_IDS.PAGE_LOADER,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,compatibilityDate:r.compatibilityDate,scanDirs:[`.`],noExternals:[`estree-walker`,/^@useavalon\//,/^estree-util/]};n.renderer===!1?i.renderer=!1:r.renderer&&(i.renderer=r.renderer),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,t.integrations,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 R(e,s,t,a))return;let o=await z(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,n){let r=performance.now(),i=[{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},...t.map(e=>({path:x(e,`server/renderer.ts`),assignTo:null}))],a=(await Promise.allSettled(i.map(async({path:t,assignTo:n})=>{let r=await e.ssrLoadModule(t);n===`ssr`&&(I=r),n===`layout`&&(L=r)}))).filter(e=>e.status===`fulfilled`).length,o=performance.now()-r;n&&a>0&&console.log(`🔥 SSR ready in ${o.toFixed(0)}ms (${a}/${i.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.PAGE_LOADER?RESOLVED_VIRTUAL_IDS.PAGE_LOADER: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.PAGE_LOADER?await M(t,r):e===RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST?N():e===RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG?P(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/`))&&(I=null,L=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
|
-
`}}async function M(e,t){try{let{getAllPageDirs:t}=await import(`./module-discovery.js`),{discoverPageRoutesFromMultipleDirs:n
|
|
3
|
+
`}}async function M(e,t){try{let{getAllPageDirs:t}=await import(`./module-discovery.js`),{discoverPageRoutesFromMultipleDirs:n}=await import(`../nitro/route-discovery.js`),{relative:r}=await import(`node:path`),i=process.cwd(),a=await n(await t(e.pagesDir,e.modules,i),{developmentMode:e.isDev}),o=[],s=[];for(let e=0;e<a.length;e++){let t=a[e],n=`page_${e}`,c=r(i,t.filePath).replaceAll(`\\`,`/`),l=c.startsWith(`/`)?c:`/`+c;o.push(`import * as ${n} from '${l}';`),s.push(` { pattern: ${JSON.stringify(t.pattern)}, params: ${JSON.stringify(t.params)}, module: ${n} }`)}return[...o,``,`const routes = [`,s.join(`,
|
|
4
4
|
`),`];`,``,`/**`,` * Match a pathname against discovered routes and return the page module.`,` * Uses the same pattern matching as Avalon's route discovery.`,` */`,`export function loadPage(pathname) {`,` const cleanPath = pathname.split('?')[0];`,` for (const route of routes) {`,` if (matchRoute(cleanPath, route.pattern, route.params)) {`,` return route.module;`,` }`,` }`,` return null;`,`}`,``,`function matchRoute(pathname, pattern, paramNames) {`,` // Exact match`,` if (pattern === pathname) return true;`,` // Normalize trailing slashes`,` const normPath = pathname === '/' ? '/' : pathname.replace(/\\/$/, '');`,` const normPattern = pattern === '/' ? '/' : pattern.replace(/\\/$/, '');`,` if (normPath === normPattern) return true;`,` // Dynamic segments: /users/:id matches /users/123`,` if (paramNames.length > 0) {`,` const patternParts = normPattern.split('/');`,` const pathParts = normPath.split('/');`,` if (patternParts.length !== pathParts.length) return false;`,` return patternParts.every((part, i) => part.startsWith(':') || part === pathParts[i]);`,` }`,` return false;`,`}`,``,`export default { loadPage, routes };`,``].join(`
|
|
5
5
|
`)}catch(e){return console.error(`[page-loader] Failed to generate page loader:`,e),`export function loadPage() { return null; }
|
|
6
6
|
export default { loadPage, routes: [] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{dirname as t,join as n}from"node:path";import{resolveConfig as r,checkDirectoriesExist as i}from"./config.js";import{activateIntegrations as a,activateSingleIntegration as o}from"./integration-activator.js";import{discoverIntegrationsFromIslandUsage as s}from"./auto-discover.js";import{validateActiveIntegrations as c,formatValidationResults as l}from"./validation.js";import{createMDXPlugin as u}from"../build/mdx-plugin.js";import{mdxIslandTransform as d}from"../build/mdx-island-transform.js";import{pageIslandTransform as f}from"../build/page-island-transform.js";import{registry as p}from"../core/integrations/registry.js";import{createNitroIntegration as m}from"./nitro-integration.js";import{islandSidecarPlugin as h}from"./island-sidecar-plugin.js";import{createImagePlugin as g}from"./image-optimization.js";export async function collectIntegrationPlugins(e,t=!1){let n=[],r=[];for(let i of e){let e=await
|
|
1
|
+
import{createRequire as e}from"node:module";import{dirname as t,join as n}from"node:path";import{resolveConfig as r,checkDirectoriesExist as i}from"./config.js";import{activateIntegrations as a,activateSingleIntegration as o}from"./integration-activator.js";import{discoverIntegrationsFromIslandUsage as s}from"./auto-discover.js";import{validateActiveIntegrations as c,formatValidationResults as l}from"./validation.js";import{createMDXPlugin as u}from"../build/mdx-plugin.js";import{mdxIslandTransform as d}from"../build/mdx-island-transform.js";import{pageIslandTransform as f}from"../build/page-island-transform.js";import{registry as p}from"../core/integrations/registry.js";import{createNitroIntegration as m}from"./nitro-integration.js";import{islandSidecarPlugin as h}from"./island-sidecar-plugin.js";import{createImagePlugin as g}from"./image-optimization.js";import{islandClientBundlerPlugin as _}from"../build/island-client-bundler.js";export async function collectIntegrationPlugins(e,t=!1){let n=[],r=[];for(let i of e){let e=await v(i,t);i===`lit`?r.push(...e):n.push(...e)}return[...r,...n]}async function v(e,t){let n=p.get(e);if(!n||typeof n.vitePlugin!=`function`)return[];try{let e=await n.vitePlugin();return(Array.isArray(e)?e:[e]).filter(e=>e!=null)}catch(t){return console.warn(`[avalon] Failed to load vite plugin for ${e}:`,t instanceof Error?t.message:t),[]}}async function y(e,t){let n=new Set;try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)e.integrations.includes(t)&&n.add(t)}catch{for(let t of e.integrations)n.add(t)}return n}async function b(e){if(!e.lazyIntegrations||e.integrations.length===0)return[...e.integrations];let t=await y(e);return t.size===0?[...e.integrations]:Array.from(t)}async function x(e){try{let t=await u({jsxImportSource:e.mdx.jsxImportSource,syntaxHighlighting:e.mdx.syntaxHighlighting,remarkPlugins:e.mdx.remarkPlugins,rehypePlugins:e.mdx.rehypePlugins,development:!0});return t.push(d({verbose:e.verbose})),t}catch(t){return e.showWarnings&&console.warn(`⚠️ Could not configure MDX plugin:`,t),[]}}function S(e,t,n){let{plugins:r,nitroOptions:i}=m(e,t);return globalThis.__nitroConfig=i,{plugins:r,options:i}}async function C(e,t,n){if(e.autoDiscoverIntegrations)try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)if(!n.has(t))try{await o(t,n,e.verbose)}catch(n){e.showWarnings&&console.warn(` ⚠️ Could not auto-load integration: ${t}`,n)}}catch(t){e.showWarnings&&console.warn(` ⚠️ Auto-discovery failed:`,t)}}function w(e,t){if(!e.validateIntegrations||t.size===0)return;let n=c(t,e.showWarnings);n.allValid||(console.error(l(n)),e.showWarnings&&console.warn(` ⚠️ Some integrations have validation issues.`))}export async function avalon(o){let s,c,l=new Set,u=r(o,!0),d=await b(u);d.length>0&&await a({...u,integrations:d},l);let p=await x(u),m=await g(u.image,u.verbose),v=[];l.size>0&&(v=await collectIntegrationPlugins(l,u.verbose));let y=[];if(o?.nitro){let{plugins:e}=S(u,o.nitro,u.verbose);y=e}let T=h({verbose:u.verbose}),E=e(import.meta.url),D=null;try{D=n(t(E.resolve(`@useavalon/avalon/client`)),`main.js`)}catch{}let O=new Set([`preact`,`react`,`vue`,`svelte`,`solid`,`lit`,`qwik`].flatMap(e=>[`/@useavalon/${e}/client`,`/@useavalon/${e}/client/hmr`,`@useavalon/${e}/client`,`@useavalon/${e}/client/hmr`])),k={name:`avalon`,enforce:`pre`,config(){let e={preact:[`preact`,`preact/hooks`],react:[`react`,`react-dom`,`react-dom/client`],vue:[`vue`],svelte:[`svelte`,`svelte/internal`],solid:[`solid-js`,`solid-js/web`],lit:[`lit`,`@lit-labs/ssr-client`],qwik:[`@builder.io/qwik`]},t=d.flatMap(t=>e[t]??[]);return{oxc:{exclude:[/node_modules\/@useavalon\/.*\.tsx?$/]},ssr:{noExternal:[/^@useavalon\//]},optimizeDeps:{exclude:[`@useavalon/avalon`,...d.map(e=>`@useavalon/${e}`)],include:t}}},configResolved(e){c=e,s=r(o,e.command===`serve`),globalThis.__avalonConfig=s,i(s,e.root)},async resolveId(e){if(e===`/src/client/main.js`&&D)return D;if(O.has(e)){let t=e.startsWith(`/`)?e.slice(1):e;return(await this.resolve(t))?.id??null}return null},async transform(e,t){if(t.includes(`@useavalon/`)&&/\.tsx?$/.test(t)){let{transform:n}=await import(`oxc-transform`),r=await n(t,e,{sourcemap:!0,typescript:{onlyRemoveTypeImports:!1}});return{code:r.code,map:r.map,moduleType:`js`}}},async buildStart(){await C(s,c?.root,l),w(s,l)},configureServer(e){globalThis.__viteDevServer=e}},A=v.filter(e=>e.name?.includes(`lit`)),j=v.filter(e=>!e.name?.includes(`lit`));return[f({pagesDir:u.pagesDir,layoutsDir:u.layoutsDir,modules:u.modules,verbose:u.verbose}),_(u),...m,...A,...p,k,T,...y,...j]}export function getResolvedConfig(){return globalThis.__avalonConfig}export function getPagesDir(){return globalThis.__avalonConfig?.pagesDir??`src/pages`}export function getLayoutsDir(){return globalThis.__avalonConfig?.layoutsDir??`src/layouts`}export function getNitroConfig(){return globalThis.__nitroConfig}export function isNitroEnabled(){return globalThis.__nitroConfig!==void 0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useavalon/avalon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.43",
|
|
4
4
|
"description": "Multi-framework islands architecture for the modern web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
"types": "./dist/src/islands/framework-detection.d.ts",
|
|
57
57
|
"default": "./dist/src/islands/framework-detection.js"
|
|
58
58
|
},
|
|
59
|
+
"./islands/integration-registry": {
|
|
60
|
+
"types": "./dist/src/core/integrations/registry.d.ts",
|
|
61
|
+
"default": "./dist/src/core/integrations/registry.js"
|
|
62
|
+
},
|
|
59
63
|
"./middleware": {
|
|
60
64
|
"types": "./dist/src/middleware/index.d.ts",
|
|
61
65
|
"default": "./dist/src/middleware/index.js"
|
|
@@ -112,7 +116,7 @@
|
|
|
112
116
|
}
|
|
113
117
|
},
|
|
114
118
|
"dependencies": {
|
|
115
|
-
"@useavalon/core": "
|
|
119
|
+
"@useavalon/core": "workspace:^",
|
|
116
120
|
"@mdx-js/rollup": "^3.0.0",
|
|
117
121
|
"h3": "^2.0.1-rc.16",
|
|
118
122
|
"marked": "^17.0.4",
|