@useavalon/avalon 0.1.46 → 0.1.47

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/README.md CHANGED
@@ -1,54 +1,54 @@
1
- # @useavalon/avalon
2
-
3
- Core framework package for [Avalon](https://useavalon.dev) — a multi-framework islands architecture for the modern web.
4
-
5
- ## Features
6
-
7
- - Islands architecture with zero JavaScript by default
8
- - Multi-framework support (React, Preact, Vue, Svelte, Solid, Lit, Qwik)
9
- - Selective hydration (`on:client`, `on:visible`, `on:idle`, `on:interaction`)
10
- - File-system routing with nested layouts
11
- - API routes and middleware
12
- - MDX support with rehype/remark plugins
13
- - SSR with streaming support
14
- - Edge deployment via Nitro (Node, Deno, Bun, Cloudflare, Vercel, etc.)
15
- - Vite 8 powered with HMR
16
-
17
- ## Quick start
18
-
19
- ```bash
20
- npm create avalon@latest
21
- # or
22
- bun create avalon
23
- ```
24
-
25
- Or install manually:
26
-
27
- ```bash
28
- bun add @useavalon/avalon
29
- ```
30
-
31
- ## Usage
32
-
33
- ```tsx
34
- // pages/index.tsx
35
- import Counter from '../components/Counter.tsx';
36
-
37
- export default function Home() {
38
- return (
39
- <div>
40
- <h1>Hello Avalon</h1>
41
- <Counter island={{ condition: 'on:visible' }} />
42
- </div>
43
- );
44
- }
45
- ```
46
-
47
- ## Links
48
-
49
- - [Documentation](https://useavalon.dev/docs/introduction)
50
- - [GitHub](https://github.com/useAvalon/Avalon)
51
-
52
- ## License
53
-
54
- MIT
1
+ # @useavalon/avalon
2
+
3
+ Core framework package for [Avalon](https://useavalon.dev) — a multi-framework islands architecture for the modern web.
4
+
5
+ ## Features
6
+
7
+ - Islands architecture with zero JavaScript by default
8
+ - Multi-framework support (React, Preact, Vue, Svelte, Solid, Lit, Qwik)
9
+ - Selective hydration (`on:client`, `on:visible`, `on:idle`, `on:interaction`)
10
+ - File-system routing with nested layouts
11
+ - API routes and middleware
12
+ - MDX support with rehype/remark plugins
13
+ - SSR with streaming support
14
+ - Edge deployment via Nitro (Node, Deno, Bun, Cloudflare, Vercel, etc.)
15
+ - Vite 8 powered with HMR
16
+
17
+ ## Quick start
18
+
19
+ ```bash
20
+ npm create avalon@latest
21
+ # or
22
+ bun create avalon
23
+ ```
24
+
25
+ Or install manually:
26
+
27
+ ```bash
28
+ bun add @useavalon/avalon
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```tsx
34
+ // pages/index.tsx
35
+ import Counter from '../components/Counter.tsx';
36
+
37
+ export default function Home() {
38
+ return (
39
+ <div>
40
+ <h1>Hello Avalon</h1>
41
+ <Counter island={{ condition: 'on:visible' }} />
42
+ </div>
43
+ );
44
+ }
45
+ ```
46
+
47
+ ## Links
48
+
49
+ - [Documentation](https://useavalon.dev/docs/introduction)
50
+ - [GitHub](https://github.com/useAvalon/Avalon)
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class LitHMRAdapter extends e{name=`lit`;elementConstructors=new WeakMap;tagNames=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e;if(t.__litElement)return!0;try{let t=e.prototype;if(t){if(`render`in t&&`requestUpdate`in t&&`updateComplete`in t)return!0;let e=t;for(;e&&e!==Object.prototype;){let t=e.constructor;if(t&&t.name===`LitElement`)return!0;e=Object.getPrototypeOf(e)}}}catch{}if(t.elementName||t.tagName)return!0;try{let t=e.toString();if(t.includes(`LitElement`)||t.includes(`customElement`)||t.includes("html`")||t.includes("css`")||t.includes(`render()`)||t.includes(`requestUpdate`))return!0}catch{}}if(typeof e!=`object`)return!1;let t=e;return t.default&&typeof t.default==`function`?this.canHandle(t.default):!!t.__litElement}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=e.getAttribute(`data-tag-name`)||this.tagNames.get(e),s=o?e.querySelector(o):e.querySelector(`[data-lit-element]`),c={},l={};if(s){for(let e in s)if(s.hasOwnProperty(e)&&!e.startsWith(`_`))try{let t=s[e];t!=null&&typeof t!=`function`&&typeof t!=`symbol`&&(c[e]=t)}catch{}for(let e=0;e<s.attributes.length;e++){let t=s.attributes[e];l[t.name]=t.value}}return{...t,framework:`lit`,data:{componentName:a,tagName:o||void 0,capturedProps:r,elementProperties:c,elementAttributes:l}}}catch(e){return console.warn(`Failed to preserve Lit state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Lit component`);let r;if(typeof t==`object`&&t){let e=t;if(e.default&&typeof e.default==`function`)r=e.default;else throw Error(`Lit component object must have a default export`)}else if(typeof t==`function`)r=t;else throw Error(`Invalid Lit component type`);try{let t=e.getAttribute(`data-tag-name`);if(t||=r.elementName,t||=r.name.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),!t||!t.includes(`-`))throw Error(`Invalid custom element tag name: `+t);this.tagNames.set(e,t),e.setAttribute(`data-tag-name`,t);let i=Array.from(e.querySelectorAll(t));if(i.length===0){let i=customElements.get(t);i?i!==r&&await this.reregisterCustomElement(t,r):customElements.define(t,r);let a=document.createElement(t);Object.entries(n).forEach(([e,t])=>{try{a[e]=t}catch(t){console.warn(`Failed to set property ${e} on Lit element:`,t)}}),e.appendChild(a),this.elementConstructors.set(e,r),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`);return}let a=customElements.get(t);if(a&&a!==r){await this.reregisterCustomElement(t,r);for(let e of i){let n={},r={};for(let t in e)if(e.hasOwnProperty(t)&&!t.startsWith(`_`))try{let r=e[t];r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&(n[t]=r)}catch{}for(let t=0;t<e.attributes.length;t++){let n=e.attributes[t];r[n.name]=n.value}let i=document.createElement(t);Object.entries(r).forEach(([e,t])=>{i.setAttribute(e,t)}),Object.entries(n).forEach(([e,t])=>{try{i[e]=t}catch(t){console.warn(`Failed to restore property ${e}:`,t)}}),e.parentNode?.replaceChild(i,e)}}else if(a)for(let e of i)Object.entries(n).forEach(([t,n])=>{try{e[t]=n}catch(e){console.warn(`Failed to update property ${t}:`,e)}}),e.requestUpdate&&e.requestUpdate();else{customElements.define(t,r);for(let e of i)e.requestUpdate&&e.requestUpdate()}this.elementConstructors.set(e,r),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Lit HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}async reregisterCustomElement(e,t){console.warn(`Custom element ${e} is already defined. Replacing all instances with new definition.`)}restoreState(e,t){try{super.restoreState(e,t);let n=t,r=n.data.tagName;if(r){let t=e.querySelector(r);t&&(n.data.elementProperties&&Object.entries(n.data.elementProperties).forEach(([e,n])=>{try{t[e]=n}catch(t){console.warn(`Failed to restore property ${e}:`,t)}}),n.data.elementAttributes&&Object.entries(n.data.elementAttributes).forEach(([e,n])=>{try{t.setAttribute(e,n)}catch(t){console.warn(`Failed to restore attribute ${e}:`,t)}}),t.requestUpdate&&t.requestUpdate())}}catch(e){console.warn(`Failed to restore Lit state:`,e)}}handleError(e,t){console.error(`Lit HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`custom element`)||e.includes(`define`)?r=` (Hint: Check that your element has a valid tag name with a hyphen)`:e.includes(`tag name`)?r=` (Hint: Custom element tag names must contain a hyphen)`:e.includes(`property`)||e.includes(`attribute`)?r=` (Hint: Check @property decorators and attribute names)`:e.includes(`render`)?r=` (Hint: Check the render() method for errors)`:e.includes(`shadow`)&&(r=` (Hint: Check Shadow DOM usage and styles)`),n.textContent=`Lit HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.lit\.(ts|js)$/,``).replace(/\.(ts|js)$/,``)}unmount(e){try{let t=this.tagNames.get(e);t&&(e.querySelectorAll(t).forEach(e=>{e.remove()}),this.tagNames.delete(e)),this.elementConstructors.delete(e)}catch(e){console.warn(`Failed to unmount Lit element:`,e)}}}export const litAdapter=new LitHMRAdapter;
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class PreactHMRAdapter extends e{name=`preact`;instances=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e,n=e.prototype;return n&&n.isReactComponent||t.$typeof,!0}if(typeof e!=`object`)return!1;let t=e;return!!(t.$typeof||t.type&&typeof t.type==`function`)}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i);return{...t,framework:`preact`,data:{componentName:a,capturedProps:r}}}catch(e){return console.warn(`Failed to preserve Preact state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Preact component`);let r=t;try{let{h:t,hydrate:i}=await import(`preact`);this.instances.get(e)?i(t(r,n),e):(i(t(r,n),e),this.instances.set(e,r)),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Preact HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Preact state:`,e)}}handleError(e,t){console.error(`Preact HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`hooks`)?r=` (Hint: Check hooks usage - hooks must be called in the same order)`:e.includes(`render`)?r=` (Hint: Check component render method for errors)`:(e.includes(`hydration`)||e.includes(`hydrate`))&&(r=` (Hint: Server and client render must match)`),n.textContent=`Preact HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(tsx?|jsx?)$/,``)}unmount(e){if(this.instances.get(e))try{this.instances.delete(e),e.innerHTML=``}catch(e){console.warn(`Failed to unmount Preact component:`,e)}}}export const preactAdapter=new PreactHMRAdapter;
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class QwikHMRAdapter extends e{name=`qwik`;containers=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e;if(t.__brand===`QwikComponent`||t.__qrl||t.getSymbol||t.getHash)return!0;try{let t=e.toString();if(t.includes(`component$`)||t.includes(`qrl`)||t.includes(`useSignal`)||t.includes(`useStore`)||t.includes(`useTask$`)||t.includes(`useVisibleTask$`)||t.includes(`_qrl`)||t.includes(`qwik`))return!0}catch{}}if(typeof e==`object`&&e){let t=e;if(t.default&&typeof t.default==`function`)return this.canHandle(t.default);if(t.__qrl||t.__brand===`QwikComponent`)return!0}return!1}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=e.closest(`[q\\:container]`)||e,s=o.querySelector(`script[type="qwik/json"]`)?.textContent||null,c={},l=o.attributes;if(l)for(let e=0;e<l.length;e++){let t=l[e];t.name.startsWith(`q:`)&&(c[t.name]=t.value)}return{...t,framework:`qwik`,data:{componentName:a,capturedProps:r,containerState:s,qContainerAttrs:c}}}catch(e){return console.warn(`Failed to preserve Qwik state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Qwik component`);let r;if(typeof t==`object`&&t){let e=t;if(e.default&&typeof e.default==`function`)r=e.default;else throw Error(`Qwik component object must have a default export`)}else if(typeof t==`function`)r=t;else throw Error(`Invalid Qwik component type`);try{let t=this.containers.get(e);if(t?.cleanup)try{t.cleanup()}catch(e){console.warn(`Failed to clean up existing Qwik container:`,e)}let i=await import(`@builder.io/qwik`);if(i.render){let t=typeof i.jsx==`function`?i.jsx(r,n):r(n);await i.render(e,t)}else{console.warn(`Qwik render API not available, using innerHTML fallback`);let t=r(n);typeof t==`string`&&(e.innerHTML=t)}this.containers.set(e,{}),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Qwik HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Qwik state:`,e)}}handleError(e,t){console.error(`Qwik HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`component$`)||e.includes(`component\\$`)?r=` (Hint: Ensure component is wrapped with component$())`:e.includes(`useSignal`)||e.includes(`useStore`)?r=` (Hint: Qwik hooks must be called inside component$() body)`:e.includes(`QRL`)||e.includes(`qrl`)?r=` (Hint: Check that lazy-loaded boundaries use $ correctly)`:e.includes(`serialize`)||e.includes(`container`)?r=` (Hint: Ensure all state is serializable — Qwik serializes state to the DOM)`:(e.includes(`resumable`)||e.includes(`resume`))&&(r=` (Hint: Server and client container state must match for resumability)`),n.textContent=`Qwik HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.qwik\.(tsx?|jsx?)$/,``).replace(/\.(tsx?|jsx?)$/,``)}unmount(e){let t=this.containers.get(e);if(t)try{t.cleanup&&t.cleanup(),this.containers.delete(e)}catch(e){console.warn(`Failed to unmount Qwik component:`,e)}}}export const qwikAdapter=new QwikHMRAdapter;
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class ReactHMRAdapter extends e{name=`react`;roots=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e,n=e.prototype;return n&&n.isReactComponent||t.$$typeof,!0}if(typeof e!=`object`)return!1;let t=e;return!!(t.$$typeof||t.type&&typeof t.type==`function`)}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i);return{...t,framework:`react`,data:{componentName:a,capturedProps:r}}}catch(e){return console.warn(`Failed to preserve React state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid React component`);let r=t;try{let[t,i]=await Promise.all([import(`react`),import(`react-dom/client`)]),{createElement:a}=t,{hydrateRoot:o}=i,s=this.roots.get(e);if(s){let e=a(r,n);s.render(e)}else{let t=o(e,a(r,n),{onRecoverableError:e=>{console.warn(`React hydration recoverable error during HMR:`,e)}});this.roots.set(e,t)}e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`React HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore React state:`,e)}}handleError(e,t){console.error(`React HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`hooks`)?r=` (Hint: Check hooks usage - hooks must be called in the same order)`:e.includes(`render`)?r=` (Hint: Check component render method for errors)`:e.includes(`hydration`)&&(r=` (Hint: Server and client render must match)`),n.textContent=`React HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(tsx?|jsx?)$/,``)}unmount(e){let t=this.roots.get(e);if(t)try{t.unmount(),this.roots.delete(e)}catch(e){console.warn(`Failed to unmount React root:`,e)}}}export const reactAdapter=new ReactHMRAdapter;
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class SolidHMRAdapter extends e{name=`solid`;disposers=new WeakMap;componentIds=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){if(e.__solid)return!0;try{let t=e.toString();if(t.includes(`createSignal`)||t.includes(`createEffect`)||t.includes(`createMemo`)||t.includes(`createResource`)||t.includes(`createStore`)||t.includes(`_$`)||t.includes(`_tmpl$`))return!0}catch{}return!0}if(typeof e!=`object`)return!1;let t=e;return t.default&&typeof t.default==`function`?this.canHandle(t.default):!!t.__solid}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=e.dataset.solidRenderId||e.dataset.renderId;return{...t,framework:`solid`,data:{componentName:a,capturedProps:r,renderId:o}}}catch(e){return console.warn(`Failed to preserve Solid state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Solid component`);let r;if(typeof t==`object`&&t){let e=t;if(e.default&&typeof e.default==`function`)r=e.default;else throw Error(`Solid component object must have a default export`)}else if(typeof t==`function`)r=t;else throw Error(`Invalid Solid component type`);try{let t=this.disposers.get(e),i=this.componentIds.get(e),a=globalThis.__SOLID_HMR__;if(a&&i)try{if(a.reload(i,r),t)return}catch(e){console.warn(`Solid HMR runtime reload failed, falling back to full remount:`,e)}if(t)try{t(),this.disposers.delete(e)}catch(e){console.warn(`Failed to dispose existing Solid component:`,e)}let{hydrate:o,createComponent:s}=await import(`solid-js/web`),c=o(()=>s(r,n),e,{renderId:e.dataset.solidRenderId||e.dataset.renderId});this.disposers.set(e,c);let l=e.getAttribute(`data-src`)||``,u=this.generateComponentId(l);if(this.componentIds.set(e,u),a)try{a.createRecord(u,r)}catch(e){console.warn(`Failed to register with Solid HMR runtime:`,e)}e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Solid HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Solid state:`,e)}}handleError(e,t){console.error(`Solid HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`signal`)||e.includes(`Signal`)?r=` (Hint: Check signal usage - signals must be called as functions)`:e.includes(`effect`)||e.includes(`Effect`)?r=` (Hint: Check effect usage - effects run after render)`:e.includes(`hydration`)||e.includes(`hydrate`)?r=` (Hint: Server and client render must match)`:e.includes(`createSignal`)||e.includes(`createEffect`)?r=` (Hint: Solid primitives must be called inside component functions)`:e.includes(`reactive`)&&(r=` (Hint: Check reactive dependencies - they must be accessed inside tracking scopes)`),n.textContent=`Solid HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.solid\.(tsx?|jsx?)$/,``).replace(/\.(tsx?|jsx?)$/,``)}generateComponentId(e){return e.replace(/[^a-zA-Z0-9]/g,`_`)}unmount(e){let t=this.disposers.get(e);if(t)try{t(),this.disposers.delete(e),this.componentIds.delete(e)}catch(e){console.warn(`Failed to unmount Solid component:`,e)}}}export const solidAdapter=new SolidHMRAdapter;
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class SvelteHMRAdapter extends e{name=`svelte`;instances=new WeakMap;componentIds=new WeakMap;storeSubscriptions=new WeakMap;isSvelteFunction(e){if(e.$$render)return!0;let t=e.prototype;if(t&&(t.$set&&t.$destroy||t.$$))return!0;try{let t=e.toString();if(t.includes(`$set`)||t.includes(`$destroy`)||t.includes(`$$`))return!0}catch{}return!1}canHandle(e){if(!e)return!1;if(typeof e==`function`)return this.isSvelteFunction(e);if(typeof e!=`object`)return!1;let t=e;return t.default&&typeof t.default==`function`?this.canHandle(t.default):t.$$render!==void 0}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.dataset.props,r=n?JSON.parse(n):{},i=e.dataset.src||``,a=this.extractComponentName(i),o=this.captureLocalState(e),s=this.captureStoreValues(e);return{...t,framework:`svelte`,data:{componentName:a,capturedProps:r,localState:o,storeValues:s}}}catch(e){return console.warn(`Failed to preserve Svelte state:`,e),null}}extractComponent(e){if(typeof e==`object`&&e){let t=e;if(t.default&&typeof t.default==`function`)return t.default;throw Error(`Svelte component object must have a default export`)}if(typeof e==`function`)return e;throw TypeError(`Invalid Svelte component type`)}async cleanupInstance(e,t){try{let n=this.storeSubscriptions.get(e);n&&(n.forEach(e=>e()),this.storeSubscriptions.delete(e));let r=(await import(`svelte`)).unmount;r?r(t):t.$destroy&&t.$destroy()}catch{t.$destroy&&t.$destroy()}}async mountComponent(e,t,n){try{let r=(await import(`svelte`)).mount;return r?r(e,{target:t,props:n}):new e({target:t,props:n,hydrate:!1,intro:!1})}catch(r){return console.debug(`Svelte 5 API not available, using constructor API:`,r),new e({target:t,props:n,hydrate:!1,intro:!1})}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Svelte component`);let r=this.extractComponent(t);try{let t=this.instances.get(e);t&&await this.cleanupInstance(e,t).catch(e=>{console.warn(`Failed to destroy existing Svelte instance:`,e)}),e.innerHTML=``;let i=await this.mountComponent(r,e,n);this.instances.set(e,i);let a=e.dataset.src||``;this.componentIds.set(e,this.generateComponentId(a)),e.dataset.hydrated=`true`,e.dataset.hydrationStatus=`success`}catch(t){throw console.error(`Svelte HMR update failed:`,t),e.dataset.hydrationStatus=`error`,t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Svelte state:`,e)}}handleError(e,t){console.error(`Svelte HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`$:`)||e.includes(`reactive`)?r=` (Hint: Check reactive statements ($:) - they must be at component top level)`:e.includes(`store`)?r=` (Hint: Check store usage - stores must be imported and subscribed correctly)`:e.includes(`hydration`)||e.includes(`hydrate`)?r=` (Hint: Server and client render must match)`:e.includes(`target`)?r=` (Hint: Check component target - it must be a valid DOM element)`:e.includes(`props`)&&(r=` (Hint: Check component props - they must match the component definition)`),n.textContent=`Svelte HMR Error: ${e}${r}`}}extractComponentName(e){return(e.split(`/`).at(-1)??``).replace(/\.svelte$/,``)}detectSSRContent(e){let t=e.textContent&&e.textContent.trim().length>0,n=e.children&&e.children.length>0,r=e.dataset.ssrContent!==void 0||e.dataset.svelteRendered!==void 0;return t||n||r}generateComponentId(e){return e.replaceAll(/[^a-zA-Z0-9]/g,`_`)}captureLocalState(e){try{let t=this.instances.get(e);if(!t)return;let n=t.$$;return n?.ctx?{ctx:n.ctx,props:n.props,bound:n.bound}:void 0}catch(e){console.debug(`Could not capture Svelte local state:`,e);return}}captureStoreValues(e){}async unmount(e){let t=this.instances.get(e);if(t)try{await this.cleanupInstance(e,t),this.instances.delete(e),this.componentIds.delete(e)}catch(e){console.warn(`Failed to unmount Svelte component:`,e)}}}export const svelteAdapter=new SvelteHMRAdapter;
@@ -0,0 +1 @@
1
+ import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class VueHMRAdapter extends e{name=`vue`;apps=new WeakMap;componentIds=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`)return!0;if(typeof e!=`object`)return!1;let t=e;return`setup`in t||`data`in t||`render`in t||`template`in t||`props`in t||`computed`in t||`methods`in t||`components`in t||`emits`in t||`mounted`in t||`created`in t||`beforeMount`in t||`beforeCreate`in t||`__vccOpts`in t}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=this.captureReactiveData(e);return{...t,framework:`vue`,data:{componentName:a,capturedProps:r,reactiveData:o}}}catch(e){return console.warn(`Failed to preserve Vue state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Vue component`);let r=t;try{let{createApp:t}=await import(`vue`),i=this.apps.get(e),a=this.componentIds.get(e),o=globalThis.__VUE_HMR_RUNTIME__;if(o&&a)try{if(o.reload(a,r),i)return}catch(e){console.warn(`Vue HMR runtime reload failed, falling back to full remount:`,e)}if(i)try{i.unmount()}catch(e){console.warn(`Failed to unmount existing Vue app:`,e)}let s=t(r,n);s.config.errorHandler=(e,t,n)=>{console.error(`Vue component error during HMR:`,e,n)},s.mount(e,!0),this.apps.set(e,s);let c=e.getAttribute(`data-src`)||``,l=this.generateComponentId(c);this.componentIds.set(e,l),o&&o.createRecord(l,r),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Vue HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Vue state:`,e)}}handleError(e,t){console.error(`Vue HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`reactive`)||e.includes(`ref`)?r=` (Hint: Check reactive state usage - refs must be accessed with .value)`:e.includes(`render`)?r=` (Hint: Check component render function or template for errors)`:e.includes(`hydration`)||e.includes(`mismatch`)?r=` (Hint: Server and client render must match)`:e.includes(`setup`)&&(r=` (Hint: Check setup function - it should return render function or object)`),n.textContent=`Vue HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(vue|tsx?|jsx?)$/,``)}generateComponentId(e){return e.replace(/[^a-zA-Z0-9]/g,`_`)}captureReactiveData(e){try{let t=e.__vueParentComponent;if(t&&typeof t==`object`){let e=t.data;if(e&&typeof e==`object`)return{...e}}}catch(e){console.debug(`Could not capture Vue reactive data:`,e)}}unmount(e){let t=this.apps.get(e);if(t)try{t.unmount(),this.apps.delete(e),this.componentIds.delete(e)}catch(e){console.warn(`Failed to unmount Vue app:`,e)}}}export const vueAdapter=new VueHMRAdapter;
@@ -1 +1 @@
1
- export{PersistentIsland}from"../components/PersistentIsland.js";export{usePersistentIslandContext,PersistentIslandProvider,createPersistentIslandContext}from"../core/islands/persistent-island-context.js";export{usePersistentState}from"../core/islands/use-persistent-state.js";export{IslandPersistence,defaultIslandPersistence}from"../core/islands/island-persistence.js";export{IslandStateSerializer}from"../core/islands/island-state-serializer.js";export{IslandErrorBoundary,withIslandErrorBoundary}from"../components/IslandErrorBoundary.js";export{LayoutErrorBoundary}from"../components/LayoutErrorBoundary.js";export{LayoutDataErrorBoundary}from"../components/LayoutDataErrorBoundary.js";export{StreamingErrorBoundary,withStreamingErrorBoundary}from"../components/StreamingErrorBoundary.js";export{StreamingLayout,StreamingSuspense,withStreaming,useStreamingState}from"../components/StreamingLayout.js";export{Image}from"../components/Image.js";
1
+ export{PersistentIsland}from"../components/PersistentIsland.tsx";export{usePersistentIslandContext,PersistentIslandProvider,createPersistentIslandContext}from"../core/islands/persistent-island-context.tsx";export{usePersistentState}from"../core/islands/use-persistent-state.js";export{IslandPersistence,defaultIslandPersistence}from"../core/islands/island-persistence.js";export{IslandStateSerializer}from"../core/islands/island-state-serializer.js";export{IslandErrorBoundary,withIslandErrorBoundary}from"../components/IslandErrorBoundary.tsx";export{LayoutErrorBoundary}from"../components/LayoutErrorBoundary.tsx";export{LayoutDataErrorBoundary}from"../components/LayoutDataErrorBoundary.tsx";export{StreamingErrorBoundary,withStreamingErrorBoundary}from"../components/StreamingErrorBoundary.tsx";export{StreamingLayout,StreamingSuspense,withStreaming,useStreamingState}from"../components/StreamingLayout.tsx";export{Image}from"../components/Image.tsx";
@@ -1,68 +1,68 @@
1
- /**
2
- * Type declarations for framework runtime imports
3
- *
4
- * These are dynamic imports that are resolved by Vite at runtime in the browser.
5
- * The actual packages are provided by the user's project dependencies.
6
- */
7
-
8
- declare module 'react' {
9
- export function createElement<P = Record<string, unknown>>(
10
- component: unknown,
11
- props: P | null,
12
- ...children: unknown[]
13
- ): unknown;
14
- export const version: string;
15
- }
16
-
17
- declare module 'react-dom/client' {
18
- export interface Root {
19
- render(element: unknown): void;
20
- unmount(): void;
21
- }
22
-
23
- export function hydrateRoot(
24
- container: HTMLElement,
25
- element: unknown,
26
- options?: {
27
- onRecoverableError?: (error: Error) => void;
28
- }
29
- ): Root;
30
-
31
- export function createRoot(container: HTMLElement): Root;
32
- }
33
-
34
- declare module 'vue' {
35
- export interface App {
36
- mount(rootContainer: HTMLElement | string, isHydrate?: boolean): unknown;
37
- unmount(): void;
38
- use(plugin: unknown, ...options: unknown[]): App;
39
- component(name: string, component: unknown): App;
40
- directive(name: string, directive: unknown): App;
41
- provide(key: string | symbol, value: unknown): App;
42
- config: {
43
- errorHandler?: (err: Error, instance: unknown, info: string) => void;
44
- warnHandler?: (msg: string, instance: unknown, trace: string) => void;
45
- };
46
- }
47
-
48
- export function createApp(rootComponent: unknown, rootProps?: Record<string, unknown>): App;
49
- export const version: string;
50
- }
51
-
52
-
53
- declare module 'svelte' {
54
- export interface SvelteComponent {
55
- new (options: {
56
- target: HTMLElement;
57
- props?: Record<string, unknown>;
58
- hydrate?: boolean;
59
- intro?: boolean;
60
- anchor?: Element | null;
61
- context?: Map<unknown, unknown>;
62
- }): {
63
- $set(props: Record<string, unknown>): void;
64
- $destroy(): void;
65
- $on?(event: string, handler: (...args: unknown[]) => void): () => void;
66
- };
67
- }
68
- }
1
+ /**
2
+ * Type declarations for framework runtime imports
3
+ *
4
+ * These are dynamic imports that are resolved by Vite at runtime in the browser.
5
+ * The actual packages are provided by the user's project dependencies.
6
+ */
7
+
8
+ declare module 'react' {
9
+ export function createElement<P = Record<string, unknown>>(
10
+ component: unknown,
11
+ props: P | null,
12
+ ...children: unknown[]
13
+ ): unknown;
14
+ export const version: string;
15
+ }
16
+
17
+ declare module 'react-dom/client' {
18
+ export interface Root {
19
+ render(element: unknown): void;
20
+ unmount(): void;
21
+ }
22
+
23
+ export function hydrateRoot(
24
+ container: HTMLElement,
25
+ element: unknown,
26
+ options?: {
27
+ onRecoverableError?: (error: Error) => void;
28
+ }
29
+ ): Root;
30
+
31
+ export function createRoot(container: HTMLElement): Root;
32
+ }
33
+
34
+ declare module 'vue' {
35
+ export interface App {
36
+ mount(rootContainer: HTMLElement | string, isHydrate?: boolean): unknown;
37
+ unmount(): void;
38
+ use(plugin: unknown, ...options: unknown[]): App;
39
+ component(name: string, component: unknown): App;
40
+ directive(name: string, directive: unknown): App;
41
+ provide(key: string | symbol, value: unknown): App;
42
+ config: {
43
+ errorHandler?: (err: Error, instance: unknown, info: string) => void;
44
+ warnHandler?: (msg: string, instance: unknown, trace: string) => void;
45
+ };
46
+ }
47
+
48
+ export function createApp(rootComponent: unknown, rootProps?: Record<string, unknown>): App;
49
+ export const version: string;
50
+ }
51
+
52
+
53
+ declare module 'svelte' {
54
+ export interface SvelteComponent {
55
+ new (options: {
56
+ target: HTMLElement;
57
+ props?: Record<string, unknown>;
58
+ hydrate?: boolean;
59
+ intro?: boolean;
60
+ anchor?: Element | null;
61
+ context?: Map<unknown, unknown>;
62
+ }): {
63
+ $set(props: Record<string, unknown>): void;
64
+ $destroy(): void;
65
+ $on?(event: string, handler: (...args: unknown[]) => void): () => void;
66
+ };
67
+ }
68
+ }
@@ -1,46 +1,46 @@
1
- /**
2
- * Type definitions for Vite HMR API
3
- */
4
-
5
- declare module 'vite/types/hmrPayload' {
6
- export interface HMRPayload {
7
- type: 'update' | 'full-reload' | 'prune' | 'error' | 'connected' | 'custom';
8
- updates?: Update[];
9
- timestamp?: number;
10
- path?: string;
11
- err?: Error;
12
- data?: unknown;
13
- event?: string;
14
- }
15
-
16
- export interface Update {
17
- type: 'js-update' | 'css-update';
18
- path: string;
19
- acceptedPath: string;
20
- timestamp: number;
21
- explicitImportRequired?: boolean;
22
- }
23
- }
24
-
25
- declare global {
26
- interface ImportMeta {
27
- hot?: {
28
- accept(): void;
29
- accept(cb: (mod: unknown) => void): void;
30
- accept(dep: string, cb: (mod: unknown) => void): void;
31
- accept(deps: readonly string[], cb: (mods: unknown[]) => void): void;
32
-
33
- dispose(cb: (data: unknown) => void): void;
34
- decline(): void;
35
- invalidate(): void;
36
-
37
- on(event: string, cb: (payload: unknown) => void): void;
38
- off(event: string, cb: (payload: unknown) => void): void;
39
- send(event: string, data?: unknown): void;
40
-
41
- data: unknown;
42
- };
43
- }
44
- }
45
-
46
- export {};
1
+ /**
2
+ * Type definitions for Vite HMR API
3
+ */
4
+
5
+ declare module 'vite/types/hmrPayload' {
6
+ export interface HMRPayload {
7
+ type: 'update' | 'full-reload' | 'prune' | 'error' | 'connected' | 'custom';
8
+ updates?: Update[];
9
+ timestamp?: number;
10
+ path?: string;
11
+ err?: Error;
12
+ data?: unknown;
13
+ event?: string;
14
+ }
15
+
16
+ export interface Update {
17
+ type: 'js-update' | 'css-update';
18
+ path: string;
19
+ acceptedPath: string;
20
+ timestamp: number;
21
+ explicitImportRequired?: boolean;
22
+ }
23
+ }
24
+
25
+ declare global {
26
+ interface ImportMeta {
27
+ hot?: {
28
+ accept(): void;
29
+ accept(cb: (mod: unknown) => void): void;
30
+ accept(dep: string, cb: (mod: unknown) => void): void;
31
+ accept(deps: readonly string[], cb: (mods: unknown[]) => void): void;
32
+
33
+ dispose(cb: (data: unknown) => void): void;
34
+ decline(): void;
35
+ invalidate(): void;
36
+
37
+ on(event: string, cb: (payload: unknown) => void): void;
38
+ off(event: string, cb: (payload: unknown) => void): void;
39
+ send(event: string, data?: unknown): void;
40
+
41
+ data: unknown;
42
+ };
43
+ }
44
+ }
45
+
46
+ export {};
@@ -1,70 +1,70 @@
1
- /**
2
- * Type declarations for Vite virtual modules
3
- *
4
- * These modules are resolved by Vite at runtime in the browser.
5
- * They don't exist as actual files but are provided by Vite's plugin system.
6
- */
7
-
8
- declare module '/@useavalon/preact/client' {
9
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
10
- export function getHydrationScript(): string;
11
- }
12
-
13
- declare module '/@useavalon/react/client' {
14
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
15
- export function getHydrationScript(): string;
16
- }
17
-
18
- declare module '/@useavalon/vue/client' {
19
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
20
- export function getHydrationScript(): string;
21
- }
22
-
23
- declare module '/@useavalon/svelte/client' {
24
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
25
- export function getHydrationScript(): string;
26
- }
27
-
28
- declare module '/@useavalon/solid/client' {
29
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
30
- export function getHydrationScript(): string;
31
- }
32
-
33
- declare module '/@useavalon/lit/client' {
34
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
35
- export function getHydrationScript(): string;
36
- }
37
-
38
- declare module '/@useavalon/qwik/client' {
39
- export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
40
- export function getHydrationScript(): string;
41
- }
42
-
43
- // HMR adapter virtual modules
44
- declare module '/@useavalon/react/client/hmr' {
45
- export { reactAdapter } from '@useavalon/react/client/hmr';
46
- }
47
-
48
- declare module '/@useavalon/preact/client/hmr' {
49
- export { preactAdapter } from '@useavalon/preact/client/hmr';
50
- }
51
-
52
- declare module '/@useavalon/vue/client/hmr' {
53
- export { vueAdapter } from '@useavalon/vue/client/hmr';
54
- }
55
-
56
- declare module '/@useavalon/svelte/client/hmr' {
57
- export { svelteAdapter } from '@useavalon/svelte/client/hmr';
58
- }
59
-
60
- declare module '/@useavalon/solid/client/hmr' {
61
- export { solidAdapter } from '@useavalon/solid/client/hmr';
62
- }
63
-
64
- declare module '/@useavalon/lit/client/hmr' {
65
- export { litAdapter } from '@useavalon/lit/client/hmr';
66
- }
67
-
68
- declare module '/@useavalon/qwik/client/hmr' {
69
- export { qwikAdapter } from '@useavalon/qwik/client/hmr';
70
- }
1
+ /**
2
+ * Type declarations for Vite virtual modules
3
+ *
4
+ * These modules are resolved by Vite at runtime in the browser.
5
+ * They don't exist as actual files but are provided by Vite's plugin system.
6
+ */
7
+
8
+ declare module '/@useavalon/preact/client' {
9
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
10
+ export function getHydrationScript(): string;
11
+ }
12
+
13
+ declare module '/@useavalon/react/client' {
14
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
15
+ export function getHydrationScript(): string;
16
+ }
17
+
18
+ declare module '/@useavalon/vue/client' {
19
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
20
+ export function getHydrationScript(): string;
21
+ }
22
+
23
+ declare module '/@useavalon/svelte/client' {
24
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
25
+ export function getHydrationScript(): string;
26
+ }
27
+
28
+ declare module '/@useavalon/solid/client' {
29
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
30
+ export function getHydrationScript(): string;
31
+ }
32
+
33
+ declare module '/@useavalon/lit/client' {
34
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
35
+ export function getHydrationScript(): string;
36
+ }
37
+
38
+ declare module '/@useavalon/qwik/client' {
39
+ export function hydrate(container: Element, component: unknown, props?: Record<string, unknown>): void;
40
+ export function getHydrationScript(): string;
41
+ }
42
+
43
+ // HMR adapter virtual modules
44
+ declare module '/@useavalon/react/client/hmr' {
45
+ export { reactAdapter } from '@useavalon/react/client/hmr';
46
+ }
47
+
48
+ declare module '/@useavalon/preact/client/hmr' {
49
+ export { preactAdapter } from '@useavalon/preact/client/hmr';
50
+ }
51
+
52
+ declare module '/@useavalon/vue/client/hmr' {
53
+ export { vueAdapter } from '@useavalon/vue/client/hmr';
54
+ }
55
+
56
+ declare module '/@useavalon/svelte/client/hmr' {
57
+ export { svelteAdapter } from '@useavalon/svelte/client/hmr';
58
+ }
59
+
60
+ declare module '/@useavalon/solid/client/hmr' {
61
+ export { solidAdapter } from '@useavalon/solid/client/hmr';
62
+ }
63
+
64
+ declare module '/@useavalon/lit/client/hmr' {
65
+ export { litAdapter } from '@useavalon/lit/client/hmr';
66
+ }
67
+
68
+ declare module '/@useavalon/qwik/client/hmr' {
69
+ export { qwikAdapter } from '@useavalon/qwik/client/hmr';
70
+ }
@@ -140,6 +140,43 @@ export interface AvalonNitroConfig {
140
140
  brotli?: boolean;
141
141
  zstd?: boolean;
142
142
  };
