@alexgyver/component 1.4.1 → 2.0.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/Component.min.js CHANGED
@@ -1 +1 @@
1
- var e={d:(t,a)=>{for(var c in a)e.o(a,c)&&!e.o(t,c)&&Object.defineProperty(t,c,{enumerable:!0,get:a[c]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{EL:()=>a,LV:()=>r,cj:()=>s,t4:()=>n,uA:()=>c});class a{static context;constructor(e,t={},c=!1){a.context=this,this.$root=a.make(e,t,c)}static make(e,t={},c=!1){return e&&"object"==typeof t?t instanceof Node?t:("svg"==e&&(c=!0),a.config(c?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e),t,c)):null}static makeIn(e,t,c={},n=!1){return c.context=e,a.make(t,c,n)}static config(e,t,c=!1){if(Array.isArray(e))return e.forEach(e=>a.config(e,t,c)),null;if(!(e instanceof Node)||"object"!=typeof t)return e;let n=t.context;a.context=null===n?null:n||a.context,n=a.context;let s=t=>{if(t)if(t instanceof Node)e.appendChild(t);else if(t instanceof a)e.appendChild(t.$root);else if("string"==typeof t)e.innerHTML+=t;else if("object"==typeof t){let n=a.make(t.tag??"div",t,c||"svg"==t.tag);n&&e.appendChild(n)}};for(const[c,r]of Object.entries(t)){switch(c){case"text":e.textContent=null==r?"":r+"";continue;case"html":e.innerHTML=null==r?"":r+"";continue;case"tag":case"context":case"get":case"also":continue}if(r)switch(c){case"class":(Array.isArray(r)?r:r.split(" ")).map(t=>t&&e.classList.add(t));break;case"push":r.push(e);break;case"$":case"var":n&&(n["$"+r]=e);break;case"events":for(let t in r)e.addEventListener(t,n?r[t].bind(n):r[t]);break;case"click":case"change":case"input":case"mousewheel":e.addEventListener(c,n?r.bind(n):r);break;case"parent":r.appendChild(e);break;case"attrs":for(let t in r)e.setAttribute(t,r[t]);break;case"props":for(let t in r)e[t]=r[t];break;case"child_r":a.clear(e);case"child":s(r);break;case"children_r":a.clear(e);case"children":for(let e of r)s(e);break;case"style_r":e.style.cssText="";case"style":if("string"==typeof r)e.style.cssText+=r+";";else for(let t in r)r[t]&&(e.style[t]=r[t]);break;default:e[c]=r}}return t.also&&n&&t.also.call(n,e),e}static configIn(e,t,c,n=!1){return c.context=e,a.config(t,c,n)}static clear(e){for(;e.firstChild;)e.removeChild(e.lastChild)}static makeArray(e,t=!1){return e&&Array.isArray(e)?e.map(e=>a.make(e.tag,e,t)):[]}static makeShadow(e,t={},c=null){if(!e||"object"!=typeof t)return null;let n=e instanceof Node?e:document.createElement(e);return n.attachShadow({mode:"open"}),a.config(n.shadowRoot,{context:t.context,children:[{tag:"style",textContent:c??""},t.child??{},...t.children??[]]}),delete t.children,delete t.child,a.config(n,t),n}}const c=a;class n{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={})=>n._make("svg",e,t);static rect=(e,t,a,c,s,r,o={},i={})=>n._make("rect",{...o,x:e,y:t,width:a,height:c,rx:s,ry:r},i);static circle=(e,t,a,c={},s={})=>n._make("circle",{...c,cx:e,cy:t,r:a},s);static line=(e,t,a,c,s={},r={})=>n._make("line",{...s,x1:e,y1:t,x2:a,y2:c},r);static polyline=(e,t={},a={})=>n._make("polyline",{...t,points:e},a);static polygon=(e,t={},a={})=>n._make("polygon",{...t,points:e},a);static path=(e,t={},a={})=>n._make("path",{...t,d:e},a);static text=(e,t,a,c={},s={})=>n._make("text",{...c,x:t,y:a},{...s,text:e});static _make=(e,t={},a={})=>n.make(e,{attrs:{...t},...a})}class s{static addStyle(e,t,a=!1){if(e&&t&&("object"==typeof t&&(t=t.constructor.name),!s.#e.has(t)&&!s.#t.has(t)))if(a){let a=document.createElement("style");document.head.appendChild(a),a.textContent=e,s.#t.set(t,a)}else s.#a||(s.#a=document.head.appendChild(document.createElement("style"))),s.#a.textContent+=e+"\r\n",s.#e.add(t)}static removeStyle(e){"object"==typeof e&&(e=e.constructor.name),s.#t.has(e)&&(s.#t.get(e).remove(),s.#t.delete(e))}static#a=null;static#e=new Set;static#t=new Map}class r extends a{constructor(e,t={},a=null,c=null,n=!1){super(e,t),s.addStyle(a,c,n)}static make(e,t={},c=null,n=null,r=!1){return s.addStyle(c,n,r),a.make(e,t)}}const o=t.uA,i=t.EL,l=t.t4,d=t.cj,h=t.LV;export{o as Component,i as EL,l as SVG,d as Sheet,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||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",...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 y{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 g(t){return new y(t)}export{c as EL,v as SVG,y as State,e as addCSS,n as removeCSS,g as useState,r as watchMount,o as watchResize};
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||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(!i.node(t)||!i.obj(e))return t;t.ctx=e.ctx??e.context??t.ctx;for(let[n,s]of Object.entries(e))l(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"]),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:a=0,onEnd:o=null,...c}=e;t.style.transition=Object.keys(c).map(t=>`${t} ${n}ms ${r} ${a}ms`).join(", "),o&&s.events(t,{transitionend:{handler:o,once:!0}}),requestAnimationFrame(()=>s.style(t,c))},events(t,e){for(let n in e){let s=e[n],r={};if(i.obj(s)&&(r=s,s=s.handler,!s))continue;const a=e=>s.call(t.ctx,Object.assign(e,{el:t,ctx:t.ctx}));t.addEventListener(n,a,r)}},events_r(t,e){s.events(t,e)},child(t,e){o(t,e)},child_r(e,n){t.clear(e),o(e,n)},style(t,e){a("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){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,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 a(t,e,n,r,a){if(i.str(n))r(n);else for(let r in n)"_raw"==r?s[t](e,n[r]):a(r,c(0,0,0,n[r]))}function o(e,n){n&&(i.str(n)?e.insertAdjacentHTML("beforeend",n):i.arr(n)?n.forEach(t=>o(e,t)):i.node(n)?t.mount(n,e):n instanceof t?t.mount(n.$root,e):i.obj(n)&&t.make(null,{ctx:e.ctx,...n,parent:e},e instanceof SVGElement))}function c(t,e,n,s){return s}function l(t,r,a){if(e.has(r))return;(r=n[r]??r).startsWith("on")&&(a={[r.slice(2).toLowerCase()]:a},r="events");const o=s[r];null!=a&&o?o(t,a):s.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||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"]),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 x(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,x as watchResize};
Binary file