Comparing version 1.8.1 to 1.9.0
@@ -1,2 +0,2 @@ | ||
var e,t,r,a,n,o,s,i,d,c,l,h,u,p,f=Object.defineProperty,b=Object.defineProperties,m=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,g=(e,t,r)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))y.call(t,r)&&g(e,r,t[r]);if(v)for(var r of v(t))M.call(t,r)&&g(e,r,t[r]);return e},k=(e,t,r)=>(g(e,"symbol"!=typeof t?t+"":t,r),r),S=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},O=(e,t,r)=>(S(e,t,"read from private field"),r?r.call(e):t.get(e)),x=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},T=(e,t,r,a)=>(S(e,t,"write to private field"),a?a.call(e,r):t.set(e,r),r),W=(e,t,r)=>(S(e,t,"access private method"),r);class _{constructor(){this.startMarker=document.createTextNode(""),this.endMarker=document.createTextNode("")}static from(e,t){const r=new this;return e.before(r.startMarker),t.after(r.endMarker),r}before(...e){this.startMarker.before(...e)}prepend(...e){this.startMarker.after(...e)}append(...e){this.endMarker.before(...e)}after(...e){this.endMarker.after(...e)}remove(){const e=document.createRange();e.setStartBefore(this.startMarker),e.setEndAfter(this.endMarker),e.deleteContents()}replaceChildren(...e){const t=document.createRange();t.setStartAfter(this.startMarker),t.setEndBefore(this.endMarker),t.deleteContents(),this.startMarker.after(...e)}replaceWith(...e){this.endMarker.after(...e),this.remove()}get childNodes(){const e=[];for(let t=this.startMarker.nextSibling;t!=this.endMarker&&t;t=t.nextSibling)e.push(t);return e}get children(){return this.childNodes.filter((e=>e instanceof HTMLElement))}}var j=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",LiveFragment:_});const A=Symbol.for("bruh reactive");e=A,t=new WeakMap,r=new WeakMap;const N=class{constructor(e,t){x(this,u),k(this,a,!0),x(this,n,void 0),x(this,o,new Set),x(this,s,void 0),x(this,i,0),x(this,d,new Set),t?(T(this,n,t()),T(this,s,t),T(this,i,Math.max(...e.map((e=>O(e,i))))+1),e.forEach((e=>O(e,d).add(this)))):T(this,n,e)}get value(){return O(N,c).size&&N.applyUpdates(),O(this,n)}set value(e){0===O(this,i)&&(O(N,c).size||queueMicrotask(N.applyUpdates),O(N,c).set(this,e))}addReaction(e){return O(this,o).add(e),()=>O(this,o).delete(e)}static applyUpdates(){var e,t,r;if(O(N,c).size){for(const[t,r]of O(N,c).entries())W(e=t,u,p).call(e,r);O(N,c).clear();for(const e of O(N,l))if(e)for(const a of e)W(r=a,u,p).call(r,O(t=a,s).call(t));O(N,l).length=0;for(const e of O(N,h))e();O(N,h).length=0}}};let E=N;a=A,n=new WeakMap,o=new WeakMap,s=new WeakMap,i=new WeakMap,d=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakSet,p=function(e){if(e===O(this,n))return;T(this,n,e),O(N,h).push(...O(this,o));const t=O(N,l);for(const r of O(this,d)){const e=O(r,i);t[e]||(t[e]=new Set),t[e].add(r)}},x(E,c,new Map),x(E,l,[]),x(E,h,[]);const C=(e,t)=>{if(null==e?void 0:e[A])return t(e.value),e.addReaction((()=>t(e.value)));t(e)};var R=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",SimpleReactive:class{constructor(a){k(this,e,!0),x(this,t,void 0),x(this,r,new Set),T(this,t,a)}get value(){return O(this,t)}set value(e){if(e!==O(this,t)){T(this,t,e);for(const e of O(this,r))e()}}addReaction(e){return O(this,r).add(e),()=>O(this,r).delete(e)}},FunctionalReactive:E,r:(e,t)=>new E(e,t),reactiveDo:C});const P=(e,t)=>r=>{Array.isArray(r)?r.length?e(r[0]):t():e(r)};var z=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",pipe:(e,...t)=>t.reduce(((e,t)=>t(e)),e),dispatch:(e,t,r)=>e.dispatchEvent(new CustomEvent(t,w({bubbles:!0,cancelable:!0,composed:!0},r))),createDestructable:(e,t)=>{const r=(a=w({},e),n={[Symbol.iterator]:()=>t[Symbol.iterator]()},b(a,m(n)));var a,n;return Object.defineProperty(r,Symbol.iterator,{enumerable:!1}),r},maybeDo:P,functionAsObject:e=>new Proxy({},{get:(t,r)=>e(r)})});const D=Symbol.for("bruh reactive"),B=Symbol.for("bruh meta node"),F=Symbol.for("bruh meta text node"),U=Symbol.for("bruh meta element"),L=e=>e[B]?e.node:e instanceof Node?e:document.createTextNode(e),q=e=>e.flat(1/0).flatMap((e=>{if(!e[D])return[L(e)];if(Array.isArray(e.value)){const t=new _;return e.addReaction((()=>{t.replaceChildren(...q(e.value))})),[t.startMarker,...q(e.value),t.endMarker]}let t=L(e.value);return e.addReaction((()=>{const r=t;t=L(e.value),r.replaceWith(t)})),[t]}));class H{constructor(e){this[B]=this[F]=!0,e[D]?(this.node=document.createTextNode(e.value),e.addReaction((()=>{this.node.textContent=e.value}))):this.node=document.createTextNode(e)}addProperties(e={}){return Object.assign(this.node,e),this}}class I{constructor(e,t){this[B]=this[U]=!0,this.node=t?document.createElementNS(t,e):document.createElement(e)}static from(e){const t=new this("div");return t.node=e,t}addProperties(e={}){return Object.assign(this.node,e),this}addAttributes(e={}){for(const t in e)C(e[t],P((e=>this.node.setAttribute(t,e)),(()=>this.node.removeAttribute(t))));return this}addDataAttributes(e={}){for(const t in e)C(e[t],P((e=>this.node.dataset[t]=e),(()=>delete this.node.dataset[t])));return this}before(...e){this.node.before(...q(e))}prepend(...e){this.node.prepend(...q(e))}append(...e){this.node.append(...q(e))}after(...e){this.node.after(...q(e))}replaceChildren(...e){this.node.replaceChildren(...q(e))}replaceWith(...e){this.node.replaceWith(...q(e))}}var J=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",childrenToNodes:q,MetaTextNode:H,MetaElement:I,hydrateTextNodes:()=>{const e={},t=document.getElementsByTagName("bruh-textnode");for(const r of t){const t=document.createTextNode(r.textContent);r.dataset.tag&&(e[r.dataset.tag]=t),r.replaceWith(t)}return e},t:e=>new H(e),e:(e,t)=>(...r)=>{const a=new I(e,t);if((null==(n=r[0])?void 0:n[B])||(null==n?void 0:n[D])||n instanceof Node||Array.isArray(n)||"function"!=typeof n)a.append(r);else{const[e,...t]=r;a.addAttributes(e),a.append(t)}var n;return a},h:(e,t,...r)=>{if("string"==typeof e){const a=new I(e);return a.addAttributes(t||{}),a.append(r),a}return e(Object.assign({},t,{children:r}))},JSXFragment:({children:e})=>e});export{J as dom,j as liveFragment,R as reactive,z as util}; | ||
var e,t,r,a,n,o,s,i,d,c,l,h,u,p,f,b,m,v,y=Object.defineProperty,M=Object.defineProperties,g=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,O=(e,t,r)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))k.call(t,r)&&O(e,r,t[r]);if(w)for(var r of w(t))S.call(t,r)&&O(e,r,t[r]);return e},W=(e,t,r)=>(O(e,"symbol"!=typeof t?t+"":t,r),r),x=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},_=(e,t,r)=>(x(e,t,"read from private field"),r?r.call(e):t.get(e)),j=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},A=(e,t,r,a)=>(x(e,t,"write to private field"),a?a.call(e,r):t.set(e,r),r),N=(e,t,r)=>(x(e,t,"access private method"),r);class E{constructor(){W(this,"startMarker",document.createTextNode("")),W(this,"endMarker",document.createTextNode(""))}static from(e,t){const r=new this;return e.before(r.startMarker),t.after(r.endMarker),r}before(...e){this.startMarker.before(...e)}prepend(...e){this.startMarker.after(...e)}append(...e){this.endMarker.before(...e)}after(...e){this.endMarker.after(...e)}remove(){const e=document.createRange();e.setStartBefore(this.startMarker),e.setEndAfter(this.endMarker),e.deleteContents()}replaceChildren(...e){const t=document.createRange();t.setStartAfter(this.startMarker),t.setEndBefore(this.endMarker),t.deleteContents(),this.startMarker.after(...e)}replaceWith(...e){this.endMarker.after(...e),this.remove()}get childNodes(){const e=[];for(let t=this.startMarker.nextSibling;t!=this.endMarker&&t;t=t.nextSibling)e.push(t);return e}get children(){return this.childNodes.filter((e=>e instanceof HTMLElement))}}var C=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",LiveFragment:E});const P=Symbol.for("bruh reactive");e=P,t=new WeakMap,r=new WeakMap;const R=class{constructor(e,t){j(this,u),W(this,a,!0),j(this,n,void 0),j(this,o,new Set),j(this,s,void 0),j(this,i,0),j(this,d,new Set),t?(A(this,n,t()),A(this,s,t),A(this,i,Math.max(...e.map((e=>_(e,i))))+1),e.forEach((e=>_(e,d).add(this)))):A(this,n,e)}get value(){return _(R,c).size&&R.applyUpdates(),_(this,n)}set value(e){0===_(this,i)&&(_(R,c).size||queueMicrotask(R.applyUpdates),_(R,c).set(this,e))}addReaction(e){return _(this,o).add(e),()=>_(this,o).delete(e)}static applyUpdates(){var e,t,r;if(_(R,c).size){for(const[t,r]of _(R,c).entries())N(e=t,u,p).call(e,r);_(R,c).clear();for(const e of _(R,l))if(e)for(const a of e)N(r=a,u,p).call(r,_(t=a,s).call(t));_(R,l).length=0;for(const e of _(R,h))e();_(R,h).length=0}}};let z=R;a=P,n=new WeakMap,o=new WeakMap,s=new WeakMap,i=new WeakMap,d=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakSet,p=function(e){if(e===_(this,n))return;A(this,n,e),_(R,h).push(..._(this,o));const t=_(R,l);for(const r of _(this,d)){const e=_(r,i);t[e]||(t[e]=new Set),t[e].add(r)}},j(z,c,new Map),j(z,l,[]),j(z,h,[]);const D=(e,t)=>{if(null==e?void 0:e[P])return t(e.value),e.addReaction((()=>t(e.value)));t(e)};var B=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",SimpleReactive:class{constructor(a){W(this,e,!0),j(this,t,void 0),j(this,r,new Set),A(this,t,a)}get value(){return _(this,t)}set value(e){if(e!==_(this,t)){A(this,t,e);for(const e of _(this,r))e()}}addReaction(e){return _(this,r).add(e),()=>_(this,r).delete(e)}},FunctionalReactive:z,r:(e,t)=>new z(e,t),reactiveDo:D});const F=(e,t)=>r=>{Array.isArray(r)?r.length?e(r[0]):t():e(r)};var L=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",pipe:(e,...t)=>t.reduce(((e,t)=>t(e)),e),dispatch:(e,t,r)=>e.dispatchEvent(new CustomEvent(t,T({bubbles:!0,cancelable:!0,composed:!0},r))),createDestructable:(e,t)=>{const r=(a=T({},e),n={[Symbol.iterator]:()=>t[Symbol.iterator]()},M(a,g(n)));var a,n;return Object.defineProperty(r,Symbol.iterator,{enumerable:!1}),r},maybeDo:F,functionAsObject:e=>new Proxy({},{get:(t,r)=>e(r)})});const U=Symbol.for("bruh reactive"),q=Symbol.for("bruh meta node"),H=Symbol.for("bruh meta element"),I=e=>e[q]?e.node:e instanceof Node?e:document.createTextNode(e),J=e=>e.flat(1/0).flatMap((e=>{if(!e[U])return[I(e)];if(Array.isArray(e.value)){const t=new E;return e.addReaction((()=>{t.replaceChildren(...J(e.value))})),[t.startMarker,...J(e.value),t.endMarker]}let t=I(e.value);return e.addReaction((()=>{const r=t;t=I(e.value),r.replaceWith(t)})),[t]}));class X{constructor(e){W(this,f,!0),W(this,b,!0),W(this,"node"),e[U]?(this.node=document.createTextNode(e.value),e.addReaction((()=>{this.node.textContent=e.value}))):this.node=document.createTextNode(e)}addProperties(e={}){return Object.assign(this.node,e),this}}f=q,b=H;class G{constructor(e,t){W(this,m,!0),W(this,v,!0),W(this,"node"),this.node=t?document.createElementNS(t,e):document.createElement(e)}static from(e){const t=new this("div");return t.node=e,t}addProperties(e={}){return Object.assign(this.node,e),this}addAttributes(e={}){for(const t in e)D(e[t],F((e=>this.node.setAttribute(t,e)),(()=>this.node.removeAttribute(t))));return this}addDataAttributes(e={}){for(const t in e)D(e[t],F((e=>this.node.dataset[t]=e),(()=>delete this.node.dataset[t])));return this}addStyles(e={}){for(const t in e)D(e[t],F((e=>this.node.style.setProperty(t,e)),(()=>this.node.style.removeProperty(t))));return this}toggleClasses(e={}){for(const t in e)D(e[t],(e=>this.node.classList.toggle(t,e)));return this}before(...e){this.node.before(...J(e))}prepend(...e){this.node.prepend(...J(e))}append(...e){this.node.append(...J(e))}after(...e){this.node.after(...J(e))}replaceChildren(...e){this.node.replaceChildren(...J(e))}replaceWith(...e){this.node.replaceWith(...J(e))}}m=q,v=H;var K=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",childrenToNodes:J,MetaTextNode:X,MetaElement:G,hydrateTextNodes:()=>{const e={},t=document.getElementsByTagName("bruh-textnode");for(const r of t){const t=document.createTextNode(r.textContent);r.dataset.tag&&(e[r.dataset.tag]=t),r.replaceWith(t)}return e},t:e=>new X(e),e:(e,t)=>(...r)=>{const a=new G(e,t);if((null==(n=r[0])?void 0:n[q])||(null==n?void 0:n[U])||n instanceof Node||Array.isArray(n)||"function"!=typeof n)a.append(r);else{const[e,...t]=r;a.addAttributes(e),a.append(t)}var n;return a},h:(e,t,...r)=>{if("string"==typeof e){const a=new G(e);return a.addAttributes(t||{}),a.append(r),a}return e(Object.assign({},t,{children:r}))},JSXFragment:({children:e})=>e});export{K as dom,C as liveFragment,B as reactive,L as util}; | ||
//# sourceMappingURL=bruh.es.js.map |
@@ -1,2 +0,2 @@ | ||
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,r)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),r),__accessCheck=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},__privateSet=(e,t,r,a)=>(__accessCheck(e,t,"write to private field"),a?a.call(e,r):t.set(e,r),r),__privateMethod=(e,t,r)=>(__accessCheck(e,t,"access private method"),r);!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bruh={})}(this,(function(e){var t,r,a,o,i,n,s,d,_,p,c,l,h,u;class f{constructor(){this.startMarker=document.createTextNode(""),this.endMarker=document.createTextNode("")}static from(e,t){const r=new this;return e.before(r.startMarker),t.after(r.endMarker),r}before(...e){this.startMarker.before(...e)}prepend(...e){this.startMarker.after(...e)}append(...e){this.endMarker.before(...e)}after(...e){this.endMarker.after(...e)}remove(){const e=document.createRange();e.setStartBefore(this.startMarker),e.setEndAfter(this.endMarker),e.deleteContents()}replaceChildren(...e){const t=document.createRange();t.setStartAfter(this.startMarker),t.setEndBefore(this.endMarker),t.deleteContents(),this.startMarker.after(...e)}replaceWith(...e){this.endMarker.after(...e),this.remove()}get childNodes(){const e=[];for(let t=this.startMarker.nextSibling;t!=this.endMarker&&t;t=t.nextSibling)e.push(t);return e}get children(){return this.childNodes.filter((e=>e instanceof HTMLElement))}}var v=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",LiveFragment:f});const b=Symbol.for("bruh reactive");t=b,r=new WeakMap,a=new WeakMap;const m=class{constructor(e,t){__privateAdd(this,h),__publicField(this,o,!0),__privateAdd(this,i,void 0),__privateAdd(this,n,new Set),__privateAdd(this,s,void 0),__privateAdd(this,d,0),__privateAdd(this,_,new Set),t?(__privateSet(this,i,t()),__privateSet(this,s,t),__privateSet(this,d,Math.max(...e.map((e=>__privateGet(e,d))))+1),e.forEach((e=>__privateGet(e,_).add(this)))):__privateSet(this,i,e)}get value(){return __privateGet(m,p).size&&m.applyUpdates(),__privateGet(this,i)}set value(e){0===__privateGet(this,d)&&(__privateGet(m,p).size||queueMicrotask(m.applyUpdates),__privateGet(m,p).set(this,e))}addReaction(e){return __privateGet(this,n).add(e),()=>__privateGet(this,n).delete(e)}static applyUpdates(){var e,t,r;if(__privateGet(m,p).size){for(const[t,r]of __privateGet(m,p).entries())__privateMethod(e=t,h,u).call(e,r);__privateGet(m,p).clear();for(const e of __privateGet(m,c))if(e)for(const a of e)__privateMethod(r=a,h,u).call(r,__privateGet(t=a,s).call(t));__privateGet(m,c).length=0;for(const e of __privateGet(m,l))e();__privateGet(m,l).length=0}}};let y=m;o=b,i=new WeakMap,n=new WeakMap,s=new WeakMap,d=new WeakMap,_=new WeakMap,p=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakSet,u=function(e){if(e===__privateGet(this,i))return;__privateSet(this,i,e),__privateGet(m,l).push(...__privateGet(this,n));const t=__privateGet(m,c);for(const r of __privateGet(this,_)){const e=__privateGet(r,d);t[e]||(t[e]=new Set),t[e].add(r)}},__privateAdd(y,p,new Map),__privateAdd(y,c,[]),__privateAdd(y,l,[]);const g=(e,t)=>{if(null==e?void 0:e[b])return t(e.value),e.addReaction((()=>t(e.value)));t(e)};var M=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",SimpleReactive:class{constructor(e){__publicField(this,t,!0),__privateAdd(this,r,void 0),__privateAdd(this,a,new Set),__privateSet(this,r,e)}get value(){return __privateGet(this,r)}set value(e){if(e!==__privateGet(this,r)){__privateSet(this,r,e);for(const e of __privateGet(this,a))e()}}addReaction(e){return __privateGet(this,a).add(e),()=>__privateGet(this,a).delete(e)}},FunctionalReactive:y,r:(e,t)=>new y(e,t),reactiveDo:g});const S=(e,t)=>r=>{Array.isArray(r)?r.length?e(r[0]):t():e(r)};var w=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",pipe:(e,...t)=>t.reduce(((e,t)=>t(e)),e),dispatch:(e,t,r)=>e.dispatchEvent(new CustomEvent(t,__spreadValues({bubbles:!0,cancelable:!0,composed:!0},r))),createDestructable:(e,t)=>{const r=__spreadProps(__spreadValues({},e),{[Symbol.iterator]:()=>t[Symbol.iterator]()});return Object.defineProperty(r,Symbol.iterator,{enumerable:!1}),r},maybeDo:S,functionAsObject:e=>new Proxy({},{get:(t,r)=>e(r)})});const k=Symbol.for("bruh reactive"),G=Symbol.for("bruh meta node"),A=Symbol.for("bruh meta text node"),P=Symbol.for("bruh meta element"),O=e=>e[G]?e.node:e instanceof Node?e:document.createTextNode(e),T=e=>e.flat(1/0).flatMap((e=>{if(!e[k])return[O(e)];if(Array.isArray(e.value)){const t=new f;return e.addReaction((()=>{t.replaceChildren(...T(e.value))})),[t.startMarker,...T(e.value),t.endMarker]}let t=O(e.value);return e.addReaction((()=>{const r=t;t=O(e.value),r.replaceWith(t)})),[t]}));class x{constructor(e){this[G]=this[A]=!0,e[k]?(this.node=document.createTextNode(e.value),e.addReaction((()=>{this.node.textContent=e.value}))):this.node=document.createTextNode(e)}addProperties(e={}){return Object.assign(this.node,e),this}}class N{constructor(e,t){this[G]=this[P]=!0,this.node=t?document.createElementNS(t,e):document.createElement(e)}static from(e){const t=new this("div");return t.node=e,t}addProperties(e={}){return Object.assign(this.node,e),this}addAttributes(e={}){for(const t in e)g(e[t],S((e=>this.node.setAttribute(t,e)),(()=>this.node.removeAttribute(t))));return this}addDataAttributes(e={}){for(const t in e)g(e[t],S((e=>this.node.dataset[t]=e),(()=>delete this.node.dataset[t])));return this}before(...e){this.node.before(...T(e))}prepend(...e){this.node.prepend(...T(e))}append(...e){this.node.append(...T(e))}after(...e){this.node.after(...T(e))}replaceChildren(...e){this.node.replaceChildren(...T(e))}replaceWith(...e){this.node.replaceWith(...T(e))}}var j=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",childrenToNodes:T,MetaTextNode:x,MetaElement:N,hydrateTextNodes:()=>{const e={},t=document.getElementsByTagName("bruh-textnode");for(const r of t){const t=document.createTextNode(r.textContent);r.dataset.tag&&(e[r.dataset.tag]=t),r.replaceWith(t)}return e},t:e=>new x(e),e:(e,t)=>(...r)=>{const a=new N(e,t);if((null==(o=r[0])?void 0:o[G])||(null==o?void 0:o[k])||o instanceof Node||Array.isArray(o)||"function"!=typeof o)a.append(r);else{const[e,...t]=r;a.addAttributes(e),a.append(t)}var o;return a},h:(e,t,...r)=>{if("string"==typeof e){const a=new N(e);return a.addAttributes(t||{}),a.append(r),a}return e(Object.assign({},t,{children:r}))},JSXFragment:({children:e})=>e});e.dom=j,e.liveFragment=v,e.reactive=M,e.util=w,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"})); | ||
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,r)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),r),__accessCheck=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},__privateSet=(e,t,r,a)=>(__accessCheck(e,t,"write to private field"),a?a.call(e,r):t.set(e,r),r),__privateMethod=(e,t,r)=>(__accessCheck(e,t,"access private method"),r);!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bruh={})}(this,(function(e){var t,r,a,i,o,n,s,d,_,p,c,l,h,u,f,v,b,m;class y{constructor(){__publicField(this,"startMarker",document.createTextNode("")),__publicField(this,"endMarker",document.createTextNode(""))}static from(e,t){const r=new this;return e.before(r.startMarker),t.after(r.endMarker),r}before(...e){this.startMarker.before(...e)}prepend(...e){this.startMarker.after(...e)}append(...e){this.endMarker.before(...e)}after(...e){this.endMarker.after(...e)}remove(){const e=document.createRange();e.setStartBefore(this.startMarker),e.setEndAfter(this.endMarker),e.deleteContents()}replaceChildren(...e){const t=document.createRange();t.setStartAfter(this.startMarker),t.setEndBefore(this.endMarker),t.deleteContents(),this.startMarker.after(...e)}replaceWith(...e){this.endMarker.after(...e),this.remove()}get childNodes(){const e=[];for(let t=this.startMarker.nextSibling;t!=this.endMarker&&t;t=t.nextSibling)e.push(t);return e}get children(){return this.childNodes.filter((e=>e instanceof HTMLElement))}}var g=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",LiveFragment:y});const M=Symbol.for("bruh reactive");t=M,r=new WeakMap,a=new WeakMap;const S=class{constructor(e,t){__privateAdd(this,h),__publicField(this,i,!0),__privateAdd(this,o,void 0),__privateAdd(this,n,new Set),__privateAdd(this,s,void 0),__privateAdd(this,d,0),__privateAdd(this,_,new Set),t?(__privateSet(this,o,t()),__privateSet(this,s,t),__privateSet(this,d,Math.max(...e.map((e=>__privateGet(e,d))))+1),e.forEach((e=>__privateGet(e,_).add(this)))):__privateSet(this,o,e)}get value(){return __privateGet(S,p).size&&S.applyUpdates(),__privateGet(this,o)}set value(e){0===__privateGet(this,d)&&(__privateGet(S,p).size||queueMicrotask(S.applyUpdates),__privateGet(S,p).set(this,e))}addReaction(e){return __privateGet(this,n).add(e),()=>__privateGet(this,n).delete(e)}static applyUpdates(){var e,t,r;if(__privateGet(S,p).size){for(const[t,r]of __privateGet(S,p).entries())__privateMethod(e=t,h,u).call(e,r);__privateGet(S,p).clear();for(const e of __privateGet(S,c))if(e)for(const a of e)__privateMethod(r=a,h,u).call(r,__privateGet(t=a,s).call(t));__privateGet(S,c).length=0;for(const e of __privateGet(S,l))e();__privateGet(S,l).length=0}}};let w=S;i=M,o=new WeakMap,n=new WeakMap,s=new WeakMap,d=new WeakMap,_=new WeakMap,p=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakSet,u=function(e){if(e===__privateGet(this,o))return;__privateSet(this,o,e),__privateGet(S,l).push(...__privateGet(this,n));const t=__privateGet(S,c);for(const r of __privateGet(this,_)){const e=__privateGet(r,d);t[e]||(t[e]=new Set),t[e].add(r)}},__privateAdd(w,p,new Map),__privateAdd(w,c,[]),__privateAdd(w,l,[]);const k=(e,t)=>{if(null==e?void 0:e[M])return t(e.value),e.addReaction((()=>t(e.value)));t(e)};var G=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",SimpleReactive:class{constructor(e){__publicField(this,t,!0),__privateAdd(this,r,void 0),__privateAdd(this,a,new Set),__privateSet(this,r,e)}get value(){return __privateGet(this,r)}set value(e){if(e!==__privateGet(this,r)){__privateSet(this,r,e);for(const e of __privateGet(this,a))e()}}addReaction(e){return __privateGet(this,a).add(e),()=>__privateGet(this,a).delete(e)}},FunctionalReactive:w,r:(e,t)=>new w(e,t),reactiveDo:k});const P=(e,t)=>r=>{Array.isArray(r)?r.length?e(r[0]):t():e(r)};var A=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",pipe:(e,...t)=>t.reduce(((e,t)=>t(e)),e),dispatch:(e,t,r)=>e.dispatchEvent(new CustomEvent(t,__spreadValues({bubbles:!0,cancelable:!0,composed:!0},r))),createDestructable:(e,t)=>{const r=__spreadProps(__spreadValues({},e),{[Symbol.iterator]:()=>t[Symbol.iterator]()});return Object.defineProperty(r,Symbol.iterator,{enumerable:!1}),r},maybeDo:P,functionAsObject:e=>new Proxy({},{get:(t,r)=>e(r)})});const O=Symbol.for("bruh reactive"),T=Symbol.for("bruh meta node"),N=Symbol.for("bruh meta element"),x=e=>e[T]?e.node:e instanceof Node?e:document.createTextNode(e),j=e=>e.flat(1/0).flatMap((e=>{if(!e[O])return[x(e)];if(Array.isArray(e.value)){const t=new y;return e.addReaction((()=>{t.replaceChildren(...j(e.value))})),[t.startMarker,...j(e.value),t.endMarker]}let t=x(e.value);return e.addReaction((()=>{const r=t;t=x(e.value),r.replaceWith(t)})),[t]}));class W{constructor(e){__publicField(this,f,!0),__publicField(this,v,!0),__publicField(this,"node"),e[O]?(this.node=document.createTextNode(e.value),e.addReaction((()=>{this.node.textContent=e.value}))):this.node=document.createTextNode(e)}addProperties(e={}){return Object.assign(this.node,e),this}}f=T,v=N;class C{constructor(e,t){__publicField(this,b,!0),__publicField(this,m,!0),__publicField(this,"node"),this.node=t?document.createElementNS(t,e):document.createElement(e)}static from(e){const t=new this("div");return t.node=e,t}addProperties(e={}){return Object.assign(this.node,e),this}addAttributes(e={}){for(const t in e)k(e[t],P((e=>this.node.setAttribute(t,e)),(()=>this.node.removeAttribute(t))));return this}addDataAttributes(e={}){for(const t in e)k(e[t],P((e=>this.node.dataset[t]=e),(()=>delete this.node.dataset[t])));return this}addStyles(e={}){for(const t in e)k(e[t],P((e=>this.node.style.setProperty(t,e)),(()=>this.node.style.removeProperty(t))));return this}toggleClasses(e={}){for(const t in e)k(e[t],(e=>this.node.classList.toggle(t,e)));return this}before(...e){this.node.before(...j(e))}prepend(...e){this.node.prepend(...j(e))}append(...e){this.node.append(...j(e))}after(...e){this.node.after(...j(e))}replaceChildren(...e){this.node.replaceChildren(...j(e))}replaceWith(...e){this.node.replaceWith(...j(e))}}b=T,m=N;var E=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",childrenToNodes:j,MetaTextNode:W,MetaElement:C,hydrateTextNodes:()=>{const e={},t=document.getElementsByTagName("bruh-textnode");for(const r of t){const t=document.createTextNode(r.textContent);r.dataset.tag&&(e[r.dataset.tag]=t),r.replaceWith(t)}return e},t:e=>new W(e),e:(e,t)=>(...r)=>{const a=new C(e,t);if((null==(i=r[0])?void 0:i[T])||(null==i?void 0:i[O])||i instanceof Node||Array.isArray(i)||"function"!=typeof i)a.append(r);else{const[e,...t]=r;a.addAttributes(e),a.append(t)}var i;return a},h:(e,t,...r)=>{if("string"==typeof e){const a=new C(e);return a.addAttributes(t||{}),a.append(r),a}return e(Object.assign({},t,{children:r}))},JSXFragment:({children:e})=>e});e.dom=E,e.liveFragment=g,e.reactive=G,e.util=A,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"})); | ||
//# sourceMappingURL=bruh.umd.js.map |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.8.1", | ||
"version": "1.9.0", | ||
"license": "MIT", | ||
@@ -16,0 +16,0 @@ "author": { |
@@ -1,2 +0,2 @@ | ||
export declare const isReactive: unique symbol | ||
declare const isReactive: unique symbol | ||
@@ -25,3 +25,3 @@ export declare type Reactive<T> = { | ||
constructor(value: T) | ||
constructor(dependencies: Iterable<FunctionalReactive<unknown>>, f: () => T) | ||
constructor(dependencies: Array<FunctionalReactive<unknown>>, f: () => T) | ||
@@ -33,1 +33,6 @@ [isReactive]: true | ||
} | ||
export declare const r: { | ||
<T>(value: T): FunctionalReactive<T> | ||
<T>(dependencies: Array<FunctionalReactive<unknown>>, f: () => T): FunctionalReactive<T> | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
86052
826