@deijose/nix-js 1.3.0 → 1.3.2-beta.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/dist/lib/nix-js.cjs +8 -8
- package/dist/lib/nix-js.js +8 -8
- package/package.json +3 -3
package/dist/lib/nix-js.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(){return{__isPortalOutlet:!0,_container:null}}function ie(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ae(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var oe=S("nix:portal-outlet");function se(e){O(oe,e)}function ce(){return k(oe)}function le(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment("nix-eb");n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}a=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else a=o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function ue(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function A(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e)||0))}function j(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(A(r.transitionDuration||"0"),A(r.animationDuration||"0")),l=o>0?o+100:t>0?t:0;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function de(e,t={}){let n=ue(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment("nix-t");r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await j(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await j(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function fe(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function pe(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[o]&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function M(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function me(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function he(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function ge(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function _e(e,t,n){let r=[],o=[],l=he(e),i=ge(e);for(let e=0;e<t.length;e++){let a=t[e],u=n[e];if("event"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=u,s=a.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){u.el=n,r.push(()=>{u.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof u){let n=m(()=>{let n=!!u(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?u:!u)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof u){let e=m(()=>{let e=u();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=u??"":null!=u&&!1!==u&&n.setAttribute(o,String(u));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof u){if(x(u)){let e,n,l=u;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(M(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else M(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=u&&!1!==u&&s.parentNode.insertBefore(document.createTextNode(String(u)),s);continue}let c=null,f=null,d=null,p=w(),h=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(M(e))f=e._render(s.parentNode,s);else if(x(e)){let t,n,r=e;D(p,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(me(e)){d||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of d)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),d.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;for(let e of n)t.insertBefore(e,o)}o=e.start}else{let n=document.createComment("nix-ke"),a=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(a,n);let u,s=e.renderFn(i,r);if(x(s)){let r,o;D(p,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}u=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else u=s._render(t,n);d.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}else if(M(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(h(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}function N(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=fe(r);n.push(o),r+="__nix__"}let o=pe(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:a,postMountHooks:u}=_e(i,n,t),s=document.createComment("nix-scope");e.insertBefore(s,r);let c=i.firstChild;for(;c;){let t=c.nextSibling;e.insertBefore(c,r),c=t}return u.forEach(e=>e()),()=>{a.forEach(e=>e());let e=s.nextSibling;for(;e&&e!==r;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function ve(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function ye(e,t){let n={};for(let t of Object.keys(e))n[t]=p(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}return o}var P=null,F=null;function I(){if(!P)throw Error("[Nix] No active router. Call createRouter() first.");return P}function L(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function R(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function be(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function xe(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function z(e,t="",n=[]){let r=[];for(let o of e){let e=xe(t,o.path),l=[...n,o.component],i=be(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...z(o.children,e,l))}return r}function Se(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ce(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function B(e,t){let n,r={},o=-1;for(let l of t){let t=Se(e,l);if(null===t)continue;let i=Ce(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function V(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function we(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return V(new URL(t,window.location.origin).pathname)}catch{return V(t)}}function Te(e,t){let n=null==t?.base?we():V(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=z(e),a=B(l,i),u=p(l),s=p(a?.params??{}),c=p(L(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():_(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:L(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}F&&=(F(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=B(e,i),a=L(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+R(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+R(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=B(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),F=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=B(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=B(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return P&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),P=b,queueMicrotask(()=>{v||m(l,"",B(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=B("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Ee(){return I()}var De=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return N`<div class="router-view">${()=>{let t=I(),n=B(t.current.value,t._flat);return n?e>=n.route.chain.length?N`<span></span>`:n.route.chain[e]():N`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(){return{__isPortalOutlet:!0,_container:null}}function ie(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ae(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var A=S("nix:portal-outlet");function oe(e){O(A,e)}function se(){return k(A)}function ce(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment("nix-eb");n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}a=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else a=o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function le(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function j(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e)||0))}function ue(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(j(r.transitionDuration||"0"),j(r.animationDuration||"0")),l=o>0?o+100:t>0?t:0;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function de(e,t={}){let n=le(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment("nix-t");r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await ue(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await ue(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function fe(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function pe(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[o]&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function M(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function me(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function he(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function ge(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function _e(e,t,n){let r=[],o=[],l=he(e),i=ge(e);for(let e=0;e<t.length;e++){let a=t[e],u=n[e];if("event"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=u,s=a.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){u.el=n,r.push(()=>{u.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof u){let n=m(()=>{let n=!!u(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?u:!u)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof u){let e=m(()=>{let e=u();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=u??"":null!=u&&!1!==u&&n.setAttribute(o,String(u));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof u){if(x(u)){let e,n,l=u;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(M(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else M(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=u&&!1!==u&&s.parentNode.insertBefore(document.createTextNode(String(u)),s);continue}let c=null,f=null,d=null,p=w(),h=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(M(e))f=e._render(s.parentNode,s);else if(x(e)){let t,n,r=e;D(p,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(me(e)){d||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of d)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),d.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;let l=document.createDocumentFragment();for(let e of n)l.appendChild(e);t.insertBefore(l,o)}o=e.start}else{let n=document.createComment("nix-ke"),a=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(a,n);let u,s=e.renderFn(i,r);if(x(s)){let r,o;D(p,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}u=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else u=s._render(t,n);d.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}else if(M(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(h(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}var N=new WeakMap;function P(e,...t){let n=N.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++){r+=e[n];let o=fe(r);t.push(o),r+="__nix__"}let o=pe(e,t),l=document.createElement("template");l.innerHTML=o,n={tpl:l,contexts:t},N.set(e,n)}let{tpl:r,contexts:o}=n;function l(e,n){let l=r.content.cloneNode(!0),{disposes:i,postMountHooks:a}=_e(l,o,t),u=document.createComment("nix-scope");e.insertBefore(u,n);let s=l.firstChild;for(;s;){let t=s.nextSibling;e.insertBefore(s,n),s=t}return a.forEach(e=>e()),()=>{i.forEach(e=>e());let e=u.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}u.parentNode?.removeChild(u)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function ve(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function ye(e,t){let n={};for(let t of Object.keys(e))n[t]=p(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}return o}var F=null,I=null;function L(){if(!F)throw Error("[Nix] No active router. Call createRouter() first.");return F}function R(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function z(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function be(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function xe(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function B(e,t="",n=[]){let r=[];for(let o of e){let e=xe(t,o.path),l=[...n,o.component],i=be(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...B(o.children,e,l))}return r}function Se(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ce(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function V(e,t){let n,r={},o=-1;for(let l of t){let t=Se(e,l);if(null===t)continue;let i=Ce(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function H(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function we(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return H(new URL(t,window.location.origin).pathname)}catch{return H(t)}}function Te(e,t){let n=null==t?.base?we():H(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=B(e),a=V(l,i),u=p(l),s=p(a?.params??{}),c=p(R(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():_(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:R(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}I&&=(I(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=V(e,i),a=R(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+z(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+z(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=V(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),I=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=V(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=V(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return F&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),F=b,queueMicrotask(()=>{v||m(l,"",V(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=V("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Ee(){return L()}var De=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return P`<div class="router-view">${()=>{let t=L(),n=V(t.current.value,t._flat);return n?e>=n.route.chain.length?P`<span></span>`:n.route.chain[e]():P`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
|
-
</div>`}}</div>`}},Oe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return
|
|
4
|
-
href=${(
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function
|
|
3
|
+
</div>`}}</div>`}},Oe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return P`<a
|
|
4
|
+
href=${(L()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
5
|
+
style=${()=>L().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
|
|
6
|
+
@click=${t=>{t.preventDefault(),L().navigate(e)}}
|
|
7
|
+
>${t}</a>`}};function U(){return P`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function W(e){return P`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var
|
|
21
|
+
`}var G=new Map,ke=3e5,K=null,q=ke;function Ae(){null===K&&(K=setInterval(()=>{let e=Date.now();for(let[t,n]of G)n.subscribers<=0&&e-n.fetchedAt>q&&G.delete(t);0===G.size&&null!==K&&(clearInterval(K),K=null)},6e4))}function J(e){return G.get(e)}function Y(e,t){let n=G.get(e);G.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ae()}function X(e){let t=G.get(e);t&&t.subscribers++}function je(e){let t=G.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Me(e,t){let n=G.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Ne(e){void 0===e?G.clear():G.delete(e)}function Pe(e){q=e}function Fe(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??U(),c=o??W;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?J(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&X(a);let e=a?J(a):void 0;if(e&&Me(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&G.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&je(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Y(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return P`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function Ie(e){G.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Le(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??U(),c=l??W;return new class extends b{_state;constructor(){super();let t=J(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),X(e);let r=J(e),o=Me(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),je(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Y(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return P`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function Re(e,t){let n=null;return()=>n?new n:Fe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function ze(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Be(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ve(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function He(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Ue(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function We(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Ge(e){return e}const Ke={required:ze,minLength:Be,maxLength:Ve,email:He,pattern:Q,min:Ue,max:We};function qe(e,t){return{...e,...t}}function $(e,t=[]){let n=p(e),r=p(!1),o=p(!1),l=p(null),i=h(()=>{if(l.value)return l.value;if(!r.value&&!o.value)return null;for(let e of t){let t=e(n.value);if(t)return t}return null});function a(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:n,error:i,touched:r,dirty:o,onInput:e=>{n.value=a(e.target),o.value=!0,l.value=null},onBlur:()=>{r.value=!0},reset:function(){n.value=e,r.value=!1,o.value=!1,l.value=null},_setExternalError:function(e){l.value=e,e&&(r.value=!0)}}}function Je(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=h(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=h(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=h(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=h(()=>{for(let e in n)if(n[e].dirty.value)return!0;return!1});function a(e){for(let t in e)n[t]?._setExternalError(e[t]??null)}return{fields:n,values:r,errors:o,valid:l,dirty:i,handleSubmit:function(e){return o=>{o.preventDefault();for(let e in n)n[e].touched.value=!0;let l=r.value;if(t.validate){let e=t.validate(l);if(e){let t={},n=!1;for(let r in e){let o=e[r],l=Array.isArray(o)?o[0]??null:o??null;l&&(t[r]=l,n=!0)}if(n)return void a(t)}}for(let e in n)if(n[e].error.value)return;e(l)}},reset:function(){for(let e in n)n[e].reset()},setErrors:a}}exports.Link=Oe,exports.NixComponent=b,exports.RouterView=De,exports.Signal=f,exports.batch=g,exports.clearQueryCache=Ne,exports.computed=h,exports.createErrorBoundary=ce,exports.createForm=Je,exports.createInjectionKey=S,exports.createPortalOutlet=re,exports.createQuery=Le,exports.createRouter=Te,exports.createStore=ye,exports.createValidator=Ge,exports.effect=m,exports.email=He,exports.extendValidators=qe,exports.html=P,exports.inject=k,exports.injectOutlet=se,exports.invalidateQueries=Ie,exports.lazy=Re,exports.max=We,exports.maxLength=Ve,exports.min=Ue,exports.minLength=Be,exports.mount=ve,exports.nextTick=y,exports.pattern=Q,exports.portal=ae,exports.portalOutlet=ie,exports.provide=O,exports.provideOutlet=oe,exports.ref=ee,exports.repeat=ne,exports.required=ze,exports.setQueryCacheTime=Pe,exports.showWhen=te,exports.signal=p,exports.suspend=Fe,exports.transition=de,exports.untrack=_,exports.useField=$,exports.useRouter=Ee,exports.validators=Ke,exports.watch=v;
|
package/dist/lib/nix-js.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(){return{__isPortalOutlet:!0,_container:null}}function ie(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ae(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var oe=S("nix:portal-outlet");function se(e){O(oe,e)}function ce(){return k(oe)}function le(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment("nix-eb");n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}a=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else a=o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function ue(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function A(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e)||0))}function j(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(A(r.transitionDuration||"0"),A(r.animationDuration||"0")),l=o>0?o+100:t>0?t:0;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function de(e,t={}){let n=ue(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment("nix-t");r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await j(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},h=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await j(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},p=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;p=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?h():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,p?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function fe(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function pe(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[o]&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function M(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function me(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function he(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function ge(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function _e(e,t,n){let r=[],o=[],l=he(e),i=ge(e);for(let e=0;e<t.length;e++){let a=t[e],u=n[e];if("event"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=u,s=a.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){u.el=n,r.push(()=>{u.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof u){let n=m(()=>{let n=!!u(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?u:!u)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof u){let e=m(()=>{let e=u();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=u??"":null!=u&&!1!==u&&n.setAttribute(o,String(u));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof u){if(x(u)){let e,n,l=u;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(M(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else M(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=u&&!1!==u&&s.parentNode.insertBefore(document.createTextNode(String(u)),s);continue}let c=null,f=null,d=null,h=w(),p=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(M(e))f=e._render(s.parentNode,s);else if(x(e)){let t,n,r=e;D(h,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(me(e)){d||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of d)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),d.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;for(let e of n)t.insertBefore(e,o)}o=e.start}else{let n=document.createComment("nix-ke"),a=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(a,n);let u,s=e.renderFn(i,r);if(x(s)){let r,o;D(h,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}u=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else u=s._render(t,n);d.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}else if(M(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(p(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}function N(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=fe(r);n.push(o),r+="__nix__"}let o=pe(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:a,postMountHooks:u}=_e(i,n,t),s=document.createComment("nix-scope");e.insertBefore(s,r);let c=i.firstChild;for(;c;){let t=c.nextSibling;e.insertBefore(c,r),c=t}return u.forEach(e=>e()),()=>{a.forEach(e=>e());let e=s.nextSibling;for(;e&&e!==r;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function ve(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function ye(e,t){let n={};for(let t of Object.keys(e))n[t]=p(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}return o}var P=null,F=null;function I(){if(!P)throw Error("[Nix] No active router. Call createRouter() first.");return P}function L(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function R(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function be(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function xe(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function z(e,t="",n=[]){let r=[];for(let o of e){let e=xe(t,o.path),l=[...n,o.component],i=be(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...z(o.children,e,l))}return r}function Se(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ce(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function B(e,t){let n,r={},o=-1;for(let l of t){let t=Se(e,l);if(null===t)continue;let i=Ce(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function V(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function we(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return V(new URL(t,window.location.origin).pathname)}catch{return V(t)}}function Te(e,t){let n=null==t?.base?we():V(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=z(e),a=B(l,i),u=p(l),s=p(a?.params??{}),c=p(L(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:L(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}F&&=(F(),null);let g=()=>{let e=r(),t=u.value,n=c.value,l=B(e,i),a=L(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+R(n))})};function _(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+R(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=B(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!1))}window.addEventListener("popstate",g),F=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=B(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=B(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return P&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),P=x,queueMicrotask(()=>{v||m(l,"",B(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=B("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Ee(){return I()}var De=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return N`<div class="router-view">${()=>{let t=I(),n=B(t.current.value,t._flat);return n?e>=n.route.chain.length?N`<span></span>`:n.route.chain[e]():N`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(){return{__isPortalOutlet:!0,_container:null}}function ie(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ae(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var A=S("nix:portal-outlet");function oe(e){O(A,e)}function se(){return k(A)}function ce(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment("nix-eb");n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}a=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else a=o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function le(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function j(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e)||0))}function ue(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(j(r.transitionDuration||"0"),j(r.animationDuration||"0")),l=o>0?o+100:t>0?t:0;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function de(e,t={}){let n=le(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment("nix-t");r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await ue(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},h=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await ue(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},p=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;p=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?h():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,p?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function fe(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function pe(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[o]&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function M(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function me(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function he(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function ge(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function _e(e,t,n){let r=[],o=[],l=he(e),i=ge(e);for(let e=0;e<t.length;e++){let a=t[e],u=n[e];if("event"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=u,s=a.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){u.el=n,r.push(()=>{u.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof u){let n=m(()=>{let n=!!u(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?u:!u)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof u){let e=m(()=>{let e=u();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=u??"":null!=u&&!1!==u&&n.setAttribute(o,String(u));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof u){if(x(u)){let e,n,l=u;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(M(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else M(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=u&&!1!==u&&s.parentNode.insertBefore(document.createTextNode(String(u)),s);continue}let c=null,f=null,d=null,h=w(),p=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(M(e))f=e._render(s.parentNode,s);else if(x(e)){let t,n,r=e;D(h,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(me(e)){d||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of d)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),d.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;let l=document.createDocumentFragment();for(let e of n)l.appendChild(e);t.insertBefore(l,o)}o=e.start}else{let n=document.createComment("nix-ke"),a=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(a,n);let u,s=e.renderFn(i,r);if(x(s)){let r,o;D(h,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}u=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else u=s._render(t,n);d.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}else if(M(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(p(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}var N=new WeakMap;function P(e,...t){let n=N.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++){r+=e[n];let o=fe(r);t.push(o),r+="__nix__"}let o=pe(e,t),l=document.createElement("template");l.innerHTML=o,n={tpl:l,contexts:t},N.set(e,n)}let{tpl:r,contexts:o}=n;function l(e,n){let l=r.content.cloneNode(!0),{disposes:i,postMountHooks:a}=_e(l,o,t),u=document.createComment("nix-scope");e.insertBefore(u,n);let s=l.firstChild;for(;s;){let t=s.nextSibling;e.insertBefore(s,n),s=t}return a.forEach(e=>e()),()=>{i.forEach(e=>e());let e=u.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}u.parentNode?.removeChild(u)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function ve(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function ye(e,t){let n={};for(let t of Object.keys(e))n[t]=p(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}return o}var F=null,I=null;function L(){if(!F)throw Error("[Nix] No active router. Call createRouter() first.");return F}function R(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function z(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function be(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function xe(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function B(e,t="",n=[]){let r=[];for(let o of e){let e=xe(t,o.path),l=[...n,o.component],i=be(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...B(o.children,e,l))}return r}function Se(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ce(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function V(e,t){let n,r={},o=-1;for(let l of t){let t=Se(e,l);if(null===t)continue;let i=Ce(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function H(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function we(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return H(new URL(t,window.location.origin).pathname)}catch{return H(t)}}function Te(e,t){let n=null==t?.base?we():H(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=B(e),a=V(l,i),u=p(l),s=p(a?.params??{}),c=p(R(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:R(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}I&&=(I(),null);let g=()=>{let e=r(),t=u.value,n=c.value,l=V(e,i),a=R(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+z(n))})};function _(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+z(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=V(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!1))}window.addEventListener("popstate",g),I=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=V(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=V(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return F&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),F=x,queueMicrotask(()=>{v||m(l,"",V(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=V("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Ee(){return L()}var De=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return P`<div class="router-view">${()=>{let t=L(),n=V(t.current.value,t._flat);return n?e>=n.route.chain.length?P`<span></span>`:n.route.chain[e]():P`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
|
-
</div>`}}</div>`}},Oe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return
|
|
4
|
-
href=${(
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function
|
|
3
|
+
</div>`}}</div>`}},Oe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return P`<a
|
|
4
|
+
href=${(L()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
5
|
+
style=${()=>L().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
|
|
6
|
+
@click=${t=>{t.preventDefault(),L().navigate(e)}}
|
|
7
|
+
>${t}</a>`}};function U(){return P`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s()
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function W(e){return P`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var
|
|
21
|
+
`}var G=new Map,ke=3e5,K=null,q=ke;function Ae(){null===K&&(K=setInterval(()=>{let e=Date.now();for(let[t,n]of G)n.subscribers<=0&&e-n.fetchedAt>q&&G.delete(t);0===G.size&&null!==K&&(clearInterval(K),K=null)},6e4))}function J(e){return G.get(e)}function Y(e,t){let n=G.get(e);G.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ae()}function X(e){let t=G.get(e);t&&t.subscribers++}function je(e){let t=G.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Me(e,t){let n=G.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Ne(e){void 0===e?G.clear():G.delete(e)}function Pe(e){q=e}function Fe(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??U(),c=o??W;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?J(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&X(a);let e=a?J(a):void 0;if(e&&Me(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&G.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&je(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Y(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return P`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function Ie(e){G.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Le(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??U(),c=l??W;return new class extends b{_state;constructor(){super();let t=J(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),X(e);let r=J(e),o=Me(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),je(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Y(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return P`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function Re(e,t){let n=null;return()=>n?new n:Fe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function ze(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Be(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ve(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function He(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Ue(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function We(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Ge(e){return e}const Ke={required:ze,minLength:Be,maxLength:Ve,email:He,pattern:Q,min:Ue,max:We};function qe(e,t){return{...e,...t}}function $(e,t=[]){let n=p(e),r=p(!1),o=p(!1),l=p(null),i=h(()=>{if(l.value)return l.value;if(!r.value&&!o.value)return null;for(let e of t){let t=e(n.value);if(t)return t}return null});function a(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:n,error:i,touched:r,dirty:o,onInput:e=>{n.value=a(e.target),o.value=!0,l.value=null},onBlur:()=>{r.value=!0},reset:function(){n.value=e,r.value=!1,o.value=!1,l.value=null},_setExternalError:function(e){l.value=e,e&&(r.value=!0)}}}function Je(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=h(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=h(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=h(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=h(()=>{for(let e in n)if(n[e].dirty.value)return!0;return!1});function a(e){for(let t in e)n[t]?._setExternalError(e[t]??null)}return{fields:n,values:r,errors:o,valid:l,dirty:i,handleSubmit:function(e){return o=>{o.preventDefault();for(let e in n)n[e].touched.value=!0;let l=r.value;if(t.validate){let e=t.validate(l);if(e){let t={},n=!1;for(let r in e){let o=e[r],l=Array.isArray(o)?o[0]??null:o??null;l&&(t[r]=l,n=!0)}if(n)return void a(t)}}for(let e in n)if(n[e].error.value)return;e(l)}},reset:function(){for(let e in n)n[e].reset()},setErrors:a}}export{Oe as Link,b as NixComponent,De as RouterView,f as Signal,g as batch,Ne as clearQueryCache,h as computed,ce as createErrorBoundary,Je as createForm,S as createInjectionKey,re as createPortalOutlet,Le as createQuery,Te as createRouter,ye as createStore,Ge as createValidator,m as effect,He as email,qe as extendValidators,P as html,k as inject,se as injectOutlet,Ie as invalidateQueries,Re as lazy,We as max,Ve as maxLength,Ue as min,Be as minLength,ve as mount,y as nextTick,Q as pattern,ae as portal,ie as portalOutlet,O as provide,oe as provideOutlet,ee as ref,ne as repeat,ze as required,Pe as setQueryCacheTime,te as showWhen,p as signal,Fe as suspend,de as transition,_ as untrack,$ as useField,Ee as useRouter,Ke as validators,v as watch};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deijose/nix-js",
|
|
3
|
-
"version": "1.3.0",
|
|
3
|
+
"version": "1.3.2-beta.0",
|
|
4
4
|
"description": "A lightweight, fully reactive micro-framework — no virtual DOM, no compiler, just signals and tagged templates.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://nix-js-landing
|
|
6
|
+
"homepage": "https://nix-js-landing.vercel.app/",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/DeijoseDevelop/nix-js.git"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"build:lib": "vite build --config vite.lib.config.ts && tsc --project tsconfig.lib.json && terser dist/lib/nix-js.js -c -m -o dist/lib/nix-js.js && terser dist/lib/nix-js.cjs -c -m -o dist/lib/nix-js.cjs",
|
|
51
51
|
"typecheck": "tsc --noEmit",
|
|
52
52
|
"test": "vitest run",
|
|
53
|
-
"prepublishOnly": "
|
|
53
|
+
"prepublishOnly": "bun run build:lib && cp README.md .readme-full.md && cp .readme-npm.md README.md",
|
|
54
54
|
"postpublish": "mv .readme-full.md README.md"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|