ladrillosjs 2.0.0-beta.3 → 2.0.0-beta.3.2
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/README.md +152 -4
- package/dist/core/main.d.ts +2 -0
- package/dist/{index-DymB3-NG.mjs → index-JWdjGiUA.mjs} +216 -190
- package/dist/index-JWdjGiUA.mjs.map +1 -0
- package/dist/index-qEisp6n5.js +19 -0
- package/dist/index-qEisp6n5.js.map +1 -0
- package/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +1 -1
- package/dist/ladrillosjs.umd.js +17 -17
- package/dist/ladrillosjs.umd.js.map +1 -1
- package/dist/{webcomponent-BQLjYvOH.js → webcomponent-B-2Pj2ku.js} +2 -2
- package/dist/{webcomponent-BQLjYvOH.js.map → webcomponent-B-2Pj2ku.js.map} +1 -1
- package/dist/{webcomponent-DrCSyWrI.mjs → webcomponent-DT_kduma.mjs} +2 -2
- package/dist/{webcomponent-DrCSyWrI.mjs.map → webcomponent-DT_kduma.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-DZgn4gH2.js +0 -19
- package/dist/index-DZgn4gH2.js.map +0 -1
- package/dist/index-DymB3-NG.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var lt=Object.defineProperty,ut=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var K=e=>{throw TypeError(e)};var J=(e,n,t)=>n in e?lt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,F=(e,n)=>{for(var t in n||(n={}))ft.call(n,t)&&J(e,t,n[t]);if(G)for(var t of G(n))ht.call(n,t)&&J(e,t,n[t]);return e},Q=(e,n)=>ut(e,dt(n));var U=(e,n,t)=>n.has(e)||K("Cannot "+t);var x=(e,n,t)=>(U(e,n,"read from private field"),t?t.call(e):n.get(e)),_=(e,n,t)=>n.has(e)?K("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(e):n.set(e,t),M=(e,n,t,s)=>(U(e,n,"write to private field"),s?s.call(e,t):n.set(e,t),t),W=(e,n,t)=>(U(e,n,"access private method"),t);var I=(e,n,t)=>new Promise((s,o)=>{var i=d=>{try{c(t.next(d))}catch(a){o(a)}},r=d=>{try{c(t.throw(d))}catch(a){o(a)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(i,r);c((t=t.apply(e,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./index-
|
|
1
|
+
"use strict";var lt=Object.defineProperty,ut=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var K=e=>{throw TypeError(e)};var J=(e,n,t)=>n in e?lt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,F=(e,n)=>{for(var t in n||(n={}))ft.call(n,t)&&J(e,t,n[t]);if(G)for(var t of G(n))ht.call(n,t)&&J(e,t,n[t]);return e},Q=(e,n)=>ut(e,dt(n));var U=(e,n,t)=>n.has(e)||K("Cannot "+t);var x=(e,n,t)=>(U(e,n,"read from private field"),t?t.call(e):n.get(e)),_=(e,n,t)=>n.has(e)?K("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(e):n.set(e,t),M=(e,n,t,s)=>(U(e,n,"write to private field"),s?s.call(e,t):n.set(e,t),t),W=(e,n,t)=>(U(e,n,"access private method"),t);var I=(e,n,t)=>new Promise((s,o)=>{var i=d=>{try{c(t.next(d))}catch(a){o(a)}},r=d=>{try{c(t.throw(d))}catch(a){o(a)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(i,r);c((t=t.apply(e,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./index-qEisp6n5.js"),pt=(e,n,t)=>{if(!n)return;const s=document.createElement("style");s.textContent=n,t?e.appendChild(s):document.head.appendChild(s)},mt=(e,n)=>{e.innerHTML=n;const t=bt(e),s=gt(e),o=Et(e),i=$t(e);return{bindings:t,twoWayBindings:s,conditionals:o,loops:i}},Y=e=>{const n=[],t=e.match(/\((.*)\)/);if(!t)return n;const s=t[1].trim();return s&&s.split(",").map(i=>i.trim()).forEach(i=>{if(/^['"]/.test(i)||/^\d+/.test(i))return;const r=i.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);r&&n.push(r[1])}),n},bt=e=>{const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),t=[];let s;const o=r=>{let c=r.parentElement;for(;c;){if(c.hasAttribute&&c.hasAttribute("$for"))return!0;c=c.parentElement}return!1};for(;s=n.nextNode();){if(o(s))continue;const r=[...s.textContent.matchAll(A.REGEX_PATTERNS.bindings)];if(r.length>0){const c=s.textContent,d=r.map(a=>{const l=a[1].trim(),u=l.includes("(")&&l.includes(")"),f=/[+*/%<>=!&|]/.test(l)||/\s-\s/.test(l),p=/^(!|typeof\s|void\s|delete\s)/.test(l),E=f||p||/\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(l)||/\bnew\s+/.test(l)||/\b(typeof|instanceof|void|delete)\b/.test(l),m=u?[l.split("(")[0].trim()]:l.split(".").map(T=>T.trim()),b=u?Y(l):[];return{raw:l,path:m,isFunction:u,isExpression:E,functionArgs:b}});t.push({node:s,bindings:d,original:c})}}return e.querySelectorAll("*").forEach(r=>{if(!(r.hasAttribute("$for")||o(r)))for(const c of r.attributes){if(c.name==="$if"||c.name==="$else-if"||c.name==="$else"||c.name==="$bind")continue;const d=[...c.value.matchAll(A.REGEX_PATTERNS.bindings)];if(d.length>0){const a=c.value,l=d.map(u=>{const f=u[1].trim(),p=f.includes("(")&&f.includes(")"),E=/[+*/%<>=!&|]/.test(f)||/\s-\s/.test(f),m=/^(!|typeof\s|void\s|delete\s)/.test(f),b=E||m||/\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(f)||/\bnew\s+/.test(f)||/\b(typeof|instanceof|void|delete)\b/.test(f),T=p?[f.split("(")[0].trim()]:f.split(".").map(q=>q.trim()),B=p?Y(f):[];return{raw:f,path:T,isFunction:p,isExpression:b,functionArgs:B}});t.push({node:r,bindings:l,original:a,isAttribute:!0,attributeName:c.name})}}}),t},gt=e=>{const n=[];return e.querySelectorAll("[\\$bind]").forEach(s=>{var c;const o=s.getAttribute("$bind");if(!o)return;const i=o.trim(),r=i.split(".").map(d=>d.trim());s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?(n.push({element:s,path:r,raw:i,isContentEditable:!1,initialValue:s.value||""}),s.removeAttribute("$bind")):s instanceof HTMLElement&&s.hasAttribute("contenteditable")&&(n.push({element:s,path:r,raw:i,isContentEditable:!0,initialValue:((c=s.textContent)==null?void 0:c.trim())||""}),s.removeAttribute("$bind"))}),n},Et=e=>{const n=[],t=new Set;return e.querySelectorAll("[\\$if]").forEach(o=>{if(t.has(o))return;const i=[];let r=o;for(;r;){const c=r.hasAttribute("$if"),d=r.hasAttribute("$else-if"),a=r.hasAttribute("$else");if(!c&&!d&&!a)break;t.add(r);let l,u="";c?(l="if",u=r.getAttribute("$if")||"",r.removeAttribute("$if")):d?(l="else-if",u=r.getAttribute("$else-if")||"",r.removeAttribute("$else-if")):(l="else",r.removeAttribute("$else"));const f=document.createComment(`conditional:${l}:${u}`),p=r.parentElement||e,E=r.nextSibling;p.insertBefore(f,r);const m={element:r,condition:u.trim(),type:l,placeholder:f,group:[],originalParent:p,nextSibling:E};i.push(m);const b=r.nextElementSibling;if(r.remove(),r=b,b&&!b.hasAttribute("$else-if")&&!b.hasAttribute("$else"))break}i.forEach(c=>{c.group=i}),n.push(i)}),n},wt=e=>{const n=new Set;return e.forEach(t=>{t.forEach(s=>{let o=s.condition;o=o.replace(/\{([^}]+)\}/g,"$1");const i=/\b([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\b/g,r=new Set(["true","false","null","undefined","typeof","instanceof","new","return","if","else","for","while","do","switch","case","break","continue"]);let c;for(;(c=i.exec(o))!==null;){const a=c[1].split(".")[0];r.has(a)||n.add(a)}})}),n},$t=e=>{const n=[];return e.querySelectorAll("[\\$for]").forEach(s=>{var p;const o=s.getAttribute("$for");if(!o)return;const i=s.getAttribute("$key")||void 0,r=o.match(/^\s*(?:\(([^,]+),\s*([^)]+)\)|([^\s]+))\s+(?:in|of)\s+(.+)\s*$/);if(!r){A.logParseError(`Invalid $for expression: "${o}"`,{expression:o,lineHint:"$for attribute parsing"});return}const c=(r[1]||r[3]).trim(),d=(p=r[2])==null?void 0:p.trim(),a=r[4].trim(),l=document.createComment(`loop:${o}`),u=s.parentElement||e;u.insertBefore(l,s),s.removeAttribute("$for"),i&&s.removeAttribute("$key"),s.remove();const f={template:s,expression:o,itemName:c,indexName:d,arrayName:a,keyAttribute:i,placeholder:l,renderedElements:[],originalParent:u};n.push(f)}),n},yt=e=>{const n=new Set;return e.forEach(t=>{const s=t.arrayName.split(".")[0];n.add(s)}),n},O=new Map,vt=100,Z=e=>{const n=O.get(e);if(n)return O.delete(e),O.set(e,n),n;const t=new Function("component",`
|
|
2
2
|
const { Date, Array, Math, String, Number, Boolean, Object, JSON, RegExp } = globalThis;
|
|
3
3
|
with(component) {
|
|
4
4
|
return ${e};
|
|
@@ -76,4 +76,4 @@
|
|
|
76
76
|
${d}
|
|
77
77
|
}
|
|
78
78
|
`).call(this,a,n)}),r[`__processed_${c}`]=!0)})})},Tt=(i,r,c,...d)=>I(null,[i,r,c,...d],function*(e,n,t,s=[],o=new Set){const a=new Map;if(!(n!=null&&n.length))return a;const l=ot(e);for(const u of n)u.content&&rt(u.content,t,s,e,l,o).forEach((p,E)=>{a.has(E)||a.set(E,p)});return it(e,l),a}),kt=(e,n)=>new Promise((t,s)=>{const o=document.querySelector(`script[src="${e}"]`);if(o){if(o.dataset.loaded==="true"){t();return}o.addEventListener("load",()=>t(),{once:!0}),o.addEventListener("error",()=>s(new Error(`Failed to load external script: ${e}`)),{once:!0});return}const i=document.createElement("script");i.src=e,n&&(i.type=n),i.onload=()=>{i.dataset.loaded="true",t()},i.onerror=()=>s(new Error(`Failed to load external script: ${e}`)),document.head.appendChild(i)}),Lt=(r,c,d,...a)=>I(null,[r,c,d,...a],function*(e,n,t,s=[],o=new Set,i){var u;const l=ot(e);for(const f of n){let p;i?i.startsWith("http://")||i.startsWith("https://")?p=i:p=new URL(i,window.location.href).href:p=window.location.href;const E=new URL(f.src,p).href;if(f.external)yield kt(E,f.type);else if(f.type==="module"){const m=l.tagName.toLowerCase();window.__ladrilloContexts||(window.__ladrilloContexts=new Map),window.__ladrilloContexts.set(m,{host:e,shadowRoot:e instanceof ShadowRoot?e:null,element:l,state:l.state,setState:(u=l.setState)==null?void 0:u.bind(l)});const b=document.createElement("script");b.type="module",b.src=E,b.setAttribute("data-component",m),document.head.appendChild(b)}else yield fetch(E).then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);const b=m.headers.get("content-type");if(b&&!b.includes("javascript")&&!b.includes("text/plain"))throw new Error(`Expected JavaScript but got ${b}`);return m.text()}).then(m=>{rt(m,t,s,e,l,o)}).catch(m=>{console.error(`Failed to load external script: ${f.src}`,m)})}it(e,l)}),Rt=(e,n)=>{var a,l,u,f,p,E,m,b,X,B,ct,at;const{tagName:t,template:s,scripts:o,externalScripts:i,styles:r,sourcePath:c}=e,C=class C extends HTMLElement{constructor(){super();_(this,b);_(this,a,[]);_(this,l,[]);_(this,u,[]);_(this,f,[]);_(this,p,[]);_(this,E,c);_(this,m,new WeakMap);n&&this.attachShadow({mode:"open"});const h={},w=()=>{tt(x(this,a),this.state,this),et(x(this,u),this.state,this),nt(x(this,f),this.state,this),W(this,b,at).call(this)};this.state=new Proxy(h,{get:(y,g)=>y[g],set:(y,g,$)=>{const S=y[g];return g in y&&Object.is(S,$)||($!==null&&typeof $=="object"?y[g]=W(this,b,X).call(this,$,w):y[g]=$,Object.getOwnPropertyDescriptor(this,g)||Object.defineProperty(this,g,{get(){return this.state[g]},set(V){this.state[g]=V},enumerable:!0,configurable:!0}),w()),!0}})}setState(h){Object.assign(this.state,h)}connectedCallback(){return I(this,null,function*(){const h=n?this.shadowRoot:this,{bindings:w,twoWayBindings:y,conditionals:g,loops:$}=mt(h,s);M(this,a,w),M(this,l,y),M(this,u,g),M(this,f,$);const S=wt(g),k=yt($);pt(h,r,n),yield Lt(h,i,x(this,a),x(this,l),new Set([...S,...k]),x(this,E)),(yield Tt(h,o,x(this,a),x(this,l),new Set([...S,...k]))).forEach((v,N)=>{if(this.state[N]===void 0)try{const L=new Function(`return ${v}`);this.state[N]=L()}catch(L){this.state[N]=v}}),this._initializeStateFromAttributes(),this._setupTwoWayBindings(),tt(x(this,a),this.state,this),et(x(this,u),this.state,this),nt(x(this,f),this.state,this),this._setupAttributeObserver()})}disconnectedCallback(){this.__attributeObserver&&(this.__attributeObserver.disconnect(),this.__attributeObserver=null),x(this,p).forEach(w=>{try{w()}catch(y){A.logTwoWayBindingError("cleanup",y,A.createErrorContext(this,{lineHint:"disconnectedCallback cleanup"}))}}),M(this,p,[]);const h=this.__eventUnsubscribers;h&&Array.isArray(h)&&(h.forEach(w=>{try{w()}catch(y){A.logger.error("⚠️ Event Bus Error: Failed to unsubscribe from event",A.createErrorContext(this)),A.logger.error(` Error details: ${y.message}`)}}),this.__eventUnsubscribers=[])}_setupAttributeObserver(){const h=new MutationObserver(w=>{w.forEach(y=>{if(y.type==="attributes"&&y.attributeName){const g=this.getAttribute(y.attributeName);this._handleAttributeChange(y.attributeName,g)}})});h.observe(this,{attributes:!0,attributeOldValue:!0}),this.__attributeObserver=h}_initializeStateFromAttributes(){this.getAttributeNames().forEach(h=>{const w=this.getAttribute(h);this._handleAttributeChange(h,w)})}_handleAttributeChange(h,w){var g;if(h){const $="this.state.";h.startsWith($)&&(h=h.slice($.length))}const y=W(g=C,B,ct).call(g,w);this.state[h]=y}_setupTwoWayBindings(){x(this,l).forEach(({element:h,path:w,raw:y,isContentEditable:g,initialValue:$})=>{var k,V;if(this._getNestedValue(w)===void 0){const v=$||"";D(this.state,w,v)}if(g){const v=h;v.textContent=(k=this._getNestedValue(w))!=null?k:"";const N=z=>{const R=z.target.textContent||"";D(this.state,w,R)};v.addEventListener("input",N);const L=()=>{v.removeEventListener("input",N)};x(this,p).push(L)}else{const v=h,N=v instanceof HTMLInputElement&&v.type==="checkbox";v instanceof HTMLInputElement&&v.type,N?v.checked=!!this._getNestedValue(w):v.value=(V=this._getNestedValue(w))!=null?V:"";const L=H=>{const R=H.target;let j;R instanceof HTMLInputElement&&R.type==="checkbox"?j=R.checked:(R instanceof HTMLInputElement&&R.type,j=R.value),D(this.state,w,j)};v.addEventListener("input",L);const z=()=>{v.removeEventListener("input",L)};if(x(this,p).push(z),v instanceof HTMLSelectElement||v instanceof HTMLInputElement&&["checkbox","radio","file"].includes(v.type)){v.addEventListener("change",L);const H=()=>{v.removeEventListener("change",L)};x(this,p).push(H)}}})}_getNestedValue(h){return h.reduce((w,y)=>w==null?void 0:w[y],this.state)}};a=new WeakMap,l=new WeakMap,u=new WeakMap,f=new WeakMap,p=new WeakMap,E=new WeakMap,m=new WeakMap,b=new WeakSet,X=function(h,w){if(h===null||typeof h!="object"||h instanceof HTMLElement||h instanceof Node)return h;if(x(this,m).has(h))return x(this,m).get(h);const y=new Proxy(h,{get:(g,$)=>{const S=g[$];return Array.isArray(g)&&typeof S=="function"&&["push","pop","shift","unshift","splice","sort","reverse"].includes($)?(...V)=>{const v=S.apply(g,V);return w(),v}:S!==null&&typeof S=="object"?W(this,b,X).call(this,S,w):S},set:(g,$,S)=>{const k=g[$];return Object.is(k,S)||(g[$]=S,w()),!0}});return x(this,m).set(h,y),y},B=new WeakSet,ct=function(h){if(h===null||h==="")return null;if(h!=="undefined")try{return JSON.parse(h)}catch(w){return h}},at=function(){x(this,l).forEach(({element:h,path:w,isContentEditable:y})=>{const g=this._getNestedValue(w);if(y){const $=h;$.textContent!==g&&($.textContent=g!=null?g:"")}else{const $=h;if($ instanceof HTMLInputElement&&$.type==="checkbox"){const S=!!g;$.checked!==S&&($.checked=S)}else $.value!==g&&($.value=g!=null?g:"")}})},_(C,B);let d=C;customElements.get(t)||(customElements.define(t,d),A.logger.log(`Web component defined: <${t}></${t}>`))};exports.defineWebComponent=Rt;
|
|
79
|
-
//# sourceMappingURL=webcomponent-
|
|
79
|
+
//# sourceMappingURL=webcomponent-B-2Pj2ku.js.map
|