what-core 0.6.8 → 0.6.9
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/compiler.js +59 -91
- package/dist/compiler.js.map +3 -3
- package/dist/compiler.min.js +1 -1
- package/dist/compiler.min.js.map +3 -3
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.min.js.map +1 -1
- package/dist/index.js +59 -91
- package/dist/index.js.map +3 -3
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +3 -3
- package/dist/render.js +59 -91
- package/dist/render.js.map +3 -3
- package/dist/render.min.js +2 -2
- package/dist/render.min.js.map +3 -3
- package/dist/testing.js +59 -91
- package/dist/testing.js.map +3 -3
- package/dist/testing.min.js +1 -1
- package/dist/testing.min.js.map +3 -3
- package/package.json +2 -2
- package/src/dom.js +31 -22
- package/src/reactive.js +36 -59
package/dist/render.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var b=!(typeof process<"u"),w=null;var L=null,F=null,G=null,me=!1,se=0,I=[],Y=!1,Ge=new WeakMap,Ve=Symbol("needs_upstream");function q(e,n){let t=e,r=new Set;function o(...i){if(i.length===0)return L&&(r.add(L),L.deps.push(r)),t;b&&me&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let l=typeof i[0]=="function"?i[0](t):i[0];Object.is(t,l)||(t=l,b&&w&&w.onSignalUpdate(o),r.size>0&&ge(r))}return o.set=i=>{b&&me&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let l=typeof i=="function"?i(t):i;Object.is(t,l)||(t=l,b&&w&&w.onSignalUpdate(o),r.size>0&&ge(r))},o.peek=()=>t,o.subscribe=i=>T(()=>i(o())),o._signal=!0,b&&(o._subs=r,n&&(o._debugName=n)),b&&w&&w.onSignalCreate(o),o}function ye(e){let n=0,t=e.deps;for(let r=0;r<t.length;r++){let o=Ge.get(t[r]);if(o){let i=o._level;i>n&&(n=i)}}e._level=n+1}function T(e,n){let t=qe(e);t._level=1;let r=L;L=t;try{let i=t.fn();typeof i=="function"&&(t._cleanup=i)}finally{L=r}ye(t),n?.stable&&(t._stable=!0);let o=()=>ze(t);return F&&F.disposals.push(o),o}function qe(e,n){let t={fn:e,deps:[],lazy:n||!1,_onNotify:null,disposed:!1,_pending:!1,_stable:!1,_level:0,_computed:!1,_computedSubs:null,_isDirty:null,_markDirty:null};return b&&w&&w.onEffectCreate(t),t}function Pe(e){if(e.disposed)return;if(e._stable){if(e._cleanup){try{e._cleanup()}catch(r){b&&console.warn("[what] Error in effect cleanup:",r)}e._cleanup=null}let t=L;L=null;try{let r=e.fn();typeof r=="function"&&(e._cleanup=r)}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:e}),b&&console.warn("[what] Error in stable effect:",r)}finally{L=t}b&&w?.onEffectRun&&w.onEffectRun(e);return}if(_e(e),e._cleanup){try{e._cleanup()}catch(t){w?.onError&&w.onError(t,{type:"effect-cleanup",effect:e}),b&&console.warn("[what] Error in effect cleanup:",t)}e._cleanup=null}let n=L;L=e;try{let t=e.fn();typeof t=="function"&&(e._cleanup=t)}catch(t){throw t===Ve||w?.onError&&w.onError(t,{type:"effect",effect:e}),t}finally{L=n}b&&w?.onEffectRun&&w.onEffectRun(e)}function ze(e){if(e.disposed=!0,b&&w&&w.onEffectDispose(e),_e(e),e._cleanup){try{e._cleanup()}catch(n){b&&console.warn("[what] Error in effect cleanup on dispose:",n)}e._cleanup=null}}function _e(e){let n=e.deps;for(let t=0;t<n.length;t++)n[t].delete(e);n.length=0}var ce=0,U=null,V=0;function ge(e){if(ce===0){ce=1;try{for(let n of e)if(!n.disposed){if(n._onNotify)n._onNotify();else if(se===0&&n._stable){let t=L;L=null;try{let r=n.fn();if(typeof r=="function"){if(n._cleanup)try{n._cleanup()}catch{}n._cleanup=r}}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:n}),b&&console.warn("[what] Error in stable effect:",r)}finally{L=t}}else if(!n._pending){n._pending=!0;let t=n._level,r=I.length;r>0&&I[r-1]._level>t&&(Y=!0),I.push(n)}}if(V>0){let n=0;for(;n<V;){let t=U[n];U[n]=null,n++;for(let r of t)if(!r.disposed){if(r._onNotify)r._onNotify();else if(se===0&&r._stable){let o=L;L=null;try{let i=r.fn();if(typeof i=="function"){if(r._cleanup)try{r._cleanup()}catch{}r._cleanup=i}}catch(i){w?.onError&&w.onError(i,{type:"effect",effect:r}),b&&console.warn("[what] Error in stable effect:",i)}finally{L=o}}else if(!r._pending){r._pending=!0;let o=r._level,i=I.length;i>0&&I[i-1]._level>o&&(Y=!0),I.push(r)}}}V=0}}finally{ce=0}se===0&&I.length>0&&Fe()}else U===null&&(U=[]),V>=U.length?U.push(e):U[V]=e,V++}var le=!1;function Fe(){le||(le=!0,queueMicrotask(()=>{le=!1,Ke()}))}var fe=!1;function Ke(){if(!fe){fe=!0;try{let e=0;for(;I.length>0&&e<25;){let n=I;I=[],n.length>1&&Y&&n.sort((t,r)=>t._level-r._level),Y=!1;for(let t=0;t<n.length;t++){let r=n[t];if(r._pending=!1,!r.disposed&&!r._onNotify){let o=r.deps.length;Pe(r),!r._computed&&r.deps.length!==o&&ye(r)}}e++}if(e>=25){for(let n=0;n<I.length;n++)I[n]._pending=!1;if(I.length=0,b){let t=I.slice(0,3).map(r=>r.fn?.name||r.fn?.toString().slice(0,60)||"(anonymous)");console.warn(`[what] Possible infinite effect loop detected (25 iterations). Likely cause: an effect writes to a signal it also reads, creating a cycle. Use untrack() to read signals without subscribing. Looping effects: ${t.join(", ")}`)}else console.warn("[what] Possible infinite effect loop detected")}}finally{fe=!1}}}function ae(e){let n=L;L=null;try{return e()}finally{L=n}}function j(e){let n=F,t=G,r={disposals:[],owner:G,children:[],_disposed:!1};G&&G.children.push(r),F=r,G=r;try{return e(()=>{if(!r._disposed){r._disposed=!0;for(let i=r.children.length-1;i>=0;i--)we(r.children[i]);r.children.length=0;for(let i=r.disposals.length-1;i>=0;i--)r.disposals[i]();if(r.disposals.length=0,r.owner){let i=r.owner.children.indexOf(r);i>=0&&r.owner.children.splice(i,1)}}})}finally{F=n,G=t}}function we(e){if(!e._disposed){e._disposed=!0;for(let n=e.children.length-1;n>=0;n--)we(e.children[n]);e.children.length=0;for(let n=e.disposals.length-1;n>=0;n--)e.disposals[n]();e.disposals.length=0}}var Ce=null;function be(e){Ce=e}function Ee(e,n){let t=n||Ce?.();for(;t;){if(t._errorBoundary)return t._errorBoundary(e),!0;t=t._parentCtx}return!1}var Je=null;function xe(e){Je=e}var Xe=new Set(["href","src","action","formaction","poster","cite","background","xlink:href"]),Ye=new Set(["srcset"]);function ue(e){return String(e).toLowerCase()}function Ze(e){return String(e).trim().replace(/[\s\x00-\x1f\x7f]/g,"").toLowerCase()}function Se(e){if(typeof e!="string")return!0;let n=Ze(e);return!(n.startsWith("javascript:")||n.startsWith("data:")||n.startsWith("vbscript:"))}function Qe(e){return typeof e!="string"?!0:e.split(",").every(n=>{let t=n.trim().split(/\s+/,1)[0]||"";return t===""||Se(t)})}function et(e){return Xe.has(ue(e))}function tt(e){return Ye.has(ue(e))}function Z(e,n){return tt(e)?Qe(n):et(e)?Se(n):!0}function Q(e){return e==="className"?"class":e==="htmlFor"?"for":ue(e)==="formaction"?"formaction":e}var nt=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","symbol","clipPath","mask","pattern","image","text","tspan","textPath","foreignObject","linearGradient","radialGradient","stop","marker","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),rt="http://www.w3.org/2000/svg",Ae=new Set,ee=new WeakMap;function ot(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function de(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function Ne(e){if(!e.disposed){if(e.disposed=!0,e.cleanups)for(let n of e.cleanups)try{n()}catch(t){console.error("[what] cleanup error:",t)}if(e.effects)for(let n of e.effects)try{n()}catch{}if(e.hooks){for(let n of e.hooks)if(n&&typeof n.cleanup=="function")try{n.cleanup()}catch(t){console.error("[what] hook cleanup error:",t)}}if(e._cleanupCallbacks)for(let n of e._cleanupCallbacks)try{n()}catch(t){console.error("[what] onCleanup error:",t)}b&&w?.onComponentUnmount&&w.onComponentUnmount(e),Ae.delete(e)}}function H(e){if(!e)return;e._componentCtx&&Ne(e._componentCtx);let n=ee.get(e);if(n&&Ne(n),e._dispose)try{e._dispose()}catch{}if(e._propEffects)for(let t in e._propEffects)try{e._propEffects[t]()}catch{}if(e.childNodes)for(let t of e.childNodes)H(t)}function v(e,n,t){if(e==null||e===!1||e===!0)return document.createComment("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(ot(e))return e;if(typeof e=="function"){let r=document.createComment("fn"),o=document.createComment("/fn"),i=[],l=document.createDocumentFragment();l.appendChild(r),l.appendChild(o);let s=T(()=>{let f=e(),c=f==null||f===!1||f===!0?[]:Array.isArray(f)?f:[f],p=o.parentNode;if(p){for(let u of i)H(u),u.parentNode===p&&p.removeChild(u);i=[];for(let u of c){let _=v(u,p,n?._isSvg);if(_)if(_.nodeType===11){let y=Array.from(_.childNodes);p.insertBefore(_,o);for(let m of y)i.push(m)}else p.insertBefore(_,o),i.push(_)}}});return r._dispose=s,o._dispose=s,l}if(Array.isArray(e)){let r=document.createDocumentFragment();for(let o of e){let i=v(o,n,t);i&&r.appendChild(i)}return r}return de(e)&&typeof e.tag=="function"||de(e)&&(e.tag==="__errorBoundary"||e.tag==="__suspense"||e.tag==="__portal")?Le(e,n,t):de(e)?lt(e,n,t):document.createTextNode(String(e))}var M=[];function Me(){return M[M.length-1]}be(Me);xe(Me);function Te(){return M}function Le(e,n,t){let{tag:r,props:o,children:i}=e;if(typeof r=="function"&&(r.prototype?.isReactComponent||r.prototype?.render)){let h=r;r=function(d){return new h(d).render()},r.displayName=h.displayName||h.name||"ClassComponent"}if(r==="__errorBoundary"||e.tag==="__errorBoundary")return it(e,n);if(r==="__suspense"||e.tag==="__suspense")return st(e,n);if(r==="__portal"||e.tag==="__portal")return ct(e,n);let l={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:r,_parentCtx:M[M.length-1]||null,_errorBoundary:(()=>{let h=M[M.length-1];for(;h;){if(h._errorBoundary)return h._errorBoundary;h=h._parentCtx}return null})()},s=document.createComment("c:start"),f=document.createComment("c:end");ee.set(s,l),l._startComment=s,l._endComment=f;let c=document.createDocumentFragment();c._componentCtx=l,l._wrapper=s,Ae.add(l),b&&w?.onComponentMount&&w.onComponentMount(l);let p=i.length===0?void 0:i.length===1?i[0]:i,u=q({...o,children:p});l._propsSignal=u;let _=new Proxy({},{get(h,E){return u()[E]},has(h,E){let d=u();return E in d},ownKeys(){let h=u();return Reflect.ownKeys(h)},getOwnPropertyDescriptor(h,E){let d=u();if(E in d)return{value:d[E],writable:!1,enumerable:!0,configurable:!0}}});M.push(l);let y;try{y=r(_)}catch(h){if(M.pop(),!Ee(h,l))throw console.error("[what] Uncaught error in component:",r.name||"Anonymous",h),h;return c.appendChild(s),c.appendChild(f),c}M.pop(),l.mounted=!0,l._mountCallbacks&&queueMicrotask(()=>{if(!l.disposed)for(let h of l._mountCallbacks)try{h()}catch(E){console.error("[what] onMount error:",E)}}),c.appendChild(s);let m=Array.isArray(y)?y:[y];for(let h of m){let E=v(h,c,t);E&&c.appendChild(E)}return c.appendChild(f),c}function it(e,n){let{errorState:t,handleError:r,fallback:o,reset:i}=e.props,l=e.children,s=document.createComment("eb:start"),f=document.createComment("eb:end"),c={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null,_errorBoundary:r,_startComment:s,_endComment:f};ee.set(s,c);let p=document.createDocumentFragment();p._componentCtx=c,p.appendChild(s),p.appendChild(f);let u=T(()=>{let _=t();if(M.push(c),s.parentNode)for(;s.nextSibling&&s.nextSibling!==f;){let m=s.nextSibling;H(m),m.parentNode.removeChild(m)}let y;_?y=typeof o=="function"?[o({error:_,reset:i})]:[o]:y=l,y=Array.isArray(y)?y:[y];for(let m of y){let h=v(m,n);h&&(f.parentNode?f.parentNode.insertBefore(h,f):p.insertBefore(h,f))}M.pop()});return c.effects.push(u),p}function st(e,n){let{boundary:t,fallback:r,loading:o}=e.props,i=e.children,l=document.createComment("sb:start"),s=document.createComment("sb:end"),f={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null,_startComment:l,_endComment:s};ee.set(l,f);let c=document.createDocumentFragment();c._componentCtx=f,c.appendChild(l),c.appendChild(s);let p=T(()=>{let _=o()?[r]:i,y=Array.isArray(_)?_:[_];if(M.push(f),l.parentNode)for(;l.nextSibling&&l.nextSibling!==s;){let m=l.nextSibling;H(m),m.parentNode.removeChild(m)}for(let m of y){let h=v(m,n);h&&(s.parentNode?s.parentNode.insertBefore(h,s):c.insertBefore(h,s))}M.pop()});return f.effects.push(p),c}function ct(e,n){let{container:t}=e.props,r=e.children;if(!t)return console.warn("[what] Portal: target container not found"),document.createComment("portal:empty");let o={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null},i=document.createComment("portal");i._componentCtx=o;let l=[];for(let s of r){let f=v(s,t);f&&(t.appendChild(f),l.push(f))}return o._cleanupCallbacks=[()=>{for(let s of l)H(s),s.parentNode&&s.parentNode.removeChild(s)}],i}function lt(e,n,t){let{tag:r,props:o,children:i}=e,l=t||nt.has(r),s=l?document.createElementNS(rt,r):document.createElement(r);o&&ft(s,o,{},l);for(let f of i){let c=v(f,s,l&&r!=="foreignObject");c&&s.appendChild(c)}return s._vnode=e,s}function ft(e,n,t,r){n=n||{},t=t||{};for(let o in n)if(!(o==="key"||o==="children")){if(o==="ref"){typeof n.ref=="function"?n.ref(e):n.ref&&(n.ref.current=e);continue}ke(e,o,n[o],r)}}function ke(e,n,t,r){if(!Z(n,t)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${t}`),e.removeAttribute(Q(n));return}if(typeof t=="function"&&!(n.startsWith("on")&&n.length>2)&&n!=="ref"){if(e._propEffects||(e._propEffects={}),e._propEffects[n])try{e._propEffects[n]()}catch{}e._propEffects[n]=T(()=>{let o=t();ke(e,n,o,r)});return}if(n.startsWith("on")&&n.length>2){let o=n.slice(2),i=!1;o.endsWith("Capture")&&(o=o.slice(0,-7),i=!0);let l=o.toLowerCase(),s=i?l+"_capture":l,f=e._events?.[s];if(f&&f._original===t||(f&&e.removeEventListener(l,f,i),t==null))return;e._events||(e._events={});let c=u=>(u.nativeEvent||(u.nativeEvent=u),ae(()=>t(u)));c._original=t,e._events[s]=c;let p=t._eventOpts;e.addEventListener(l,c,p||i||void 0);return}if(n==="className"||n==="class"){r?e.setAttribute("class",t||""):e.className=t||"";return}if(n==="style"){if(typeof t=="string")e.style.cssText=t,e._prevStyle=null;else if(typeof t=="object"){let o=e._prevStyle||{};for(let i in o)i in t||(e.style[i]="");for(let i in t)e.style[i]=t[i]??"";e._prevStyle={...t}}return}if(n==="dangerouslySetInnerHTML"){e.innerHTML=t?.__html??"";return}if(n==="innerHTML"){if(t==null)return;if(t&&typeof t=="object"&&"__html"in t)e.innerHTML=t.__html??"";else{b&&console.warn("[what] innerHTML received a raw string. This is a security risk (XSS). Use innerHTML={{ __html: trustedString }} or dangerouslySetInnerHTML={{ __html: trustedString }} instead.");return}return}if(typeof t=="boolean"){t?e.setAttribute(n,""):e.removeAttribute(n);return}if(n.startsWith("data-")||n.startsWith("aria-")){e.setAttribute(n,t);return}if(r){t===!1||t==null?e.removeAttribute(n):e.setAttribute(n,t===!0?"":String(t));return}n in e?e[n]=t:e.setAttribute(n,t)}var at={INFINITE_EFFECT:{code:"ERR_INFINITE_EFFECT",severity:"error",template:'Effect "{{effectName}}" exceeded 25 flush iterations \u2014 likely an infinite loop.',suggestion:"An effect is writing to a signal it also reads, creating a cycle. Use untrack() to read the signal without subscribing, or restructure so the write and read are in separate effects.",codeExample:`// Bad \u2014 reads and writes count, creating a cycle:
|
|
1
|
+
var E=!(typeof process<"u"),C=null;var k=null,F=null,W=null,ye=!1,se=0,I=[],Y=!1,qe=new WeakMap,Pe=Symbol("needs_upstream");function q(e,n){let t=e,r=new Set;function o(...i){if(i.length===0)return k&&(r.add(k),k.deps.push(r)),t;E&&ye&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let l=typeof i[0]=="function"?i[0](t):i[0];Object.is(t,l)||(t=l,E&&C&&C.onSignalUpdate(o),r.size>0&&_e(r))}return o.set=i=>{E&&ye&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let l=typeof i=="function"?i(t):i;Object.is(t,l)||(t=l,E&&C&&C.onSignalUpdate(o),r.size>0&&_e(r))},o.peek=()=>t,o.subscribe=i=>M(()=>i(o())),o._signal=!0,E&&(o._subs=r,n&&(o._debugName=n)),E&&C&&C.onSignalCreate(o),o}function we(e){let n=0,t=e.deps;for(let r=0;r<t.length;r++){let o=qe.get(t[r]);if(o){let i=o._level;i>n&&(n=i)}}e._level=n+1}function M(e,n){let t=ze(e);t._level=1;let r=k;k=t;try{let i=t.fn();typeof i=="function"&&(t._cleanup=i)}finally{k=r}we(t),n?.stable&&(t._stable=!0);let o=()=>Ke(t);return F&&F.disposals.push(o),o}function ze(e,n){let t={fn:e,deps:[],lazy:n||!1,_onNotify:null,disposed:!1,_pending:!1,_stable:!1,_level:0,_computed:!1,_computedSubs:null,_isDirty:null,_markDirty:null};return E&&C&&C.onEffectCreate(t),t}function Fe(e){if(e.disposed)return;if(e._stable){ae(e);return}Ce(e),ue(e,"effect cleanup");let n=k;k=e;try{let t=e.fn();typeof t=="function"&&(e._cleanup=t)}catch(t){throw t===Pe||C?.onError&&C.onError(t,{type:"effect",effect:e}),t}finally{k=n}E&&C?.onEffectRun&&C.onEffectRun(e)}function Ke(e){e.disposed=!0,E&&C&&C.onEffectDispose(e),Ce(e),ue(e,"effect cleanup on dispose")}function Je(e,n,t){C?.onError&&C.onError(e,{type:"effect-cleanup",effect:n,phase:t}),E&&console.warn(`[what] Error in ${t}:`,e)}function ue(e,n){if(!e._cleanup)return;let t=e._cleanup;e._cleanup=null;try{t()}catch(r){Je(r,e,n)}}function ae(e){let n=k;k=null;try{ue(e,"stable effect cleanup");let t=e.fn();typeof t=="function"&&(e._cleanup=t)}catch(t){C?.onError&&C.onError(t,{type:"effect",effect:e}),E&&console.warn("[what] Error in stable effect:",t)}finally{k=n}E&&C?.onEffectRun&&C.onEffectRun(e)}function Ce(e){let n=e.deps;for(let t=0;t<n.length;t++)n[t].delete(e);n.length=0}var ce=0,U=null,V=0;function _e(e){if(ce===0){ce=1;try{for(let n of e)if(!n.disposed){if(n._onNotify)n._onNotify();else if(se===0&&n._stable)ae(n);else if(!n._pending){n._pending=!0;let t=n._level,r=I.length;r>0&&I[r-1]._level>t&&(Y=!0),I.push(n)}}if(V>0){let n=0;for(;n<V;){let t=U[n];U[n]=null,n++;for(let r of t)if(!r.disposed){if(r._onNotify)r._onNotify();else if(se===0&&r._stable)ae(r);else if(!r._pending){r._pending=!0;let o=r._level,i=I.length;i>0&&I[i-1]._level>o&&(Y=!0),I.push(r)}}}V=0}}finally{ce=0}se===0&&I.length>0&&Xe()}else U===null&&(U=[]),V>=U.length?U.push(e):U[V]=e,V++}var fe=!1;function Xe(){fe||(fe=!0,queueMicrotask(()=>{fe=!1,Ye()}))}var le=!1;function Ye(){if(!le){le=!0;try{let e=0;for(;I.length>0&&e<25;){let n=I;I=[],n.length>1&&Y&&n.sort((t,r)=>t._level-r._level),Y=!1;for(let t=0;t<n.length;t++){let r=n[t];if(r._pending=!1,!r.disposed&&!r._onNotify){let o=r.deps.length;Fe(r),!r._computed&&r.deps.length!==o&&we(r)}}e++}if(e>=25){for(let n=0;n<I.length;n++)I[n]._pending=!1;if(I.length=0,E){let t=I.slice(0,3).map(r=>r.fn?.name||r.fn?.toString().slice(0,60)||"(anonymous)");console.warn(`[what] Possible infinite effect loop detected (25 iterations). Likely cause: an effect writes to a signal it also reads, creating a cycle. Use untrack() to read signals without subscribing. Looping effects: ${t.join(", ")}`)}else console.warn("[what] Possible infinite effect loop detected")}}finally{le=!1}}}function de(e){let n=k;k=null;try{return e()}finally{k=n}}function j(e){let n=F,t=W,r={disposals:[],owner:W,children:[],_disposed:!1};W&&W.children.push(r),F=r,W=r;try{return e(()=>{if(!r._disposed){r._disposed=!0;for(let i=r.children.length-1;i>=0;i--)be(r.children[i]);r.children.length=0;for(let i=r.disposals.length-1;i>=0;i--)r.disposals[i]();if(r.disposals.length=0,r.owner){let i=r.owner.children.indexOf(r);i>=0&&r.owner.children.splice(i,1)}}})}finally{F=n,W=t}}function be(e){if(!e._disposed){e._disposed=!0;for(let n=e.children.length-1;n>=0;n--)be(e.children[n]);e.children.length=0;for(let n=e.disposals.length-1;n>=0;n--)e.disposals[n]();e.disposals.length=0}}var Ee=null;function xe(e){Ee=e}function Se(e,n){let t=n||Ee?.();for(;t;){if(t._errorBoundary)return t._errorBoundary(e),!0;t=t._parentCtx}return!1}var Ze=null;function Ne(e){Ze=e}var Qe=new Set(["href","src","action","formaction","poster","cite","background","xlink:href"]),et=new Set(["srcset"]);function pe(e){return String(e).toLowerCase()}function tt(e){return String(e).trim().replace(/[\s\x00-\x1f\x7f]/g,"").toLowerCase()}function Le(e){if(typeof e!="string")return!0;let n=tt(e);return!(n.startsWith("javascript:")||n.startsWith("data:")||n.startsWith("vbscript:"))}function nt(e){return typeof e!="string"?!0:e.split(",").every(n=>{let t=n.trim().split(/\s+/,1)[0]||"";return t===""||Le(t)})}function rt(e){return Qe.has(pe(e))}function ot(e){return et.has(pe(e))}function Z(e,n){return ot(e)?nt(n):rt(e)?Le(n):!0}function Q(e){return e==="className"?"class":e==="htmlFor"?"for":pe(e)==="formaction"?"formaction":e}var it=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","symbol","clipPath","mask","pattern","image","text","tspan","textPath","foreignObject","linearGradient","radialGradient","stop","marker","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),st="http://www.w3.org/2000/svg",Te=new Set,ee=new WeakMap;function ct(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function he(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function Ae(e){if(!e.disposed){if(e.disposed=!0,e.cleanups)for(let n of e.cleanups)try{n()}catch(t){console.error("[what] cleanup error:",t)}if(e.effects)for(let n of e.effects)try{n()}catch{}if(e.hooks){for(let n of e.hooks)if(n&&typeof n.cleanup=="function")try{n.cleanup()}catch(t){console.error("[what] hook cleanup error:",t)}}if(e._cleanupCallbacks)for(let n of e._cleanupCallbacks)try{n()}catch(t){console.error("[what] onCleanup error:",t)}E&&C?.onComponentUnmount&&C.onComponentUnmount(e),Te.delete(e)}}function v(e){if(!e)return;e._componentCtx&&Ae(e._componentCtx);let n=ee.get(e);if(n&&Ae(n),e._dispose)try{e._dispose()}catch{}if(e._propEffects)for(let t in e._propEffects)try{e._propEffects[t]()}catch{}if(e.childNodes)for(let t of e.childNodes)v(t)}function H(e,n,t){if(e==null||e===!1||e===!0)return document.createComment("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(ct(e))return e;if(typeof e=="function"){let r=document.createComment("fn"),o=document.createComment("/fn"),i=[],l=document.createDocumentFragment();l.appendChild(r),l.appendChild(o);let s=M(()=>{let f=e(),c=f==null||f===!1||f===!0?[]:Array.isArray(f)?f:[f],p=o.parentNode;if(p){for(let u of i)v(u),u.parentNode===p&&p.removeChild(u);i=[];for(let u of c){let _=H(u,p,n?._isSvg);if(_)if(_.nodeType===11){let y=Array.from(_.childNodes);p.insertBefore(_,o);for(let m of y)i.push(m)}else p.insertBefore(_,o),i.push(_)}}});return r._dispose=s,o._dispose=s,l}if(Array.isArray(e)){let r=document.createDocumentFragment();for(let o of e){let i=H(o,n,t);i&&r.appendChild(i)}return r}return he(e)&&typeof e.tag=="function"||he(e)&&(e.tag==="__errorBoundary"||e.tag==="__suspense"||e.tag==="__portal")?Me(e,n,t):he(e)?ut(e,n,t):document.createTextNode(String(e))}var A=[];function ke(){return A[A.length-1]}xe(ke);Ne(ke);function Re(){return A}function Me(e,n,t){let{tag:r,props:o,children:i}=e;if(typeof r=="function"&&(r.prototype?.isReactComponent||r.prototype?.render)){let h=r;r=function(d){return new h(d).render()},r.displayName=h.displayName||h.name||"ClassComponent"}if(r==="__errorBoundary"||e.tag==="__errorBoundary")return ft(e,n);if(r==="__suspense"||e.tag==="__suspense")return lt(e,n);if(r==="__portal"||e.tag==="__portal")return at(e,n);let l={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:r,_parentCtx:A[A.length-1]||null,_errorBoundary:(()=>{let h=A[A.length-1];for(;h;){if(h._errorBoundary)return h._errorBoundary;h=h._parentCtx}return null})()},s=document.createComment("c:start"),f=document.createComment("c:end");ee.set(s,l),l._startComment=s,l._endComment=f;let c=document.createDocumentFragment();c._componentCtx=l,l._wrapper=s,Te.add(l),E&&C?.onComponentMount&&C.onComponentMount(l);let p=i.length===0?void 0:i.length===1?i[0]:i,u=q({...o,children:p});l._propsSignal=u;let _=new Proxy({},{get(h,b){return u()[b]},has(h,b){let d=u();return b in d},ownKeys(){let h=u();return Reflect.ownKeys(h)},getOwnPropertyDescriptor(h,b){let d=u();if(b in d)return{value:d[b],writable:!1,enumerable:!0,configurable:!0}}});A.push(l);let y;try{y=r(_)}catch(h){if(A.pop(),!Se(h,l))throw console.error("[what] Uncaught error in component:",r.name||"Anonymous",h),h;return c.appendChild(s),c.appendChild(f),c}A.pop(),l.mounted=!0,l._mountCallbacks&&queueMicrotask(()=>{if(!l.disposed)for(let h of l._mountCallbacks)try{h()}catch(b){console.error("[what] onMount error:",b)}}),c.appendChild(s);let m=Array.isArray(y)?y:[y];for(let h of m){let b=H(h,c,t);b&&c.appendChild(b)}return c.appendChild(f),c}function ft(e,n){let{errorState:t,handleError:r,fallback:o,reset:i}=e.props,l=e.children,s=document.createComment("eb:start"),f=document.createComment("eb:end"),c={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:A[A.length-1]||null,_errorBoundary:r,_startComment:s,_endComment:f};ee.set(s,c);let p=document.createDocumentFragment();p._componentCtx=c,p.appendChild(s),p.appendChild(f);let u=M(()=>{let _=t();if(A.push(c),s.parentNode)for(;s.nextSibling&&s.nextSibling!==f;){let m=s.nextSibling;v(m),m.parentNode.removeChild(m)}let y;_?y=typeof o=="function"?[o({error:_,reset:i})]:[o]:y=l,y=Array.isArray(y)?y:[y];for(let m of y){let h=H(m,n);h&&(f.parentNode?f.parentNode.insertBefore(h,f):p.insertBefore(h,f))}A.pop()});return c.effects.push(u),p}function lt(e,n){let{boundary:t,fallback:r,loading:o}=e.props,i=e.children,l=document.createComment("sb:start"),s=document.createComment("sb:end"),f={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:A[A.length-1]||null,_startComment:l,_endComment:s};ee.set(l,f);let c=document.createDocumentFragment();c._componentCtx=f,c.appendChild(l),c.appendChild(s);let p=M(()=>{let _=o()?[r]:i,y=Array.isArray(_)?_:[_];if(A.push(f),l.parentNode)for(;l.nextSibling&&l.nextSibling!==s;){let m=l.nextSibling;v(m),m.parentNode.removeChild(m)}for(let m of y){let h=H(m,n);h&&(s.parentNode?s.parentNode.insertBefore(h,s):c.insertBefore(h,s))}A.pop()});return f.effects.push(p),c}function at(e,n){let{container:t}=e.props,r=e.children;if(!t)return console.warn("[what] Portal: target container not found"),document.createComment("portal:empty");let o={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:A[A.length-1]||null},i=document.createComment("portal");i._componentCtx=o;let l=[];for(let s of r){let f=H(s,t);f&&(t.appendChild(f),l.push(f))}return o._cleanupCallbacks=[()=>{for(let s of l)v(s),s.parentNode&&s.parentNode.removeChild(s)}],i}function ut(e,n,t){let{tag:r,props:o,children:i}=e,l=t||it.has(r),s=l?document.createElementNS(st,r):document.createElement(r);o&&dt(s,o,{},l);for(let f of i){let c=H(f,s,l&&r!=="foreignObject");c&&s.appendChild(c)}return s._vnode=e,s}function dt(e,n,t,r){n=n||{},t=t||{};for(let o in n)if(!(o==="key"||o==="children")){if(o==="ref"){typeof n.ref=="function"?n.ref(e):n.ref&&(n.ref.current=e);continue}Ie(e,o,n[o],r)}}function Ie(e,n,t,r){if(n.startsWith("on")&&n.length>2){let o=n.slice(2),i=!1;o.endsWith("Capture")&&(o=o.slice(0,-7),i=!0);let l=o.toLowerCase(),s=i?l+"_capture":l,f=e._events?.[s];if(f&&f._original===t||(f&&e.removeEventListener(l,f,i),t==null))return;e._events||(e._events={});let c=u=>(u.nativeEvent||(u.nativeEvent=u),de(()=>t(u)));c._original=t,e._events[s]=c;let p=t._eventOpts;e.addEventListener(l,c,p||i||void 0);return}if(n==="ref"){typeof t=="function"?t(e):t&&(t.current=e);return}if(!Z(n,t)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${t}`),e.removeAttribute(Q(n));return}if(typeof t=="function"){if(e._propEffects||(e._propEffects={}),e._propEffects[n])try{e._propEffects[n]()}catch{}e._propEffects[n]=M(()=>{let o=t();Ie(e,n,o,r)});return}if(n==="className"||n==="class"){r?e.setAttribute("class",t||""):e.className=t||"";return}if(n==="style"){if(typeof t=="string")e.style.cssText=t,e._prevStyle=null;else if(typeof t=="object"){let o=e._prevStyle||{};for(let i in o)i in t||(e.style[i]="");for(let i in t)e.style[i]=t[i]??"";e._prevStyle={...t}}return}if(n==="dangerouslySetInnerHTML"){e.innerHTML=t?.__html??"";return}if(n==="innerHTML"){if(t==null)return;if(t&&typeof t=="object"&&"__html"in t)e.innerHTML=t.__html??"";else{E&&console.warn("[what] innerHTML received a raw string. This is a security risk (XSS). Use innerHTML={{ __html: trustedString }} or dangerouslySetInnerHTML={{ __html: trustedString }} instead.");return}return}if(typeof t=="boolean"){t?e.setAttribute(n,""):e.removeAttribute(n);return}if(n.startsWith("data-")||n.startsWith("aria-")){e.setAttribute(n,t);return}if(r){t===!1||t==null?e.removeAttribute(n):e.setAttribute(n,t===!0?"":String(t));return}n in e?e[n]=t:e.setAttribute(n,t)}var pt={INFINITE_EFFECT:{code:"ERR_INFINITE_EFFECT",severity:"error",template:'Effect "{{effectName}}" exceeded 25 flush iterations \u2014 likely an infinite loop.',suggestion:"An effect is writing to a signal it also reads, creating a cycle. Use untrack() to read the signal without subscribing, or restructure so the write and read are in separate effects.",codeExample:`// Bad \u2014 reads and writes count, creating a cycle:
|
|
2
2
|
effect(() => { count(count() + 1); });
|
|
3
3
|
|
|
4
4
|
// Good \u2014 use untrack() so the read doesn't subscribe:
|
|
@@ -55,5 +55,5 @@ html\`<div>\${sanitizedContent}</div>\``},MISSING_KEY:{code:"ERR_MISSING_KEY",se
|
|
|
55
55
|
<For each={items()}>{item => <li>{item.name}</li>}</For>
|
|
56
56
|
|
|
57
57
|
// Good \u2014 stable key:
|
|
58
|
-
<For each={items()}>{item => <li key={item.id}>{item.name}</li>}</For>`}},ne=class extends Error{constructor({code:n,message:t,suggestion:r,file:o,line:i,component:l,signal:s,effect:f}){super(t),this.name="WhatError",this.code=n,this.suggestion=r,this.file=o,this.line=i,this.component=l,this.signal=s,this.effect=f}toJSON(){return{code:this.code,message:this.message,suggestion:this.suggestion,file:this.file,line:this.line,component:this.component,signal:this.signal,effect:this.effect}}};function Ie(e,n={}){let t=typeof e=="string"?at[e]:e;if(!t)return new ne({code:"ERR_UNKNOWN",message:`Unknown error: ${e}`,suggestion:"Check the error code and try again."});let r=t.template;for(let[o,i]of Object.entries(n))r=r.replace(new RegExp(`\\{\\{${o}\\}\\}`,"g"),String(i));return r=r.replace(/\{\{[^}]+\}\}/g,"(unknown)"),new ne({code:t.code,message:r,suggestion:t.suggestion,file:n.file,line:n.line,component:n.component,signal:n.signal||n.signalName,effect:n.effect||n.effectName})}var te=[],Re=200;function De(e){b&&(te.push({...e.toJSON(),timestamp:Date.now()}),te.length>Re&&(te=te.slice(-Re)))}function Wt(e,n,t){if(t&&t.length>0){let r=t.length===1?t[0]:t;n=n?{...n,children:r}:{children:r}}return v({tag:e,props:n||{},children:t||[],key:null,_vnode:!0})}var ut={tr:{depth:2,wrap:"<table><tbody>",unwrap:"</tbody></table>"},td:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},th:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},thead:{depth:1,wrap:"<table>",unwrap:"</table>"},tbody:{depth:1,wrap:"<table>",unwrap:"</table>"},tfoot:{depth:1,wrap:"<table>",unwrap:"</table>"},colgroup:{depth:1,wrap:"<table>",unwrap:"</table>"},col:{depth:1,wrap:"<table>",unwrap:"</table>"},caption:{depth:1,wrap:"<table>",unwrap:"</table>"}},dt=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","text","tspan","foreignObject","clipPath","mask","pattern","linearGradient","radialGradient","stop","marker","symbol","image","animate","animateTransform","animateMotion","set","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feImage","feMorphology","feSpecularLighting","feTile","feTurbulence","feDistantLight","fePointLight","feSpotLight"]);function $e(e){let n=e.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return n?n[1]:""}function pt(e){let n=e.trim(),t=$e(n);if(dt.has(t))return ht(n);let r=ut[t];if(r){let i=document.createElement("template");return i.innerHTML=r.wrap+n+r.unwrap,()=>{let l=i.content.firstChild;for(let s=0;s<r.depth;s++)l=l.firstChild;return l.cloneNode(!0)}}let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}var ve=!1;function Gt(e){return b&&!ve&&(ve=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),pt(e)}function ht(e){let n=e.trim();if($e(n)==="svg"){let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}let r=document.createElement("template");return r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${n}</svg>`,()=>r.content.firstChild.firstChild.cloneNode(!0)}function Vt(e,n,t){if(typeof n=="function"){let r=null;return T(()=>{r=oe(e,n(),r,t||null)}),r}return oe(e,n,null,t||null)}function Ue(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function mt(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function gt(e){return typeof SVGElement<"u"&&e instanceof SVGElement&&e.tagName.toLowerCase()!=="foreignobject"}function He(e){return e==null?[]:Array.isArray(e)?e:[e]}function je(e,n,t){if(e==null||typeof e=="boolean")return t;if(Array.isArray(e)){for(let r=0;r<e.length;r++)je(e[r],n,t);return t}return typeof e=="string"||typeof e=="number"?(t.push(document.createTextNode(String(e))),t):Ue(e)?(t.push(e),t):mt(e)?(t.push(v(e,n,gt(n))),t):(t.push(document.createTextNode(String(e))),t)}function yt(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function oe(e,n,t,r){if(!e||typeof e.insertBefore!="function")return b&&console.warn("[what] reconcileInsert called with invalid parent:",e),t;let o=r||null;if(n==null||typeof n=="boolean"){let c=He(t);for(let p=0;p<c.length;p++){let u=c[p];u.parentNode===e&&(H(u),e.removeChild(u))}return null}if((typeof n=="string"||typeof n=="number")&&t&&!Array.isArray(t)&&t.nodeType===3){let c=String(n);return t.textContent!==c&&(t.textContent=c),t}let i=je(n,e,[]),l=He(t);if(yt(l,i))return t;let s=new Set(i);for(let c=0;c<l.length;c++){let p=l[c];!s.has(p)&&p.parentNode===e&&(H(p),e.removeChild(p))}let f=o;for(let c=i.length-1;c>=0;c--){let p=i[c];(p.parentNode!==e||p.nextSibling!==f)&&(f&&f.parentNode!==e&&(f=null),f?e.insertBefore(p,f):e.appendChild(p)),f=p}return i.length===0?null:i.length===1?i[0]:i}function qt(e,n,t){let r=t?.key,o=t?.raw||!1;return(i,l)=>{let s=[],f=[],c=[],p=r&&!o?new Map:null,u=document.createComment("/list");return i.insertBefore(u,l||null),T(()=>{let _=e()||[];r?bt(i,u,s,_,f,c,n,r,p):_t(i,u,s,_,f,c,n),s=_.slice()}),u}}function _t(e,n,t,r,o,i,l){let s=r.length,f=t.length;if(s===0){if(f>0){for(let d=0;d<f;d++)i[d]?.(),o[d]?.parentNode===e&&(H(o[d]),e.removeChild(o[d]));o.length=0,i.length=0}return}if(f===0){let d=document.createDocumentFragment();for(let g=0;g<s;g++){let x=r[g],N=j(k=>(i[g]=k,l(x,g)));o[g]=N,d.appendChild(N)}e.insertBefore(d,n);return}let c=0,p=Math.min(f,s);for(;c<p&&t[c]===r[c];)c++;if(c===f&&c===s)return;let u=f-1,_=s-1;for(;u>=c&&_>=c&&t[u]===r[_];)u--,_--;let y=new Array(s),m=new Array(s);for(let d=0;d<c;d++)y[d]=o[d],m[d]=i[d];for(let d=_+1;d<s;d++){let g=u+1+(d-_-1);y[d]=o[g],m[d]=i[g]}let h=_-c+1,E=u-c+1;if(h===0)for(let d=c;d<=u;d++)i[d]?.(),o[d]?.parentNode&&o[d].parentNode.removeChild(o[d]);else if(E===0){let d=c<s&&y[_+1]?y[_+1]:n,g=document.createDocumentFragment();for(let x=c;x<=_;x++){let N=r[x],k=x;y[x]=j(R=>(m[k]=R,l(N,k))),g.appendChild(y[x])}e.insertBefore(g,d)}else wt(e,n,t,r,o,i,l,c,u,_,y,m);o.length=s,i.length=s;for(let d=0;d<s;d++)o[d]=y[d],i[d]=m[d]}function wt(e,n,t,r,o,i,l,s,f,c,p,u){let _=new Map;for(let g=s;g<=f;g++)_.set(t[g],g);let y=c-s+1,m=new Int32Array(y);m.fill(-1);for(let g=s;g<=c;g++){let x=_.get(r[g]);x!==void 0&&(_.delete(r[g]),p[g]=o[x],u[g]=i[x],m[g-s]=x)}for(let[,g]of _)i[g]?.(),o[g]?.parentNode&&o[g].parentNode.removeChild(o[g]);let h=y-Ct(m,y),E=new Uint8Array(y);if(h>1){let g=new Int32Array(h),x=new Int32Array(h),N=0;for(let R=0;R<y;R++)m[R]!==-1&&(g[N]=m[R],x[N]=R,N++);let k=We(g,h);for(let R=0;R<k.length;R++)E[x[k[R]]]=1}else if(h===1){for(let g=0;g<y;g++)if(m[g]!==-1){E[g]=1;break}}for(let g=s;g<=c;g++)if(!p[g]){let x=r[g],N=g;p[g]=j(k=>(u[N]=k,l(x,N)))}let d=c+1<p.length&&p[c+1]?p[c+1]:n;for(let g=c;g>=s;g--){let x=g-s;(m[x]===-1||!E[x])&&(d&&d.parentNode!==e&&(d=n),e.insertBefore(p[g],d)),d=p[g]}}function Ct(e,n){let t=0;for(let r=0;r<n;r++)e[r]===-1&&t++;return t}function We(e,n){if(n===0)return[];if(n===1)return[0];let t=new Int32Array(n),r=new Int32Array(n),o=1;t[0]=0,r[0]=-1;for(let s=1;s<n;s++)if(e[s]>e[t[o-1]])r[s]=t[o-1],t[o++]=s;else{let f=0,c=o-1;for(;f<c;){let p=f+c>>1;e[t[p]]<e[s]?f=p+1:c=p}t[f]=s,r[s]=f>0?t[f-1]:-1}let i=new Array(o),l=t[o-1];for(let s=o-1;s>=0;s--)i[s]=l,l=r[l];return i}function bt(e,n,t,r,o,i,l,s,f){let c=r.length,p=t.length;if(c===0){if(p>0){for(let a=0;a<p;a++)i[a]?.(),o[a]?.parentNode===e&&(H(o[a]),e.removeChild(o[a]));o.length=0,i.length=0,f&&f.clear()}return}if(p===0){let a=document.createDocumentFragment();for(let C=0;C<c;C++){let S=r[C],D=C,A;if(f){let $=s(S),z=q(S);A=z,f.set($,{itemSig:z})}else A=S;let B=j($=>(i[D]=$,l(A,D)));o[C]=B,a.appendChild(B)}e.insertBefore(a,n);return}let u=0,_=Math.min(p,c);for(;u<_;){if(t[u]===r[u]){u++;continue}let a=s(t[u]),C=s(r[u]);if(a!==C)break;f&&f.get(a).itemSig.set(r[u]),u++}let y=p-1,m=c-1;for(;y>=u&&m>=u;){if(t[y]===r[m]){y--,m--;continue}let a=s(t[y]),C=s(r[m]);if(a!==C)break;f&&f.get(a).itemSig.set(r[m]),y--,m--}if(u>y&&u>m)return;let h=new Array(c),E=new Array(c);for(let a=0;a<u;a++)h[a]=o[a],E[a]=i[a];for(let a=m+1;a<c;a++){let C=y+1+(a-m-1);h[a]=o[C],E[a]=i[C]}let d=m-u+1;if(y-u+1===0){let a=m+1<c&&h[m+1]?h[m+1]:n,C=document.createDocumentFragment();for(let S=u;S<=m;S++){let D=r[S],A=S,B;if(f){let $=s(D),z=q(D);B=z,f.set($,{itemSig:z})}else B=D;h[S]=j($=>(E[A]=$,l(B,A))),C.appendChild(h[S])}e.insertBefore(C,a),pe(o,i,h,E,c);return}if(d===0){for(let a=u;a<=y;a++)i[a]?.(),o[a]?.parentNode&&e.removeChild(o[a]),f&&f.delete(s(t[a]));pe(o,i,h,E,c);return}let x=new Map;for(let a=u;a<=y;a++)x.set(s(t[a]),a);let N=new Int32Array(d);N.fill(-1);for(let a=u;a<=m;a++){let C=s(r[a]),S=x.get(C);S!==void 0&&(x.delete(C),h[a]=o[S],E[a]=i[S],N[a-u]=S,f&&r[a]!==t[S]&&f.get(C).itemSig.set(r[a]))}for(let[a,C]of x)i[C]?.(),o[C]?.parentNode&&e.removeChild(o[C]),f&&f.delete(a);for(let a=u;a<=m;a++)if(!h[a]){let C=r[a],S=a,D;if(f){let A=s(C),B=q(C);D=B,f.set(A,{itemSig:B})}else D=C;h[a]=j(A=>(E[S]=A,l(D,S)))}let k=0,R=!0,he=-1;for(let a=0;a<d;a++)N[a]!==-1&&(k++,N[a]<=he&&(R=!1),he=N[a]);let X=new Uint8Array(d);if(R)for(let a=0;a<d;a++)N[a]!==-1&&(X[a]=1);else if(k>1){let a=new Int32Array(k),C=new Int32Array(k),S=0;for(let A=0;A<d;A++)N[A]!==-1&&(a[S]=N[A],C[S]=A,S++);let D=We(a,k);for(let A=0;A<D.length;A++)X[C[D[A]]]=1}else if(k===1){for(let a=0;a<d;a++)if(N[a]!==-1){X[a]=1;break}}let P=m+1<h.length&&h[m+1]?h[m+1]:n;for(let a=m;a>=u;a--){let C=a-u;(N[C]===-1||!X[C])&&(P&&P.parentNode!==e&&(P=n),e.insertBefore(h[a],P)),P=h[a]}pe(o,i,h,E,c)}function pe(e,n,t,r,o){e.length=o,n.length=o;for(let i=0;i<o;i++)e[i]=t[i],n[i]=r[i]}function Pt(e,n){for(let t in n){let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}typeof r=="function"&&!t.startsWith("on")?t==="class"||t==="className"?T(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?T(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):T(()=>{J(e,t,r())}):J(e,t,r)}}function J(e,n,t){if(n==="ref"){typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e);return}if(n!=="key"){if(!Z(n,t)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${t}`),e.removeAttribute(Q(n));return}if(n==="class"||n==="className")e.className=t||"";else if(n==="dangerouslySetInnerHTML")e.innerHTML=t?.__html??"";else if(n==="innerHTML")t&&typeof t=="object"&&"__html"in t?e.innerHTML=t.__html??"":typeof console<"u"&&t!=null&&t!==""&&console.warn('[what] Plain string innerHTML is not allowed. Use { __html: "..." } or dangerouslySetInnerHTML={{ __html: "..." }} instead.');else if(n==="style"){if(typeof t=="string")e.style.cssText=t;else if(typeof t=="object")for(let r in t)e.style[r]=t[r]??""}else n.startsWith("data-")||n.startsWith("aria-")?e.setAttribute(n,t):typeof t=="boolean"?t?e.setAttribute(n,""):e.removeAttribute(n):n in e?e[n]=t:e.setAttribute(n,t)}}var Be=new Set;function zt(e){for(let n of e)Be.has(n)||(Be.add(n),document.addEventListener(n,t=>{let r=t.target,o="$$"+n;for(;r;){let i=r[o];if(i&&(i(t),t.cancelBubble))return;r=r.parentNode}}))}function Ft(e,n,t){return e.addEventListener(n,t),()=>e.removeEventListener(n,t)}function Kt(e,n){T(()=>{for(let t in n){let r=typeof n[t]=="function"?n[t]():n[t];e.classList.toggle(t,!!r)}})}var ie=!1,O=null;function Jt(){return ie}function Xt(e,n){ie=!0,O={parent:n,index:0},W=0;try{let t=K(e,n);return b&&W>0&&console.warn(`[what] Hydration completed with ${W} mismatch${W===1?"":"es"}. See previous warnings for details. This usually means server and client render different initial HTML.`),t}finally{ie=!1,O=null}}function Oe(e){let n=e.childNodes;for(;O.index<n.length;){let t=n[O.index];if(t.nodeType===8){let r=t.textContent;if(r==="$"||r==="/$"||r==="[]"||r==="/[]"){O.index++;continue}}return O.index++,t}return null}var W=0;function Yt(){return W}function re(e,n,t){if(W++,b){let o=Ie("HYDRATION_MISMATCH",{component:t||"unknown",serverHTML:n,clientHTML:e});De(o),w?.onHydrationMismatch&&w.onHydrationMismatch({component:t||"unknown",expected:e,actual:n,mismatchCount:W}),w?.onError&&w.onError(o,{type:"hydration",component:t}),console.warn(`[what] Hydration mismatch: expected ${e}, got ${n}`+(t?` (in ${t})`:"")+". Falling back to client render.")}}function K(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let o=Oe(n),i=String(e);if(o&&o.nodeType===3)return b&&o.textContent!==i&&(re(`text "${i}"`,`text "${o.textContent}"`,t),o.textContent=i),o;re(`text node "${i}"`,o?o.nodeName:"nothing",t);let l=document.createTextNode(i);return o?n.replaceChild(l,o):n.appendChild(l),l}if(typeof e=="function"){let o=e(),i=K(o,n,t);return T(()=>{let l=e();ie||(i=oe(n,l,i,null))}),i}if(Array.isArray(e)){let o=[];for(let i of e){let l=K(i,n,t);l&&o.push(l)}return o.length===1?o[0]:o}if(typeof e=="object"&&e._vnode){if(typeof e.tag=="function"){let s=Te(),f=e.tag,c=f.displayName||f.name||"Anonymous",p=e.props||{},u=e.children||[],_={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:f,_parentCtx:s[s.length-1]||null,_errorBoundary:null};s.push(_);let y;try{let m=u.length===0?void 0:u.length===1?u[0]:u;y=f({...p,children:m})}catch(m){return s.pop(),b&&console.error("[what] Error in component during hydration:",c,m),null}return s.pop(),_.mounted=!0,_._mountCallbacks&&queueMicrotask(()=>{if(!_.disposed)for(let m of _._mountCallbacks)try{m()}catch(h){console.error("[what] onMount error:",h)}}),K(y,n,c)}let o=Oe(n),i=e.tag.toUpperCase();if(o&&o.nodeType===1&&o.nodeName===i){if(Et(o,e.props||{}),e.props?.ref){let c=e.props.ref;typeof c=="function"?c(o):typeof c=="object"&&c!==null&&(c.current=o)}let s=O;if(O={parent:o,index:0},e.props?.dangerouslySetInnerHTML?.__html==null)for(let c of e.children)K(c,o,t);return O=s,o}re(`<${e.tag}>`,o?o.nodeName:"nothing",t);let l=document.createElement(e.tag);for(let s in e.props||{})s==="children"||s==="key"||J(l,s,e.props[s]);for(let s of e.children)oe(l,s,null,null);return o?n.replaceChild(l,o):n.appendChild(l),l}if(Ue(e))return e;let r=document.createTextNode(String(e));return n.appendChild(r),r}function Et(e,n){for(let t in n){if(t==="children"||t==="key"||t==="ref"||t==="dangerouslySetInnerHTML"||t==="innerHTML")continue;let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}if(t.startsWith("$$")){e[t]=r;continue}if(typeof r=="function"&&!t.startsWith("on")){t==="class"||t==="className"?T(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?T(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):T(()=>{J(e,t,r())});continue}if(t!=="data-hk"&&b&&typeof r=="string"){let o=t==="className"?"class":t==="htmlFor"?"for":t,i=e.getAttribute(o);i!==null&&i!==r&&(re(`${o}="${r}"`,`${o}="${i}"`,e.tagName.toLowerCase()),J(e,t,r))}}}export{Wt as _$createComponent,pt as _$template,Gt as _template,Kt as classList,zt as delegateEvents,T as effect,Yt as getHydrationMismatchCount,Xt as hydrate,Vt as insert,Jt as isHydrating,qt as mapArray,Ft as on,J as setProp,Pt as spread,ht as svgTemplate,Gt as template,ae as untrack};
|
|
58
|
+
<For each={items()}>{item => <li key={item.id}>{item.name}</li>}</For>`}},ne=class extends Error{constructor({code:n,message:t,suggestion:r,file:o,line:i,component:l,signal:s,effect:f}){super(t),this.name="WhatError",this.code=n,this.suggestion=r,this.file=o,this.line=i,this.component=l,this.signal=s,this.effect=f}toJSON(){return{code:this.code,message:this.message,suggestion:this.suggestion,file:this.file,line:this.line,component:this.component,signal:this.signal,effect:this.effect}}};function He(e,n={}){let t=typeof e=="string"?pt[e]:e;if(!t)return new ne({code:"ERR_UNKNOWN",message:`Unknown error: ${e}`,suggestion:"Check the error code and try again."});let r=t.template;for(let[o,i]of Object.entries(n))r=r.replace(new RegExp(`\\{\\{${o}\\}\\}`,"g"),String(i));return r=r.replace(/\{\{[^}]+\}\}/g,"(unknown)"),new ne({code:t.code,message:r,suggestion:t.suggestion,file:n.file,line:n.line,component:n.component,signal:n.signal||n.signalName,effect:n.effect||n.effectName})}var te=[],De=200;function ve(e){E&&(te.push({...e.toJSON(),timestamp:Date.now()}),te.length>De&&(te=te.slice(-De)))}function qt(e,n,t){if(t&&t.length>0){let r=t.length===1?t[0]:t;n=n?{...n,children:r}:{children:r}}return H({tag:e,props:n||{},children:t||[],key:null,_vnode:!0})}var ht={tr:{depth:2,wrap:"<table><tbody>",unwrap:"</tbody></table>"},td:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},th:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},thead:{depth:1,wrap:"<table>",unwrap:"</table>"},tbody:{depth:1,wrap:"<table>",unwrap:"</table>"},tfoot:{depth:1,wrap:"<table>",unwrap:"</table>"},colgroup:{depth:1,wrap:"<table>",unwrap:"</table>"},col:{depth:1,wrap:"<table>",unwrap:"</table>"},caption:{depth:1,wrap:"<table>",unwrap:"</table>"}},mt=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","text","tspan","foreignObject","clipPath","mask","pattern","linearGradient","radialGradient","stop","marker","symbol","image","animate","animateTransform","animateMotion","set","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feImage","feMorphology","feSpecularLighting","feTile","feTurbulence","feDistantLight","fePointLight","feSpotLight"]);function je(e){let n=e.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return n?n[1]:""}function gt(e){let n=e.trim(),t=je(n);if(mt.has(t))return yt(n);let r=ht[t];if(r){let i=document.createElement("template");return i.innerHTML=r.wrap+n+r.unwrap,()=>{let l=i.content.firstChild;for(let s=0;s<r.depth;s++)l=l.firstChild;return l.cloneNode(!0)}}let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}var Be=!1;function Pt(e){return E&&!Be&&(Be=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),gt(e)}function yt(e){let n=e.trim();if(je(n)==="svg"){let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}let r=document.createElement("template");return r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${n}</svg>`,()=>r.content.firstChild.firstChild.cloneNode(!0)}function zt(e,n,t){if(typeof n=="function"){let r=null;return M(()=>{r=oe(e,n(),r,t||null)}),r}return oe(e,n,null,t||null)}function Ge(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function _t(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function wt(e){return typeof SVGElement<"u"&&e instanceof SVGElement&&e.tagName.toLowerCase()!=="foreignobject"}function Oe(e){return e==null?[]:Array.isArray(e)?e:[e]}function We(e,n,t){if(e==null||typeof e=="boolean")return t;if(Array.isArray(e)){for(let r=0;r<e.length;r++)We(e[r],n,t);return t}return typeof e=="string"||typeof e=="number"?(t.push(document.createTextNode(String(e))),t):Ge(e)?(t.push(e),t):_t(e)?(t.push(H(e,n,wt(n))),t):(t.push(document.createTextNode(String(e))),t)}function Ct(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function oe(e,n,t,r){if(!e||typeof e.insertBefore!="function")return E&&console.warn("[what] reconcileInsert called with invalid parent:",e),t;let o=r||null;if(n==null||typeof n=="boolean"){let c=Oe(t);for(let p=0;p<c.length;p++){let u=c[p];u.parentNode===e&&(v(u),e.removeChild(u))}return null}if((typeof n=="string"||typeof n=="number")&&t&&!Array.isArray(t)&&t.nodeType===3){let c=String(n);return t.textContent!==c&&(t.textContent=c),t}let i=We(n,e,[]),l=Oe(t);if(Ct(l,i))return t;let s=new Set(i);for(let c=0;c<l.length;c++){let p=l[c];!s.has(p)&&p.parentNode===e&&(v(p),e.removeChild(p))}let f=o;for(let c=i.length-1;c>=0;c--){let p=i[c];(p.parentNode!==e||p.nextSibling!==f)&&(f&&f.parentNode!==e&&(f=null),f?e.insertBefore(p,f):e.appendChild(p)),f=p}return i.length===0?null:i.length===1?i[0]:i}function Ft(e,n,t){let r=t?.key,o=t?.raw||!1;return(i,l)=>{let s=[],f=[],c=[],p=r&&!o?new Map:null,u=document.createComment("/list");return i.insertBefore(u,l||null),M(()=>{let _=e()||[];r?St(i,u,s,_,f,c,n,r,p):bt(i,u,s,_,f,c,n),s=_.slice()}),u}}function bt(e,n,t,r,o,i,l){let s=r.length,f=t.length;if(s===0){if(f>0){for(let d=0;d<f;d++)i[d]?.(),o[d]?.parentNode===e&&(v(o[d]),e.removeChild(o[d]));o.length=0,i.length=0}return}if(f===0){let d=document.createDocumentFragment();for(let g=0;g<s;g++){let x=r[g],N=j(T=>(i[g]=T,l(x,g)));o[g]=N,d.appendChild(N)}e.insertBefore(d,n);return}let c=0,p=Math.min(f,s);for(;c<p&&t[c]===r[c];)c++;if(c===f&&c===s)return;let u=f-1,_=s-1;for(;u>=c&&_>=c&&t[u]===r[_];)u--,_--;let y=new Array(s),m=new Array(s);for(let d=0;d<c;d++)y[d]=o[d],m[d]=i[d];for(let d=_+1;d<s;d++){let g=u+1+(d-_-1);y[d]=o[g],m[d]=i[g]}let h=_-c+1,b=u-c+1;if(h===0)for(let d=c;d<=u;d++)i[d]?.(),o[d]?.parentNode&&o[d].parentNode.removeChild(o[d]);else if(b===0){let d=c<s&&y[_+1]?y[_+1]:n,g=document.createDocumentFragment();for(let x=c;x<=_;x++){let N=r[x],T=x;y[x]=j(R=>(m[T]=R,l(N,T))),g.appendChild(y[x])}e.insertBefore(g,d)}else Et(e,n,t,r,o,i,l,c,u,_,y,m);o.length=s,i.length=s;for(let d=0;d<s;d++)o[d]=y[d],i[d]=m[d]}function Et(e,n,t,r,o,i,l,s,f,c,p,u){let _=new Map;for(let g=s;g<=f;g++)_.set(t[g],g);let y=c-s+1,m=new Int32Array(y);m.fill(-1);for(let g=s;g<=c;g++){let x=_.get(r[g]);x!==void 0&&(_.delete(r[g]),p[g]=o[x],u[g]=i[x],m[g-s]=x)}for(let[,g]of _)i[g]?.(),o[g]?.parentNode&&o[g].parentNode.removeChild(o[g]);let h=y-xt(m,y),b=new Uint8Array(y);if(h>1){let g=new Int32Array(h),x=new Int32Array(h),N=0;for(let R=0;R<y;R++)m[R]!==-1&&(g[N]=m[R],x[N]=R,N++);let T=Ve(g,h);for(let R=0;R<T.length;R++)b[x[T[R]]]=1}else if(h===1){for(let g=0;g<y;g++)if(m[g]!==-1){b[g]=1;break}}for(let g=s;g<=c;g++)if(!p[g]){let x=r[g],N=g;p[g]=j(T=>(u[N]=T,l(x,N)))}let d=c+1<p.length&&p[c+1]?p[c+1]:n;for(let g=c;g>=s;g--){let x=g-s;(m[x]===-1||!b[x])&&(d&&d.parentNode!==e&&(d=n),e.insertBefore(p[g],d)),d=p[g]}}function xt(e,n){let t=0;for(let r=0;r<n;r++)e[r]===-1&&t++;return t}function Ve(e,n){if(n===0)return[];if(n===1)return[0];let t=new Int32Array(n),r=new Int32Array(n),o=1;t[0]=0,r[0]=-1;for(let s=1;s<n;s++)if(e[s]>e[t[o-1]])r[s]=t[o-1],t[o++]=s;else{let f=0,c=o-1;for(;f<c;){let p=f+c>>1;e[t[p]]<e[s]?f=p+1:c=p}t[f]=s,r[s]=f>0?t[f-1]:-1}let i=new Array(o),l=t[o-1];for(let s=o-1;s>=0;s--)i[s]=l,l=r[l];return i}function St(e,n,t,r,o,i,l,s,f){let c=r.length,p=t.length;if(c===0){if(p>0){for(let a=0;a<p;a++)i[a]?.(),o[a]?.parentNode===e&&(v(o[a]),e.removeChild(o[a]));o.length=0,i.length=0,f&&f.clear()}return}if(p===0){let a=document.createDocumentFragment();for(let w=0;w<c;w++){let S=r[w],D=w,L;if(f){let $=s(S),z=q(S);L=z,f.set($,{itemSig:z})}else L=S;let B=j($=>(i[D]=$,l(L,D)));o[w]=B,a.appendChild(B)}e.insertBefore(a,n);return}let u=0,_=Math.min(p,c);for(;u<_;){if(t[u]===r[u]){u++;continue}let a=s(t[u]),w=s(r[u]);if(a!==w)break;f&&f.get(a).itemSig.set(r[u]),u++}let y=p-1,m=c-1;for(;y>=u&&m>=u;){if(t[y]===r[m]){y--,m--;continue}let a=s(t[y]),w=s(r[m]);if(a!==w)break;f&&f.get(a).itemSig.set(r[m]),y--,m--}if(u>y&&u>m)return;let h=new Array(c),b=new Array(c);for(let a=0;a<u;a++)h[a]=o[a],b[a]=i[a];for(let a=m+1;a<c;a++){let w=y+1+(a-m-1);h[a]=o[w],b[a]=i[w]}let d=m-u+1;if(y-u+1===0){let a=m+1<c&&h[m+1]?h[m+1]:n,w=document.createDocumentFragment();for(let S=u;S<=m;S++){let D=r[S],L=S,B;if(f){let $=s(D),z=q(D);B=z,f.set($,{itemSig:z})}else B=D;h[S]=j($=>(b[L]=$,l(B,L))),w.appendChild(h[S])}e.insertBefore(w,a),me(o,i,h,b,c);return}if(d===0){for(let a=u;a<=y;a++)i[a]?.(),o[a]?.parentNode&&e.removeChild(o[a]),f&&f.delete(s(t[a]));me(o,i,h,b,c);return}let x=new Map;for(let a=u;a<=y;a++)x.set(s(t[a]),a);let N=new Int32Array(d);N.fill(-1);for(let a=u;a<=m;a++){let w=s(r[a]),S=x.get(w);S!==void 0&&(x.delete(w),h[a]=o[S],b[a]=i[S],N[a-u]=S,f&&r[a]!==t[S]&&f.get(w).itemSig.set(r[a]))}for(let[a,w]of x)i[w]?.(),o[w]?.parentNode&&e.removeChild(o[w]),f&&f.delete(a);for(let a=u;a<=m;a++)if(!h[a]){let w=r[a],S=a,D;if(f){let L=s(w),B=q(w);D=B,f.set(L,{itemSig:B})}else D=w;h[a]=j(L=>(b[S]=L,l(D,S)))}let T=0,R=!0,ge=-1;for(let a=0;a<d;a++)N[a]!==-1&&(T++,N[a]<=ge&&(R=!1),ge=N[a]);let X=new Uint8Array(d);if(R)for(let a=0;a<d;a++)N[a]!==-1&&(X[a]=1);else if(T>1){let a=new Int32Array(T),w=new Int32Array(T),S=0;for(let L=0;L<d;L++)N[L]!==-1&&(a[S]=N[L],w[S]=L,S++);let D=Ve(a,T);for(let L=0;L<D.length;L++)X[w[D[L]]]=1}else if(T===1){for(let a=0;a<d;a++)if(N[a]!==-1){X[a]=1;break}}let P=m+1<h.length&&h[m+1]?h[m+1]:n;for(let a=m;a>=u;a--){let w=a-u;(N[w]===-1||!X[w])&&(P&&P.parentNode!==e&&(P=n),e.insertBefore(h[a],P)),P=h[a]}me(o,i,h,b,c)}function me(e,n,t,r,o){e.length=o,n.length=o;for(let i=0;i<o;i++)e[i]=t[i],n[i]=r[i]}function Kt(e,n){for(let t in n){let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}typeof r=="function"&&!t.startsWith("on")?t==="class"||t==="className"?M(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?M(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):M(()=>{J(e,t,r())}):J(e,t,r)}}function J(e,n,t){if(n==="ref"){typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e);return}if(n!=="key"){if(!Z(n,t)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${t}`),e.removeAttribute(Q(n));return}if(n==="class"||n==="className")e.className=t||"";else if(n==="dangerouslySetInnerHTML")e.innerHTML=t?.__html??"";else if(n==="innerHTML")t&&typeof t=="object"&&"__html"in t?e.innerHTML=t.__html??"":typeof console<"u"&&t!=null&&t!==""&&console.warn('[what] Plain string innerHTML is not allowed. Use { __html: "..." } or dangerouslySetInnerHTML={{ __html: "..." }} instead.');else if(n==="style"){if(typeof t=="string")e.style.cssText=t;else if(typeof t=="object")for(let r in t)e.style[r]=t[r]??""}else n.startsWith("data-")||n.startsWith("aria-")?e.setAttribute(n,t):typeof t=="boolean"?t?e.setAttribute(n,""):e.removeAttribute(n):n in e?e[n]=t:e.setAttribute(n,t)}}var $e=new Set;function Jt(e){for(let n of e)$e.has(n)||($e.add(n),document.addEventListener(n,t=>{let r=t.target,o="$$"+n;for(;r;){let i=r[o];if(i&&(i(t),t.cancelBubble))return;r=r.parentNode}}))}function Xt(e,n,t){return e.addEventListener(n,t),()=>e.removeEventListener(n,t)}function Yt(e,n){M(()=>{for(let t in n){let r=typeof n[t]=="function"?n[t]():n[t];e.classList.toggle(t,!!r)}})}var ie=!1,O=null;function Zt(){return ie}function Qt(e,n){ie=!0,O={parent:n,index:0},G=0;try{let t=K(e,n);return E&&G>0&&console.warn(`[what] Hydration completed with ${G} mismatch${G===1?"":"es"}. See previous warnings for details. This usually means server and client render different initial HTML.`),t}finally{ie=!1,O=null}}function Ue(e){let n=e.childNodes;for(;O.index<n.length;){let t=n[O.index];if(t.nodeType===8){let r=t.textContent;if(r==="$"||r==="/$"||r==="[]"||r==="/[]"){O.index++;continue}}return O.index++,t}return null}var G=0;function en(){return G}function re(e,n,t){if(G++,E){let o=He("HYDRATION_MISMATCH",{component:t||"unknown",serverHTML:n,clientHTML:e});ve(o),C?.onHydrationMismatch&&C.onHydrationMismatch({component:t||"unknown",expected:e,actual:n,mismatchCount:G}),C?.onError&&C.onError(o,{type:"hydration",component:t}),console.warn(`[what] Hydration mismatch: expected ${e}, got ${n}`+(t?` (in ${t})`:"")+". Falling back to client render.")}}function K(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let o=Ue(n),i=String(e);if(o&&o.nodeType===3)return E&&o.textContent!==i&&(re(`text "${i}"`,`text "${o.textContent}"`,t),o.textContent=i),o;re(`text node "${i}"`,o?o.nodeName:"nothing",t);let l=document.createTextNode(i);return o?n.replaceChild(l,o):n.appendChild(l),l}if(typeof e=="function"){let o=e(),i=K(o,n,t);return M(()=>{let l=e();ie||(i=oe(n,l,i,null))}),i}if(Array.isArray(e)){let o=[];for(let i of e){let l=K(i,n,t);l&&o.push(l)}return o.length===1?o[0]:o}if(typeof e=="object"&&e._vnode){if(typeof e.tag=="function"){let s=Re(),f=e.tag,c=f.displayName||f.name||"Anonymous",p=e.props||{},u=e.children||[],_={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:f,_parentCtx:s[s.length-1]||null,_errorBoundary:null};s.push(_);let y;try{let m=u.length===0?void 0:u.length===1?u[0]:u;y=f({...p,children:m})}catch(m){return s.pop(),E&&console.error("[what] Error in component during hydration:",c,m),null}return s.pop(),_.mounted=!0,_._mountCallbacks&&queueMicrotask(()=>{if(!_.disposed)for(let m of _._mountCallbacks)try{m()}catch(h){console.error("[what] onMount error:",h)}}),K(y,n,c)}let o=Ue(n),i=e.tag.toUpperCase();if(o&&o.nodeType===1&&o.nodeName===i){if(Nt(o,e.props||{}),e.props?.ref){let c=e.props.ref;typeof c=="function"?c(o):typeof c=="object"&&c!==null&&(c.current=o)}let s=O;if(O={parent:o,index:0},e.props?.dangerouslySetInnerHTML?.__html==null)for(let c of e.children)K(c,o,t);return O=s,o}re(`<${e.tag}>`,o?o.nodeName:"nothing",t);let l=document.createElement(e.tag);for(let s in e.props||{})s==="children"||s==="key"||J(l,s,e.props[s]);for(let s of e.children)oe(l,s,null,null);return o?n.replaceChild(l,o):n.appendChild(l),l}if(Ge(e))return e;let r=document.createTextNode(String(e));return n.appendChild(r),r}function Nt(e,n){for(let t in n){if(t==="children"||t==="key"||t==="ref"||t==="dangerouslySetInnerHTML"||t==="innerHTML")continue;let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}if(t.startsWith("$$")){e[t]=r;continue}if(typeof r=="function"&&!t.startsWith("on")){t==="class"||t==="className"?M(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?M(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):M(()=>{J(e,t,r())});continue}if(t!=="data-hk"&&E&&typeof r=="string"){let o=t==="className"?"class":t==="htmlFor"?"for":t,i=e.getAttribute(o);i!==null&&i!==r&&(re(`${o}="${r}"`,`${o}="${i}"`,e.tagName.toLowerCase()),J(e,t,r))}}}export{qt as _$createComponent,gt as _$template,Pt as _template,Yt as classList,Jt as delegateEvents,M as effect,en as getHydrationMismatchCount,Qt as hydrate,zt as insert,Zt as isHydrating,Ft as mapArray,Xt as on,J as setProp,Kt as spread,yt as svgTemplate,Pt as template,de as untrack};
|
|
59
59
|
//# sourceMappingURL=render.min.js.map
|