diff --git a/sigpro/index.min.js b/sigpro/index.min.js deleted file mode 100644 index a05a272..0000000 --- a/sigpro/index.min.js +++ /dev/null @@ -1 +0,0 @@ -let activeEffect=null,currentOwner=null;const effectQueue=new Set;let isFlushing=!1;const MOUNTED_NODES=new WeakMap,flush=()=>{if(!isFlushing){for(isFlushing=!0;effectQueue.size>0;){const e=Array.from(effectQueue).sort(((e,t)=>(e.depth||0)-(t.depth||0)));effectQueue.clear();for(const t of e)t._deleted||t()}isFlushing=!1}},track=e=>{activeEffect&&!activeEffect._deleted&&(e.add(activeEffect),activeEffect._deps.add(e))},trigger=e=>{for(const t of e)t===activeEffect||t._deleted||(t._isComputed?(t.markDirty(),t._subs&&trigger(t._subs)):effectQueue.add(t));isFlushing||queueMicrotask(flush)},sweep=e=>{e._cleanups&&(e._cleanups.forEach((e=>e())),e._cleanups.clear()),e.childNodes?.forEach(sweep)},_view=e=>{const t=new Set,n=currentOwner,r=document.createElement("div");r.style.display="contents",currentOwner={cleanups:t};try{const o=e({onCleanup:e=>t.add(e)}),c=e=>{e&&(e._isRuntime?(t.add(e.destroy),r.appendChild(e.container)):Array.isArray(e)?e.forEach(c):r.appendChild(e instanceof Node?e:document.createTextNode(String(e))))};c(o)}finally{currentOwner=n}return{_isRuntime:!0,container:r,destroy:()=>{t.forEach((e=>e())),sweep(r),r.remove()}}},$=(e,t=null)=>{if("function"==typeof e){const t=new Set;let n,r=!0;const o=()=>{if(o._deleted)return;o._deps.forEach((e=>e.delete(o))),o._deps.clear();const c=activeEffect;activeEffect=o;try{const o=e();Object.is(n,o)&&!r||(n=o,r=!1,trigger(t))}finally{activeEffect=c}};return o._deps=new Set,o._isComputed=!0,o._subs=t,o._deleted=!1,o.markDirty=()=>r=!0,o.stop=()=>{o._deleted=!0,o._deps.forEach((e=>e.delete(o))),t.clear()},currentOwner&¤tOwner.cleanups.add(o.stop),()=>(r&&o(),track(t),n)}let n=e;if(t)try{const e=localStorage.getItem(t);null!==e&&(n=JSON.parse(e))}catch(e){}const r=new Set;return(...e)=>{if(e.length){const o="function"==typeof e[0]?e[0](n):e[0];Object.is(n,o)||(n=o,t&&localStorage.setItem(t,JSON.stringify(n)),trigger(r))}return track(r),n}},$watch=(e,t)=>{const n=Array.isArray(e),r=n?t:e,o=n?e:null;if("function"!=typeof r)return()=>{};const c=currentOwner,a=()=>{if(a._deleted)return;a._deps.forEach((e=>e.delete(a))),a._deps.clear(),a._cleanups.forEach((e=>e())),a._cleanups.clear();const e=activeEffect,t=currentOwner;activeEffect=a,currentOwner={cleanups:a._cleanups},a.depth=e?e.depth+1:0;try{n?(activeEffect=null,r(),activeEffect=a,o.forEach((e=>"function"==typeof e&&e()))):r()}finally{activeEffect=e,currentOwner=t}};return a._deps=new Set,a._cleanups=new Set,a._deleted=!1,a.stop=()=>{a._deleted||(a._deleted=!0,effectQueue.delete(a),a._deps.forEach((e=>e.delete(a))),a._cleanups.forEach((e=>e())),c&&c.cleanups.delete(a.stop))},c&&c.cleanups.add(a.stop),a(),a.stop},$html=(e,t={},n=[])=>{(t instanceof Node||Array.isArray(t)||"object"!=typeof t)&&(n=t,t={});const r=document.createElement(e),o=(e,t)=>"src"!==e&&"href"!==e||!String(t).toLowerCase().includes("javascript:")?t:"#";r._cleanups=new Set;for(let[e,n]of Object.entries(t)){if("ref"===e){"function"==typeof n?n(r):n.current=r;continue}const t="function"==typeof n,c=["INPUT","TEXTAREA","SELECT"].includes(r.tagName),a="value"===e||"checked"===e;if(c&&a&&t){r._cleanups.add($watch((()=>{const t=n();r[e]!==t&&(r[e]=t)})));const t="checked"===e?"change":"input",o=t=>n(t.target[e]);r.addEventListener(t,o),r._cleanups.add((()=>r.removeEventListener(t,o)))}else if(e.startsWith("on")){const t=e.slice(2).toLowerCase().split(".")[0],o=e=>n(e);r.addEventListener(t,o),r._cleanups.add((()=>r.removeEventListener(t,o)))}else t?r._cleanups.add($watch((()=>{const t=o(e,n());"class"===e?r.className=t||"":null==t?r.removeAttribute(e):r.setAttribute(e,t)}))):r.setAttribute(e,o(e,n))}const c=e=>{if(Array.isArray(e))return e.forEach(c);if("function"==typeof e){const t=document.createTextNode("");r.appendChild(t);let n=[];r._cleanups.add($watch((()=>{const r=e(),o=(Array.isArray(r)?r:[r]).map((e=>e?._isRuntime?e.container:e instanceof Node?e:document.createTextNode(e??"")));n.forEach((e=>{sweep(e),e.remove()})),o.forEach((e=>t.parentNode?.insertBefore(e,t))),n=o})))}else r.appendChild(e instanceof Node?e:document.createTextNode(e??""))};return c(n),r},$if=(e,t,n=null)=>{const r=document.createTextNode(""),o=$html("div",{style:"display:contents"},[r]);let c=null,a=null;return $watch((()=>{const s=!!("function"==typeof e?e():e);if(s!==a){a=s,c&&c.destroy();const e=s?t:n;e&&(c=_view((()=>"function"==typeof e?e():e)),o.insertBefore(c.container,r))}})),o};$if.not=(e,t,n)=>$if((()=>!("function"==typeof e?e():e)),t,n);const $for=(e,t,n)=>{const r=document.createTextNode(""),o=$html("div",{style:"display:contents"},[r]),c=new Map;return $watch((()=>{const a=("function"==typeof e?e():e)||[],s=new Set;a.forEach(((e,a)=>{const i=n(e,a);s.add(i);let l=c.get(i);l||(l=_view((()=>t(e,a))),c.set(i,l)),o.insertBefore(l.container,r)})),c.forEach(((e,t)=>{s.has(t)||(e.destroy(),c.delete(t))}))})),o},$router=e=>{const t=$(window.location.hash.replace(/^#/,"")||"/");window.addEventListener("hashchange",(()=>t(window.location.hash.replace(/^#/,"")||"/")));const n=$html("div",{class:"router-outlet"});let r=null;return $watch([t],(async()=>{const o=t(),c=e.find((e=>{const t=e.path.split("/").filter(Boolean),n=o.split("/").filter(Boolean);return t.length===n.length&&t.every(((e,t)=>e.startsWith(":")||e===n[t]))}))||e.find((e=>"*"===e.path));if(c){let e=c.component;"function"==typeof e&&e.toString().includes("import")&&(e=(await e()).default||await e());const t={};c.path.split("/").filter(Boolean).forEach(((e,n)=>{e.startsWith(":")&&(t[e.slice(1)]=o.split("/").filter(Boolean)[n])})),r&&r.destroy(),$router.params&&$router.params(t),r=_view((()=>{try{return"function"==typeof e?e(t):e}catch(e){return $html("div",{class:"p-4 text-error"},"Error loading view")}})),n.appendChild(r.container)}})),n};$router.params=$({}),$router.to=e=>window.location.hash=e.replace(/^#?\/?/,"#/"),$router.back=()=>window.history.back(),$router.path=()=>window.location.hash.replace(/^#/,"")||"/";const $mount=(e,t)=>{const n="string"==typeof t?document.querySelector(t):t;if(!n)return;MOUNTED_NODES.has(n)&&MOUNTED_NODES.get(n).destroy();const r=_view("function"==typeof e?e:()=>e);return n.replaceChildren(r.container),MOUNTED_NODES.set(n,r),r},SigProCore={$:$,$watch:$watch,$html:$html,$if:$if,$for:$for,$router:$router,$mount:$mount};if("undefined"!=typeof window){(e=>{Object.keys(e).forEach((t=>{window[t]=e[t]}));"div span p h1 h2 h3 h4 h5 h6 br hr section article aside nav main header footer address ul ol li dl dt dd a em strong small i b u mark time sub sup pre code blockquote details summary dialog form label input textarea select button option fieldset legend table thead tbody tfoot tr th td caption img video audio canvas svg iframe picture source progress meter".split(/\s+/).forEach((e=>{const t=e.charAt(0).toUpperCase()+e.slice(1);t in window||(window[t]=(t,n)=>$html(e,t,n))})),window.SigPro=Object.freeze(e)})(SigProCore)}export{$,$watch,$html,$if,$for,$router,$mount};export default SigProCore; \ No newline at end of file