143
+ /**
144
+ * Prerender configuration for static site generation (SSG).
145
+ *
146
+ * Nitro will fetch each listed route at build time using the SSR handler
147
+ * and write the resulting HTML to the public output directory. These pages
148
+ * are then served as static files from the CDN — zero function invocations.
149
+ *
150
+ * Islands on prerendered pages still hydrate normally on the client.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * prerender: {
155
+ * routes: ['/', '/docs', '/blog'],
156
+ * crawlLinks: true,
157
+ * }
158
+ * ```
159
+ */
160
+ prerender?: {
161
+ /** Explicit routes to prerender at build time */
162
+ routes?: string[];
163
+ /** Crawl `<a>` links in prerendered pages to discover more routes */
164
+ crawlLinks?: boolean;
165
+ /** Number of concurrent prerender requests */
166
+ concurrency?: number;
167
+ /** Delay in ms between prerender requests */
168
+ interval?: number;
169
+ /** Fail the build if a prerender route errors */
170
+ failOnError?: boolean;
171
+ /** Routes to ignore (strings, RegExps, or filter functions) */
172
+ ignore?: Array<string | RegExp | ((path: string) => undefined | null | boolean)>;
173
+ /** Number of retry attempts per route @default 3 */
174
+ retry?: number;
175
+ /** Delay between retries in ms @default 500 */
176
+ retryDelay?: number;
177
+ /** Write `/about` as `/about/index.html` @default true */
178
+ autoSubfolderIndex?: boolean;
179
+ };
143
180
  }
