Comparing version 1.8.0 to 1.8.1
@@ -1,2 +0,2 @@ | ||
var e,t,r,a,n,o,s,i,d,c,l,h,u,p=Object.defineProperty,f=Object.defineProperties,b=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,M=(e,t,r)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))v.call(t,r)&&M(e,r,t[r]);if(m)for(var r of m(t))y.call(t,r)&&M(e,r,t[r]);return e},w=(e,t,r)=>(M(e,"symbol"!=typeof t?t+"":t,r),r),k=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},S=(e,t,r)=>(k(e,t,"read from private field"),r?r.call(e):t.get(e)),O=(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)},x=(e,t,r,a)=>(k(e,t,"write to private field"),a?a.call(e,r):t.set(e,r),r),T=(e,t,r)=>(k(e,t,"access private method"),r);class W{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 _=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",LiveFragment:W});const j=Symbol.for("bruh reactive");e=j,t=new WeakMap,r=new WeakMap;const A=class{constructor(e,t){O(this,h),w(this,a,!0),O(this,n,void 0),O(this,o,new Set),O(this,s,void 0),O(this,i,0),O(this,d,new Set),t?(x(this,n,t()),x(this,s,t),x(this,i,Math.max(...e.map((e=>S(e,i))))+1),e.forEach((e=>S(e,d).add(this)))):x(this,n,e)}get value(){return S(A,c).size&&A.applyUpdates(),S(this,n)}set value(e){0===S(this,i)&&(S(A,c).size||queueMicrotask(A.applyUpdates),S(A,c).set(this,e))}addReaction(e){return S(this,o).add(e),()=>S(this,o).delete(e)}static applyUpdates(){var e,t,r;if(S(A,c).size){for(const[t,r]of S(A,c).entries())T(e=t,h,u).call(e,r);S(A,c).clear();for(const e of S(A,l))if(e)for(const a of e)T(r=a,h,u).call(r,S(t=a,s).call(t));S(A,l).length=0}}};let N=A;a=j,n=new WeakMap,o=new WeakMap,s=new WeakMap,i=new WeakMap,d=new WeakMap,c=new WeakMap,l=new WeakMap,h=new WeakSet,u=function(e){if(e===S(this,n))return;x(this,n,e);for(const r of S(this,o))r(e);const t=S(A,l);for(const r of S(this,d)){const e=S(r,i);t[e]||(t[e]=new Set),t[e].add(r)}},O(N,c,new Map),O(N,l,[]);const E=(e,t)=>{if(null==e?void 0:e[j])return t(e.value),e.addReaction((()=>t(e.value)));t(e)};var C=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",SimpleReactive:class{constructor(a){w(this,e,!0),O(this,t,void 0),O(this,r,new Set),x(this,t,a)}get value(){return S(this,t)}set value(e){if(e!==S(this,t)){x(this,t,e);for(const e of S(this,r))e()}}addReaction(e){return S(this,r).add(e),()=>S(this,r).delete(e)}},FunctionalReactive:N,r:(e,t)=>new N(e,t),reactiveDo:E});const R=(e,t)=>r=>{Array.isArray(r)?r.length?e(r[0]):t():e(r)};var P=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,g({bubbles:!0,cancelable:!0,composed:!0},r))),createDestructable:(e,t)=>{const r=(a=g({},e),n={[Symbol.iterator]:()=>t[Symbol.iterator]()},f(a,b(n)));var a,n;return Object.defineProperty(r,Symbol.iterator,{enumerable:!1}),r},maybeDo:R,functionAsObject:e=>new Proxy({},{get:(t,r)=>e(r)})});const z=Symbol.for("bruh reactive"),D=Symbol.for("bruh meta node"),B=Symbol.for("bruh meta text node"),F=Symbol.for("bruh meta element"),U=e=>e[D]?e.node:e instanceof Node?e:document.createTextNode(e),L=e=>e.flat(1/0).flatMap((e=>{if(!e[z])return[U(e)];if(Array.isArray(e.value)){const t=new W;return e.addReaction((()=>{t.replaceChildren(...L(e.value))})),[t.startMarker,...L(e.value),t.endMarker]}let t=U(e.value);return e.addReaction((()=>{const r=t;t=U(e.value),r.replaceWith(t)})),[t]}));class q{constructor(e){this[D]=this[B]=!0,e[z]?(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 H{constructor(e,t){this[D]=this[F]=!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)E(e[t],R((e=>this.node.setAttribute(t,e)),(()=>this.node.removeAttribute(t))));return this}addDataAttributes(e={}){for(const t in e)E(e[t],R((e=>this.node.dataset[t]=e),(()=>delete this.node.dataset[t])));return this}before(...e){this.node.before(...L(e))}prepend(...e){this.node.prepend(...L(e))}append(...e){this.node.append(...L(e))}after(...e){this.node.after(...L(e))}replaceChildren(...e){this.node.replaceChildren(...L(e))}replaceWith(...e){this.node.replaceWith(...L(e))}}var I=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",childrenToNodes:L,MetaTextNode:q,MetaElement:H,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 q(e),e:(e,t)=>(...r)=>{const a=new H(e,t);if((null==(n=r[0])?void 0:n[D])||(null==n?void 0:n[z])||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 H(e);return a.addAttributes(t||{}),a.append(r),a}return e(Object.assign({},t,{children:r}))},JSXFragment:({children:e})=>e});export{I as dom,_ as liveFragment,C as reactive,P as util}; | ||
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}; | ||
//# 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;class u{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 f=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",LiveFragment:u});const v=Symbol.for("bruh reactive");t=v,r=new WeakMap,a=new WeakMap;const b=class{constructor(e,t){__privateAdd(this,l),__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(b,p).size&&b.applyUpdates(),__privateGet(this,i)}set value(e){0===__privateGet(this,d)&&(__privateGet(b,p).size||queueMicrotask(b.applyUpdates),__privateGet(b,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(b,p).size){for(const[t,r]of __privateGet(b,p).entries())__privateMethod(e=t,l,h).call(e,r);__privateGet(b,p).clear();for(const e of __privateGet(b,c))if(e)for(const a of e)__privateMethod(r=a,l,h).call(r,__privateGet(t=a,s).call(t));__privateGet(b,c).length=0}}};let m=b;o=v,i=new WeakMap,n=new WeakMap,s=new WeakMap,d=new WeakMap,_=new WeakMap,p=new WeakMap,c=new WeakMap,l=new WeakSet,h=function(e){if(e===__privateGet(this,i))return;__privateSet(this,i,e);for(const r of __privateGet(this,n))r(e);const t=__privateGet(b,c);for(const r of __privateGet(this,_)){const e=__privateGet(r,d);t[e]||(t[e]=new Set),t[e].add(r)}},__privateAdd(m,p,new Map),__privateAdd(m,c,[]);const y=(e,t)=>{if(null==e?void 0:e[v])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:m,r:(e,t)=>new m(e,t),reactiveDo:y});const M=(e,t)=>r=>{Array.isArray(r)?r.length?e(r[0]):t():e(r)};var S=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:M,functionAsObject:e=>new Proxy({},{get:(t,r)=>e(r)})});const w=Symbol.for("bruh reactive"),k=Symbol.for("bruh meta node"),P=Symbol.for("bruh meta text node"),A=Symbol.for("bruh meta element"),G=e=>e[k]?e.node:e instanceof Node?e:document.createTextNode(e),O=e=>e.flat(1/0).flatMap((e=>{if(!e[w])return[G(e)];if(Array.isArray(e.value)){const t=new u;return e.addReaction((()=>{t.replaceChildren(...O(e.value))})),[t.startMarker,...O(e.value),t.endMarker]}let t=G(e.value);return e.addReaction((()=>{const r=t;t=G(e.value),r.replaceWith(t)})),[t]}));class T{constructor(e){this[k]=this[P]=!0,e[w]?(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 x{constructor(e,t){this[k]=this[A]=!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)y(e[t],M((e=>this.node.setAttribute(t,e)),(()=>this.node.removeAttribute(t))));return this}addDataAttributes(e={}){for(const t in e)y(e[t],M((e=>this.node.dataset[t]=e),(()=>delete this.node.dataset[t])));return this}before(...e){this.node.before(...O(e))}prepend(...e){this.node.prepend(...O(e))}append(...e){this.node.append(...O(e))}after(...e){this.node.after(...O(e))}replaceChildren(...e){this.node.replaceChildren(...O(e))}replaceWith(...e){this.node.replaceWith(...O(e))}}var N=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",childrenToNodes:O,MetaTextNode:T,MetaElement:x,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 T(e),e:(e,t)=>(...r)=>{const a=new x(e,t);if((null==(o=r[0])?void 0:o[k])||(null==o?void 0:o[w])||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 x(e);return a.addAttributes(t||{}),a.append(r),a}return e(Object.assign({},t,{children:r}))},JSXFragment:({children:e})=>e});e.dom=N,e.liveFragment=f,e.reactive=g,e.util=S,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,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"})); | ||
//# sourceMappingURL=bruh.umd.js.map |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"license": "MIT", | ||
@@ -16,0 +16,0 @@ "author": { |
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
82282
771