ladrillosjs 0.1.3 → 0.1.4

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./main-DEaqXlbt.js");exports.ladrillos=e.ladrillos;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./main-DZj0hnti.js");exports.ladrillos=e.ladrillos;
@@ -1,4 +1,4 @@
1
- import { a as o } from "./main-BLGdqIcm.mjs";
1
+ import { a as o } from "./main-Ds8zereY.mjs";
2
2
  export {
3
3
  o as ladrillos
4
4
  };
@@ -1,5 +1,5 @@
1
1
  (function(o,s){typeof exports=="object"&&typeof module!="undefined"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis!="undefined"?globalThis:o||self,s(o.ladrillosjs={}))})(this,function(o){"use strict";var M=Object.defineProperty;var R=o=>{throw TypeError(o)};var q=(o,s,i)=>s in o?M(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i;var x=(o,s,i)=>q(o,typeof s!="symbol"?s+"":s,i),H=(o,s,i)=>s.has(o)||R("Cannot "+i);var A=(o,s,i)=>(H(o,s,"read from private field"),i?i.call(o):s.get(o)),B=(o,s,i)=>s.has(o)?R("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(o):s.set(o,i);var v=(o,s,i)=>new Promise((b,C)=>{var $=l=>{try{f(i.next(l))}catch(c){C(c)}},E=l=>{try{f(i.throw(l))}catch(c){C(c)}},f=l=>l.done?b(l.value):Promise.resolve(l.value).then($,E);f((i=i.apply(o,s)).next())});var f;const s={log(l,...c){},error(l,...c){console.error(l,...c)},warn(l,...c){}};class i{constructor(){B(this,f,new Map);this.components={}}registerComponent(c,h,d=!0){return v(this,null,function*(){if(this.components[c]){s.log(`Component ${c} already registered, skipping.`);return}try{let u=A(this,f).get(h);u||(u=yield(yield fetch(h)).text(),A(this,f).set(h,u));const _=u.replace(/<!--[\s\S]*?-->/g,""),w=new DOMParser().parseFromString(_,"text/html");let y="";const S=Array.from(w.querySelectorAll("script:not([type='module'])"));for(const e of S){if(e.src){const n=e.getAttribute("src");let a;try{a=n}catch(r){console.error(`Invalid script URL "${n}" (base "${h}") - skipping:`,r),e.remove();continue}try{const r=yield fetch(a);if(!r.ok)throw new Error(`HTTP ${r.status}`);y+=`
2
2
  `+(yield r.text())}catch(r){console.error(`Could not load script at ${a} - skipping:`,r)}}else y+=`
3
- `+e.textContent;e.remove()}y=y.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trim();let m="";const T=Array.from(w.querySelectorAll("link[rel='stylesheet']"));for(const e of T){const n=e.getAttribute("href");let a;try{a=n+"?raw"}catch(r){console.error(`Invalid stylesheet URL "${n}" (base "${h}") - skipping:`,r),e.remove();continue}try{const r=yield fetch(a);if(!r.ok)throw new Error(`HTTP ${r.status}`);m+=`
3
+ `+e.textContent;e.remove()}y=y.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trim();let m="";const T=Array.from(w.querySelectorAll("link[rel='stylesheet']"));for(const e of T){const n=e.getAttribute("href");let a;try{a=n}catch(r){console.error(`Invalid stylesheet URL "${n}" (base "${h}") - skipping:`,r),e.remove();continue}try{const r=yield fetch(a);if(!r.ok)throw new Error(`HTTP ${r.status}`);m+=`
4
4
  `+(yield r.text())}catch(r){console.error(`Could not load stylesheet at ${a} - skipping:`,r)}e.remove()}const g=Array.from(w.querySelectorAll("style"));for(const e of g)m+=`
5
5
  `+e.textContent,e.remove();m=m.trim();const t=document.createElement("template");t.innerHTML=w.body.innerHTML,this.components[c]={tagName:c,template:t,script:y,style:m},this._defineWebComponent(c,d),s.log(`Component ${c} registered successfully`)}catch(u){s.error(`Failed to register component ${c}:`,u)}})}_defineWebComponent(c,h){return v(this,null,function*(){const{defineWebComponent:d}=yield Promise.resolve().then(()=>E);d(this.components[c],h)})}}f=new WeakMap,x(i,"_SCRIPT_ALL",/<script>([\s\S]*?)<\/script>/g),x(i,"_STYLE_ALL",/<style>([\s\S]*?)<\/style>/g),x(i,"_SCRIPT_ONE",/<script>([\s\S]*?)<\/script>/),x(i,"_STYLE_ONE",/<style>([\s\S]*?)<\/style>/);const b=new i;function C(l,c={}){return new Proxy(c,{set(h,d,u){const _=h[d];return h[d]=u,_!==u&&!l._initializing&&(typeof l._updateBinding=="function"?l._updateBinding(d,u):l._update()),!0},get(h,d){return h[d]}})}const E=Object.freeze(Object.defineProperty({__proto__:null,defineWebComponent:(l,c)=>{if(!l){s.error("Component is not defined or invalid.");return}if(customElements.get(l.tagName)){s.warn(`Component ${l.tagName} is already defined.`);return}const{tagName:h,template:d,script:u,style:_}=l,w=(g=>{const t=/{(.*?)}/g,e=new Set;let n;for(;(n=t.exec(g.innerHTML))!==null;)e.add(n[1].trim().toLowerCase());return Array.from(e)})(d),y=u.replace(/\b(?:const|let|var)\s+([\w$]+)\s*=/g,"state.$1 =").replace(/function\s+([\w$]+)\s*\(/g,"state.$1 = function ("),S=u?new Function("state",`with(state){${y}}`):()=>{},m=[];d.content.querySelectorAll("*").forEach(g=>{Array.from(g.attributes).forEach(t=>{if(!t.name.startsWith("on"))return;const e=t.name.slice(2),n=t.value.match(/{\s*([\w$]+)\(\)\s*}/);if(!n)return;const a=n[1];g.dataset._evtIndex=m.length,m.push({evt:e,fnName:a}),g.removeAttribute(t.name)})});class T extends HTMLElement{constructor(){super(),c&&this.attachShadow({mode:"open"}),this.state={},this.styleElement=document.createElement("style"),this.styleElement.textContent=_||"",this._textBindings={},this._origText=new Map}connectedCallback(){this._textBindings={},this._origText=new Map;const t=d.content.cloneNode(!0);this.shadowRoot?(this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(t)):(this.appendChild(this.styleElement),this.appendChild(t)),this.state=C(this,{}),this._initializing=!0;try{S.call(this,this.state)}catch(n){console.error("Error initializing component script:",n)}finally{this._initializing=!1}const e=this.shadowRoot||this;this._processTemplate(e)}_processTemplate(t){this._getAllTextNodes(t).forEach(n=>{const a=n.textContent;a.includes("{")&&a.includes("}")&&(this._origText.set(n,a),n.textContent=a.replace(/{([^}]+)}/g,(r,p)=>(p=p.trim(),this._textBindings[p]=this._textBindings[p]||[],this._textBindings[p].push(n),this.hasAttribute(p)?this.getAttribute(p):this.state[p]!==void 0?this.state[p]:r)))}),m.forEach((n,a)=>{const r=t.querySelector(`[data-_evt-index="${a}"]`);r.removeAttribute("data-_evt-index"),r.addEventListener(n.evt,p=>{const N=this.state[n.fnName];typeof N=="function"&&N.call(r,p)})})}_getAllTextNodes(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let a;for(;a=n.nextNode();)e.push(a);return e}_update(){const t=d.content.cloneNode(!0);this._processTemplate(t),this.shadowRoot?(this.shadowRoot.innerHTML="",this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(t)):(this.innerHTML="",this.appendChild(this.styleElement),this.appendChild(t))}_updateBinding(t){(this._textBindings[t]||[]).forEach(e=>{const n=this._origText.get(e)||"";e.textContent=n.replace(/{([^}]+)}/g,(a,r)=>(r=r.trim(),this.hasAttribute(r)?this.getAttribute(r):this.state[r]))})}disconnectedCallback(){s.log("disconnectedCallback",this)}static get observedAttributes(){return w}attributeChangedCallback(t,e,n){e!==n&&(this.state[t]=n)}emit(t,e){const n=e!=null?e:this.state;this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0}))}querySelector(t){return this.shadowRoot?this.shadowRoot.querySelector(t):super.querySelector(t)}querySelectorAll(t){return this.shadowRoot?this.shadowRoot.querySelectorAll(t):super.querySelectorAll(t)}}customElements.define(h,T),s.log(`Web component defined: <${h}></${h}>`)}},Symbol.toStringTag,{value:"Module"}));o.ladrillos=b,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
@@ -1,5 +1,5 @@
1
1
  "use strict";var k=Object.defineProperty;var $=t=>{throw TypeError(t)};var b=(t,e,r)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var y=(t,e,r)=>b(t,typeof e!="symbol"?e+"":e,r),v=(t,e,r)=>e.has(t)||$("Cannot "+r);var w=(t,e,r)=>(v(t,e,"read from private field"),r?r.call(t):e.get(t)),A=(t,e,r)=>e.has(t)?$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);var E=(t,e,r)=>new Promise((a,c)=>{var d=o=>{try{l(r.next(o))}catch(p){c(p)}},S=o=>{try{l(r.throw(o))}catch(p){c(p)}},l=o=>o.done?a(o.value):Promise.resolve(o.value).then(d,S);l((r=r.apply(t,e)).next())});const u={log(t,...e){},error(t,...e){console.error(t,...e)},warn(t,...e){}};var h;class f{constructor(){A(this,h,new Map);this.components={}}registerComponent(e,r,a=!0){return E(this,null,function*(){if(this.components[e]){u.log(`Component ${e} already registered, skipping.`);return}try{let c=w(this,h).get(r);c||(c=yield(yield fetch(r)).text(),w(this,h).set(r,c));const d=c.replace(/<!--[\s\S]*?-->/g,""),l=new DOMParser().parseFromString(d,"text/html");let o="";const p=Array.from(l.querySelectorAll("script:not([type='module'])"));for(const n of p){if(n.src){const m=n.getAttribute("src");let i;try{i=m}catch(s){console.error(`Invalid script URL "${m}" (base "${r}") - skipping:`,s),n.remove();continue}try{const s=yield fetch(i);if(!s.ok)throw new Error(`HTTP ${s.status}`);o+=`
2
2
  `+(yield s.text())}catch(s){console.error(`Could not load script at ${i} - skipping:`,s)}}else o+=`
3
- `+n.textContent;n.remove()}o=o.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trim();let g="";const T=Array.from(l.querySelectorAll("link[rel='stylesheet']"));for(const n of T){const m=n.getAttribute("href");let i;try{i=m+"?raw"}catch(s){console.error(`Invalid stylesheet URL "${m}" (base "${r}") - skipping:`,s),n.remove();continue}try{const s=yield fetch(i);if(!s.ok)throw new Error(`HTTP ${s.status}`);g+=`
3
+ `+n.textContent;n.remove()}o=o.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trim();let g="";const T=Array.from(l.querySelectorAll("link[rel='stylesheet']"));for(const n of T){const m=n.getAttribute("href");let i;try{i=m}catch(s){console.error(`Invalid stylesheet URL "${m}" (base "${r}") - skipping:`,s),n.remove();continue}try{const s=yield fetch(i);if(!s.ok)throw new Error(`HTTP ${s.status}`);g+=`
4
4
  `+(yield s.text())}catch(s){console.error(`Could not load stylesheet at ${i} - skipping:`,s)}n.remove()}const _=Array.from(l.querySelectorAll("style"));for(const n of _)g+=`
5
- `+n.textContent,n.remove();g=g.trim();const C=document.createElement("template");C.innerHTML=l.body.innerHTML,this.components[e]={tagName:e,template:C,script:o,style:g},this._defineWebComponent(e,a),u.log(`Component ${e} registered successfully`)}catch(c){u.error(`Failed to register component ${e}:`,c)}})}_defineWebComponent(e,r){return E(this,null,function*(){const{defineWebComponent:a}=yield Promise.resolve().then(()=>require("./webcomponent-BAieZxvs.js"));a(this.components[e],r)})}}h=new WeakMap,y(f,"_SCRIPT_ALL",/<script>([\s\S]*?)<\/script>/g),y(f,"_STYLE_ALL",/<style>([\s\S]*?)<\/style>/g),y(f,"_SCRIPT_ONE",/<script>([\s\S]*?)<\/script>/),y(f,"_STYLE_ONE",/<style>([\s\S]*?)<\/style>/);const L=new f;exports.ladrillos=L;exports.logger=u;
5
+ `+n.textContent,n.remove();g=g.trim();const C=document.createElement("template");C.innerHTML=l.body.innerHTML,this.components[e]={tagName:e,template:C,script:o,style:g},this._defineWebComponent(e,a),u.log(`Component ${e} registered successfully`)}catch(c){u.error(`Failed to register component ${e}:`,c)}})}_defineWebComponent(e,r){return E(this,null,function*(){const{defineWebComponent:a}=yield Promise.resolve().then(()=>require("./webcomponent-mLpAkIC-.js"));a(this.components[e],r)})}}h=new WeakMap,y(f,"_SCRIPT_ALL",/<script>([\s\S]*?)<\/script>/g),y(f,"_STYLE_ALL",/<style>([\s\S]*?)<\/style>/g),y(f,"_SCRIPT_ONE",/<script>([\s\S]*?)<\/script>/),y(f,"_STYLE_ONE",/<style>([\s\S]*?)<\/style>/);const L=new f;exports.ladrillos=L;exports.logger=u;
@@ -4,8 +4,8 @@ var $ = (e) => {
4
4
  };