144
181
  /**
145
182
  * Nitro configuration output structure
@@ -191,6 +228,8 @@ export interface NitroConfigOutput {
191
228
  }>;
192
229
  /** Static assets configuration */
193
230
  staticAssets?: StaticAssetsConfig;
231
+ /** Prerender configuration for SSG */
232
+ prerender?: AvalonNitroConfig['prerender'];
194
233
  }
195
234
  /**
196
235
  * Avalon-specific runtime configuration stored in Nitro's runtimeConfig
@@ -1 +1 @@
1
- export const DEFAULT_STATIC_ASSETS_CONFIG={publicDir:`public`,buildDir:`dist`,compression:!0,cacheControl:`public, max-age=31536000, immutable`,mutableCacheControl:`public, max-age=0, must-revalidate`,headers:{}};export const VALID_V3_PRESETS=[`node_server`,`node_middleware`,`vercel`,`cloudflare_module`,`cloudflare_pages`,`deno_deploy`,`deno_server`,`netlify`,`netlify_functions`,`netlify_edge`,`aws_lambda`,`azure_swa`,`firebase_functions`,`render_com`,`static`,`browser`];export function resolvePresetName(e){if(VALID_V3_PRESETS.includes(e))return e;throw Error(`Unknown Nitro preset: "${e}". Valid presets: ${VALID_V3_PRESETS.join(`, `)}`)}export const DEFAULT_NITRO_CONFIG={preset:`node_server`,serverDir:`server`,streaming:!0};export function createNitroConfig(t,i){let a=t.pagesDir??i.pagesDir,o=i.layoutsDir,s={streaming:t.streaming??DEFAULT_NITRO_CONFIG.streaming,pagesDir:a,layoutsDir:o};if(t.runtimeConfig&&`nitro`in t.runtimeConfig)throw Error(`The "nitro" key in runtimeConfig is reserved by Nitro v3 and cannot be used.`);let c={avalon:s,...t.runtimeConfig},l={...DEFAULT_STATIC_ASSETS_CONFIG,...t.staticAssets},u=mergeRouteRules(createDefaultStaticAssetRouteRules(l),t.routeRules??{}),d=[{dir:l.publicDir??DEFAULT_STATIC_ASSETS_CONFIG.publicDir,baseURL:`/`,maxAge:0}],f=t.renderer===!1?!1:t.renderer?{...t.renderer}:void 0;return{preset:resolvePresetName(process.env.NITRO_PRESET??t.preset??DEFAULT_NITRO_CONFIG.preset),serverDir:t.serverDir??DEFAULT_NITRO_CONFIG.serverDir,routeRules:u,runtimeConfig:c,publicRuntimeConfig:t.publicRuntimeConfig,renderer:f,compatibilityDate:t.compatibilityDate,traceDeps:t.traceDeps,rolldownConfig:t.rolldownConfig,serverEntry:t.serverEntry,compressPublicAssets:t.compressPublicAssets,publicAssets:d,staticAssets:l}}export function createDefaultStaticAssetRouteRules(t){let n=t.cacheControl??DEFAULT_STATIC_ASSETS_CONFIG.cacheControl,r=t.mutableCacheControl??DEFAULT_STATIC_ASSETS_CONFIG.mutableCacheControl;return{"/assets/**":{headers:{"Cache-Control":n,...t.headers}},"/islands/**":{headers:{"Cache-Control":n,...t.headers}},"/chunks/**":{headers:{"Cache-Control":n,...t.headers}},"/_nuxt/**":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff2":{headers:{"Cache-Control":n,...t.headers}},"/**/*.html":{headers:{"Cache-Control":r,...t.headers}},"/favicon.ico":{headers:{"Cache-Control":`public, max-age=86400`,...t.headers}},"/**/*.css":{headers:{"Cache-Control":r,...t.headers}}}}export function isValidPreset(e){return VALID_V3_PRESETS.includes(e)}export function mergeRouteRules(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]?n[e]={...n[e],...r,headers:{...n[e].headers,...r.headers}}:n[e]=r;return n}
1
+ export const DEFAULT_STATIC_ASSETS_CONFIG={publicDir:`public`,buildDir:`dist`,compression:!0,cacheControl:`public, max-age=31536000, immutable`,mutableCacheControl:`public, max-age=0, must-revalidate`,headers:{}};export const VALID_V3_PRESETS=[`node_server`,`node_middleware`,`vercel`,`cloudflare_module`,`cloudflare_pages`,`deno_deploy`,`deno_server`,`netlify`,`netlify_functions`,`netlify_edge`,`aws_lambda`,`azure_swa`,`firebase_functions`,`render_com`,`static`,`browser`];export function resolvePresetName(e){if(VALID_V3_PRESETS.includes(e))return e;throw Error(`Unknown Nitro preset: "${e}". Valid presets: ${VALID_V3_PRESETS.join(`, `)}`)}export const DEFAULT_NITRO_CONFIG={preset:`node_server`,serverDir:`server`,streaming:!0};export function createNitroConfig(t,i){let a=t.pagesDir??i.pagesDir,o=i.layoutsDir,s={streaming:t.streaming??DEFAULT_NITRO_CONFIG.streaming,pagesDir:a,layoutsDir:o};if(t.runtimeConfig&&`nitro`in t.runtimeConfig)throw Error(`The "nitro" key in runtimeConfig is reserved by Nitro v3 and cannot be used.`);let c={avalon:s,...t.runtimeConfig},l={...DEFAULT_STATIC_ASSETS_CONFIG,...t.staticAssets},u=mergeRouteRules(createDefaultStaticAssetRouteRules(l),t.routeRules??{}),d=[{dir:l.publicDir??DEFAULT_STATIC_ASSETS_CONFIG.publicDir,baseURL:`/`,maxAge:0}],f=t.renderer===!1?!1:t.renderer?{...t.renderer}:void 0;return{preset:resolvePresetName(process.env.NITRO_PRESET??t.preset??DEFAULT_NITRO_CONFIG.preset),serverDir:t.serverDir??DEFAULT_NITRO_CONFIG.serverDir,routeRules:u,runtimeConfig:c,publicRuntimeConfig:t.publicRuntimeConfig,renderer:f,compatibilityDate:t.compatibilityDate,traceDeps:t.traceDeps,rolldownConfig:t.rolldownConfig,serverEntry:t.serverEntry,compressPublicAssets:t.compressPublicAssets,publicAssets:d,staticAssets:l,prerender:t.prerender}}export function createDefaultStaticAssetRouteRules(t){let n=t.cacheControl??DEFAULT_STATIC_ASSETS_CONFIG.cacheControl,r=t.mutableCacheControl??DEFAULT_STATIC_ASSETS_CONFIG.mutableCacheControl;return{"/assets/**":{headers:{"Cache-Control":n,...t.headers}},"/islands/**":{headers:{"Cache-Control":n,...t.headers}},"/chunks/**":{headers:{"Cache-Control":n,...t.headers}},"/_nuxt/**":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff2":{headers:{"Cache-Control":n,...t.headers}},"/**/*.html":{headers:{"Cache-Control":r,...t.headers}},"/favicon.ico":{headers:{"Cache-Control":`public, max-age=86400`,...t.headers}},"/**/*.css":{headers:{"Cache-Control":r,...t.headers}}}}export function isValidPreset(e){return VALID_V3_PRESETS.includes(e)}export function mergeRouteRules(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]?n[e]={...n[e],...r,headers:{...n[e].headers,...r.headers}}:n[e]=r;return n}