@useavalon/avalon 0.1.53 → 0.1.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/client/main.js +2 -2
- package/package.json +1 -1
package/dist/src/client/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{executeCustomDirective as e,hasClientDirective as t}from"./custom-directives.js";import{loadIntegrationModule as n}from"virtual:avalon/integration-loader";document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r):r();function r(){let n=document.querySelectorAll(`[data-framework]`);n.length!==0&&n.forEach(n=>{try{let r=n.dataset.framework,l=n.dataset.condition||`on:client`;if(n.dataset.renderStrategy===`ssr-only`||!i(n,l))return;l===`on:client`?u(n,r):l===`on:visible`?a(n,r):l===`on:interaction`?o(n,r):l===`on:idle`?s(n,r):l.startsWith(`media:`)?c(n,r,l.slice(6)):n.dataset.customDirective||t(l)?e(n,l,()=>{u(n,r)})||(console.warn(`[avalon] Unknown hydration condition: "${l}". Hydrating immediately.`),u(n,r)):u(n,r)}catch(e){console.error(`Error processing island:`,e),d(n,n.dataset.framework||`unknown`,n.dataset.src||`unknown`,e)}})}function i(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 a(e,t){try{let n=new IntersectionObserver(r=>{r[0].isIntersecting&&(u(e,t),n.disconnect())},{rootMargin:`50px`,threshold:0});n.observe(e)}catch(n){console.error(`Failed to setup intersection observer:`,n),u(e,t)}}function o(e,t){let n=[`click`,`touchstart`,`mouseenter`,`focusin`],r=!1,i=()=>{r||(r=!0,n.forEach(t=>{e.removeEventListener(t,i)}),u(e,t))};try{n.forEach(t=>{e.addEventListener(t,i,{once:!0,passive:!0})})}catch(n){console.error(`Failed to setup interaction observer:`,n),u(e,t)}}function s(e,t){try{`requestIdleCallback`in globalThis?globalThis.requestIdleCallback(()=>{u(e,t)},{timeout:5e3}):document.readyState===`complete`?setTimeout(()=>{u(e,t)},200):globalThis.addEventListener(`load`,()=>{setTimeout(()=>{u(e,t)},200)},{once:!0})}catch(n){console.error(`Failed to setup idle callback:`,n),u(e,t)}}function c(e,t,n){try{let r=globalThis.matchMedia(n);if(r.matches){u(e,t);return}let i=n=>{n.matches&&(u(e,t),r.removeEventListener(`change`,i))};r.addEventListener(`change`,i)}catch(r){console.error(`Failed to setup media query:`,n,r),u(e,t)}}function l(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 u(e,t){if(e.dataset.hydrated)return;let r=e.dataset.src,i=e.dataset.props;if(!r){console.warn(`Island missing data-src attribute`);return}try{let a=i?JSON.parse(i):{};t===`lit`&&
|
|
1
|
+
import{executeCustomDirective as e,hasClientDirective as t}from"./custom-directives.js";import{loadIntegrationModule as n}from"virtual:avalon/integration-loader";document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r):r();function r(){let n=document.querySelectorAll(`[data-framework]`);n.length!==0&&n.forEach(n=>{try{let r=n.dataset.framework,l=n.dataset.condition||`on:client`;if(n.dataset.renderStrategy===`ssr-only`||!i(n,l))return;l===`on:client`?u(n,r):l===`on:visible`?a(n,r):l===`on:interaction`?o(n,r):l===`on:idle`?s(n,r):l.startsWith(`media:`)?c(n,r,l.slice(6)):n.dataset.customDirective||t(l)?e(n,l,()=>{u(n,r)})||(console.warn(`[avalon] Unknown hydration condition: "${l}". Hydrating immediately.`),u(n,r)):u(n,r)}catch(e){console.error(`Error processing island:`,e),d(n,n.dataset.framework||`unknown`,n.dataset.src||`unknown`,e)}})}function i(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 a(e,t){try{let n=new IntersectionObserver(r=>{r[0].isIntersecting&&(u(e,t),n.disconnect())},{rootMargin:`50px`,threshold:0});n.observe(e)}catch(n){console.error(`Failed to setup intersection observer:`,n),u(e,t)}}function o(e,t){let n=[`click`,`touchstart`,`mouseenter`,`focusin`],r=!1,i=()=>{r||(r=!0,n.forEach(t=>{e.removeEventListener(t,i)}),u(e,t))};try{n.forEach(t=>{e.addEventListener(t,i,{once:!0,passive:!0})})}catch(n){console.error(`Failed to setup interaction observer:`,n),u(e,t)}}function s(e,t){try{`requestIdleCallback`in globalThis?globalThis.requestIdleCallback(()=>{u(e,t)},{timeout:5e3}):document.readyState===`complete`?setTimeout(()=>{u(e,t)},200):globalThis.addEventListener(`load`,()=>{setTimeout(()=>{u(e,t)},200)},{once:!0})}catch(n){console.error(`Failed to setup idle callback:`,n),u(e,t)}}function c(e,t,n){try{let r=globalThis.matchMedia(n);if(r.matches){u(e,t);return}let i=n=>{n.matches&&(u(e,t),r.removeEventListener(`change`,i))};r.addEventListener(`change`,i)}catch(r){console.error(`Failed to setup media query:`,n,r),u(e,t)}}function l(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 u(e,t){if(e.dataset.hydrated)return;let r=e.dataset.src,i=e.dataset.props;if(!r){console.warn(`Island missing data-src attribute`);return}try{let a=i?JSON.parse(i):{};t===`lit`&&await import(`/@useavalon/lit/client`);let o=l(await import(r),r);try{let r=await n(t);if(!r.hydrate||typeof r.hydrate!=`function`)throw Error(`Integration ${t} does not export a hydrate function`);await r.hydrate(e,o,a),e.dataset.hydrated=`true`}catch(n){import.meta.env?.DEV&&console.error(`Integration hydration failed for ${t}: ${r}`,n),e.dataset.hydrationStatus=`failed`,e.dataset.hydrationError=n.message,e.dispatchEvent(new CustomEvent(`hydration-error`,{detail:{framework:t,src:r,error:n.message,timestamp:Date.now(),hydrationType:`integration-level`},bubbles:!0}))}}catch(n){console.error(`❌ Critical error hydrating ${t} island ${r}:`,n),d(e,t,r,n)}}function d(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})),p()&&f(e,t,n,r)}function f(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 @@ import{executeCustomDirective as e,hasClientDirective as t}from"./custom-directi
|
|
|
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 p(){return import.meta.env?.DEV||import.meta.env?.MODE===`development`||globalThis.location?.hostname===`localhost`||globalThis.location?.hostname===`127.0.0.1`}function m(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 h(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 g(e,t,r,i){let a=e.dataset.props,o=a?JSON.parse(a):{};t===`lit`&&
|
|
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 p(){return import.meta.env?.DEV||import.meta.env?.MODE===`development`||globalThis.location?.hostname===`localhost`||globalThis.location?.hostname===`127.0.0.1`}function m(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 h(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 g(e,t,r,i){let a=e.dataset.props,o=a?JSON.parse(a):{};t===`lit`&&await import(`/@useavalon/lit/client`);let s=l(await import(r),i),c=await n(t);if(!c.hydrate||typeof c.hydrate!=`function`)throw Error(`Integration ${t} does not export a hydrate function`);c.hydrate(e,s,o),e.dataset.hydrated=`true`}function _(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;
|