@useavalon/avalon 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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/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`);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=`
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/${t}/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`);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/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=`
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/${t}/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;
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";function t(e){return/\s\d+w/.test(e)}export function Image({src:n,alt:r,sizes:i,loading:a=`lazy`,decoding:o=`async`,width:s,height:c,className:l,style:u}){let d,f,p,m;return typeof n==`object`&&n?(d=n.src,f=n.srcset,p=n.width,m=n.height):typeof n==`string`&&(t(n)?(f=n,d=n.split(`,`)[0]?.trim().split(` `)[0]):d=n),e(`img`,{src:d,srcSet:f,sizes:i,alt:r,loading:a,decoding:o,width:s??p,height:c??m,className:l,style:u})}export default Image;
1
+ import{jsx as e}from"preact/jsx-runtime";function t(e){return/\s\d+w/.test(e)}export function Image({src:n,alt:r,sizes:i,loading:a=`lazy`,decoding:o=`async`,width:s,height:c,className:l,style:u}){let d,f,p,m;return typeof n==`object`&&n?(d=n.src,f=n.srcset,p=n.width,m=n.height):typeof n==`string`&&(t(n)?(f=n,d=n.split(`,`)[0]?.trim().split(` `)[0]):d=n),e(`img`,{src:d,srcSet:f,sizes:i,alt:r,loading:a,decoding:o,width:s??p,height:c??m,className:l,style:u})}export default Image;
@@ -1 +1 @@
1
- import{Component as e}from"preact";import{jsx as t,jsxs as n}from"react/jsx-runtime";export class IslandErrorBoundary extends e{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:`island:${this.props.islandId}`,errorType:`island`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`IslandErrorBoundary`};if(this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n),typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`&&console.error(`Island Error [${this.props.islandId}]:`,e),!this.props.isolateError)throw e}handleRemoveIsland=()=>{let e=document.querySelector(`[data-island-id="${this.props.islandId}"]`);e&&e.remove()};handleReloadIsland=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};renderFallback(){let{error:e}=this.state,{fallback:r,islandId:i}=this.props;if(r&&e)return r(e,i);let a=typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`;return t(`div`,{class:`island-error-boundary`,"data-island-error":i,children:n(`div`,{class:`island-error-container`,children:[n(`div`,{class:`island-error-header`,children:[t(`span`,{class:`island-error-icon`,children:`⚠️`}),t(`span`,{class:`island-error-title`,children:`Island Error`})]}),n(`p`,{class:`island-error-message`,children:[`An error occurred in island "`,i,`". The rest of the page should work normally.`]}),n(`div`,{class:`island-error-actions`,children:[t(`button`,{onClick:this.handleReloadIsland,class:`island-reload-button`,children:`Reload Island`}),t(`button`,{onClick:this.handleRemoveIsland,class:`island-remove-button`,children:`Remove Island`})]}),a&&e&&n(`details`,{class:`island-error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`div`,{class:`island-error-info`,children:[n(`p`,{children:[t(`strong`,{children:`Island ID:`}),` `,i]}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]})]}),t(`pre`,{class:`island-error-stack`,children:e.stack})]})]})})}render(){return this.state.hasError?this.renderFallback():this.props.children}}export function withIslandErrorBoundary(e,n,i){return function(a){return t(IslandErrorBoundary,{islandId:n,fallback:i?.fallback,isolateError:i?.isolateError??!0,onError:i?.onError,children:t(e,{...a})})}}
1
+ import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class IslandErrorBoundary extends e{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:`island:${this.props.islandId}`,errorType:`island`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`IslandErrorBoundary`};if(this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n),typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`&&console.error(`Island Error [${this.props.islandId}]:`,e),!this.props.isolateError)throw e}handleRemoveIsland=()=>{let e=document.querySelector(`[data-island-id="${this.props.islandId}"]`);e&&e.remove()};handleReloadIsland=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};renderFallback(){let{error:e}=this.state,{fallback:r,islandId:i}=this.props;if(r&&e)return r(e,i);let a=typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`;return t(`div`,{class:`island-error-boundary`,"data-island-error":i,children:n(`div`,{class:`island-error-container`,children:[n(`div`,{class:`island-error-header`,children:[t(`span`,{class:`island-error-icon`,children:`⚠️`}),t(`span`,{class:`island-error-title`,children:`Island Error`})]}),n(`p`,{class:`island-error-message`,children:[`An error occurred in island "`,i,`". The rest of the page should work normally.`]}),n(`div`,{class:`island-error-actions`,children:[t(`button`,{onClick:this.handleReloadIsland,class:`island-reload-button`,children:`Reload Island`}),t(`button`,{onClick:this.handleRemoveIsland,class:`island-remove-button`,children:`Remove Island`})]}),a&&e&&n(`details`,{class:`island-error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`div`,{class:`island-error-info`,children:[n(`p`,{children:[t(`strong`,{children:`Island ID:`}),` `,i]}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]})]}),t(`pre`,{class:`island-error-stack`,children:e.stack})]})]})})}render(){return this.state.hasError?this.renderFallback():this.props.children}}export function withIslandErrorBoundary(e,n,i){return function(a){return t(IslandErrorBoundary,{islandId:n,fallback:i?.fallback,isolateError:i?.isolateError??!0,onError:i?.onError,children:t(e,{...a})})}}
@@ -1 +1 @@
1
- import{Component as e}from"preact";import{jsx as t,jsxs as n}from"react/jsx-runtime";export class LayoutDataErrorBoundary extends e{maxRetries=3;constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null,retryCount:0,isRetrying:!1,fallbackData:e.fallbackData||null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:this.props.layoutPath,errorType:`loader`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`LayoutDataErrorBoundary`};this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n)}handleRetry=async()=>{if(!(this.state.retryCount>=this.maxRetries||!this.props.retryLoader)){this.setState({isRetrying:!0});try{let e=await this.props.retryLoader();this.setState({hasError:!1,error:null,errorInfo:null,retryCount:this.state.retryCount+1,isRetrying:!1,fallbackData:e})}catch(e){this.setState({retryCount:this.state.retryCount+1,isRetrying:!1,error:e instanceof Error?e:Error(String(e))})}}};handleUseFallback=()=>{this.state.fallbackData&&this.setState({hasError:!1,error:null,errorInfo:null})};renderErrorUI(){let{error:e,retryCount:r,isRetrying:i,fallbackData:a}=this.state,o=r<this.maxRetries&&this.props.retryLoader,s=a!==null,c=typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`;return t(`div`,{class:`layout-data-error-boundary`,children:n(`div`,{class:`error-container`,children:[t(`h3`,{children:`Data Loading Error`}),n(`p`,{children:[`Failed to load data for layout: `,this.props.layoutPath]}),n(`div`,{class:`error-actions`,children:[o&&t(`button`,{onClick:this.handleRetry,disabled:i,class:`retry-button`,children:i?`Retrying...`:`Retry (${this.maxRetries-r} left)`}),s&&t(`button`,{onClick:this.handleUseFallback,class:`fallback-button`,children:`Use Cached Data`})]}),c&&e&&n(`details`,{class:`error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`div`,{class:`error-info`,children:[n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),n(`p`,{children:[t(`strong`,{children:`Layout:`}),` `,this.props.layoutPath]}),n(`p`,{children:[t(`strong`,{children:`Retry Count:`}),` `,r]})]}),t(`pre`,{class:`error-stack`,children:e.stack})]})]})})}render(){return this.state.hasError?this.renderErrorUI():this.props.children}}
1
+ import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class LayoutDataErrorBoundary extends e{maxRetries=3;constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null,retryCount:0,isRetrying:!1,fallbackData:e.fallbackData||null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:this.props.layoutPath,errorType:`loader`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`LayoutDataErrorBoundary`};this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n)}handleRetry=async()=>{if(!(this.state.retryCount>=this.maxRetries||!this.props.retryLoader)){this.setState({isRetrying:!0});try{let e=await this.props.retryLoader();this.setState({hasError:!1,error:null,errorInfo:null,retryCount:this.state.retryCount+1,isRetrying:!1,fallbackData:e})}catch(e){this.setState({retryCount:this.state.retryCount+1,isRetrying:!1,error:e instanceof Error?e:Error(String(e))})}}};handleUseFallback=()=>{this.state.fallbackData&&this.setState({hasError:!1,error:null,errorInfo:null})};renderErrorUI(){let{error:e,retryCount:r,isRetrying:i,fallbackData:a}=this.state,o=r<this.maxRetries&&this.props.retryLoader,s=a!==null,c=typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`;return t(`div`,{class:`layout-data-error-boundary`,children:n(`div`,{class:`error-container`,children:[t(`h3`,{children:`Data Loading Error`}),n(`p`,{children:[`Failed to load data for layout: `,this.props.layoutPath]}),n(`div`,{class:`error-actions`,children:[o&&t(`button`,{onClick:this.handleRetry,disabled:i,class:`retry-button`,children:i?`Retrying...`:`Retry (${this.maxRetries-r} left)`}),s&&t(`button`,{onClick:this.handleUseFallback,class:`fallback-button`,children:`Use Cached Data`})]}),c&&e&&n(`details`,{class:`error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`div`,{class:`error-info`,children:[n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),n(`p`,{children:[t(`strong`,{children:`Layout:`}),` `,this.props.layoutPath]}),n(`p`,{children:[t(`strong`,{children:`Retry Count:`}),` `,r]})]}),t(`pre`,{class:`error-stack`,children:e.stack})]})]})})}render(){return this.state.hasError?this.renderErrorUI():this.props.children}}
@@ -1 +1 @@
1
- import{Component as e}from"preact";import{jsxs as t,jsx as n}from"react/jsx-runtime";export class LayoutErrorBoundary extends e{maxRetries=3;constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null,retryCount:0}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:this.props.layoutPath||`unknown`,errorType:this.props.errorType||`component`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:this.constructor.name};this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n),typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`&&(console.error(`Layout Error Boundary caught an error:`,e),console.error(`Error Info:`,n),console.error(`Component Stack:`,t.componentStack))}handleRetry=()=>{this.state.retryCount<this.maxRetries&&this.setState({hasError:!1,error:null,errorInfo:null,retryCount:this.state.retryCount+1})};renderFallback(){let{error:e}=this.state,{fallback:r}=this.props;return r&&e?r(e,this.handleRetry):n(`div`,{class:`layout-error-boundary`,children:t(`div`,{class:`error-container`,children:[n(`h2`,{children:`Something went wrong`}),n(`p`,{children:`An error occurred while rendering this layout.`}),this.state.retryCount<this.maxRetries&&t(`button`,{onClick:this.handleRetry,class:`retry-button`,children:[`Try Again (`,this.maxRetries-this.state.retryCount,` attempts left)`]}),typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`&&t(`details`,{class:`error-details`,children:[n(`summary`,{children:`Error Details (Development)`}),n(`pre`,{children:e?.stack}),this.state.errorInfo&&t(`div`,{children:[t(`p`,{children:[n(`strong`,{children:`Layout Path:`}),` `,this.state.errorInfo.layoutPath]}),t(`p`,{children:[n(`strong`,{children:`Error Type:`}),` `,this.state.errorInfo.errorType]}),t(`p`,{children:[n(`strong`,{children:`Timestamp:`}),` `,new Date(this.state.errorInfo.timestamp).toISOString()]})]})]})]})})}render(){return this.state.hasError?this.renderFallback():this.props.children}}
1
+ import{Component as e}from"preact";import{jsxs as t,jsx as n}from"preact/jsx-runtime";export class LayoutErrorBoundary extends e{maxRetries=3;constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null,retryCount:0}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:this.props.layoutPath||`unknown`,errorType:this.props.errorType||`component`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:this.constructor.name};this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n),typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`&&(console.error(`Layout Error Boundary caught an error:`,e),console.error(`Error Info:`,n),console.error(`Component Stack:`,t.componentStack))}handleRetry=()=>{this.state.retryCount<this.maxRetries&&this.setState({hasError:!1,error:null,errorInfo:null,retryCount:this.state.retryCount+1})};renderFallback(){let{error:e}=this.state,{fallback:r}=this.props;return r&&e?r(e,this.handleRetry):n(`div`,{class:`layout-error-boundary`,children:t(`div`,{class:`error-container`,children:[n(`h2`,{children:`Something went wrong`}),n(`p`,{children:`An error occurred while rendering this layout.`}),this.state.retryCount<this.maxRetries&&t(`button`,{onClick:this.handleRetry,class:`retry-button`,children:[`Try Again (`,this.maxRetries-this.state.retryCount,` attempts left)`]}),typeof Deno<`u`&&Deno.env.get(`NODE_ENV`)===`development`&&t(`details`,{class:`error-details`,children:[n(`summary`,{children:`Error Details (Development)`}),n(`pre`,{children:e?.stack}),this.state.errorInfo&&t(`div`,{children:[t(`p`,{children:[n(`strong`,{children:`Layout Path:`}),` `,this.state.errorInfo.layoutPath]}),t(`p`,{children:[n(`strong`,{children:`Error Type:`}),` `,this.state.errorInfo.errorType]}),t(`p`,{children:[n(`strong`,{children:`Timestamp:`}),` `,new Date(this.state.errorInfo.timestamp).toISOString()]})]})]})]})})}render(){return this.state.hasError?this.renderFallback():this.props.children}}
@@ -1 +1 @@
1
- import{Component as e}from"preact";import{jsx as t,jsxs as n}from"react/jsx-runtime";export class StreamingErrorBoundary extends e{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(this.setState({errorInfo:t}),console.error(`[StreamingErrorBoundary] Caught error:`,{componentId:this.props.componentId,error:e.message,stack:e.stack,componentStack:t.componentStack}),this.props.onError&&this.props.onError(e,t),!this.props.isolateError)throw e}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};renderFallback(){let{error:e}=this.state,{fallback:r,componentId:i}=this.props;if(r&&e)return r(e,this.handleRetry);let a=typeof Deno<`u`&&Deno.env.get(`DENO_ENV`)!==`production`;return n(`div`,{class:`streaming-error-boundary`,"data-error-boundary":`true`,"data-component-id":i,style:{background:`#fff3cd`,border:`2px solid #ffc107`,borderRadius:`8px`,padding:`20px`,margin:`20px 0`,fontFamily:`system-ui, -apple-system, sans-serif`},children:[n(`div`,{class:`error-boundary-header`,style:{display:`flex`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[t(`span`,{style:{fontSize:`24px`},children:`⚠️`}),t(`h3`,{style:{margin:0,color:`#856404`},children:`Component Error`})]}),t(`p`,{style:{margin:`10px 0`,color:`#856404`},children:`An error occurred while rendering this component. The rest of the page should work normally.`}),t(`button`,{onClick:this.handleRetry,style:{background:`#ffc107`,border:`none`,borderRadius:`4px`,padding:`8px 16px`,cursor:`pointer`,fontWeight:`bold`,color:`#856404`,marginTop:`10px`},children:`Retry`}),a&&e&&n(`details`,{style:{marginTop:`15px`},children:[t(`summary`,{style:{cursor:`pointer`,color:`#856404`,fontWeight:`bold`},children:`Error Details (Development Mode)`}),n(`div`,{style:{marginTop:`10px`},children:[i&&n(`p`,{children:[t(`strong`,{children:`Component ID:`}),` `,i]}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),e.stack&&t(`pre`,{style:{background:`#f5f5f5`,padding:`10px`,borderRadius:`4px`,overflowX:`auto`,fontSize:`12px`,marginTop:`10px`},children:e.stack}),this.state.errorInfo?.componentStack&&n(`div`,{children:[t(`p`,{children:t(`strong`,{children:`Component Stack:`})}),t(`pre`,{style:{background:`#f5f5f5`,padding:`10px`,borderRadius:`4px`,overflowX:`auto`,fontSize:`12px`,marginTop:`10px`},children:this.state.errorInfo.componentStack})]})]})]})]})}render(){return this.state.hasError?this.renderFallback():this.props.children}}export function withStreamingErrorBoundary(e,n){return function(i){return t(StreamingErrorBoundary,{componentId:n?.componentId,fallback:n?.fallback,isolateError:n?.isolateError??!0,onError:n?.onError,children:t(e,{...i})})}}
1
+ import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class StreamingErrorBoundary extends e{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(this.setState({errorInfo:t}),console.error(`[StreamingErrorBoundary] Caught error:`,{componentId:this.props.componentId,error:e.message,stack:e.stack,componentStack:t.componentStack}),this.props.onError&&this.props.onError(e,t),!this.props.isolateError)throw e}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};renderFallback(){let{error:e}=this.state,{fallback:r,componentId:i}=this.props;if(r&&e)return r(e,this.handleRetry);let a=typeof Deno<`u`&&Deno.env.get(`DENO_ENV`)!==`production`;return n(`div`,{class:`streaming-error-boundary`,"data-error-boundary":`true`,"data-component-id":i,style:{background:`#fff3cd`,border:`2px solid #ffc107`,borderRadius:`8px`,padding:`20px`,margin:`20px 0`,fontFamily:`system-ui, -apple-system, sans-serif`},children:[n(`div`,{class:`error-boundary-header`,style:{display:`flex`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[t(`span`,{style:{fontSize:`24px`},children:`⚠️`}),t(`h3`,{style:{margin:0,color:`#856404`},children:`Component Error`})]}),t(`p`,{style:{margin:`10px 0`,color:`#856404`},children:`An error occurred while rendering this component. The rest of the page should work normally.`}),t(`button`,{onClick:this.handleRetry,style:{background:`#ffc107`,border:`none`,borderRadius:`4px`,padding:`8px 16px`,cursor:`pointer`,fontWeight:`bold`,color:`#856404`,marginTop:`10px`},children:`Retry`}),a&&e&&n(`details`,{style:{marginTop:`15px`},children:[t(`summary`,{style:{cursor:`pointer`,color:`#856404`,fontWeight:`bold`},children:`Error Details (Development Mode)`}),n(`div`,{style:{marginTop:`10px`},children:[i&&n(`p`,{children:[t(`strong`,{children:`Component ID:`}),` `,i]}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),e.stack&&t(`pre`,{style:{background:`#f5f5f5`,padding:`10px`,borderRadius:`4px`,overflowX:`auto`,fontSize:`12px`,marginTop:`10px`},children:e.stack}),this.state.errorInfo?.componentStack&&n(`div`,{children:[t(`p`,{children:t(`strong`,{children:`Component Stack:`})}),t(`pre`,{style:{background:`#f5f5f5`,padding:`10px`,borderRadius:`4px`,overflowX:`auto`,fontSize:`12px`,marginTop:`10px`},children:this.state.errorInfo.componentStack})]})]})]})]})}render(){return this.state.hasError?this.renderFallback():this.props.children}}export function withStreamingErrorBoundary(e,n){return function(i){return t(StreamingErrorBoundary,{componentId:n?.componentId,fallback:n?.fallback,isolateError:n?.isolateError??!0,onError:n?.onError,children:t(e,{...i})})}}
@@ -1,4 +1,4 @@
1
- import{Component as e}from"preact";import{useState as t,useEffect as n,useRef as r}from"preact/hooks";import{jsxs as i,jsx as a}from"react/jsx-runtime";export function StreamingLayout(e){let{component:o,componentProps:c={},children:l,fallback:u,priority:d=`medium`,isReady:f,timeout:p=5e3,onError:m,onLoadingChange:h}=e;if(typeof window>`u`)return l;let[g,_]=t({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1}),v=r(),y=r(!0);return n(()=>()=>{y.current=!1},[]),n(()=>{if(!f){_(e=>({...e,isReady:!0,isLoading:!1})),h?.(!1);return}let e=!1;return(async()=>{try{p>0&&(v.current=setTimeout(()=>{!e&&y.current&&(_(e=>({...e,hasTimedOut:!0,isLoading:!1})),h?.(!1))},p));let t=await f();if(e||!y.current)return;v.current&&clearTimeout(v.current),_(e=>({...e,isReady:t,isLoading:!1,hasTimedOut:!1})),h?.(!1)}catch(t){if(e||!y.current)return;v.current&&clearTimeout(v.current),_(e=>({...e,error:t,isLoading:!1})),h?.(!1)}})(),()=>{e=!0,v.current&&clearTimeout(v.current)}},[f,p,h]),g.error?m?m(g.error):i(`div`,{class:`streaming-error`,"data-priority":d,children:[i(`p`,{children:[`Failed to load component: `,g.error.message]}),a(`button`,{onClick:()=>{_({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1}),h?.(!0)},children:`Retry`})]}):g.hasTimedOut?a(`div`,{class:`streaming-timeout`,"data-priority":d,children:u||i(`div`,{class:`timeout-message`,children:[a(`p`,{children:`Component loading timed out`}),a(`button`,{onClick:()=>{_({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1}),h?.(!0)},children:`Retry`})]})}):g.isLoading||!g.isReady?a(`div`,{class:`streaming-loading`,"data-priority":d,children:u||a(s,{priority:d})}):a(`div`,{class:`streaming-ready`,"data-priority":d,children:a(o,{...c,children:l})})}function s({priority:e}){return i(`div`,{class:`streaming-skeleton ${`skeleton-${e}`}`,children:[i(`div`,{class:`skeleton-content`,children:[a(`div`,{class:`skeleton-line skeleton-line-1`}),a(`div`,{class:`skeleton-line skeleton-line-2`}),a(`div`,{class:`skeleton-line skeleton-line-3`})]}),a(`style`,{children:`
1
+ import{Component as e}from"preact";import{useState as t,useEffect as n,useRef as r}from"preact/hooks";import{jsxs as i,jsx as a}from"preact/jsx-runtime";export function StreamingLayout(e){let{component:o,componentProps:c={},children:l,fallback:u,priority:d=`medium`,isReady:f,timeout:p=5e3,onError:m,onLoadingChange:h}=e;if(typeof window>`u`)return l;let[g,_]=t({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1}),v=r(),y=r(!0);return n(()=>()=>{y.current=!1},[]),n(()=>{if(!f){_(e=>({...e,isReady:!0,isLoading:!1})),h?.(!1);return}let e=!1;return(async()=>{try{p>0&&(v.current=setTimeout(()=>{!e&&y.current&&(_(e=>({...e,hasTimedOut:!0,isLoading:!1})),h?.(!1))},p));let t=await f();if(e||!y.current)return;v.current&&clearTimeout(v.current),_(e=>({...e,isReady:t,isLoading:!1,hasTimedOut:!1})),h?.(!1)}catch(t){if(e||!y.current)return;v.current&&clearTimeout(v.current),_(e=>({...e,error:t,isLoading:!1})),h?.(!1)}})(),()=>{e=!0,v.current&&clearTimeout(v.current)}},[f,p,h]),g.error?m?m(g.error):i(`div`,{class:`streaming-error`,"data-priority":d,children:[i(`p`,{children:[`Failed to load component: `,g.error.message]}),a(`button`,{onClick:()=>{_({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1}),h?.(!0)},children:`Retry`})]}):g.hasTimedOut?a(`div`,{class:`streaming-timeout`,"data-priority":d,children:u||i(`div`,{class:`timeout-message`,children:[a(`p`,{children:`Component loading timed out`}),a(`button`,{onClick:()=>{_({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1}),h?.(!0)},children:`Retry`})]})}):g.isLoading||!g.isReady?a(`div`,{class:`streaming-loading`,"data-priority":d,children:u||a(s,{priority:d})}):a(`div`,{class:`streaming-ready`,"data-priority":d,children:a(o,{...c,children:l})})}function s({priority:e}){return i(`div`,{class:`streaming-skeleton ${`skeleton-${e}`}`,children:[i(`div`,{class:`skeleton-content`,children:[a(`div`,{class:`skeleton-line skeleton-line-1`}),a(`div`,{class:`skeleton-line skeleton-line-2`}),a(`div`,{class:`skeleton-line skeleton-line-3`})]}),a(`style`,{children:`
2
2
  .streaming-skeleton {
3
3
  padding: 1rem;
4
4
  border-radius: 0.5rem;
@@ -1 +1 @@
1
- import{createContext as e}from"preact";import{useContext as t}from"preact/hooks";import{defaultIslandPersistence as n}from"./island-persistence.js";import{jsx as r}from"react/jsx-runtime";export const PersistentIslandContextProvider=e(null);export function createPersistentIslandContext(e,t=n){return{saveState:n=>{t.saveState(e,n)},loadState:()=>t.loadState(e),clearState:()=>{t.clearState(e)}}}export function usePersistentIslandContext(){let e=t(PersistentIslandContextProvider);if(!e)throw Error(`usePersistentIslandContext must be used within a PersistentIsland component`);return e}export function PersistentIslandProvider({persistentId:e,children:t,persistence:i=n}){let a=createPersistentIslandContext(e,i);return r(PersistentIslandContextProvider.Provider,{value:a,children:t})}
1
+ import{createContext as e}from"preact";import{useContext as t}from"preact/hooks";import{defaultIslandPersistence as n}from"./island-persistence.js";import{jsx as r}from"preact/jsx-runtime";export const PersistentIslandContextProvider=e(null);export function createPersistentIslandContext(e,t=n){return{saveState:n=>{t.saveState(e,n)},loadState:()=>t.loadState(e),clearState:()=>{t.clearState(e)}}}export function usePersistentIslandContext(){let e=t(PersistentIslandContextProvider);if(!e)throw Error(`usePersistentIslandContext must be used within a PersistentIsland component`);return e}export function PersistentIslandProvider({persistentId:e,children:t,persistence:i=n}){let a=createPersistentIslandContext(e,i);return r(PersistentIslandContextProvider.Provider,{value:a,children:t})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,8 @@
22
22
  "scripts": {
23
23
  "build:client": "bun run scripts/build-client.ts",
24
24
  "build": "bun run scripts/build.ts",
25
- "prepublishOnly": "bun run build"
25
+ "prepublishOnly": "bun run build",
26
+ "postpublish": "bun run scripts/postpublish.ts"
26
27
  },
27
28
  "exports": {
28
29
  ".": "./dist/mod.js",