what-core 0.14.0 → 0.15.0
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/LICENSE +21 -0
- package/README.md +64 -38
- package/a11y.d.ts +128 -0
- package/data.d.ts +294 -0
- package/dist/a11y.js +510 -0
- package/dist/a11y.min.js +413 -0
- package/dist/actions.js +158 -0
- package/dist/actions.min.js +112 -0
- package/dist/animation.js +481 -0
- package/dist/animation.min.js +295 -0
- package/dist/async.js +180 -0
- package/dist/async.min.js +134 -0
- package/dist/components.js +577 -0
- package/dist/components.min.js +413 -0
- package/dist/data.js +1212 -0
- package/dist/data.min.js +918 -0
- package/dist/diagnostics.js +187 -0
- package/dist/diagnostics.min.js +134 -0
- package/dist/dom.js +796 -0
- package/dist/dom.min.js +603 -0
- package/dist/entries/a11y.js +43 -0
- package/dist/entries/a11y.min.js +43 -0
- package/dist/entries/data.js +29 -0
- package/dist/entries/data.min.js +29 -0
- package/dist/entries/dom.js +45 -0
- package/dist/entries/dom.min.js +45 -0
- package/dist/entries/form.js +31 -0
- package/dist/entries/form.min.js +31 -0
- package/dist/entries/internal.js +123 -0
- package/dist/entries/internal.min.js +123 -0
- package/dist/entries/motion.js +23 -0
- package/dist/entries/motion.min.js +23 -0
- package/dist/entries/ui.js +25 -0
- package/dist/entries/ui.min.js +25 -0
- package/dist/env.js +5 -0
- package/dist/env.min.js +5 -0
- package/dist/errors.js +1518 -0
- package/dist/errors.min.js +548 -0
- package/dist/form.js +936 -0
- package/dist/form.min.js +703 -0
- package/dist/guardrails.js +84 -0
- package/dist/guardrails.min.js +55 -0
- package/dist/h.js +232 -0
- package/dist/h.min.js +171 -0
- package/dist/head.js +241 -0
- package/dist/head.min.js +207 -0
- package/dist/helpers.js +126 -0
- package/dist/helpers.min.js +98 -0
- package/dist/hooks.js +255 -0
- package/dist/hooks.min.js +153 -0
- package/dist/hot.js +215 -0
- package/dist/hot.min.js +24 -0
- package/dist/hydration-data.js +495 -0
- package/dist/hydration-data.min.js +371 -0
- package/dist/import-changes.js +273 -0
- package/dist/import-changes.min.js +272 -0
- package/dist/index.js +95 -0
- package/dist/index.min.js +95 -227
- package/dist/jsx-dev-runtime.js +10 -0
- package/dist/jsx-dev-runtime.min.js +10 -1
- package/dist/jsx-runtime.js +27 -0
- package/dist/jsx-runtime.min.js +15 -1
- package/dist/live.js +54 -0
- package/dist/live.min.js +49 -0
- package/dist/markup-rules.js +250 -0
- package/dist/markup-rules.min.js +213 -0
- package/dist/reactive.js +3334 -0
- package/dist/reactive.min.js +2033 -0
- package/dist/render.js +4746 -0
- package/dist/render.min.js +2797 -1
- package/dist/scheduler.js +225 -0
- package/dist/scheduler.min.js +162 -0
- package/dist/selector.js +11 -0
- package/dist/selector.min.js +10 -0
- package/dist/server-context.js +148 -0
- package/dist/server-context.min.js +121 -0
- package/dist/skeleton.js +342 -0
- package/dist/skeleton.min.js +310 -0
- package/dist/store.js +72 -0
- package/dist/store.min.js +50 -0
- package/dist/testing.js +720 -0
- package/dist/testing.min.js +458 -1
- package/dist/vnode-adoption.js +19 -0
- package/dist/vnode-adoption.min.js +19 -0
- package/dist/vnode-renderer.js +61 -0
- package/dist/vnode-renderer.min.js +47 -0
- package/dom.d.ts +44 -0
- package/form.d.ts +218 -0
- package/hot.d.ts +35 -0
- package/index.d.ts +421 -736
- package/internal.d.ts +284 -0
- package/jsx-runtime.d.ts +160 -137
- package/markup-rules.d.ts +83 -0
- package/motion.d.ts +156 -0
- package/package.json +117 -3
- package/render.d.ts +278 -29
- package/src/a11y.js +64 -59
- package/src/actions.js +226 -0
- package/src/animation.js +105 -57
- package/src/async.js +259 -0
- package/src/components.js +495 -144
- package/src/data.js +1410 -1159
- package/src/diagnostics.js +263 -0
- package/src/dom.js +1159 -872
- package/src/entries/a11y.js +24 -0
- package/src/entries/data.js +17 -0
- package/src/entries/dom.js +29 -0
- package/src/entries/form.js +16 -0
- package/src/entries/internal.js +63 -0
- package/src/entries/motion.js +13 -0
- package/src/entries/ui.js +13 -0
- package/src/env-development.js +12 -0
- package/src/env.js +33 -0
- package/src/errors.js +1144 -168
- package/src/form.js +723 -225
- package/src/guardrails.js +38 -126
- package/src/h.js +227 -152
- package/src/head.js +189 -19
- package/src/helpers.js +47 -75
- package/src/hooks.js +233 -248
- package/src/hot.js +316 -0
- package/src/hydration-data.js +859 -16
- package/src/import-changes.js +156 -0
- package/src/index.js +38 -188
- package/src/jsx-dev-runtime.js +7 -14
- package/src/jsx-runtime.js +25 -9
- package/src/live.js +80 -0
- package/src/markup-rules.js +387 -0
- package/src/reactive.js +4400 -862
- package/src/render.js +6502 -2570
- package/src/scheduler.js +56 -21
- package/src/selector.js +31 -0
- package/src/server-context.js +252 -22
- package/src/skeleton.js +22 -12
- package/src/store.js +17 -31
- package/src/testing.js +389 -63
- package/src/vnode-adoption.js +48 -0
- package/src/vnode-renderer.js +114 -0
- package/testing.d.ts +81 -1
- package/ui.d.ts +20 -0
- package/dist/chunk-6YOUZ6T4.min.js +0 -1
- package/dist/chunk-FN6HXME3.min.js +0 -11
- package/dist/chunk-VKZY7JPN.min.js +0 -1
- package/src/agent-context.js +0 -127
- package/src/warnings.js +0 -193
package/dist/index.min.js
CHANGED
|
@@ -1,227 +1,95 @@
|
|
|
1
|
-
import{A as Mn,B as Fn,C as Pn,D as Hn,E as Gn,K as $n,L as Vn,M as jn,N as Un,O as qn,a as dn,b as fn,c as pn,d as hn,e as gn,f as mn,g as yn,h as vn,i as wn,j as xn,k as En,l as bn,m as Sn,n as _n,o as kn,p as Rn,q as Cn,r as An,s as In,t as Tn,u as Nn,w as Dn,x as On,y as Je,z as Ln}from"./chunk-FN6HXME3.min.js";import{$ as ln,A as Bt,B as Wt,C as Yt,D as Xt,F as zt,G as Qt,H as Kt,I as Jt,J as Zt,K as en,L as tn,M as nn,N as rn,O as on,P as sn,Q as Ne,S as an,X as cn,Z as W,a as L,aa as un,c as At,d,e as P,f as $,g as O,h as It,i as Tt,j as ce,k as Nt,l as Dt,m as Ot,o as Lt,p as Mt,q as Ht,r as ge,s as Te,t as Gt,u as $t,v as Vt,w as jt,x as Ut,y as qt}from"./chunk-VKZY7JPN.min.js";import{a as N,b as Ft,c as Pt}from"./chunk-6YOUZ6T4.min.js";var re;function De(){if(re!==void 0)return re;if(typeof document>"u")return re=null;let e=document.getElementById("__what_data");if(!e)return re=null;try{re=JSON.parse(e.textContent)}catch{re=null}return re}function Bn(){re=void 0}function Oe(){let e=De();return e?e.loaderData:void 0}function Le(e){let t=De();return t&&t.resources?t.resources[e]:void 0}function Wn(){if(Te()){let e=ge();return e?e.loaderData:void 0}return Oe()}function Y(e){let t=W();if(!t)throw new Error(`[what] ${e||"Hook"}() can only be called inside a component function. Did you call it outside of a component or in an async callback? If you need reactive state outside a component, use signal() directly.`);return t}function oe(e){let t=e.hookIndex++;return{index:t,exists:t<e.hooks.length}}function Yn(e){let t=Y("useState"),{index:n,exists:r}=oe(t);if(!r){let s=d(typeof e=="function"?e():e);t.hooks[n]=s}let o=t.hooks[n];return[o,o.set]}function Xn(e){let t=Y("useSignal"),{index:n,exists:r}=oe(t);return r||(t.hooks[n]=d(typeof e=="function"?e():e)),t.hooks[n]}function zn(e){let t=Y("useComputed"),{index:n,exists:r}=oe(t);return r||(t.hooks[n]=P(e)),t.hooks[n]}function Qn(e,t){let n=Y("useEffect"),{index:r,exists:o}=oe(n);if(o||(n.hooks[r]={cleanup:null,dispose:null}),L&&Array.isArray(t)&&t.length>0)for(let a=0;a<t.length;a++){let c=t[a];c!=null&&typeof c!="function"&&console.warn(`[what] useEffect dep at index ${a} is not a function. Did you mean to pass a signal? Use count instead of count()`)}let s=n.hooks[r];s.dispose||(t===void 0?queueMicrotask(()=>{n.disposed||(s.dispose=$(()=>{if(s.cleanup){try{s.cleanup()}catch{}s.cleanup=null}let a=e();typeof a=="function"&&(s.cleanup=a)}),n.effects=n.effects||[],n.effects.push(s.dispose))}):t.length===0?(queueMicrotask(()=>{if(n.disposed)return;let a=e();typeof a=="function"&&(s.cleanup=a)}),s.dispose=!0):queueMicrotask(()=>{n.disposed||(s.dispose=$(()=>{for(let c=0;c<t.length;c++){let u=t[c];typeof u=="function"&&u._signal&&u()}if(s.cleanup){try{s.cleanup()}catch{}s.cleanup=null}let a=ce(()=>e());typeof a=="function"&&(s.cleanup=a)}),n.effects=n.effects||[],n.effects.push(s.dispose))}))}function Kn(e,t){let n=Y("useMemo"),{index:r,exists:o}=oe(n);return o||(n.hooks[r]={computed:P(e)}),n.hooks[r].computed}function Jn(e,t){let n=Y("useCallback"),{index:r,exists:o}=oe(n);return o||(n.hooks[r]={callback:e}),n.hooks[r].callback}function Zn(e){let t=Y("useRef"),{index:n,exists:r}=oe(t);return r||(t.hooks[n]={current:e}),t.hooks[n]}function Ze(e){let t=W();for(L&&!t&&console.warn(`[what] useContext(${e?.displayName||"Context"}) called outside of component render. useContext must be called during component rendering, not inside effects or event handlers. Store the context value in a variable during render and use that variable in your callback.`);t;){if(t._contextValues&&t._contextValues.has(e)){let n=t._contextValues.get(e);return n&&n._signal?n():n}t=t._parentCtx}return e._defaultValue}function er(e){let t={_defaultValue:e,Provider:({value:n,children:r})=>{let o=Y("Context.Provider");if(o._contextValues||(o._contextValues=new Map),o._contextSignals||(o._contextSignals=new Map),o._contextSignals.has(t))o._contextSignals.get(t).set(n);else{let s=d(n);o._contextSignals.set(t,s),o._contextValues.set(t,s)}return r},Consumer:({children:n})=>{let r=Ze(t);return typeof n=="function"?n(r):n}};return t.Provider._deferChildren=!0,t}function tr(e,t,n){let r=Y("useReducer"),{index:o,exists:s}=oe(r);if(!s){let c=n?n(t):t,u=d(c),p=i=>{u.set(h=>e(h,i))};r.hooks[o]={signal:u,dispatch:p}}let a=r.hooks[o];return[a.signal,a.dispatch]}function nr(e){let t=Y("onMount");t.mounted||(t._mountCallbacks=t._mountCallbacks||[],t._mountCallbacks.push(e))}function rr(e){let t=Y("onCleanup");t._cleanupCallbacks=t._cleanupCallbacks||[],t._cleanupCallbacks.push(e)}function or(e,t={}){if(Te()){let i=ge();if(i){let h=t.key!=null?t.key:`__r${i.resourceCounter++}`,g=i.resources.get(h);if(g&&g.status==="ready")return[()=>g.value,{loading:()=>!1,error:()=>null,refetch:()=>{},mutate:()=>{}}];if(g&&g.status==="error")return[()=>{},{loading:()=>!1,error:()=>g.error,refetch:()=>{},mutate:()=>{}}];if(!g){let b=Promise.resolve().then(()=>e(t.source??!0,{})).then(S=>{i.resources.set(h,{status:"ready",value:S})}).catch(S=>{i.resources.set(h,{status:"error",error:S})});throw i.resources.set(h,{status:"pending",promise:b}),b}throw g.promise}if(t.initialValue!=null)return[()=>t.initialValue,{loading:()=>!1,error:()=>null,refetch:()=>{},mutate:()=>{}}];throw Promise.resolve().then(()=>e(t.source??!0,{}))}let n=t.initialValue;if(n==null&&t.key!=null){let i=Le(t.key);i!==void 0&&(n=i)}let r=d(n??null),o=d(n==null),s=d(null),a=null,c=async i=>{a&&a.abort(),a=new AbortController;let{signal:h}=a;o.set(!0),s.set(null);try{let g=await e(i,{signal:h});h.aborted||O(()=>{r.set(g),o.set(!1)})}catch(g){h.aborted||O(()=>{s.set(g),o.set(!1)})}},u=i=>{r.set(typeof i=="function"?i(r()):i)},p=W?.();return p&&(p._cleanupCallbacks=p._cleanupCallbacks||[],p._cleanupCallbacks.push(()=>{a&&a.abort()})),n==null&&c(t.source),[r,{loading:o,error:s,refetch:c,mutate:u}]}function nt(e){return e._storeComputed=!0,e}var et=!1;function sr(e){return et||(et=!0,console.warn("[what] storeComputed() is deprecated. Use derived() instead.")),nt(e)}function ar(e){let t={},n={},r={};for(let[o,s]of Object.entries(e))typeof s=="function"&&s._storeComputed?(L&&s.length===0&&console.warn(`[what] derived() for "${o}" should accept the state parameter, e.g. derived(state => ...).`),n[o]=s):typeof s=="function"?r[o]=s:t[o]=d(s);for(let[o,s]of Object.entries(n)){let a=new Proxy({},{get(c,u){if(t[u])return t[u]();if(n[u])return n[u]()}});n[o]=P(()=>s(a))}for(let[o,s]of Object.entries(r))r[o]=(...a)=>{let c;return O(()=>{let u=new Proxy({},{get(p,i){if(t[i])return t[i].peek();if(n[i])return n[i].peek();if(r[i])return r[i]},set(p,i,h){return t[i]&&t[i].set(h),!0}});c=s.apply(u,a)}),c};return function(){let s={};for(let[a,c]of Object.entries(t))Object.defineProperty(s,a,{get:()=>c(),enumerable:!0});for(let[a,c]of Object.entries(n))Object.defineProperty(s,a,{get:()=>c(),enumerable:!0});for(let[a,c]of Object.entries(r))s[a]=c;return s}}var tt=!1;function ir(e){return tt||(tt=!0,console.warn("[what] atom() is deprecated. Use signal() directly instead.")),d(e)}var Me={title:null,metas:new Map,links:new Map};function cr({title:e,meta:t,link:n,children:r}){if(typeof document>"u"){let o=ge();return o&&o.head&&ur(o.head,{title:e,meta:t,link:n}),r??null}if(e&&(document.title=e,Me.title=e),t)for(let o of Array.isArray(t)?t:[t]){let s=o.name||o.property||o.httpEquiv||JSON.stringify(o);ot("meta",s,o)}if(n)for(let o of Array.isArray(n)?n:[n]){let s=o.rel+(o.href||"");ot("link",s,o)}return r||null}function lr(e){return e.name||e.property||e.httpEquiv||JSON.stringify(e)}function ur(e,{title:t,meta:n,link:r}){if(t!=null&&(e.title=t),n)for(let o of Array.isArray(n)?n:[n])e.metas.set(lr(o),o);if(r)for(let o of Array.isArray(r)?r:[r])e.links.set(o.rel+(o.href||""),o)}function dr(){return{title:null,metas:new Map,links:new Map}}function fr(e){if(!e)return"";let t="";e.title!=null&&(t+=`<title>${st(String(e.title))}</title>`);for(let n of e.metas.values())t+=rt("meta",n);for(let n of e.links.values())t+=rt("link",n);return t}var pr=/^[a-zA-Z_:][a-zA-Z0-9:._-]*$/;function Fe(e){if(!pr.test(e))return!1;let t=e.toLowerCase();return!(t.startsWith("on")&&t.length>2)}function ke(e){return e==="httpEquiv"?"http-equiv":e}function rt(e,t){let n=`<${e}`;for(let[r,o]of Object.entries(t)){if(o==null||o===!1)continue;let s=ke(r);Fe(s)&&(n+=` ${s}="${st(String(o))}"`)}return n+">"}function st(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hr(e){let t=String(e);return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n.codePointAt(0).toString(16)} `)}function ot(e,t,n){let r=document.head.querySelector(`[data-what-head="${hr(t)}"]`);if(r){gr(r,n);return}let o=document.createElement(e);o.setAttribute("data-what-head",t);for(let[s,a]of Object.entries(n))Fe(ke(s))&&o.setAttribute(ke(s),a);document.head.appendChild(o)}function gr(e,t){for(let[n,r]of Object.entries(t)){let o=ke(n);Fe(o)&&e.getAttribute(o)!==r&&e.setAttribute(o,r)}}function mr(){let e=document.head.querySelectorAll("[data-what-head]");for(let t of e)t.remove();Me.metas.clear(),Me.links.clear()}var me=[],ye=[],Ge=!1;function Z(e){return me.push(e),$e(),()=>{let t=me.indexOf(e);t!==-1&&me.splice(t,1)}}function se(e){return ye.push(e),$e(),()=>{let t=ye.indexOf(e);t!==-1&&ye.splice(t,1)}}function at(){for(;me.length>0;){let e=me.shift();try{e()}catch(t){console.error("[what] Scheduler read error:",t)}}for(;ye.length>0;){let e=ye.shift();try{e()}catch(t){console.error("[what] Scheduler write error:",t)}}Ge=!1,(me.length>0||ye.length>0)&&$e()}function $e(){Ge||(Ge=!0,requestAnimationFrame(at))}function yr(e){return new Promise(t=>{Z(()=>{t(e())})})}function vr(e){return new Promise(t=>{se(()=>{e(),t()})})}function wr(e,t){let n=Symbol("scheduledEffect");return $(()=>{it(n,()=>{Z(()=>{let r=e();t&&se(()=>t(r))})})})}function xr(){let e,t=new Promise((n,r)=>{let o=requestAnimationFrame(n);e=()=>{cancelAnimationFrame(o),r(new Error("Cancelled"))}});return t.cancel=e,t}var we=new Map;function it(e,t){we.has(e)?we.set(e,t):(we.set(e,t),requestAnimationFrame(()=>{let n=we.get(e);we.delete(e),n&&n()}))}var Pe=new WeakMap,He=null;function Er(e,t){if(typeof ResizeObserver>"u")return t(e.getBoundingClientRect()),()=>{};He||(He=new ResizeObserver(r=>{Z(()=>{for(let o of r){let s=Pe.get(o.target);s&&s(o.contentRect)}})}));let n=He;return Pe.set(e,t),n.observe(e),()=>{Pe.delete(e),n.unobserve(e)}}function br(e,t,n={}){if(typeof IntersectionObserver>"u")return t({isIntersecting:!0,intersectionRatio:1}),()=>{};let r=new IntersectionObserver(o=>{Z(()=>{for(let s of o)t(s)})},n);return r.observe(e),()=>r.disconnect()}function Sr(e,t={}){let{duration:n=300,easing:r=o=>o*(2-o)}=t;return new Promise(o=>{let s,a,c;Z(()=>{s=window.scrollY;let p=e.getBoundingClientRect();a=s+p.top,c=performance.now(),u()});function u(){Z(()=>{let p=performance.now()-c,i=Math.min(p/n,1),h=r(i),g=s+(a-s)*h;se(()=>{window.scrollTo(0,g),i<1?requestAnimationFrame(u):o()})})}})}function ct(e){let t=W?.(),n=$(e);return t&&t.effects.push(n),n}function lt(e,t={}){let{stiffness:n=100,damping:r=10,mass:o=1,precision:s=.01}=t,a=d(e),c=d(e),u=d(0),p=d(!1),i=null,h=null;function g(k){if(h===null){h=k,i=requestAnimationFrame(g);return}let v=Math.min((k-h)/1e3,.064);h=k;let T=a.peek(),D=c.peek(),C=u.peek(),_=T-D,m=-n*_,f=-r*C,A=(m+f)/o,F=C+A*v,G=T+F*v;if(O(()=>{u.set(F),a.set(G)}),Math.abs(F)<s&&Math.abs(_)<s){O(()=>{a.set(D),u.set(0),p.set(!1)}),i=null,h=null;return}i=requestAnimationFrame(g)}function b(k){c.set(k),i===null&&(p.set(!0),h=null,i=requestAnimationFrame(g))}function S(){i&&(cancelAnimationFrame(i),i=null),p.set(!1),h=null}function I(k){S(),O(()=>{a.set(k),c.set(k),u.set(0)})}let R=W?.();return R&&(R._cleanupCallbacks=R._cleanupCallbacks||[],R._cleanupCallbacks.push(S)),{current:()=>a(),target:()=>c(),velocity:()=>u(),isAnimating:()=>p(),set:b,stop:S,snap:I,subscribe:a.subscribe}}function ut(e,t,n={}){let{duration:r=300,easing:o=b=>b*(2-b),onUpdate:s,onComplete:a}=n,c=d(0),u=d(e),p=d(!0),i=null,h=null;function g(b){i===null&&(i=b);let I=b-i,R=Math.min(I/r,1),k=o(R),v=e+(t-e)*k;O(()=>{c.set(R),u.set(v)}),s&&s(v,R),R<1?h=requestAnimationFrame(g):(p.set(!1),a&&a())}return h=requestAnimationFrame(g),{progress:()=>c(),value:()=>u(),isAnimating:()=>p(),cancel:()=>{h&&cancelAnimationFrame(h),p.set(!1)},subscribe:u.subscribe}}var dt={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:-1+(4-2*e)*e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInElastic:e=>e===0?0:e===1?1:-Math.pow(2,10*e-10)*Math.sin((e*10-10.75)*(2*Math.PI/3)),easeOutElastic:e=>e===0?0:e===1?1:Math.pow(2,-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1,easeOutBounce:e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375};function _r(e={}){let{duration:t=300,easing:n=dt.easeOutQuad}=e,r=d(!1),o=d(0);async function s(a){return r.set(!0),o.set(0),new Promise(c=>{let u=performance.now();function p(i){let h=i-u,g=Math.min(h/t,1);o.set(n(g)),g<1?requestAnimationFrame(p):(r.set(!1),a&&a(),c())}requestAnimationFrame(p)})}return{isTransitioning:()=>r(),progress:()=>o(),start:s}}function kr(e,t={}){let{onDrag:n,onDragStart:r,onDragEnd:o,onPinch:s,onSwipe:a,onTap:c,onLongPress:u,preventDefault:p=!1}=t,i={isDragging:d(!1),startX:0,startY:0,currentX:d(0),currentY:d(0),deltaX:d(0),deltaY:d(0),velocity:d({x:0,y:0})},h=0,g=0,b=0,S=null;function I(_){let m=_.touches?_.touches[0]:_;i.startX=m.clientX,i.startY=m.clientY,g=m.clientX,b=m.clientY,h=performance.now(),i.isDragging.set(!0),r&&r({x:i.startX,y:i.startY}),u&&(S=setTimeout(()=>{i.isDragging.peek()&&u({x:g,y:b})},500))}function R(_){if(!i.isDragging.peek())return;let m=_.touches?_.touches[0]:_,f=m.clientX,A=m.clientY,F=performance.now(),G=F-h;O(()=>{i.currentX.set(f),i.currentY.set(A),i.deltaX.set(f-i.startX),i.deltaY.set(A-i.startY),G>0&&i.velocity.set({x:(f-g)/G*1e3,y:(A-b)/G*1e3})}),g=f,b=A,h=F,S&&Math.sqrt(i.deltaX.peek()**2+i.deltaY.peek()**2)>10&&(clearTimeout(S),S=null),n&&n({x:f,y:A,deltaX:i.deltaX.peek(),deltaY:i.deltaY.peek(),velocity:i.velocity.peek()})}function k(_){if(!i.isDragging.peek())return;S&&(clearTimeout(S),S=null);let m=i.deltaX.peek(),f=i.deltaY.peek(),A=i.velocity.peek();if(Math.sqrt(m**2+f**2)<10&&c&&c({x:i.startX,y:i.startY}),a&&(Math.abs(A.x)>500||Math.abs(A.y)>500)){let G=Math.abs(A.x)>Math.abs(A.y)?A.x>0?"right":"left":A.y>0?"down":"up";a({direction:G,velocity:A})}o&&o({deltaX:m,deltaY:f,velocity:A}),i.isDragging.set(!1)}let v=null;function T(_){if(!s||_.touches.length!==2)return;let m=_.touches[0],f=_.touches[1],A=Math.sqrt((f.clientX-m.clientX)**2+(f.clientY-m.clientY)**2);v===null&&(v=A);let F=A/v,G=(m.clientX+f.clientX)/2,w=(m.clientY+f.clientY)/2;s({scale:F,centerX:G,centerY:w})}function D(){v=null}typeof e=="function"?ct(()=>{let _=ce(e);if(_)return C(_)}):e?.current!==void 0?ct(()=>{let _=e.current;if(_)return C(_)}):e&&C(e);function C(_){return _.addEventListener("mousedown",I),_.addEventListener("touchstart",I,{passive:!p}),window.addEventListener("mousemove",R),window.addEventListener("touchmove",T),window.addEventListener("touchmove",R),window.addEventListener("mouseup",k),window.addEventListener("touchend",k),window.addEventListener("touchend",D),()=>{_.removeEventListener("mousedown",I),_.removeEventListener("touchstart",I),window.removeEventListener("mousemove",R),window.removeEventListener("touchmove",T),window.removeEventListener("touchmove",R),window.removeEventListener("mouseup",k),window.removeEventListener("touchend",k),window.removeEventListener("touchend",D)}}return i}function Rr(e){let t=d(e);return{value:()=>t(),setValue:n=>t.set(n),spring(n,r={}){let o=lt(t.peek(),r);o.set(n);let s=$(()=>{t.set(o.current())});return{stop:()=>{o.stop(),s()}}},timing(n,r={}){let o=ut(t.peek(),n,{...r,onUpdate:s=>t.set(s)});return{stop:()=>o.cancel()}},interpolate(n,r){return()=>{let o=t();for(let s=0;s<n.length-1;s++)if(o>=n[s]&&o<=n[s+1]){let a=(o-n[s])/(n[s+1]-n[s]);return r[s]+(r[s+1]-r[s])*a}return o<=n[0]?r[0]:r[r.length-1]}},subscribe:t.subscribe}}function ft(e){return{enter:`${e}-enter`,enterActive:`${e}-enter-active`,enterDone:`${e}-enter-done`,exit:`${e}-exit`,exitActive:`${e}-exit-active`,exitDone:`${e}-exit-done`}}async function Cr(e,t,n="enter",r=300){let o=ft(t);return new Promise(s=>{se(()=>{e.classList.add(o[n]),Z(()=>{e.offsetHeight,se(()=>{e.classList.add(o[`${n}Active`]),setTimeout(()=>{se(()=>{e.classList.remove(o[n],o[`${n}Active`]),e.classList.add(o[`${n}Done`]),s()})},r)})})})})}var Ar=`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`,pt=!1;function le(){if(pt||typeof document>"u")return;pt=!0;let e=document.createElement("style");e.textContent=Ar,document.head.appendChild(e)}function Ve({width:e,height:t,variant:n="shimmer",circle:r=!1,class:o,style:s,count:a=1}){le();let c=`what-skeleton ${n==="pulse"?"what-skeleton-pulse":""} ${n==="wave"?"what-skeleton-wave":""}`,u=o?`${c} ${o}`:c,p={width:typeof e=="number"?`${e}px`:e,height:typeof t=="number"?`${t}px`:t,borderRadius:r?"50%":void 0,...s};return a===1?N("div",{class:u,style:p,"aria-hidden":"true"}):Array.from({length:a},(i,h)=>N("div",{key:h,class:u,style:{...p,marginBottom:h<a-1?"8px":void 0},"aria-hidden":"true"}))}function je({lines:e=3,lastLineWidth:t="60%",lineHeight:n=16,gap:r=8,variant:o="shimmer"}){return le(),N("div",{class:"what-skeleton-text","aria-hidden":"true"},Array.from({length:e},(s,a)=>N("div",{key:a,class:`what-skeleton ${o==="pulse"?"what-skeleton-pulse":""}`,style:{height:`${n}px`,width:a===e-1?t:"100%",marginBottom:a<e-1?`${r}px`:void 0}})))}function Ir({size:e=40,variant:t="shimmer"}){return Ve({width:e,height:e,circle:!0,variant:t})}function ht({imageHeight:e=200,lines:t=3,variant:n="shimmer"}){return le(),N("div",{class:"what-skeleton-card","aria-hidden":"true"},N("div",{class:`what-skeleton ${n==="pulse"?"what-skeleton-pulse":""}`,style:{height:`${e}px`,width:"100%",marginBottom:"16px"}}),N("div",{class:`what-skeleton ${n==="pulse"?"what-skeleton-pulse":""}`,style:{height:"24px",width:"70%",marginBottom:"12px"}}),je({lines:t,variant:n}))}function Tr({rows:e=5,columns:t=4,variant:n="shimmer"}){return le(),N("div",{class:"what-skeleton-table","aria-hidden":"true"},N("div",{style:{display:"flex",gap:"16px",marginBottom:"16px"}},Array.from({length:t},(r,o)=>N("div",{key:o,class:`what-skeleton ${n==="pulse"?"what-skeleton-pulse":""}`,style:{height:"20px",flex:1}}))),Array.from({length:e},(r,o)=>N("div",{key:o,style:{display:"flex",gap:"16px",marginBottom:o<e-1?"12px":void 0}},Array.from({length:t},(s,a)=>N("div",{key:a,class:`what-skeleton ${n==="pulse"?"what-skeleton-pulse":""}`,style:{height:"16px",flex:1}})))))}function Nr({type:e="default",height:t,children:n}){return le(),e==="card"?ht({}):e==="text"?je({}):n||N("div",{class:"what-skeleton what-island-skeleton",style:{height:typeof t=="number"?`${t}px`:t||"100px",width:"100%"},"aria-hidden":"true"})}function Dr(e,t=[]){let n=d(!0),r=d(null),o=d(null);return $(()=>{n.set(!0),o.set(null),Promise.resolve(e()).then(s=>{r.set(s),n.set(!1)}).catch(s=>{o.set(s),n.set(!1)})}),{isLoading:()=>n(),data:()=>r(),error:()=>o(),Skeleton:s=>n()?Ve(s):null}}function Or({width:e="100%",height:t=100,label:n="Loading...",showLabel:r=!1,variant:o="shimmer"}){return le(),N("div",{class:`what-skeleton ${o==="pulse"?"what-skeleton-pulse":""}`,style:{width:typeof e=="number"?`${e}px`:e,height:typeof t=="number"?`${t}px`:t,display:"flex",alignItems:"center",justifyContent:"center"},"aria-label":n,role:"status"},r&&N("span",{style:{color:"var(--skeleton-text, #999)",fontSize:"14px"}},n))}function Lr({size:e=8,color:t="#666"}){le();let n={width:`${e}px`,height:`${e}px`,borderRadius:"50%",backgroundColor:t,animation:"what-skeleton-pulse 1s infinite ease-in-out"};return N("div",{class:"what-loading-dots",style:{display:"flex",gap:`${e/2}px`},"aria-label":"Loading",role:"status"},N("div",{style:{...n,animationDelay:"0s"}}),N("div",{style:{...n,animationDelay:"0.2s"}}),N("div",{style:{...n,animationDelay:"0.4s"}}))}function Mr({size:e=24,color:t="#666",strokeWidth:n=2}){return N("svg",{width:e,height:e,viewBox:"0 0 24 24",style:{animation:"spin 1s linear infinite"},"aria-label":"Loading",role:"status"},N("style",null,"@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"),N("circle",{cx:12,cy:12,r:10,stroke:t,strokeWidth:n,fill:"none",strokeDasharray:"31.4 31.4",strokeLinecap:"round"}))}var j=new Map,ee=new Map,te=new Map,z=new Map,gt=200;function ae(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t:JSON.stringify(t)??String(t)).map(t=>t.replace(/([\\:])/g,"\\$1")).join(":"):e}function Re(e){return z.set(e,Date.now()),j.has(e)||(j.set(e,d(null)),j.size>gt&&Pr()),j.get(e)}function mt(e){return ee.has(e)||ee.set(e,d(null)),ee.get(e)}function Fr(e){return te.has(e)||te.set(e,d(!1)),te.get(e)}function Pr(){let e=[...z.entries()].sort((n,r)=>n[1]-r[1]),t=Math.floor(gt*.2);for(let n=0;n<t&&n<e.length;n++){let r=e[n][0];X.has(r)&&X.get(r).size>0||(j.delete(r),ee.delete(r),te.delete(r),z.delete(r),Ee.delete(r))}}var X=new Map;function Be(e,t){return X.has(e)||X.set(e,new Set),X.get(e).add(t),()=>{let n=X.get(e);n&&(n.delete(t),n.size===0&&X.delete(e))}}var Ue=new Set;function We(e){return Ue.add(e),()=>Ue.delete(e)}var ue=new Map,Ee=new Map,Ye=new Map;function yt(e){return Ye.get(e)||0}function Hr(e){Ye.set(e,yt(e)+1)}function xe(e){return e&&typeof e.unref=="function"&&e.unref(),e}function K(e){let t=W?.(),n=$(e);return t&&t.effects.push(n),n}function vt(e){let t=W?.();t&&t.effects.push(e)}function wt(e){let t=typeof e=="function"?e:()=>e,n=d(ce(()=>!!t()));return K(()=>{n.set(!!t())}),n}function Gr(e,t={}){let{method:n="GET",body:r,headers:o={},transform:s=g=>g,initialData:a=null}=t,c=d(a),u=d(null),p=d(!0),i=null;async function h(){i&&i.abort(),i=new AbortController;let{signal:g}=i;p.set(!0),u.set(null);try{let b=await fetch(e,{method:n,headers:{"Content-Type":"application/json",...o},body:r?JSON.stringify(r):void 0,signal:g});if(!b.ok)throw new Error(`HTTP ${b.status}: ${b.statusText}`);let S=await b.json();g.aborted||c.set(s(S))}catch(b){g.aborted||u.set(b)}finally{g.aborted||p.set(!1)}}return K(()=>(h(),()=>{i&&i.abort()})),{data:()=>c(),error:()=>u(),isLoading:()=>p(),refetch:h,mutate:g=>c.set(g)}}function $r(e,t,n={}){let{revalidateOnFocus:r=!0,revalidateOnReconnect:o=!0,refreshInterval:s=0,dedupingInterval:a=2e3,fallbackData:c,onSuccess:u,onError:p}=n;if(e==null||e===!1){let v=d(c||null),T=d(null);return{data:()=>v(),error:()=>T(),isLoading:()=>!1,isValidating:()=>!1,mutate:D=>v.set(typeof D=="function"?D(v()):D),revalidate:()=>Promise.resolve()}}let i=ae(e),h=Re(i),g=mt(i),b=Fr(i),S=P(()=>h()??c??null),I=P(()=>{let v=h()==null,T=b();return v&&T}),R=null;async function k({force:v=!1}={}){let T=Date.now(),D=yt(i);if(ue.has(i)){let f=ue.get(i);if(v?f.epoch===D:T-f.timestamp<a)return f.refCount++,f.promise}let C=Ee.get(i);if(!v&&C&&T-C<a&&h.peek()!=null)return h.peek();if(R){let f=ue.get(i);(!f||f.refCount<=1)&&R.abort()}R=new AbortController;let{signal:_}=R;b.set(!0);let m=t(e,{signal:_});ue.set(i,{promise:m,timestamp:T,refCount:1,epoch:D});try{let f=await m;return _.aborted?void 0:(O(()=>{h.set(f),g.set(null)}),z.set(i,Date.now()),Ee.set(i,Date.now()),u&&u(f,e),f)}catch(f){if(_.aborted)return;throw g.set(f),p&&p(f,e),f}finally{_.aborted||b.set(!1);let f=ue.get(i);f&&(f.refCount--,f.refCount<=0&&ue.delete(i))}}return K(()=>{let v=Be(i,()=>k({force:!0}).catch(()=>{})),T=We(()=>{R&&(R.abort(),R=null)});return k().catch(()=>{}),()=>{R&&R.abort(),v(),T()}}),r&&typeof window<"u"&&K(()=>{let v=()=>{document.visibilityState==="visible"&&k().catch(()=>{})};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)}),o&&typeof window<"u"&&K(()=>{let v=()=>k().catch(()=>{});return window.addEventListener("online",v),()=>window.removeEventListener("online",v)}),s>0&&K(()=>{let v=xe(setInterval(()=>{k().catch(()=>{})},s));return()=>clearInterval(v)}),{data:()=>S(),error:()=>g(),isLoading:()=>I(),isValidating:()=>b(),mutate:(v,T=!0)=>{let D=typeof v=="function"?v(h.peek()):v;h.set(D),z.set(i,Date.now()),T&&k().catch(()=>{})},revalidate:k}}function Vr(e){let{queryKey:t,queryFn:n,enabled:r=!0,staleTime:o=0,cacheTime:s=300*1e3,refetchOnWindowFocus:a=!0,refetchInterval:c=!1,retry:u=3,retryDelay:p=w=>Math.min(1e3*2**w,3e4),onSuccess:i,onError:h,onSettled:g,select:b,placeholderData:S}=e,I=ae(t),R=wt(r),k=Re(I),v=P(()=>{let w=k();return b&&w!=null?b(w):w}),T=mt(I),D=d(k.peek()!=null?"success":R.peek()?"loading":"idle"),C=d("idle"),_=P(()=>{let w=D(),M=k()!=null,ie=T()!=null,J=C()==="fetching";return w==="success"&&!M||w==="error"&&!ie?J?"loading":"idle":w}),m=0,f=null,A=null;async function F({force:w=!1,manual:M=!1}={}){if(!M&&!R.peek())return;let ie=Date.now();if(!w&&k.peek()!=null&&ie-m<o)return k.peek();f&&f.controller.abort();let J=new AbortController;f={controller:J,manual:M};let{signal:U}=J;C.set("fetching"),k.peek()==null&&D.set("loading");let l=0;async function x(){try{let E=await n({queryKey:Array.isArray(t)?t:[t],signal:U});return U.aborted?void 0:(O(()=>{k.set(E),T.set(null),D.set("success"),C.set("idle")}),m=Date.now(),z.set(I,Date.now()),i&&i(E),g&&g(E,null),A&&clearTimeout(A),A=xe(setTimeout(()=>{if(Date.now()-m>=s){let y=X.get(I);(!y||y.size===0)&&(j.delete(I),ee.delete(I),te.delete(I),z.delete(I),Ee.delete(I))}},s)),E)}catch(E){if(U.aborted)return;if(l++,l<u)return await new Promise((y,q)=>{let B=xe(setTimeout(y,p(l)));U.addEventListener("abort",()=>{clearTimeout(B),q(new DOMException("Aborted","AbortError"))},{once:!0})}).catch(y=>{if(y.name!=="AbortError")throw y}),U.aborted?void 0:x();throw O(()=>{T.set(E),D.set("error"),C.set("idle")}),h&&h(E),g&&g(null,E),E}}try{return await x()}finally{f&&f.controller===J&&(f=null)}}function G(){f&&(f.controller.abort(),f=null),O(()=>{D.peek()!=="idle"&&D.set("idle"),C.peek()!=="idle"&&C.set("idle")})}return K(()=>{let w=Be(I,()=>F({force:!0}).catch(()=>{})),M=We(G);return R()?F().catch(()=>{}):f?.manual||O(()=>{D.peek()==="loading"&&D.set("idle"),C.peek()!=="idle"&&C.set("idle")}),()=>{f&&!f.manual&&(f.controller.abort(),f=null),w(),M()}}),vt(()=>{f&&(f.controller.abort(),f=null)}),a&&typeof window<"u"&&K(()=>{let w=()=>{document.visibilityState==="visible"&&F().catch(()=>{})};return document.addEventListener("visibilitychange",w),()=>document.removeEventListener("visibilitychange",w)}),c&&K(()=>{let w=xe(setInterval(()=>{F().catch(()=>{})},c));return()=>clearInterval(w)}),{data:()=>v()??S,error:()=>T(),status:()=>_(),fetchStatus:()=>C(),isLoading:()=>_()==="loading",isError:()=>_()==="error",isSuccess:()=>_()==="success",isIdle:()=>_()==="idle",isFetching:()=>C()==="fetching",isEnabled:()=>R(),refetch:()=>F({force:!0,manual:!0})}}function jr(e){let{queryKey:t,queryFn:n,getNextPageParam:r,getPreviousPageParam:o,initialPageParam:s,enabled:a=!0,select:c,retry:u=3,retryDelay:p=w=>Math.min(1e3*2**w,3e4),onSuccess:i,onError:h,onSettled:g}=e,b=wt(a),S=d([]),I=d([]),R=d(!0),k=d(!1),v=d(!1),T=d(!1),D=d(null),C=d(b.peek()?"loading":"idle"),_=ae(t),m=null;function f(){m&&(m.controller.abort(),m=null),O(()=>{S.set([]),I.set([]),R.set(!0),k.set(!1),v.set(!1),T.set(!1),D.set(null),C.set("idle")})}async function A(w,M="next",{replace:ie=!1,manual:J=!1}={}){m&&m.controller.abort();let U=new AbortController;m={controller:U,manual:J,direction:M};let{signal:l}=U,x=M==="next"?v:T;x.set(!0),S.peek().length===0&&C.set("loading");let E=0;try{for(;;)try{let y=await n({queryKey:Array.isArray(t)?t:[t],pageParam:w,signal:l});return l.aborted?void 0:(O(()=>{ie?(S.set([y]),I.set([w])):M==="next"?(S.set([...S.peek(),y]),I.set([...I.peek(),w])):(S.set([y,...S.peek()]),I.set([w,...I.peek()]));let q=r?.(y,S.peek());if(R.set(q!==void 0),o){let B=o(y,S.peek());k.set(B!==void 0)}D.set(null),C.set("success")}),i&&i(y),g&&g(y,null),y)}catch(y){if(l.aborted)return;if(E++,E<u){if(await new Promise((q,B)=>{let _e=xe(setTimeout(q,p(E)));l.addEventListener("abort",()=>{clearTimeout(_e),B(new DOMException("Aborted","AbortError"))},{once:!0})}).catch(q=>{if(q.name!=="AbortError")throw q}),l.aborted)return;continue}throw O(()=>{D.set(y),C.set("error")}),h&&h(y),g&&g(null,y),y}}finally{let y=m&&m.controller!==U?m:null;(!l.aborted||!y||y.direction!==M)&&x.set(!1),m&&m.controller===U&&(m=null)}}function F({manual:w=!1}={}){return A(s,"next",{replace:!0,manual:w})}let G=P(()=>{let w={pages:S(),pageParams:I()};return c?c(w):w});return K(()=>{let w=Be(_,()=>{b.peek()&&F().catch(()=>{})}),M=We(f);return b()?A(s,"next",{replace:!0}).catch(()=>{}):m?.manual||O(()=>{C.peek()==="loading"&&C.set("idle"),v.peek()&&v.set(!1),T.peek()&&T.set(!1)}),()=>{m&&!m.manual&&(m.controller.abort(),m=null),w(),M()}}),vt(()=>{m&&(m.controller.abort(),m=null)}),{data:()=>G(),error:()=>D(),status:()=>C(),isLoading:()=>C()==="loading",isError:()=>C()==="error",isSuccess:()=>C()==="success",isIdle:()=>C()==="idle",isFetching:()=>v()||T(),isEnabled:()=>b(),hasNextPage:()=>R(),hasPreviousPage:()=>k(),isFetchingNextPage:()=>v(),isFetchingPreviousPage:()=>T(),fetchNextPage:async()=>{let w=S.peek();if(w.length===0)return A(s,"next",{replace:!0,manual:!0});let M=r?.(w[w.length-1],w);if(M!==void 0)return A(M,"next",{manual:!0})},fetchPreviousPage:async()=>{let w=S.peek();if(w.length===0)return A(s,"previous",{replace:!0,manual:!0});let M=o?.(w[0],w);if(M!==void 0)return A(M,"previous",{manual:!0})},refetch:()=>F({manual:!0})}}function qe(){let e=new Set(j.keys());for(let t of X.keys())e.add(t);return e}function Ur(e,t={}){let{hard:n=!1,exact:r=!1}=t,o=[];if(typeof e=="function")for(let s of qe())e(s)&&o.push(s);else if(Array.isArray(e)&&!r){let s=ae(e),a=s+":";for(let c of qe())(c===s||typeof c=="string"&&c.startsWith(a))&&o.push(c)}else o.push(ae(e));for(let s of o){Hr(s),n&&j.has(s)&&j.get(s).set(null);let a=X.get(s);if(a)for(let c of a)c()}}function qr(e,t){e=ae(e);let n=Re(e);return t(e).then(r=>(n.set(r),z.set(e,Date.now()),r))}function Br(e,t){e=ae(e);let n=Re(e),r=n.peek();n.set(typeof t=="function"?t(r):t),z.set(e,Date.now())}function Wr(e){return e=ae(e),j.has(e)?j.get(e).peek():void 0}function Yr(){O(()=>{for(let e of qe()){j.get(e)?.set(void 0),ee.get(e)?.set(null),te.get(e)?.set(!1);let t=X.get(e);t!==void 0&&t.size>0?z.set(e,Date.now()):(j.delete(e),ee.delete(e),te.delete(e),z.delete(e))}for(let e of Ue)e()}),Ee.clear(),ue.clear(),Ye.clear()}function Xr(){let e=[];for(let[t,n]of j)e.push({key:t,data:n.peek(),error:ee.has(t)?ee.get(t).peek():null,isValidating:te.has(t)?te.get(t).peek():!1});return e}function xt(e,t){typeof e=="function"?e(t):e&&typeof e=="object"&&(e.current=t)}function zr(e,t){return typeof e!="function"?t:typeof t!="function"?e:function(...r){return e.apply(this,r),t.apply(this,r)}}function Qr(e,t){let n={...e},r=new Map;for(let o in n)Ne(o)&&r.set(o.slice(2).toLowerCase(),o);for(let o in t){let s=t[o];if(!Ne(o)){n[o]=s;continue}let a=r.get(o.slice(2).toLowerCase());if(a===void 0){n[o]=s,r.set(o.slice(2).toLowerCase(),o);continue}n[a]=zr(s,n[a])}return n}function Kr(e={}){let t=W?.();if(t){let n=t.hookIndex++;return t.hooks[n]||(t.hooks[n]=Et(e)),t.hooks[n]}return Et(e)}function Et(e={}){let{defaultValues:t={},mode:n="onSubmit",reValidateMode:r="onChange",resolver:o}=e,s={},a={},c={},u=d({});function p(l){return s[l]||(s[l]=d(t[l]??"")),s[l]}function i(l){return a[l]||(a[l]=d(null)),a[l]}function h(l){return c[l]||(c[l]=d(!1)),c[l]}let g=d(!1),b=d(!1),S=d(!1),I=d(!1),R=d(0);function k(l=!1){let x={...t};for(let[E,y]of Object.entries(s))x[E]=l?y():y.peek();return x}function v(l=!1){return l?u():u.peek()}function T(l,x){let E=x??null;i(l).set(E),u.set(y=>{if(y[l]===E)return y;if(E==null){if(!Object.prototype.hasOwnProperty.call(y,l))return y;let B={...y};return delete B[l],B}return{...y,[l]:E}})}function D(l={}){let x=l||{};O(()=>{for(let[E,y]of Object.entries(a))Object.prototype.hasOwnProperty.call(x,E)||y.set(null);for(let[E,y]of Object.entries(x))i(E).set(y??null);u.set({...x})})}let C=P(()=>Object.keys(v(!0)).length===0),_=P(()=>{let l={};for(let[x,E]of Object.entries(s))E()!==(t[x]??"")&&(l[x]=!0);return l});async function m(l){if(!o)return!0;I.set(!0);try{let E=(await o(k(!1)))?.errors||{};if(l){let y=E[l]??null;return T(l,y),!y}else return D(E),Object.keys(E).length===0}finally{I.set(!1)}}function f(l,x={}){let E=p(l),y=x.type==="radio",q=x.type==="checkbox",B=y&&x.value!==void 0;function _e(V){if(B)return x.value;if(V)return typeof V.hasAttribute=="function"?V.hasAttribute("value")?V.value:void 0:V.value}let Qe=!1,Ke=!1,Ie=V=>{let H=V&&V.target;if(!H){L&&console.warn(`[what] register("${l}") change handler was called without an event. Pass the DOM event through (or call form.setValue() directly). Ignoring.`);return}let he=x.type||H.type,ne;if(he==="radio"){if(ne=_e(H),ne===void 0){L&&!Qe&&(Qe=!0,console.warn(`[what] register("${l}", { type: 'radio' }) cannot tell which value this radio contributes: pass { value } or give the <input> a value attribute. Field left unchanged.`));return}}else he==="checkbox"?ne=H.checked:ne=H.value;A(l,ne),(n==="onChange"||S.peek()&&r==="onChange")&&m(l)},Q={name:l,onBlur:()=>{h(l).set(!0),(n==="onBlur"||S.peek()&&r==="onBlur")&&m(l)},onFocus:()=>{},ref:x.ref};if(y){let V=B?()=>E()===x.value:()=>!1;B&&(Q.value=x.value),Q.checked=V,Q.onchange=Ie,Q.ref=H=>{if(xt(x.ref,H),!H||typeof H!="object")return;H._propEffects||(H._propEffects={});let he="checked:property";if(H._propEffects[he])try{H._propEffects[he]()}catch{}H._propEffects[he]=$(()=>{let ne=_e(H);H.checked=ne!==void 0&&E()===ne})}}else q?(Object.defineProperty(Q,"checked",{get(){return!!E()},enumerable:!0}),Q.onchange=Ie):(Object.defineProperty(Q,"value",{get(){return E()},enumerable:!0}),Q.oninput=Ie,Q.ref=V=>{xt(x.ref,V),L&&!Ke&&V&&V.type==="radio"&&(Ke=!0,console.warn(`[what] register("${l}") was spread onto <input type="radio"> without a type. Radios in a group share one field holding the SELECTED option, so the registration must be told this radio's value: register("${l}", { type: 'radio', value: ... }), or use <Radio name value register />. As written, the registration overwrote the input's own value and the group cannot record a choice.`))});return Q}function A(l,x,E={}){let{shouldValidate:y=!1,shouldDirty:q=!0}=E;p(l).set(x),q&&g.set(!0),y&&m(l)}function F(l){return p(l)()}function G(l,x){T(l,x)}function w(l){T(l,null)}function M(){D({})}function ie(l=t){O(()=>{for(let[x,E]of Object.entries(s))E.set(l[x]??"");for(let x of Object.values(a))x.set(null);u.set({});for(let x of Object.values(c))x.set(!1);g.set(!1),S.set(!1)})}function J(l,x){return async E=>{E&&E.preventDefault(),b.set(!0),S.set(!0),R.set(R.peek()+1);try{await m()?await l(k()):x&&x(v(!1))}finally{b.set(!1)}}}function U(l){return l?P(()=>p(l)()):P(()=>k(!0))}return{register:f,handleSubmit:J,setValue:A,getValue:F,setError:G,clearError:w,clearErrors:M,reset:ie,watch:U,validate:m,formState:{get values(){return k(!0)},get errors(){return v(!0)},error:l=>i(l)(),get touched(){let l={};for(let[x,E]of Object.entries(c))E()&&(l[x]=!0);return l},isDirty:()=>g(),isValid:C,isValidating:()=>I(),isSubmitting:()=>b(),isSubmitted:()=>S(),submitCount:()=>R(),dirtyFields:_}}}function Jr(e){return!e||typeof e!="object"?null:Array.isArray(e.issues)?e.issues:Array.isArray(e.errors)?e.errors:null}function Zr(e){let t=e?.path;if(t==null)return"";if(!Array.isArray(t))return String(t);let n="";for(let r=0;r<t.length;r++){let o=t[r];n+=(r?".":"")+(typeof o=="symbol"?o.toString():String(o))}return n}function eo(e){return async t=>{try{return{values:await e.parseAsync(t),errors:{}}}catch(n){let r=Jr(n);if(!r)throw n;let o={};for(let s of r){let a=Zr(s);o[a]||(o[a]={type:s.code??"validation",message:s.message})}return Object.keys(o).length===0&&(o[""]={type:"validation",message:n?.message||"Validation failed"}),{values:{},errors:o}}}}function to(e){return!e||typeof e!="object"?!1:e.name==="ValidationError"||Array.isArray(e.inner)}function no(e){return async t=>{try{return{values:await e.validate(t,{abortEarly:!1}),errors:{}}}catch(n){if(!to(n))throw n;let r={},o=Array.isArray(n.inner)&&n.inner.length>0?n.inner:[n];for(let s of o){let a=s.path??"";r[a]||(r[a]={type:s.type??"validation",message:s.message})}return{values:{},errors:r}}}}function ro(e){return async t=>{let n={};for(let[r,o]of Object.entries(e)){let s=t[r];for(let a of o){let c=a(s,t);if(c){n[r]={type:"validation",message:c};break}}}return{values:t,errors:n}}}var oo={required:(e="This field is required")=>t=>{if(t==null||t==="")return e},minLength:(e,t)=>n=>{if(typeof n=="string"&&n.length<e)return t||`Must be at least ${e} characters`},maxLength:(e,t)=>n=>{if(typeof n=="string"&&n.length>e)return t||`Must be at most ${e} characters`},min:(e,t)=>n=>{if(typeof n=="number"&&n<e)return t||`Must be at least ${e}`},max:(e,t)=>n=>{if(typeof n=="number"&&n>e)return t||`Must be at most ${e}`},pattern:(e,t="Invalid format")=>n=>{if(typeof n=="string"&&!e.test(n))return t},email:(e="Invalid email address")=>t=>{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t))return e},url:(e="Invalid URL")=>t=>{try{typeof t=="string"&&t&&new URL(t)}catch{return e}},match:(e,t)=>(n,r)=>{if(n!==r[e])return t||`Must match ${e}`},custom:e=>e};function so(e,t={}){let{validate:n,defaultValue:r=""}=t,o=d(r),s=d(null),a=d(!1),c=d(!1);async function u(){if(!n)return!0;let p=await n(o.peek());return s.set(p||null),!p}return{name:e,value:()=>o(),error:()=>s(),isTouched:()=>a(),isDirty:()=>c(),setValue:p=>{o.set(p),c.set(!0)},setError:p=>s.set(p),validate:u,reset:()=>{o.set(r),s.set(null),a.set(!1),c.set(!1)},inputProps:()=>({name:e,value:o(),onInput:p=>{o.set(p.target.value),c.set(!0)},onBlur:()=>{a.set(!0),u()}})}}function ao(e){let{register:t,error:n,...r}=e,o=t?t(e.name):{};return N("input",{...r,...o,"aria-invalid":n?"true":void 0})}function io(e){let{register:t,error:n,...r}=e,o=t?t(e.name):{};return N("textarea",{...r,...o,"aria-invalid":n?"true":void 0})}function co(e){let{register:t,error:n,children:r,...o}=e,s=t?t(e.name):{};return N("select",{...o,...s,"aria-invalid":n?"true":void 0},r)}function lo(e){let{register:t,...n}=e,r=t?t(e.name):{};return N("input",{type:"checkbox",...n,...r,checked:r.value})}function uo(e){let{register:t,value:n,...r}=e;if(n===void 0)return L&&console.warn(`[what] <Radio name="${e.name}"> is missing a \`value\` prop. Radios in a group share one field holding the selected option's value, so a valueless radio has nothing to contribute and cannot be checked. Rendering it unregistered.`),N("input",{type:"radio",...r});let o=t?t(e.name,{type:"radio",value:n,ref:r.ref}):{};return N("input",Qr({type:"radio",value:n,...r},o))}function fo({name:e,formState:t,errors:n,render:r}){let o=t&&typeof t.error=="function"?t.error(e):(t?.errors!=null?t.errors:typeof n=="function"?n():n)?.[e]||null;return o?r?r({message:o.message,type:o.type}):N("span",{class:"what-error",role:"alert"},o.message):null}var ze={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:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
effect(() => {
|
|
97
|
-
window.addEventListener('resize', handler);
|
|
98
|
-
return () => window.removeEventListener('resize', handler);
|
|
99
|
-
});`},UNSAFE_INNERHTML:{code:"ERR_UNSAFE_INNERHTML",severity:"warning",template:"innerHTML set on element without using the __html safety marker.",suggestion:"Use the html tagged template literal or pass { __html: content } to mark innerHTML as intentional and reviewed.",codeExample:`// Bad \u2014 raw innerHTML (XSS risk):
|
|
100
|
-
<div innerHTML={userInput} />
|
|
101
|
-
|
|
102
|
-
// Good \u2014 explicit opt-in:
|
|
103
|
-
<div innerHTML={{ __html: sanitizedContent }} />
|
|
104
|
-
|
|
105
|
-
// Better \u2014 use the html template literal:
|
|
106
|
-
html\`<div>\${sanitizedContent}</div>\``},MISSING_KEY:{code:"ERR_MISSING_KEY",severity:"warning",template:'List rendered without key prop in component "{{component}}". Items may re-order incorrectly.',suggestion:"Add a unique key prop to each item in a list. Use a stable identifier (like an ID), not the array index.",codeExample:`// Bad \u2014 no key:
|
|
107
|
-
<For each={items()}>{item => <li>{item.name}</li>}</For>
|
|
108
|
-
|
|
109
|
-
// Good \u2014 stable key:
|
|
110
|
-
<For each={items()}>{item => <li key={item.id}>{item.name}</li>}</For>`},ASYNC_MIDDLEWARE:{code:"ERR_ASYNC_MIDDLEWARE",severity:"error",template:"Route middleware must be synchronous; received a promise or thenable.",suggestion:"Return true or void to continue, false to deny access, or a redirect path synchronously. Promises and thenables fail closed: the protected component never mounts, and their results are not awaited or used to authorize navigation. For async authorization, wrap the route component with asyncGuard(check)(Component), optionally passing fallback and loading options to asyncGuard.",codeExample:`// Bad - an async middleware result cannot authorize a route:
|
|
111
|
-
{ path: '/private', component: Component, middleware: [async () => check()] }
|
|
112
|
-
|
|
113
|
-
// Good - the component wrapper waits for the authorization check:
|
|
114
|
-
{ path: '/private', component: asyncGuard(check)(Component) }
|
|
115
|
-
|
|
116
|
-
// Optional denial redirect and loading UI:
|
|
117
|
-
{ path: '/private', component: asyncGuard(check, { fallback: '/login', loading: Spinner })(Component) }`},UNSAFE_REDIRECT:{code:"ERR_UNSAFE_REDIRECT",severity:"error",template:"redirect() refused an unsafe target: {{target}}.",suggestion:'redirect() accepts same-origin paths and http:, https:, mailto: or tel: URLs only. Protocol-relative ("//host"), backslash-smuggled and javascript:/data: targets are open-redirect vectors. Check a user-supplied target against an allowlist first.',codeExample:`// Bad - a user-controlled target can leave your origin:
|
|
118
|
-
redirect(query.next);
|
|
119
|
-
|
|
120
|
-
// Good - allowlist the target first:
|
|
121
|
-
redirect(ALLOWED.has(query.next) ? query.next : '/');`},REDIRECT_NOT_CAUGHT:{code:"ERR_REDIRECT_NOT_CAUGHT",severity:"error",template:'A redirect() to "{{target}}" surfaced uncaught, so nothing performed the navigation.',suggestion:"redirect() is caught in route middleware and in a component body. From an event handler, a promise callback, a timer or a reactive thunk, call navigate(to) instead. If the call is inside a try/catch, rethrow anything whose name is RouterRedirect. On the server this signal escapes renderToString to its caller: read its `to` and emit a 302 rather than calling navigate().",codeExample:`// Bad - a reactive thunk re-runs outside the render the Router caught:
|
|
122
|
-
<div>{() => (loggedOut() ? redirect('/login') : <Dashboard />)}</div>
|
|
123
|
-
|
|
124
|
-
// Good - navigate() from a thunk or a handler:
|
|
125
|
-
<div>{() => (loggedOut() ? (navigate('/login'), null) : <Dashboard />)}</div>
|
|
126
|
-
<button onclick={() => navigate('/login')}>Sign in</button>
|
|
127
|
-
|
|
128
|
-
// On the server, catch it instead of navigating:
|
|
129
|
-
try { html = renderToString(<App />); }
|
|
130
|
-
catch (e) { if (e.name === 'RouterRedirect') return Response.redirect(e.to, 302); throw e; }`},NO_SECURE_RANDOM:{code:"ERR_NO_SECURE_RANDOM",severity:"error",template:"[what] No secure random source available for CSRF token generation.",suggestion:"Neither globalThis.crypto.getRandomValues nor node:crypto was reachable. On Node this means a build older than 18 or a bundler that stripped node:crypto; on an edge runtime it means the Web Crypto global was not provided. A CSRF token from Math.random is not a token, so this refuses rather than degrading.",codeExample:`// Node 18+ exposes Web Crypto globally; nothing to configure.
|
|
131
|
-
// If a bundler dropped it, restore the global before creating the server:
|
|
132
|
-
import { webcrypto } from 'node:crypto';
|
|
133
|
-
globalThis.crypto ??= webcrypto;`},ACTION_FAILED:{code:"ERR_ACTION_FAILED",severity:"error",template:"{{message}}",suggestion:"The server action rejected. The message is the one the action threw, forwarded to the client by the action handler. Throw a typed error from the action and branch on its shape rather than parsing this string.",codeExample:`// In the action, fail with something the client can read:
|
|
134
|
-
export const save = action(async (data) => {
|
|
135
|
-
if (!data.email) throw Object.assign(new Error('Email required'), { field: 'email' });
|
|
136
|
-
});`},STATIC_WRITE_ESCAPE:{code:"ERR_STATIC_WRITE_ESCAPE",severity:"error",template:"[what-server] Refusing to write outside outDir: {{path}}.",suggestion:'A route path resolved to a location outside the export directory, which a "../" segment in a route or a param can do. Sanitize the route path, or drop the route from the static export.',codeExample:`// Bad \u2014 a param that can contain a slash escapes outDir:
|
|
137
|
-
{ path: '/docs/:slug*', mode: 'static' }
|
|
138
|
-
|
|
139
|
-
// Good \u2014 constrain the param, or precompute the exact paths:
|
|
140
|
-
{ path: '/docs/:slug', mode: 'static', paths: () => slugs.map(slug => ({ slug })) }`},INVALID_HTML_NESTING:{code:"ERR_INVALID_HTML_NESTING",severity:"error",template:"<{{parent}}> cannot contain <{{child}}>: the HTML parser closed the outer tag early, so the rendered tree does not match your JSX.",suggestion:"The compiler turns each element into an HTML template string, and the browser parses it under real HTML rules. Some nestings are not expressible: <p> may only hold phrasing content, <a> may not hold another <a>, and a table section may not hold arbitrary elements. The parser silently reorders them, which leaves compiled output walking a tree that no longer matches your source. Change the outer tag (usually <p> to <div>) or move the child out.",codeExample:`// Bad \u2014 the parser closes <p> before <div>, producing four sibling nodes:
|
|
141
|
-
<p>Intro<div>{body()}</div>Outro</p>
|
|
142
|
-
|
|
143
|
-
// Good \u2014 a block container can hold block content:
|
|
144
|
-
<div class="prose">Intro<div>{body()}</div>Outro</div>
|
|
145
|
-
|
|
146
|
-
// Good \u2014 or keep the paragraph and use phrasing content:
|
|
147
|
-
<p>Intro<span>{body()}</span>Outro</p>`},INVALID_SSR_TAG:{code:"ERR_INVALID_SSR_TAG",severity:"error",template:"[what-server] Invalid tag name in SSR: {{tag}}.",suggestion:"renderToString reached a vnode whose tag is neither a string nor a component function. This is almost always a component that returned a raw object, or a value interpolated where an element was expected.",codeExample:`// Bad \u2014 returns a plain object, not a vnode:
|
|
148
|
-
function Row() { return { name: 'a' }; }
|
|
149
|
-
|
|
150
|
-
// Good \u2014 return elements, and interpolate values as children:
|
|
151
|
-
function Row({ name }) { return <li>{name}</li>; }`},COMPILED_JSX_IN_SSR:{code:"ERR_COMPILED_JSX_IN_SSR",severity:"error",template:"what-compiler output cannot be server-rendered: {{file}}.",suggestion:'what-compiler lowers JSX to module-scope _$template() calls that run document.createElement() at import time, and to _$createComponent() which builds DOM. Neither has a server-rendered form, so a module it compiled throws "document is not defined" when a server imports it. Server-rendered views have two supported spellings: author them with h(), or compile them with the automatic JSX runtime (jsxImportSource: "what-framework"), which emits h() calls that renderToString understands. what-compiler stays on the client entry, where the fine-grained output is the point.',codeExample:`// Bad \u2014 a server module compiled by what-compiler:
|
|
152
|
-
// vite.config.js: plugins: [what()] + vite build --ssr
|
|
153
|
-
export function Page() { return <h1>Hi</h1>; } // throws on import
|
|
154
|
-
|
|
155
|
-
// Good \u2014 h(), which renderToString understands:
|
|
156
|
-
import { h } from 'what-framework';
|
|
157
|
-
export function Page() { return h('h1', null, 'Hi'); }
|
|
158
|
-
|
|
159
|
-
// Good \u2014 the automatic JSX runtime for the server build:
|
|
160
|
-
// vite.config.js (server): esbuild: { jsx: 'automatic',
|
|
161
|
-
// jsxImportSource: 'what-framework' }
|
|
162
|
-
export function Page() { return <h1>Hi</h1>; } // lowers to h()`},FORM_ACTION_NOT_REGISTERED:{code:"ERR_FORM_ACTION_NOT_REGISTERED",severity:"error",template:"[what] <Form action={fn}>: that function is not a server action.",suggestion:"Wrap it with action() from what-server, or pass the action id as a string. A plain function has no id, so there is nothing for the form post to address.",codeExample:`// Bad \u2014 a plain function:
|
|
163
|
-
async function save(data) {}
|
|
164
|
-
<Form action={save} />
|
|
165
|
-
|
|
166
|
-
// Good \u2014 a registered action:
|
|
167
|
-
export const save = action(async (data) => {});
|
|
168
|
-
<Form action={save} />`},FORM_ACTION_MISSING:{code:"ERR_FORM_ACTION_MISSING",severity:"error",template:"[what] <Form> requires an `action` prop: a server action or its id.",suggestion:"Pass the action itself, or the string id it was registered under.",codeExample:`// Bad:
|
|
169
|
-
<Form method="post" />
|
|
170
|
-
|
|
171
|
-
// Good:
|
|
172
|
-
<Form action={save} />
|
|
173
|
-
<Form action="save-user" />`},ISLAND_STORE_OUTSIDE_RENDER:{code:"ERR_ISLAND_STORE_OUTSIDE_RENDER",severity:"error",template:'[what-server] Island store "{{name}}" was accessed outside an active server render.',suggestion:"A module-scoped island store resolves against the current request, so it can only be read or written from a component rendered by renderDocument/renderPage. Reading one at module scope, or from a background task, has no request to bind to.",codeExample:`// Bad \u2014 runs at import time, with no request in scope:
|
|
174
|
-
const count = cart.items.length;
|
|
175
|
-
|
|
176
|
-
// Good \u2014 read it inside a component the server is rendering:
|
|
177
|
-
function Cart() { return <span>{cart.items.length}</span>; }`},ISR_MISSING_CLIENT:{code:"ERR_ISR_MISSING_CLIENT",severity:"error",template:"[what-isr] createRedisStore requires { client }.",suggestion:"what-isr ships no Redis driver on purpose, so the client is injected. Pass an ioredis or node-redis instance (get/set/del/sadd/srem/smembers, optionally expire/scan/keys).",codeExample:`import Redis from 'ioredis';
|
|
178
|
-
const store = createRedisStore({ client: new Redis(process.env.REDIS_URL) });`},ISR_VARY_UNRESOLVED:{code:"ERR_ISR_VARY_UNRESOLVED",severity:"error",template:"[what-isr] cannot build a cache key: `vary` is declared but could not be resolved against the request.",suggestion:"A declared vary is a list of names that must be resolved against real request headers before it can be part of a key. Either pass the request headers alongside the declaration, or pass an already-resolved name -> value object. Guessing would cache one visitor page under another visitor key.",codeExample:`// Bad \u2014 a declaration with nothing to resolve it against:
|
|
179
|
-
cacheKey({ path, vary: ['cookie:session'] });
|
|
180
|
-
|
|
181
|
-
// Good \u2014 supply the headers:
|
|
182
|
-
cacheKey({ path, vary: ['cookie:session'], headers: request.headers });
|
|
183
|
-
|
|
184
|
-
// Good \u2014 or resolve it yourself:
|
|
185
|
-
cacheKey({ path, vary: { 'cookie:session': sessionId } });`},ISR_VARY_NO_HEADERS:{code:"ERR_ISR_VARY_NO_HEADERS",severity:"error",template:"[what-isr] route declares `vary` but the adapter supplied no request headers; refusing to cache.",suggestion:"The route varies its output per header, and the adapter called the engine without them. Caching anyway would serve one variant to every request. Forward the request headers from the adapter into the engine call.",codeExample:`// In the adapter:
|
|
186
|
-
await engine.handle(routeMatch, { headers: request.headers });`},DUPLICATE_ACTION_ID:{code:"ERR_DUPLICATE_ACTION_ID",severity:"error",template:'Duplicate server action ID "{{id}}".',suggestion:"Action ids are the wire address of a server action, so two actions cannot share one. Ids derive from the file path and export name, so this usually means the same action is being registered twice, or an explicit id was reused.",codeExample:`// Bad \u2014 two actions pinned to the same id:
|
|
187
|
-
export const save = action(fn, { id: 'save' });
|
|
188
|
-
export const store = action(fn, { id: 'save' });
|
|
189
|
-
|
|
190
|
-
// Good \u2014 let ids derive, or make them distinct:
|
|
191
|
-
export const save = action(fn);
|
|
192
|
-
export const store = action(fn, { id: 'store-user' });`},PAGE_NO_DEFAULT_EXPORT:{code:"ERR_PAGE_NO_DEFAULT_EXPORT",severity:"error",template:"Page module has no default-exported component.",suggestion:"A page file must default-export the component to render. A named export cannot be found by the file-router.",codeExample:`// Bad:
|
|
193
|
-
export function Home() { return <h1>Hi</h1>; }
|
|
194
|
-
|
|
195
|
-
// Good:
|
|
196
|
-
export default function Home() { return <h1>Hi</h1>; }`},HOOK_OUTSIDE_RENDER:{code:"ERR_HOOK_OUTSIDE_RENDER",severity:"error",template:"[what-react] {{hookName}}() called outside of a component render.",suggestion:"Hooks can only be called while a what-react component is rendering. When this happens inside a React library, the usual cause is two module instances: make sure every `react` and `react-dom` import is aliased to what-react by the reactCompat() vite plugin.",codeExample:`// vite.config.js
|
|
197
|
-
import { reactCompat } from 'what-react/vite';
|
|
198
|
-
export default { plugins: [reactCompat()] };`},CHILDREN_ONLY:{code:"ERR_CHILDREN_ONLY",severity:"error",template:"React.Children.only expected to receive a single React element child.",suggestion:"Children.only asserts exactly one element. Pass one child, or use Children.toArray/Children.map when the count can vary.",codeExample:`// Bad:
|
|
199
|
-
<Tooltip><span>a</span><span>b</span></Tooltip>
|
|
200
|
-
|
|
201
|
-
// Good:
|
|
202
|
-
<Tooltip><span>a</span></Tooltip>`},USE_INVALID_ARG:{code:"ERR_USE_INVALID_ARG",severity:"error",template:"[what-react] use() expects a promise or a context.",suggestion:"use() reads either a thenable or a context object. Anything else has nothing to suspend on or subscribe to.",codeExample:`// Good:
|
|
203
|
-
const value = use(ThemeContext);
|
|
204
|
-
const data = use(fetchUser(id));`},PRETEXT_NOT_INSTALLED:{code:"ERR_PRETEXT_NOT_INSTALLED",severity:"error",template:"[what-text] Failed to load @chenglou/pretext: {{message}}.",suggestion:"what-text declares pretext as an optional peer so the package installs without it. Install it to use the text engine: npm install @chenglou/pretext",codeExample:"npm install @chenglou/pretext"},DESTRUCTURED_PROPS:{code:"ERR_DESTRUCTURED_PROPS",severity:"warning",template:"Destructuring '{{binding}}' in the component body snapshots props and loses reactivity.",suggestion:"What components run ONCE, so the body is not re-run when a prop changes. Reading `props.foo` goes through the reactive proxy and tracks; `const { foo } = props` reads the value once and detaches it. Read through the proxy inside JSX and effects, or wrap each field in an accessor.",codeExample:`// Bad - snapshots at first run, never updates:
|
|
205
|
-
function Row(props) {
|
|
206
|
-
const { label } = props;
|
|
207
|
-
return <span>{label}</span>;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Good - reads through the proxy each time:
|
|
211
|
-
function Row(props) {
|
|
212
|
-
return <span>{props.label}</span>;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Good - an accessor keeps the destructured name:
|
|
216
|
-
function Row(props) {
|
|
217
|
-
const label = () => props.label;
|
|
218
|
-
return <span>{label()}</span>;
|
|
219
|
-
}`},RUNTIME:{code:"ERR_RUNTIME",severity:"error",template:"{{message}}",suggestion:"An error surfaced that the framework could not classify, so the message is the original one verbatim. The stack, file and line on the error narrow it; if the same shape shows up repeatedly it is worth its own code here.",codeExample:`// Inspect the structured form rather than the string:
|
|
220
|
-
try { render(); } catch (e) { console.log(classifyError(e).toJSON()); }`},UNKNOWN:{code:"ERR_UNKNOWN",severity:"error",template:"Unknown error: {{errorCode}}.",suggestion:"createWhatError() was called with a code that is not in this catalogue. Check the spelling against ERROR_CODES, or add the entry.",codeExample:`// Bad - not a catalogue key:
|
|
221
|
-
createWhatError('MISSING_KEYS');
|
|
222
|
-
|
|
223
|
-
// Good:
|
|
224
|
-
createWhatError('MISSING_KEY', { component: 'TodoList' });`},UNKNOWN_TOOL:{code:"ERR_UNKNOWN_TOOL",severity:"error",template:"Unknown tool: {{name}}.",suggestion:"The MCP client called a tool this server does not expose. Call tools/list to enumerate what is available; a stale client cache is the usual cause.",codeExample:`// List what the server actually exposes:
|
|
225
|
-
{ "method": "tools/list" }`}},Xe=null;function St(e){return Xe===null&&(Xe=new Map(Object.values(ze).map(t=>[t.code,t]))),Xe.get(e)}var pe=class extends Error{constructor({code:t,message:n,suggestion:r,codeExample:o,file:s,line:a,component:c,signal:u,effect:p}){super(n),this.name="WhatError",this.code=t,this.suggestion=r,this.codeExample=o,this.file=s,this.line=a,this.component=c,this.signal=u,this.effect=p}toJSON(){return{code:this.code,message:this.message,suggestion:this.suggestion,codeExample:this.codeExample,file:this.file,line:this.line,component:this.component,signal:this.signal,effect:this.effect}}};function fe(e,t={}){let n=typeof e=="string"?ze[e]:e;if(!n)return new pe({code:"ERR_UNKNOWN",message:`Unknown error: ${e}`,suggestion:"Check the error code and try again."});let r=n.template;for(let[o,s]of Object.entries(t))r=r.replace(new RegExp(`\\{\\{${o}\\}\\}`,"g"),String(s));return r=r.replace(/\{\{[^}]+\}\}/g,"(unknown)"),new pe({code:n.code,message:r,suggestion:n.suggestion,codeExample:n.codeExample,file:t.file,line:t.line,component:t.component,signal:t.signal||t.signalName,effect:t.effect||t.effectName})}var de=[],bt=200;function Ce(e){L&&(de.push({...e.toJSON(),timestamp:Date.now()}),de.length>bt&&(de=de.slice(-bt)))}function Ae(e){return e?de.filter(t=>t.timestamp>e):de.slice()}function po(){de=[]}function ho(e,t={}){let n=e?.message||String(e);if(e&&typeof e.code=="string"){let r=St(e.code);if(r)return new pe({code:r.code,message:n,suggestion:r.suggestion,codeExample:r.codeExample,file:t.file,line:t.line,component:t.component,signal:t.signal||t.signalName,effect:t.effect||t.effectName})}return n.includes("infinite effect loop")||n.includes("25 iterations")?fe("INFINITE_EFFECT",t):n.includes("hydration")||n.includes("Hydration")?fe("HYDRATION_MISMATCH",t):n.includes("Signal.set() called inside a computed")?fe("SIGNAL_WRITE_IN_RENDER",{...t,signalName:n.match(/signal: (\w+)/)?.[1]||t.signalName}):new pe({code:"ERR_RUNTIME",message:n,suggestion:"Check the stack trace and component context for more details.",...t})}var be={signalReadDetection:!0,componentNaming:!0,importValidation:!0};function go(e){Object.assign(be,e)}function mo(){return{...be}}function yo(e,t){return!L||!be.signalReadDetection||(e.toString=function(){let n=fe("MISSING_SIGNAL_READ",{signalName:t||"(unnamed)"});return console.warn(`[what] ${n.message}
|
|
226
|
-
Suggestion: ${n.suggestion}`),Ce(n),String(e())},e.valueOf=function(){let n=fe("MISSING_SIGNAL_READ",{signalName:t||"(unnamed)"});return console.warn(`[what] ${n.message}
|
|
227
|
-
Suggestion: ${n.suggestion}`),Ce(n),e()}),e}function vo(e){if(!L||!be.componentNaming||!e||/^[A-Z]/.test(e))return null;let t=`Component "${e}" should use PascalCase (e.g., "${wo(e)}"). PascalCase distinguishes components from HTML elements in JSX and is required by the What Framework compiler.`;return console.warn(`[what] ${t}`),{code:"WARN_COMPONENT_NAMING",name:e,suggestion:t}}function wo(e){return e.charAt(0).toUpperCase()+e.slice(1)}var _t=new Set(["signal","computed","effect","signalMemo","batch","untrack","flushSync","createRoot","getOwner","runWithOwner","onRootCleanup","__setDevToolsHooks","template","_template","svgTemplate","insert","mapArray","spread","setProp","delegateEvents","on","classList","hydrate","isHydrating","_$createComponent","h","Fragment","html","mount","useState","useSignal","useComputed","useEffect","useMemo","useCallback","useRef","useContext","useReducer","createContext","onMount","onCleanup","createResource","memo","lazy","Suspense","ErrorBoundary","Show","For","Switch","Match","Island","createStore","derived","storeComputed","atom","Head","clearHead","each","cls","style","debounce","throttle","useMediaQuery","useLocalStorage","useClickOutside","Portal","transition","scheduleRead","scheduleWrite","flushScheduler","measure","mutate","useScheduledEffect","nextFrame","raf","onResize","onIntersect","smoothScrollTo","_setTextInsertHook","spring","tween","easings","useTransition","useGesture","useAnimatedValue","createTransitionClasses","cssTransition","useFocus","useFocusRestore","useFocusTrap","FocusTrap","announce","announceAssertive","SkipLink","useAriaExpanded","useAriaSelected","useAriaChecked","useRovingTabIndex","VisuallyHidden","LiveRegion","useId","useIds","useDescribedBy","useLabelledBy","Keys","onKey","onKeys","Skeleton","SkeletonText","SkeletonAvatar","SkeletonCard","SkeletonTable","IslandSkeleton","useSkeleton","Placeholder","LoadingDots","Spinner","useFetch","useSWR","useQuery","useInfiniteQuery","invalidateQueries","prefetchQuery","setQueryData","getQueryData","clearCache","__getCacheSnapshot","useForm","useField","rules","simpleResolver","zodResolver","yupResolver","Input","Textarea","Select","Checkbox","Radio","ErrorMessage"]);function xo(e){if(!L||!be.importValidation)return[];let t=[];for(let n of e)_t.has(n)||t.push({name:n,message:`"${n}" is not a valid export from what-framework.`,suggestion:`Check the API reference. Did you mean: ${Eo(n)}?`});return t}function Eo(e){let t=e.toLowerCase(),n=null,r=1/0;for(let o of _t){let s=bo(t,o.toLowerCase());s<r&&(r=s,n=o)}return r<=3?n:"(no close match found)"}function bo(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[];for(let r=0;r<=t.length;r++)n[r]=[r];for(let r=0;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=t.length;r++)for(let o=1;o<=e.length;o++){let s=t[r-1]===e[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+s)}return n[t.length][e.length]}var So="0.14.0",Se=[];function _o(e){L&&Se.push(e)}function ko(e){if(!L)return;let t=Se.indexOf(e);t>=0&&Se.splice(t,1)}function kt(){return Se.slice()}var ve=[];function Ro(e){L&&ve.push(e)}function Co(e){if(!L)return;let t=ve.indexOf(e);t>=0&&ve.splice(t,1)}function Rt(){return ve.slice()}function Ct(){let e=Ae(),t=e.filter(u=>Date.now()-u.timestamp<6e4),r=e.filter(u=>u.code==="ERR_INFINITE_EFFECT").length>0,o=e.filter(u=>u.code==="ERR_ORPHAN_EFFECT"),s=ve.filter(u=>!!(u._subs&&u._subs.size===0)).length,a=ve.length,c=a>1e4?"high":a>1e3?"medium":"low";return{effectCycleRisk:r,orphanEffects:o.length,signalLeaks:s,memoryPressure:c,recentErrorCount:t.length,totalSignals:a,totalComponents:Se.length}}function Ao(){L&&(typeof globalThis>"u"||(globalThis.__WHAT_AGENT__={framework:"what-framework",version:So,mode:"development",features:["signals","effects","computed","ssr","islands","router","stores","forms","animations","a11y"],components:()=>kt().map(e=>({id:e.id,name:e.name||e.displayName||e.constructor?.name})),signals:()=>Rt().map((e,t)=>({id:t,name:e._debugName||`signal_${t}`,value:typeof e=="function"?e.peek?.():void 0,subscriberCount:e._subs?e._subs.size:0})),errors:()=>Ae(),health:()=>Ct(),api:{reactive:["signal","computed","effect","batch","untrack","flushSync","createRoot","memo"],hooks:["useState","useSignal","useComputed","useEffect","useMemo","useCallback","useRef","useContext","onMount","onCleanup"],components:["Show","For","Switch","Match","Suspense","ErrorBoundary","lazy","Island"],data:["useSWR","useQuery","useFetch","useInfiniteQuery"],store:["createStore","derived","atom"]}}))}export{lo as Checkbox,ze as ERROR_CODES,qt as ErrorBoundary,fo as ErrorMessage,hn as FocusTrap,Wt as For,Ft as Fragment,cr as Head,ao as Input,zt as Island,Nr as IslandSkeleton,An as Keys,Sn as LiveRegion,Lr as LoadingDots,Xt as Match,Or as Placeholder,rn as Portal,uo as Radio,co as Select,Bt as Show,Ve as Skeleton,Ir as SkeletonAvatar,ht as SkeletonCard,Tr as SkeletonTable,je as SkeletonText,yn as SkipLink,Mr as Spinner,Ut as Suspense,Yt as Switch,io as Textarea,bn as VisuallyHidden,pe as WhatError,Dn as _$createComponent,On as _$template,Mt as __drainPreinstallBuffer,Xr as __getCacheSnapshot,Ht as __installServerContextStorage,De as __readHydrationData,Bn as __resetHydrationData,At as __setDevToolsHooks,ln as _beginComponentSSR,un as _endComponentSSR,an as _isAriaAttr,Pn as _mapArrayToArray,Nn as _setTextInsertHook,Je as _template,gn as announce,mn as announceAssertive,ir as atom,O as batch,dr as beginHeadCollection,vo as checkComponentName,jn as classList,ho as classifyError,Yr as clearCache,po as clearCollectedErrors,mr as clearHead,Kt as cls,Ce as collectError,P as computed,go as configureGuardrails,er as createContext,or as createResource,Ot as createRoot,ar as createStore,ft as createTransitionClasses,fe as createWhatError,Cr as cssTransition,Zt as debounce,$n as delegateEvents,nt as derived,Qt as each,dt as easings,$ as effect,fr as endHeadCollection,at as flushScheduler,Tt as flushSync,Rt as getActiveSignals,Ae as getCollectedErrors,St as getErrorDefinition,mo as getGuardrailConfig,Ct as getHealth,Oe as getLoaderData,kt as getMountedComponents,Nt as getOwner,Wr as getQueryData,Le as getResource,ge as getServerContext,N as h,Pt as html,qn as hydrate,Mn as insert,Ao as installAgentContext,yo as installSignalReadGuardrail,Ur as invalidateQueries,Un as isHydrating,jt as lazy,Fn as mapArray,yr as measure,Vt as memo,cn as mount,vr as mutate,xr as nextFrame,Vn as on,rr as onCleanup,br as onIntersect,In as onKey,Tn as onKeys,nr as onMount,Er as onResize,Lt as onRootCleanup,qr as prefetchQuery,it as raf,_o as registerComponent,Ro as registerSignal,oo as rules,Dt as runWithOwner,$t as runWithServerContext,Z as scheduleRead,se as scheduleWrite,Gn as setProp,Br as setQueryData,Gt as setServerContext,d as signal,It as signalMemo,ro as simpleResolver,Sr as smoothScrollTo,Hn as spread,lt as spring,sr as storeComputed,Jt as style,Ln as svgTemplate,Je as template,en as throttle,sn as transition,ut as tween,ko as unregisterComponent,Co as unregisterSignal,ce as untrack,Rr as useAnimatedValue,xn as useAriaChecked,vn as useAriaExpanded,wn as useAriaSelected,Jn as useCallback,on as useClickOutside,zn as useComputed,Ze as useContext,Rn as useDescribedBy,Qn as useEffect,Gr as useFetch,so as useField,dn as useFocus,fn as useFocusRestore,pn as useFocusTrap,Kr as useForm,kr as useGesture,_n as useId,kn as useIds,jr as useInfiniteQuery,Cn as useLabelledBy,Wn as useLoaderData,nn as useLocalStorage,tn as useMediaQuery,Kn as useMemo,Vr as useQuery,tr as useReducer,Zn as useRef,En as useRovingTabIndex,$r as useSWR,wr as useScheduledEffect,Xn as useSignal,Dr as useSkeleton,Yn as useState,_r as useTransition,xo as validateImports,no as yupResolver,eo as zodResolver};
|
|
1
|
+
// src/index.js
|
|
2
|
+
import { signal as t, effect as o, batch as s, untrack as a, flushSync as u, createRoot as n, getOwner as m, runWithOwner as i } from "./reactive.min.js";
|
|
3
|
+
import { computed as p, refresh as c, isPending as x, startTransition as d, useTransition as l, useOptimistic as g, use as h, settled as S } from "./async.min.js";
|
|
4
|
+
import { useActionState as y, useFormStatus as C } from "./actions.min.js";
|
|
5
|
+
import { createSelector as R } from "./selector.min.js";
|
|
6
|
+
import { live as E } from "./live.min.js";
|
|
7
|
+
import { h as M, Fragment as O, html as k } from "./h.min.js";
|
|
8
|
+
import { mount as B } from "./dom.min.js";
|
|
9
|
+
import { hydrate as T } from "./render.min.js";
|
|
10
|
+
import { applyStreamedBoundaries as z } from "./hydration-data.min.js";
|
|
11
|
+
import {
|
|
12
|
+
useState as H,
|
|
13
|
+
useSignal as I,
|
|
14
|
+
useComputed as L,
|
|
15
|
+
useEffect as j,
|
|
16
|
+
useMemo as q,
|
|
17
|
+
useCallback as G,
|
|
18
|
+
useRef as J,
|
|
19
|
+
useReducer as K,
|
|
20
|
+
createContext as N,
|
|
21
|
+
useContext as Q,
|
|
22
|
+
onMount as U,
|
|
23
|
+
onCleanup as V,
|
|
24
|
+
createResource as X,
|
|
25
|
+
useLoaderData as Y
|
|
26
|
+
} from "./hooks.min.js";
|
|
27
|
+
import { useId as _ } from "./a11y.min.js";
|
|
28
|
+
import { memo as ee, lazy as re, Suspense as te, ErrorBoundary as oe, Show as se, For as ae, Switch as ue, Match as ne } from "./components.min.js";
|
|
29
|
+
import { Portal as ie } from "./helpers.min.js";
|
|
30
|
+
import { createStore as pe, derived as ce } from "./store.min.js";
|
|
31
|
+
import { Head as de } from "./head.min.js";
|
|
32
|
+
import { getResponse as ge } from "./server-context.min.js";
|
|
33
|
+
import { getDiagnostics as Se, subscribe as be, clearDiagnostics as ye } from "./diagnostics.min.js";
|
|
34
|
+
import { getErrorDefinition as De, WhatError as Re } from "./errors.min.js";
|
|
35
|
+
export {
|
|
36
|
+
oe as ErrorBoundary,
|
|
37
|
+
ae as For,
|
|
38
|
+
O as Fragment,
|
|
39
|
+
de as Head,
|
|
40
|
+
ne as Match,
|
|
41
|
+
ie as Portal,
|
|
42
|
+
se as Show,
|
|
43
|
+
te as Suspense,
|
|
44
|
+
ue as Switch,
|
|
45
|
+
Re as WhatError,
|
|
46
|
+
z as applyStreamedBoundaries,
|
|
47
|
+
s as batch,
|
|
48
|
+
ye as clearDiagnostics,
|
|
49
|
+
p as computed,
|
|
50
|
+
N as createContext,
|
|
51
|
+
X as createResource,
|
|
52
|
+
n as createRoot,
|
|
53
|
+
R as createSelector,
|
|
54
|
+
pe as createStore,
|
|
55
|
+
ce as derived,
|
|
56
|
+
o as effect,
|
|
57
|
+
u as flushSync,
|
|
58
|
+
Se as getDiagnostics,
|
|
59
|
+
De as getErrorDefinition,
|
|
60
|
+
m as getOwner,
|
|
61
|
+
ge as getResponse,
|
|
62
|
+
M as h,
|
|
63
|
+
k as html,
|
|
64
|
+
T as hydrate,
|
|
65
|
+
x as isPending,
|
|
66
|
+
re as lazy,
|
|
67
|
+
E as live,
|
|
68
|
+
ee as memo,
|
|
69
|
+
B as mount,
|
|
70
|
+
V as onCleanup,
|
|
71
|
+
U as onMount,
|
|
72
|
+
c as refresh,
|
|
73
|
+
i as runWithOwner,
|
|
74
|
+
S as settled,
|
|
75
|
+
t as signal,
|
|
76
|
+
d as startTransition,
|
|
77
|
+
be as subscribeDiagnostics,
|
|
78
|
+
a as untrack,
|
|
79
|
+
h as use,
|
|
80
|
+
y as useActionState,
|
|
81
|
+
G as useCallback,
|
|
82
|
+
L as useComputed,
|
|
83
|
+
Q as useContext,
|
|
84
|
+
j as useEffect,
|
|
85
|
+
C as useFormStatus,
|
|
86
|
+
_ as useId,
|
|
87
|
+
Y as useLoaderData,
|
|
88
|
+
q as useMemo,
|
|
89
|
+
g as useOptimistic,
|
|
90
|
+
K as useReducer,
|
|
91
|
+
J as useRef,
|
|
92
|
+
I as useSignal,
|
|
93
|
+
H as useState,
|
|
94
|
+
l as useTransition
|
|
95
|
+
};
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
// src/jsx-dev-runtime.js
|
|
2
|
+
import { Fragment as t } from "./h.min.js";
|
|
3
|
+
import { jsx as o } from "./jsx-runtime.min.js";
|
|
4
|
+
var x = o;
|
|
5
|
+
export {
|
|
6
|
+
t as Fragment,
|
|
7
|
+
o as jsx,
|
|
8
|
+
o as jsxDEV,
|
|
9
|
+
x as jsxs
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/jsx-runtime.js
|
|
2
|
+
import { Fragment, _jsxVNode } from "./h.js";
|
|
3
|
+
function jsx(type, props, key) {
|
|
4
|
+
const rest = {};
|
|
5
|
+
let children;
|
|
6
|
+
let k = key;
|
|
7
|
+
if (props != null) {
|
|
8
|
+
for (const name in props) {
|
|
9
|
+
if (!Object.hasOwn(props, name)) continue;
|
|
10
|
+
if (name === "children") children = props[name];
|
|
11
|
+
else if (name === "key") {
|
|
12
|
+
if (k === void 0) k = props[name];
|
|
13
|
+
} else rest[name] = props[name];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (typeof k === "function" && k._signal !== true && k.length > 0) {
|
|
17
|
+
rest.key = k;
|
|
18
|
+
k = void 0;
|
|
19
|
+
}
|
|
20
|
+
return _jsxVNode(type, rest, children, k === void 0 ? null : k);
|
|
21
|
+
}
|
|
22
|
+
var jsxs = jsx;
|
|
23
|
+
export {
|
|
24
|
+
Fragment,
|
|
25
|
+
jsx,
|
|
26
|
+
jsxs
|
|
27
|
+
};
|
package/dist/jsx-runtime.min.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// src/jsx-runtime.js
|
|
2
|
+
import { Fragment as r, _jsxVNode as c } from "./h.min.js";
|
|
3
|
+
function d(l, t, u) {
|
|
4
|
+
let i = {}, f, e = u;
|
|
5
|
+
if (t != null)
|
|
6
|
+
for (let n in t)
|
|
7
|
+
Object.hasOwn(t, n) && (n === "children" ? f = t[n] : n === "key" ? e === void 0 && (e = t[n]) : i[n] = t[n]);
|
|
8
|
+
return typeof e == "function" && e._signal !== !0 && e.length > 0 && (i.key = e, e = void 0), c(l, i, f, e === void 0 ? null : e);
|
|
9
|
+
}
|
|
10
|
+
var s = d;
|
|
11
|
+
export {
|
|
12
|
+
r as Fragment,
|
|
13
|
+
d as jsx,
|
|
14
|
+
s as jsxs
|
|
15
|
+
};
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/live.js
|
|
2
|
+
import { _readKey, untrack } from "./reactive.js";
|
|
3
|
+
function live(source) {
|
|
4
|
+
if (typeof source !== "function") throw new TypeError("live(source): source must be a function that returns the current value");
|
|
5
|
+
const target = /* @__PURE__ */ Object.create(null);
|
|
6
|
+
const current = (key) => _readKey(key, source);
|
|
7
|
+
const peek = () => untrack(() => _readKey(null, source));
|
|
8
|
+
const define = (key) => {
|
|
9
|
+
if (!Object.hasOwn(target, key) && Object.isExtensible(target)) {
|
|
10
|
+
Object.defineProperty(target, key, {
|
|
11
|
+
get: () => {
|
|
12
|
+
const value = current(key);
|
|
13
|
+
return value == null ? void 0 : value[key];
|
|
14
|
+
},
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return new Proxy(target, {
|
|
21
|
+
get(t, key) {
|
|
22
|
+
if (typeof key !== "string") return void 0;
|
|
23
|
+
const value = current(key);
|
|
24
|
+
if (value == null) return void 0;
|
|
25
|
+
if (Object.hasOwn(value, key)) define(key);
|
|
26
|
+
return value[key];
|
|
27
|
+
},
|
|
28
|
+
getOwnPropertyDescriptor(t, key) {
|
|
29
|
+
if (typeof key !== "string") return void 0;
|
|
30
|
+
if (!Object.hasOwn(t, key)) {
|
|
31
|
+
const value = peek();
|
|
32
|
+
if (value == null || !Object.hasOwn(value, key)) return void 0;
|
|
33
|
+
define(key);
|
|
34
|
+
}
|
|
35
|
+
return Reflect.getOwnPropertyDescriptor(t, key);
|
|
36
|
+
},
|
|
37
|
+
has(t, key) {
|
|
38
|
+
if (typeof key !== "string") return false;
|
|
39
|
+
const value = peek();
|
|
40
|
+
return value != null && key in Object(value) || Object.hasOwn(t, key);
|
|
41
|
+
},
|
|
42
|
+
ownKeys(t) {
|
|
43
|
+
const value = source();
|
|
44
|
+
if (value != null) for (const key of Object.keys(value)) define(key);
|
|
45
|
+
return Reflect.ownKeys(t);
|
|
46
|
+
},
|
|
47
|
+
set() {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
live
|
|
54
|
+
};
|