@alexgyver/component 1.5.0 → 2.0.1

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/Component.min.js CHANGED
@@ -1 +1 @@
1
- var e={d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{EL:()=>a,LV:()=>o,Uw:()=>s,cj:()=>c,t4:()=>r,uA:()=>n});class a{static context;constructor(e,t={},n=!1){this.$root=a.makeIn(this,e,t,n)}make(e,t={},n=!1){return a.makeIn(this,e,t,n)}makeArray(e,t=!1){return a.makeArrayIn(this,e,t)}config(e,t,n=!1){return a.configIn(this,e,t,n)}makeShadow(e,t={},n=null){return a.makeShadowIn(this,e,t,n)}static make(e,t={},n=!1){return t instanceof Node?t:("svg"==e&&(n=!0),a.config(n?document.createElementNS("http://www.w3.org/2000/svg",e??"svg"):document.createElement(e??"div"),t,n))}static makeIn(e,t,n={},s=!1){return a.make(t,{...n,context:e},s)}static config(e,t,n=!1){if(!(e instanceof Node)||"object"!=typeof t)return e;if(Array.isArray(e))return e.map(e=>a.config(e,t,n));const s="context"in t?a.context=t.context:a.context,r=t=>{t&&(t instanceof Node?e.appendChild(t):t instanceof a?e.appendChild(t.$root):"string"==typeof t?e.insertAdjacentHTML("beforeend",t):"object"==typeof t&&a.make(t.tag,{...t,parent:e},n||"svg"==t.tag))},c=t=>{t&&t.call(s,e,s)};for(const[n,o]of Object.entries(t)){switch(n){case"text":e.textContent=null==o?"":String(o);continue;case"html":e.innerHTML=null==o?"":String(o);continue;case"tag":case"get":case"also":case"parent":case"context":case"onMount":case"onUpdate":case"onDestroy":continue}if(null!=o)switch(n){case"push":o.push(e);break;case"$":case"var":s&&(s["$"+o]=e);break;case"events":for(let t in o)e.addEventListener(t,a=>o[t].call(s,a,e,s));break;case"click":case"input":case"change":case"mousewheel":e.addEventListener(n,t=>o.call(s,t,e,s));break;case"attrs":for(let t in o)e.setAttribute(t,o[t]);break;case"props":for(let t in o)e[t]=o[t];break;case"data":for(let t in o)e.dataset[t]=o[t];break;case"child_r":a.clear(e);case"child":r(o);break;case"children_r":a.clear(e);case"children":for(let e of o)r(e);break;case"style_r":e.style.cssText="";case"style":if("string"==typeof o)e.style.cssText+=o+";";else for(let t in o)o[t]&&(e.style[t]=o[t]);break;case"class_r":e.className="";case"class":{const t=e=>Array.isArray(e)?Object.fromEntries(e.filter(Boolean).map(e=>[e,!0])):"string"==typeof e?t(e.split(/\s+/)):e;for(const[a,n]of Object.entries(t(o)))n?e.classList.add(a):e.classList.remove(a)}break;case"animate":{const{duration:t=300,easing:a="ease",onEnd:n=null,...s}=o;e.style.transition=Object.keys(s).map(e=>`${e} ${t}ms ${a}`).join(", "),requestAnimationFrame(()=>{for(let t in s)e.style[t]=s[t]});const r=()=>{e.removeEventListener("transitionend",r),c(n)};e.addEventListener("transitionend",r)}break;default:e[n]=o}}t.parent&&t.parent.appendChild(e);let o=50;const i=()=>{e._mounted||(e.isConnected?(e._mounted=!0,c(t.onMount)):--o&&requestAnimationFrame(i))};return i(),t.onDestroy&&(e._onDestroy=t.onDestroy.bind(s,e,s)),t.onUpdate&&(e._onUpdate=t.onUpdate.bind(s,e,s)),e._onUpdate&&e._onUpdate(),c(t.also),e}static configIn(e,t,n,s=!1){return a.config(t,{...n,context:e},s)}static clear(e,t=!0){for(;e.firstChild;)t&&a.clear(e.firstChild,!0),a.remove(e.firstChild,!1)}static remove(e,t=!0){t&&a.clear(e),e._onDestroy&&e._onDestroy(),e.remove()}static makeArray(e,t=!1){return e&&Array.isArray(e)?e.map(e=>a.make(e.tag,e,t)):[]}static makeArrayIn(e,t,n){return a.makeArray(t.map(t=>({...t,context:e})),n)}static makeShadow(e,t={},n=null){if(!e||"object"!=typeof t)return null;let s=e instanceof Node?e:document.createElement(e);return s.attachShadow({mode:"open"}),a.config(s.shadowRoot,{context:t.context,children:[{tag:"style",textContent:n??""},t.child??{},...t.children??[]]}),delete t.children,delete t.child,a.config(s,t),s}static makeShadowIn(e,t,n={},s=null){return a.makeShadow(t,{...n,context:e},s)}}const n=a;class s{constructor(e={}){this.data=e,this.subs=new Set}set(e,t){this.data[e]=t,this.subs.forEach(e=>e(this.data))}get(e){return this.data[e]}subscribe(e){return this.subs.add(e),()=>this.subs.delete(e)}}class r{static make=(e,t)=>a.make(e,t,!0);static config=(e,t)=>a.config(e,t,!0);static makeArray=e=>a.makeArray(e,!0);static svg=(e={},t={})=>r._make("svg",e,t);static rect=(e,t,a,n,s,c,o={},i={})=>r._make("rect",{...o,x:e,y:t,width:a,height:n,rx:s,ry:c},i);static circle=(e,t,a,n={},s={})=>r._make("circle",{...n,cx:e,cy:t,r:a},s);static line=(e,t,a,n,s={},c={})=>r._make("line",{...s,x1:e,y1:t,x2:a,y2:n},c);static polyline=(e,t={},a={})=>r._make("polyline",{...t,points:e},a);static polygon=(e,t={},a={})=>r._make("polygon",{...t,points:e},a);static path=(e,t={},a={})=>r._make("path",{...t,d:e},a);static text=(e,t,a,n={},s={})=>r._make("text",{...n,x:t,y:a},{...s,text:e});static _make=(e,t={},a={})=>r.make(e,{attrs:{...t},...a})}class c{static addStyle(e,t,a=!1){if(e&&t&&("object"==typeof t&&(t=t.constructor.name),!c.#e.has(t)&&!c.#t.has(t)))if(a){let a=document.createElement("style");document.head.appendChild(a),a.textContent=e,c.#t.set(t,a)}else c.#a||(c.#a=document.head.appendChild(document.createElement("style"))),c.#a.textContent+=e+"\r\n",c.#e.add(t)}static removeStyle(e){"object"==typeof e&&(e=e.constructor.name),c.#t.has(e)&&(c.#t.get(e).remove(),c.#t.delete(e))}static#a=null;static#e=new Set;static#t=new Map}class o extends a{constructor(e,t={},a=null,n=null,s=!1){super(e,t),c.addStyle(a,n,s)}static make(e,t={},n=null,s=null,r=!1){return c.addStyle(n,s,r),a.make(e,t)}}const i=t.uA,l=t.EL,d=t.t4,m=t.cj,u=t.Uw,h=t.LV;export{i as Component,l as EL,d as SVG,m as Sheet,u as State,h as StyledComponent};
1
+ var t={};function e(t,e=""){if(e||(e=s(t)),a.has(e))return;const n=document.createElement("style");return n.textContent=t,document.head.appendChild(n),a.set(e,n),n}function n(t,e=""){e||(e=s(t));const n=a.get(e);n&&(a.delete(e),n.remove())}function s(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n),e|=0;return e.toString(36)}t.d=(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})},t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const a=new Map;function r(t,e=!1,n=100){return new Promise(s=>{let a,r;const o=()=>{if(t.isConnected&&(t._mounted||(t._mounted=!0,t._onMount&&t._onMount()),a||(a=!0,e||s(t)),t.clientWidth||t.clientHeight))return t._rendered||(t._rendered=!0,t._onRender&&t._onRender()),void(r||(r=!0,e&&s(t)));n--?requestAnimationFrame(o):(e&&!r||!e&&!a)&&s(null)};o()})}function o(t,e){const n=new ResizeObserver(n=>{for(const s of n)s.target===t&&e(s)});n.observe(t);const s=new MutationObserver(()=>{t.isConnected||(n.disconnect(),s.disconnect())});s.observe(document.body,{childList:!0,subtree:!0})}class c{constructor(t,e={},n=!1){this.$root=c.make(t,{...e,ctx:this},n)}static make(t,e={},n=!1){t??=e.tag;let s="svg"==t||e.svg||n?document.createElementNS("http://www.w3.org/2000/svg",t??"svg"):document.createElement(t??"div");c.update(s,e);for(let t of i)s[t]=(...e)=>c[t](s,...e);return l.forEach(t=>{t in e&&(s["_"+t]=e[t].bind(s.ctx,{el:s,ctx:s.ctx}))}),s._onResize&&o(s,s._onResize),s}static update(t,e){if(!x.node(t)||!x.obj(e))return t;t.ctx=e.ctx??e.context??t.ctx;for(let[n,s]of Object.entries(e))b(t,n,s);return t._onUpdate&&t._onUpdate(),e.also&&e.also.call(t.ctx,{el:t,ctx:t.ctx}),t}static mount(t,e,n=!1,s=100){if(t)if(null==e)t.parentNode&&t.parentNode.removeChild(t);else if(t.parentNode!==e&&e.appendChild(t),s)return r(t,n,s);return Promise.resolve(t)}static clear(t,e=!0){if(t)for(;t.firstChild;)e&&c.clear(t.firstChild,!0),c.remove(t.firstChild,!1)}static remove(t,e=!0){t&&(e&&c.clear(t,!0),c.release(t),c.unbind(t),t._onDestroy&&t._onDestroy(),l.forEach(e=>t["_"+e]=null),t.parentNode&&t.parentNode.removeChild(t))}static replace(t,e,n=!1){return t&&(t.parentNode&&t.parentNode.replaceChild(e,t),n&&(e.ctx=t.ctx),r(e),t.remove()),e}static release(t){t&&t._events&&(t._events.forEach(({ev:e,fn:n,options:s})=>t.removeEventListener(e,n,s)),t._events=[])}static unbind(t){t&&t._unsub&&(Object.values(t._unsub).forEach(t=>t()),t._unsub={})}static makeShadow(t,e={},n=""){return t&&x.obj(e)?(x.node(t)||(t=document.createElement(t)),t.attachShadow({mode:"open"}),c.update(t.shadowRoot,{ctx:e.context??e.ctx,child:[{tag:"style",$:"style",text:n},e.child,e.children]}),delete e.child,delete e.children,c.update(t,e)):null}static setTemplate(t,e,n){c.templates.set(t,(...t)=>c.make(e,n(...t)))}static useTemplate(t,...e){const n=c.templates.get(t);return n?n(...e):null}static templates=new Map;static config=c.update}const i=["update","mount","clear","remove"],l=["onMount","onRender","onUpdate","onResize","onDestroy"],d=new Set(["tag","get","also","context","ctx","svg",...l]),u={children:"child",children_r:"child_r",text:"textContent",html:"innerHTML"},p={push(t,e){e.push(t)},$(t,e){t.ctx&&(t.ctx["$"+e]=t)},attrs(t,e){h("attrs",t,e,(e,n)=>t.setAttribute(e,n),e=>t.removeAttribute(e))},data(t,e){h("data",t,e,(e,n)=>t.dataset[e]=n,e=>delete t.dataset[e])},props(t,e){for(let n in e){let s=_(t,n,null,e[n]);t[n]=["min","max","step","selectedIndex"].includes(n)||"value"==n&&["number","range"].includes(t.type)?null==s||""===s||Number.isNaN(s)?"":+s:s??""}},transition(t,e){const{duration:n=300,easing:s="ease",delay:a=0,onEnd:r=null,...o}=e;t.style.transition=Object.keys(o).map(t=>`${t} ${n}ms ${s} ${a}ms`).join(", "),r&&p.events(t,{transitionend:{handler:r,once:!0}}),requestAnimationFrame(()=>p.style(t,o))},events(t,e){for(let n in e){let s=e[n],a={};if(x.obj(s)&&(a=s,s=s.handler,!s))continue;const r=e=>s.call(t.ctx,Object.assign(e,{el:t,ctx:t.ctx}));t.addEventListener(n,r,a),(t._events??=[]).push({ev:n,fn:r,options:a})}},events_r(t,e){c.release(t),p.events(t,e)},child(t,e){f(t,e)},child_r(t,e){c.clear(t),f(t,e)},style(t,e){m("style",t,e,e=>t.style.cssText+=e+";",(e,n)=>{e.startsWith("--")?t.style.setProperty(e,n):t.style[e]=n})},style_r(t,e){t.style.cssText="",p.style(t,e)},class(t,e){x.arr(e)&&(e=Object.fromEntries(e.filter(Boolean).map(t=>[t,!0]))),m("class",t,e,e=>e.split(/\s+/).forEach(e=>e&&t.classList.add(e)),(e,n)=>n?t.classList.add(e):t.classList.remove(e))},class_r(t,e){t.className="",p.class(t,e)},parent(t,e){c.mount(t,e,!1,t._onMount||t._onRender?100:0)}};function h(t,e,n,s,a){for(let r in n){let o=_(e,t,r,n[r]);null==o?a(r):s(r,String(o))}}function m(t,e,n,s,a){if(x.str(n))s(n);else for(let s in n)"_raw"==s?p[t](e,n[s]):a(s,_(e,t,s,n[s]))}function f(t,e){e&&(x.str(e)?t.insertAdjacentHTML("beforeend",e):x.arr(e)?e.forEach(e=>f(t,e)):x.node(e)?c.mount(e,t):e instanceof c?c.mount(e.$root,t):x.obj(e)&&c.make(null,{ctx:t.ctx,...e,parent:t},t instanceof SVGElement))}function _(t,e,n,s){if(x.func(s))return s.call(t.ctx,{el:t,ctx:t.ctx});if(x.arr(s)&&x.state(s[0]))return s.map(s=>_(t,e,n,s))[0];if(x.state(s)){const a=(a,r)=>{r=s.map({el:t,ctx:t.ctx,name:a,value:r}),b(t,e,n?{[n]:r}:r),t._onUpdate&&t._onUpdate()},r=e+"."+n+"."+s.name;return t._unsub||(t._unsub={}),r in t._unsub&&t._unsub[r](),t._unsub[r]=s._state.subscribe(s.name,a),s.map({el:t,ctx:t.ctx,name:s.name,value:s._state[s.name]})}return s}function b(t,e,n){if(d.has(e))return;(e=u[e]??e).startsWith("on")?(n={[e.slice(2).toLowerCase()]:n},e="events"):n=_(t,e,null,n);const s=p[e];null!=n&&s?s(t,n):p.props(t,{[e]:n})}const x={func:t=>"function"==typeof t,str:t=>"string"==typeof t,arr:t=>Array.isArray(t),node:t=>t instanceof Node,obj:t=>null!==t&&"object"==typeof t,state:t=>t&&t._state};class v{static svg=(t={},e={})=>({tag:"svg",...e,attrs:t});static rect=(t,e,n,s,a,r,o={},c={})=>({tag:"rect",...c,attrs:{...o,x:t,y:e,width:n,height:s,rx:a,ry:r}});static circle=(t,e,n,s={},a={})=>({tag:"circle",...a,attrs:{...s,cx:t,cy:e,r:n}});static line=(t,e,n,s,a={},r={})=>({tag:"line",...r,attrs:{...a,x1:t,y1:e,x2:n,y2:s}});static polyline=(t,e={},n={})=>({tag:"polyline",...n,attrs:{...e,points:t}});static polygon=(t,e={},n={})=>({tag:"polygon",...n,attrs:{...e,points:t}});static path=(t,e={},n={})=>({tag:"path",...n,attrs:{...e,d:t}});static text=(t,e,n,s={},a={})=>({tag:"text",...a,text:t,attrs:{...s,x:e,y:n}});static make=(t,e)=>c.make(t,e,!0);static update=c.update;static config=c.update}Object.getOwnPropertyNames(v).forEach(t=>v["make_"+t]=(...e)=>v.make(null,v[t](...e)));class g{constructor(t={}){this._data={},this._subs=new Map,this.addStates(t)}addStates(t){for(const e in t)e in this||e in this._data||(this._data[e]=t[e],Object.defineProperty(this,e,{get:()=>this._data[e],set:t=>{if(Object.is(this._data[e],t))return;this._data[e]=t;const n=this._subs.get(e);n&&n.forEach(n=>n(e,t))}}))}hasState(t){return t in this._data}bind(t,e=t=>t.value){return{_state:this,name:t,map:e}}subscribe(t,e){return this._subs.has(t)||this._subs.set(t,new Set),this._subs.get(t).add(e),()=>this._subs.get(t).delete(e)}}function y(t){return new g(t)}export{c as EL,v as SVG,g as State,e as addCSS,n as removeCSS,y as useState,r as watchMount,o as watchResize};
Binary file
@@ -0,0 +1 @@
1
+ class t{constructor(e,s={},n=!1){this.$root=t.make(e,{...s,ctx:this},n)}static make(e,s={},n=!1){e??=s.tag;let r="svg"==e||s.svg||n?document.createElementNS("http://www.w3.org/2000/svg",e??"svg"):document.createElement(e??"div");return t.update(r,s),r}static update(t,e){if(!i.node(t)||!i.obj(e))return t;t.ctx=e.ctx??e.context??t.ctx;for(let[s,n]of Object.entries(e))l(t,s,n);return e.also&&e.also.call(t.ctx,{el:t,ctx:t.ctx}),t}static mount(t,e,s=!1,n=100){return t&&t.parentNode!==e&&e.appendChild(t),Promise.resolve(t)}static clear(e,s=!0){if(e)for(;e.firstChild;)t.remove(e.firstChild,!1)}static remove(t,e=!0){t&&t.parentNode&&t.parentNode.removeChild(t)}static config=t.update}const e=new Set(["tag","get","also","context","ctx","svg"]),s={children:"child",children_r:"child_r",text:"textContent",html:"innerHTML"},n={push(t,e){e.push(t)},$(t,e){t.ctx&&(t.ctx["$"+e]=t)},attrs(t,e){r("attrs",t,e,(e,s)=>t.setAttribute(e,s),e=>t.removeAttribute(e))},data(t,e){r("data",t,e,(e,s)=>t.dataset[e]=s,e=>delete t.dataset[e])},props(t,e){for(let s in e){let n=c(0,0,0,e[s]);t[s]=["min","max","step","selectedIndex"].includes(s)||"value"==s&&["number","range"].includes(t.type)?null==n||""===n||Number.isNaN(n)?"":+n:n??""}},transition(t,e){const{duration:s=300,easing:r="ease",delay:a=0,onEnd:o=null,...c}=e;t.style.transition=Object.keys(c).map(t=>`${t} ${s}ms ${r} ${a}ms`).join(", "),o&&n.events(t,{transitionend:{handler:o,once:!0}}),requestAnimationFrame(()=>n.style(t,c))},events(t,e){for(let s in e){let n=e[s],r={};if(i.obj(n)&&(r=n,n=n.handler,!n))continue;const a=e=>n.call(t.ctx,Object.assign(e,{el:t,ctx:t.ctx}));t.addEventListener(s,a,r)}},events_r(t,e){n.events(t,e)},child(t,e){o(t,e)},child_r(e,s){t.clear(e),o(e,s)},style(t,e){a("style",t,e,e=>t.style.cssText+=e+";",(e,s)=>{e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s})},style_r(t,e){t.style.cssText="",n.style(t,e)},class(t,e){i.arr(e)&&(e=Object.fromEntries(e.filter(Boolean).map(t=>[t,!0]))),a("class",t,e,e=>e.split(/\s+/).forEach(e=>e&&t.classList.add(e)),(e,s)=>s?t.classList.add(e):t.classList.remove(e))},class_r(t,e){t.className="",n.class(t,e)},parent(e,s){t.mount(e,s,!1,e._onMount||e._onRender?100:0)}};function r(t,e,s,n,r){for(let t in s){let e=c(0,0,0,s[t]);null==e?r(t):n(t,String(e))}}function a(t,e,s,r,a){if(i.str(s))r(s);else for(let r in s)"_raw"==r?n[t](e,s[r]):a(r,c(0,0,0,s[r]))}function o(e,s){s&&(i.str(s)?e.insertAdjacentHTML("beforeend",s):i.arr(s)?s.forEach(t=>o(e,t)):i.node(s)?t.mount(s,e):s instanceof t?t.mount(s.$root,e):i.obj(s)&&t.make(null,{ctx:e.ctx,...s,parent:e},e instanceof SVGElement))}function c(t,e,s,n){return n}function l(t,r,a){if(e.has(r))return;(r=s[r]??r).startsWith("on")&&(a={[r.slice(2).toLowerCase()]:a},r="events");const o=n[r];null!=a&&o?o(t,a):n.props(t,{[r]:a})}const i={func:t=>"function"==typeof t,str:t=>"string"==typeof t,arr:t=>Array.isArray(t),node:t=>t instanceof Node,obj:t=>null!==t&&"object"==typeof t,state:t=>t&&t._state};export{t as EL};
Binary file
@@ -0,0 +1 @@
1
+ class t{constructor(e,n={},s=!1){this.$root=t.make(e,{...n,ctx:this},s)}static make(e,n={},s=!1){e??=n.tag;let r="svg"==e||n.svg||s?document.createElementNS("http://www.w3.org/2000/svg",e??"svg"):document.createElement(e??"div");return t.update(r,n),r}static update(t,e){if(!l.node(t)||!l.obj(e))return t;t.ctx=e.ctx??e.context??t.ctx;for(let[n,s]of Object.entries(e))i(t,n,s);return e.also&&e.also.call(t.ctx,{el:t,ctx:t.ctx}),t}static mount(t,e,n=!1,s=100){return t&&t.parentNode!==e&&e.appendChild(t),Promise.resolve(t)}static clear(e,n=!0){if(e)for(;e.firstChild;)t.remove(e.firstChild,!1)}static remove(t,e=!0){t&&t.parentNode&&t.parentNode.removeChild(t)}static config=t.update}const e=new Set(["tag","get","also","context","ctx","svg"]),n={children:"child",children_r:"child_r",text:"textContent",html:"innerHTML"},s={push(t,e){e.push(t)},$(t,e){t.ctx&&(t.ctx["$"+e]=t)},attrs(t,e){r("attrs",t,e,(e,n)=>t.setAttribute(e,n),e=>t.removeAttribute(e))},data(t,e){r("data",t,e,(e,n)=>t.dataset[e]=n,e=>delete t.dataset[e])},props(t,e){for(let n in e){let s=c(0,0,0,e[n]);t[n]=["min","max","step","selectedIndex"].includes(n)||"value"==n&&["number","range"].includes(t.type)?null==s||""===s||Number.isNaN(s)?"":+s:s??""}},transition(t,e){const{duration:n=300,easing:r="ease",delay:o=0,onEnd:a=null,...c}=e;t.style.transition=Object.keys(c).map(t=>`${t} ${n}ms ${r} ${o}ms`).join(", "),a&&s.events(t,{transitionend:{handler:a,once:!0}}),requestAnimationFrame(()=>s.style(t,c))},events(t,e){for(let n in e){let s=e[n],r={};if(l.obj(s)&&(r=s,s=s.handler,!s))continue;const o=e=>s.call(t.ctx,Object.assign(e,{el:t,ctx:t.ctx}));t.addEventListener(n,o,r)}},events_r(t,e){s.events(t,e)},child(t,e){a(t,e)},child_r(e,n){t.clear(e),a(e,n)},style(t,e){o("style",t,e,e=>t.style.cssText+=e+";",(e,n)=>{e.startsWith("--")?t.style.setProperty(e,n):t.style[e]=n})},style_r(t,e){t.style.cssText="",s.style(t,e)},class(t,e){l.arr(e)&&(e=Object.fromEntries(e.filter(Boolean).map(t=>[t,!0]))),o("class",t,e,e=>e.split(/\s+/).forEach(e=>e&&t.classList.add(e)),(e,n)=>n?t.classList.add(e):t.classList.remove(e))},class_r(t,e){t.className="",s.class(t,e)},parent(e,n){t.mount(e,n,!1,e._onMount||e._onRender?100:0)}};function r(t,e,n,s,r){for(let t in n){let e=c(0,0,0,n[t]);null==e?r(t):s(t,String(e))}}function o(t,e,n,r,o){if(l.str(n))r(n);else for(let r in n)"_raw"==r?s[t](e,n[r]):o(r,c(0,0,0,n[r]))}function a(e,n){n&&(l.str(n)?e.insertAdjacentHTML("beforeend",n):l.arr(n)?n.forEach(t=>a(e,t)):l.node(n)?t.mount(n,e):n instanceof t?t.mount(n.$root,e):l.obj(n)&&t.make(null,{ctx:e.ctx,...n,parent:e},e instanceof SVGElement))}function c(t,e,n,s){return s}function i(t,r,o){if(e.has(r))return;(r=n[r]??r).startsWith("on")&&(o={[r.slice(2).toLowerCase()]:o},r="events");const a=s[r];null!=o&&a?a(t,o):s.props(t,{[r]:o})}const l={func:t=>"function"==typeof t,str:t=>"string"==typeof t,arr:t=>Array.isArray(t),node:t=>t instanceof Node,obj:t=>null!==t&&"object"==typeof t,state:t=>t&&t._state};class d{static svg=(t={},e={})=>({tag:"svg",...e,attrs:t});static rect=(t,e,n,s,r,o,a={},c={})=>({tag:"rect",...c,attrs:{...a,x:t,y:e,width:n,height:s,rx:r,ry:o}});static circle=(t,e,n,s={},r={})=>({tag:"circle",...r,attrs:{...s,cx:t,cy:e,r:n}});static line=(t,e,n,s,r={},o={})=>({tag:"line",...o,attrs:{...r,x1:t,y1:e,x2:n,y2:s}});static polyline=(t,e={},n={})=>({tag:"polyline",...n,attrs:{...e,points:t}});static polygon=(t,e={},n={})=>({tag:"polygon",...n,attrs:{...e,points:t}});static path=(t,e={},n={})=>({tag:"path",...n,attrs:{...e,d:t}});static text=(t,e,n,s={},r={})=>({tag:"text",...r,text:t,attrs:{...s,x:e,y:n}});static make=(e,n)=>t.make(e,n,!0);static update=t.update;static config=t.update}function u(t,e=""){if(e||(e=f(t)),p.has(e))return;const n=document.createElement("style");return n.textContent=t,document.head.appendChild(n),p.set(e,n),n}function m(t,e=""){e||(e=f(t));const n=p.get(e);n&&(p.delete(e),n.remove())}function f(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n),e|=0;return e.toString(36)}Object.getOwnPropertyNames(d).forEach(t=>d["make_"+t]=(...e)=>d.make(null,d[t](...e)));const p=new Map;function h(t,e=!1,n=100){return new Promise(s=>{let r,o;const a=()=>{if(t.isConnected&&(t._mounted||(t._mounted=!0,t._onMount&&t._onMount()),r||(r=!0,e||s(t)),t.clientWidth||t.clientHeight))return t._rendered||(t._rendered=!0,t._onRender&&t._onRender()),void(o||(o=!0,e&&s(t)));n--?requestAnimationFrame(a):(e&&!o||!e&&!r)&&s(null)};a()})}function g(t,e){const n=new ResizeObserver(n=>{for(const s of n)s.target===t&&e(s)});n.observe(t);const s=new MutationObserver(()=>{t.isConnected||(n.disconnect(),s.disconnect())});s.observe(document.body,{childList:!0,subtree:!0})}export{t as EL,d as SVG,u as addCSS,m as removeCSS,h as watchMount,g as watchResize};
Binary file