UNPKG

@tntsuperman/rjs

Version:

simple, react, fast JavaScript framework

3 lines (2 loc) 1.91 kB
System.register("R",[],(function(e){"use strict";return{execute:function(){const t=[],n=(e,n,o)=>{t.push([e,n,o]),n(),t.pop(),o()},o=e("hook",((e,t=()=>0)=>{const o=Symbol();return n(o,e,t),o}));class r{node;#e;constructor(e){e.dispatchEvent(new window.CustomEvent("create")),this.node=e,this.#e=[e.remove.bind(e)],e.remove=()=>{for(this.#e.forEach((e=>e()));this.node.childNodes.length;)this.node.childNodes[0].remove()}}ondestroy(e){this.#e.push(e)}}e("VNode",r);e("createVElement",((e,t,n=()=>({}),s={})=>{const c=window.document.createElement(e);return o((()=>Object.entries(n()).forEach((e=>c.setAttribute(...e))))),o((()=>{for(;c.childNodes.length;)c.childNodes[0].remove();t().forEach((e=>c.appendChild(e.node)))})),Object.entries(s).forEach((e=>c.addEventListener(...e))),new r(c)})),e("createVText",(e=>{const t=new window.Text("");return o((()=>t.nodeValue=e())),new r(t)}));const s=[],c=e("createProxy",(e=>{let o=[],r=[];const i=e=>o=o.filter((t=>t[1]!=e)),{proxy:d,revoke:f}=Proxy.revocable(e,{get(e,n,s){let i=Reflect.get(e,n,s);if("object"==typeof i){const e=r.find((e=>e[0]==n));if(e)i=e[1];else{const e=c(i);r.push([n,...e]),i=e[0]}}const d=t.at(-1);return d&&o.push([n,...d]),i},set(e,t,r,c){const i=Reflect.set(e,t,r,c);return o.filter((e=>e[0]==t)).forEach((e=>{s.forEach((t=>t(e[1]))),n(e[1],e[2],e[3])})),i}});return s.push(i),[d,()=>(s.splice(s.findIndex((e=>e==i)),1),r.forEach((e=>e[2]?e[2]():0)),f())]})),i=(e,t)=>new Proxy((function(...n){if("function"==typeof n[0]){const o=t.pop();return o&&e.addEventListener(o,n[0]),i(e,t)}return e.append(...n.map((e=>"string"==typeof e?e:e instanceof r?e.node:""))),new r(e)}),{get(n,o){if("string"==typeof o)return t.push(o),2==t.length&&e.setAttribute(t.shift()??"",t.pop()??""),i(e,t)}});e("seg",new Proxy({},{get:(e,t)=>"string"==typeof t?i(window.document.createElement(t),[]):void 0}))}}})); //# sourceMappingURL=R.system.min.js.map