@useavalon/avalon 0.1.16 → 0.1.17

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 +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.17",
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",