5
5
  var b = (e, t, r) => t in e ? k(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
6
6
  var y = (e, t, r) => b(e, typeof t != "symbol" ? t + "" : t, r), v = (e, t, r) => t.has(e) || $("Cannot " + r);
7
- var w = (e, t, r) => (v(e, t, "read from private field"), r ? r.call(e) : t.get(e)), A = (e, t, r) => t.has(e) ? $("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r);
8
- var d = (e, t, r) => new Promise((a, c) => {
7
+ var d = (e, t, r) => (v(e, t, "read from private field"), r ? r.call(e) : t.get(e)), A = (e, t, r) => t.has(e) ? $("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r);
8
+ var w = (e, t, r) => new Promise((a, c) => {
9
9
  var u = (o) => {
10
10
  try {
11
11
  l(r.next(o));
@@ -58,14 +58,14 @@ class f {
58
58
  * @returns {Promise<void>}
59
59
  */
60
60
  registerComponent(t, r, a = !0) {
61
- return d(this, null, function* () {
61
+ return w(this, null, function* () {
62
62
  if (this.components[t]) {
63
63
  E.log(`Component ${t} already registered, skipping.`);
64
64
  return;
65
65
  }
66
66
  try {
67
- let c = w(this, h).get(r);
68
- c || (c = yield (yield fetch(r)).text(), w(this, h).set(r, c));
67
+ let c = d(this, h).get(r);
68
+ c || (c = yield (yield fetch(r)).text(), d(this, h).set(r, c));
69
69
  const u = c.replace(/<!--[\s\S]*?-->/g, ""), l = new DOMParser().parseFromString(u, "text/html");
70
70
  let o = "";
71
71
  const p = Array.from(
@@ -109,7 +109,7 @@ class f {
109
109
  const g = n.getAttribute("href");
110
110
  let i;
111
111
  try {
112
- i = g + "?raw";
112
+ i = g;
113
113
  } catch (s) {
114
114
  console.error(
115
115
  `Invalid stylesheet URL "${g}" (base "${r}") - skipping:`,
@@ -153,8 +153,8 @@ class f {
153
153
  * @param {boolean} useShadowDOM
154
154
  */
155
155
  _defineWebComponent(t, r) {
156
- return d(this, null, function* () {
157
- const { defineWebComponent: a } = yield import("./webcomponent-CjT9G5Wz.mjs");
156
+ return w(this, null, function* () {
157
+ const { defineWebComponent: a } = yield import("./webcomponent-MGgx7kqL.mjs");
158
158
  a(this.components[t], r);
159
159
  });
160
160
  }
@@ -1,4 +1,4 @@
1
- import { l as d } from "./main-BLGdqIcm.mjs";
1
+ import { l as d } from "./main-Ds8zereY.mjs";
2
2
  function C(a, u = {}) {
3
3
  return new Proxy(u, {
4
4
  set(l, r, h) {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./main-DEaqXlbt.js");function C(a,u={}){return new Proxy(u,{set(l,r,h){const g=l[r];return l[r]=h,g!==h&&!a._initializing&&(typeof a._updateBinding=="function"?a._updateBinding(r,h):a._update()),!0},get(l,r){return l[r]}})}const b=(a,u)=>{if(!a){d.logger.error("Component is not defined or invalid.");return}if(customElements.get(a.tagName)){d.logger.warn(`Component ${a.tagName} is already defined.`);return}const{tagName:l,template:r,script:h,style:g}=a,f=(c=>{const t=/{(.*?)}/g,i=new Set;let e;for(;(e=t.exec(c.innerHTML))!==null;)i.add(e[1].trim().toLowerCase());return Array.from(i)})(r),x=h.replace(/\b(?:const|let|var)\s+([\w$]+)\s*=/g,"state.$1 =").replace(/function\s+([\w$]+)\s*\(/g,"state.$1 = function ("),w=h?new Function("state",`with(state){${x}}`):()=>{},p=[];r.content.querySelectorAll("*").forEach(c=>{Array.from(c.attributes).forEach(t=>{if(!t.name.startsWith("on"))return;const i=t.name.slice(2),e=t.value.match(/{\s*([\w$]+)\(\)\s*}/);if(!e)return;const n=e[1];c.dataset._evtIndex=p.length,p.push({evt:i,fnName:n}),c.removeAttribute(t.name)})});class _ extends HTMLElement{constructor(){super(),u&&this.attachShadow({mode:"open"}),this.state={},this.styleElement=document.createElement("style"),this.styleElement.textContent=g||"",this._textBindings={},this._origText=new Map}connectedCallback(){this._textBindings={},this._origText=new Map;const t=r.content.cloneNode(!0);this.shadowRoot?(this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(t)):(this.appendChild(this.styleElement),this.appendChild(t)),this.state=C(this,{}),this._initializing=!0;try{w.call(this,this.state)}catch(e){console.error("Error initializing component script:",e)}finally{this._initializing=!1}const i=this.shadowRoot||this;this._processTemplate(i)}_processTemplate(t){this._getAllTextNodes(t).forEach(e=>{const n=e.textContent;n.includes("{")&&n.includes("}")&&(this._origText.set(e,n),e.textContent=n.replace(/{([^}]+)}/g,(s,o)=>(o=o.trim(),this._textBindings[o]=this._textBindings[o]||[],this._textBindings[o].push(e),this.hasAttribute(o)?this.getAttribute(o):this.state[o]!==void 0?this.state[o]:s)))}),p.forEach((e,n)=>{const s=t.querySelector(`[data-_evt-index="${n}"]`);s.removeAttribute("data-_evt-index"),s.addEventListener(e.evt,o=>{const m=this.state[e.fnName];typeof m=="function"&&m.call(s,o)})})}_getAllTextNodes(t){const i=[],e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let n;for(;n=e.nextNode();)i.push(n);return i}_update(){const t=r.content.cloneNode(!0);this._processTemplate(t),this.shadowRoot?(this.shadowRoot.innerHTML="",this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(t)):(this.innerHTML="",this.appendChild(this.styleElement),this.appendChild(t))}_updateBinding(t){(this._textBindings[t]||[]).forEach(i=>{const e=this._origText.get(i)||"";i.textContent=e.replace(/{([^}]+)}/g,(n,s)=>(s=s.trim(),this.hasAttribute(s)?this.getAttribute(s):this.state[s]))})}disconnectedCallback(){d.logger.log("disconnectedCallback",this)}static get observedAttributes(){return f}attributeChangedCallback(t,i,e){i!==e&&(this.state[t]=e)}emit(t,i){const e=i!=null?i:this.state;this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}querySelector(t){return this.shadowRoot?this.shadowRoot.querySelector(t):super.querySelector(t)}querySelectorAll(t){return this.shadowRoot?this.shadowRoot.querySelectorAll(t):super.querySelectorAll(t)}}customElements.define(l,_),d.logger.log(`Web component defined: <${l}></${l}>`)};exports.defineWebComponent=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./main-DZj0hnti.js");function C(a,u={}){return new Proxy(u,{set(l,r,h){const g=l[r];return l[r]=h,g!==h&&!a._initializing&&(typeof a._updateBinding=="function"?a._updateBinding(r,h):a._update()),!0},get(l,r){return l[r]}})}const b=(a,u)=>{if(!a){d.logger.error("Component is not defined or invalid.");return}if(customElements.get(a.tagName)){d.logger.warn(`Component ${a.tagName} is already defined.`);return}const{tagName:l,template:r,script:h,style:g}=a,f=(c=>{const t=/{(.*?)}/g,i=new Set;let e;for(;(e=t.exec(c.innerHTML))!==null;)i.add(e[1].trim().toLowerCase());return Array.from(i)})(r),x=h.replace(/\b(?:const|let|var)\s+([\w$]+)\s*=/g,"state.$1 =").replace(/function\s+([\w$]+)\s*\(/g,"state.$1 = function ("),w=h?new Function("state",`with(state){${x}}`):()=>{},p=[];r.content.querySelectorAll("*").forEach(c=>{Array.from(c.attributes).forEach(t=>{if(!t.name.startsWith("on"))return;const i=t.name.slice(2),e=t.value.match(/{\s*([\w$]+)\(\)\s*}/);if(!e)return;const n=e[1];c.dataset._evtIndex=p.length,p.push({evt:i,fnName:n}),c.removeAttribute(t.name)})});class _ extends HTMLElement{constructor(){super(),u&&this.attachShadow({mode:"open"}),this.state={},this.styleElement=document.createElement("style"),this.styleElement.textContent=g||"",this._textBindings={},this._origText=new Map}connectedCallback(){this._textBindings={},this._origText=new Map;const t=r.content.cloneNode(!0);this.shadowRoot?(this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(t)):(this.appendChild(this.styleElement),this.appendChild(t)),this.state=C(this,{}),this._initializing=!0;try{w.call(this,this.state)}catch(e){console.error("Error initializing component script:",e)}finally{this._initializing=!1}const i=this.shadowRoot||this;this._processTemplate(i)}_processTemplate(t){this._getAllTextNodes(t).forEach(e=>{const n=e.textContent;n.includes("{")&&n.includes("}")&&(this._origText.set(e,n),e.textContent=n.replace(/{([^}]+)}/g,(s,o)=>(o=o.trim(),this._textBindings[o]=this._textBindings[o]||[],this._textBindings[o].push(e),this.hasAttribute(o)?this.getAttribute(o):this.state[o]!==void 0?this.state[o]:s)))}),p.forEach((e,n)=>{const s=t.querySelector(`[data-_evt-index="${n}"]`);s.removeAttribute("data-_evt-index"),s.addEventListener(e.evt,o=>{const m=this.state[e.fnName];typeof m=="function"&&m.call(s,o)})})}_getAllTextNodes(t){const i=[],e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let n;for(;n=e.nextNode();)i.push(n);return i}_update(){const t=r.content.cloneNode(!0);this._processTemplate(t),this.shadowRoot?(this.shadowRoot.innerHTML="",this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(t)):(this.innerHTML="",this.appendChild(this.styleElement),this.appendChild(t))}_updateBinding(t){(this._textBindings[t]||[]).forEach(i=>{const e=this._origText.get(i)||"";i.textContent=e.replace(/{([^}]+)}/g,(n,s)=>(s=s.trim(),this.hasAttribute(s)?this.getAttribute(s):this.state[s]))})}disconnectedCallback(){d.logger.log("disconnectedCallback",this)}static get observedAttributes(){return f}attributeChangedCallback(t,i,e){i!==e&&(this.state[t]=e)}emit(t,i){const e=i!=null?i:this.state;this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}querySelector(t){return this.shadowRoot?this.shadowRoot.querySelector(t):super.querySelector(t)}querySelectorAll(t){return this.shadowRoot?this.shadowRoot.querySelectorAll(t):super.querySelectorAll(t)}}customElements.define(l,_),d.logger.log(`Web component defined: <${l}></${l}>`)};exports.defineWebComponent=b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ladrillosjs",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A lightweight, zero-dependency web component framework for building modular web applications.",
5
5
  "repository": {
6
6
  "type": "git",