ladrillosjs 0.1.7 → 1.0.0-rc.1
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/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +1 -1
- package/dist/ladrillosjs.umd.js +3 -5
- package/dist/main-C0peSxBK.js +3 -0
- package/dist/main-CS7d-nps.mjs +126 -0
- package/dist/webcomponent-D2l14_jr.js +1 -0
- package/dist/webcomponent-Dw20JVmS.mjs +171 -0
- package/package.json +1 -1
- package/dist/main-BhrXwJZE.js +0 -5
- package/dist/main-Bw2tFs_l.mjs +0 -171
- package/dist/webcomponent-6erZkQUw.js +0 -1
- package/dist/webcomponent-BGHBTfQy.mjs +0 -171
package/dist/ladrillosjs.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./main-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./main-C0peSxBK.js");exports.ladrillos=e.ladrillos;
|
package/dist/ladrillosjs.es.js
CHANGED
package/dist/ladrillosjs.umd.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
(function(r
|
|
2
|
-
`+(yield
|
|
3
|
-
`+
|
|
4
|
-
`+(yield i.text())}catch(i){console.error(`Could not load stylesheet at ${o} - skipping:`,i)}s.remove()}const m=Array.from(w.querySelectorAll("style"));for(const s of m)g+=`
|
|
5
|
-
`+s.textContent,s.remove();g=g.trim();const e=document.createElement("template");e.innerHTML=w.body.innerHTML,this.components[a]={tagName:a,template:e,script:y,style:g},this._defineWebComponent(a,d),n.log(`Component ${a} registered successfully`)}catch(p){n.error(`Failed to register component ${a}:`,p)}})}_defineWebComponent(a,h){return $(this,null,function*(){const{defineWebComponent:d}=yield Promise.resolve().then(()=>C);d(this.components[a],h)})}}u=new WeakMap,b(_,"_SCRIPT_ALL",/<script>([\s\S]*?)<\/script>/g),b(_,"_STYLE_ALL",/<style>([\s\S]*?)<\/style>/g),b(_,"_SCRIPT_ONE",/<script>([\s\S]*?)<\/script>/),b(_,"_STYLE_ONE",/<style>([\s\S]*?)<\/style>/);const E=new _;function T(c,a={}){return new Proxy(a,{set(h,d,p){const x=h[d];return h[d]=p,x!==p&&!c._initializing&&(typeof c._updateBinding=="function"?c._updateBinding(d,p):c._update()),!0},get(h,d){return h[d]}})}const C=Object.freeze(Object.defineProperty({__proto__:null,defineWebComponent:(c,a)=>{if(!c){n.error("Component is not defined or invalid.");return}if(customElements.get(c.tagName)){n.warn(`Component ${c.tagName} is already defined.`);return}const{tagName:h,template:d,script:p,style:x}=c,w=(m=>{const e=/{(.*?)}/g,s=new Set;let t;for(;(t=e.exec(m.innerHTML))!==null;)s.add(t[1].trim().toLowerCase());return Array.from(s)})(d),y=p.replace(/\b(?:const|let|var)\s+([\w$]+)\s*=/g,"state.$1 =").replace(/function\s+([\w$]+)\s*\(/g,"state.$1 = function ("),S=p?new Function("state",`with(state){${y}}`):()=>{},g=[];d.content.querySelectorAll("*").forEach(m=>{Array.from(m.attributes).forEach(e=>{if(!e.name.startsWith("on"))return;const s=e.name.slice(2),t=e.value.match(/{\s*([\w$]+)\(\)\s*}/);if(!t)return;const o=t[1];m.dataset._evtIndex=g.length,g.push({evt:s,fnName:o}),m.removeAttribute(e.name)})});class v extends HTMLElement{constructor(){super(),a&&this.attachShadow({mode:"open"}),this.state={},this.styleElement=document.createElement("style"),this.styleElement.textContent=x||"",this._textBindings={},this._origText=new Map,this._hasConnected=!1,this._isUpdating=!1,this._isBinding=!1}connectedCallback(){if(this._hasConnected)return;this._hasConnected=!0,this._textBindings={},this._origText=new Map;const e=d.content.cloneNode(!0);this.shadowRoot?this.shadowRoot.innerHTML="":this.innerHTML="",this.shadowRoot?(this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(e)):(this.appendChild(this.styleElement),this.appendChild(e)),this.state=T(this,{}),this._initializing=!0;try{S.call(this,this.state)}catch(t){console.error("Error initializing component script:",t)}finally{this._initializing=!1}const s=this.shadowRoot||this;this._processTemplate(s)}_processTemplate(e){this._getAllTextNodes(e).forEach(t=>{const o=t.textContent;o.includes("{")&&o.includes("}")&&(this._origText.set(t,o),t.textContent=o.replace(/{([^}]+)}/g,(i,f)=>(f=f.trim(),this._textBindings[f]=this._textBindings[f]||[],this._textBindings[f].push(t),this.hasAttribute(f)?this.getAttribute(f):this.state[f]!==void 0?this.state[f]:i)))}),g.forEach((t,o)=>{const i=e.querySelector(`[data-_evt-index="${o}"]`);i.removeAttribute("data-_evt-index"),i.addEventListener(t.evt,f=>{const N=this.state[t.fnName];typeof N=="function"&&N.call(i,f)})})}_getAllTextNodes(e){const s=[],t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1);let o;for(;o=t.nextNode();)s.push(o);return s}_update(){if(!this._isUpdating){this._isUpdating=!0;try{const e=d.content.cloneNode(!0);this._processTemplate(e),this.shadowRoot?(this.shadowRoot.innerHTML="",this.shadowRoot.appendChild(this.styleElement),this.shadowRoot.appendChild(e)):(this.innerHTML="",this.appendChild(this.styleElement),this.appendChild(e))}finally{this._isUpdating=!1}}}_updateBinding(e){if(!this._isBinding){this._isBinding=!0;try{(this._textBindings[e]||[]).forEach(s=>{const t=this._origText.get(s)||"";s.textContent=t.replace(/{([^}]+)}/g,(o,i)=>(i=i.trim(),this.hasAttribute(i)?this.getAttribute(i):this.state[i]))})}finally{this._isBinding=!1}}}disconnectedCallback(){this._hasConnected=!1,n.log("disconnectedCallback",this)}static get observedAttributes(){return w}attributeChangedCallback(e,s,t){s!==t&&(this.state[e]=t)}emit(e,s){const t=s!=null?s:this.state;this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0}))}querySelector(e){return this.shadowRoot?this.shadowRoot.querySelector(e):super.querySelector(e)}querySelectorAll(e){return this.shadowRoot?this.shadowRoot.querySelectorAll(e):super.querySelectorAll(e)}}customElements.define(h,v),n.log(`Web component defined: <${h}></${h}>`)}},Symbol.toStringTag,{value:"Module"}));r.ladrillos=E,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(i,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(i=typeof globalThis!="undefined"?globalThis:i||self,r(i.ladrillosjs={}))})(this,function(i){"use strict";var F=i=>{throw TypeError(i)};var W=(i,r,a)=>r.has(i)||F("Cannot "+a);var S=(i,r,a)=>(W(i,r,"read from private field"),a?a.call(i):r.get(i)),A=(i,r,a)=>r.has(i)?F("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,a);var B=(i,r,a)=>(W(i,r,"access private method"),a);var g=(i,r,a)=>new Promise((T,$)=>{var q=d=>{try{p(a.next(d))}catch(k){$(k)}},f=d=>{try{p(a.throw(d))}catch(k){$(k)}},p=d=>d.done?T(d.value):Promise.resolve(d.value).then(q,f);p((a=a.apply(i,r)).next())});var f,p,d,N;const r={log(_,...o){},error(_,...o){console.error(_,...o)},warn(_,...o){}},v=class v{constructor(){A(this,f,new Map);A(this,p,new DOMParser);this.components={}}registerComponent(o,h,y=!0){return g(this,null,function*(){var C,x,E;if(this.components[o]){r.log(`Component ${o} already registered.`);return}this.components[o]={__registering:!0};try{const w=yield g(this,null,function*(){const t=S(this,f).get(h);if(t)return t;const l=yield(yield fetch(h)).text();return S(this,f).set(h,l),l}),b=S(this,p).parseFromString(w.replace(/<!--[\s\S]*?-->/g,""),"text/html"),e=[],s=[];for(const t of b.querySelectorAll("script"))t.src?s.push({src:t.src,type:(C=t.type)!=null?C:null}):t.textContent&&e.push({content:t.textContent.trim(),type:(x=t.type)!=null?x:null}),t.remove();let n="";for(const t of b.querySelectorAll("link[rel='stylesheet']"))n+=`
|
|
2
|
+
`+(yield B(E=v,d,N).call(E,`${t.href}?raw`)),t.remove();for(const t of b.querySelectorAll("style"))t.textContent&&(n+=`
|
|
3
|
+
`+t.textContent.trim()),t.remove();n=n.trim(),this.components[o]={tagName:o,template:b.body.innerHTML.trim(),scripts:e,externalScripts:s,style:n},yield this._defineWebComponent(o,y),r.log(`Component ${o} registered successfully`)}catch(w){r.error(`Failed to register component ${o}:`,w),delete this.components[o]}})}_defineWebComponent(o,h){return g(this,null,function*(){const{defineWebComponent:y}=yield Promise.resolve().then(()=>q);y(this.components[o],h)})}};f=new WeakMap,p=new WeakMap,d=new WeakSet,N=function(o){return g(this,null,function*(){try{const h=yield fetch(o);if(!h.ok)throw new Error(`HTTP ${h.status}`);return yield h.text()}catch(h){return r.error(`Failed to fetch resource at ${o}:`,h),""}})},A(v,d);let a=v;const T=new a,q=Object.freeze(Object.defineProperty({__proto__:null,defineWebComponent:(_,o)=>{const{tagName:h,template:y,scripts:C,externalScripts:x,style:E}=_;class w extends HTMLElement{constructor(){super(),o&&this.attachShadow({mode:"open"}),this.state={},this._bindings=[],this._eventBindings=[],this.observer=new MutationObserver(e=>{e.forEach(s=>{if(s.type==="attributes"){const n=s.attributeName,t=this.getAttribute(n);this.handleAttributeChange(n,t)}})}),this.observer.observe(this,{attributes:!0,attributeOldValue:!0}),this._render()}connectedCallback(){this._loadTemplate(),this._loadStyles(),this._loadScript(),this._render()}handleAttributeChange(e,s){this._render()}disconnectedCallback(){this.observer.disconnect(),this._eventBindings.forEach(({element:e,event:s,listener:n})=>{e.removeEventListener(s,n)}),this._eventBindings=[]}_loadTemplate(){o?this.shadowRoot.innerHTML=y:this.innerHTML=y,this._scanBindings()}_scanBindings(){const e=document.createTreeWalker(this.shadowRoot,NodeFilter.SHOW_TEXT,null,!1);let s;for(;s=e.nextNode();){const n=[...s.textContent.matchAll(/{([^}]+)}/g)];if(n.length){const t=n.map(([,c])=>({node:s,template:s.textContent,key:c.trim()}));this._bindings.push(t)}}this._getEventBindings()}_getEventBindings(){var s;((s=this.shadowRoot)!=null?s:this).querySelectorAll("*").forEach(n=>{Array.from(n.attributes).forEach(t=>{if(!t.name.startsWith("on"))return;const c=t.name.slice(2),l=t.value;n.removeAttribute(t.name);const u=m=>{l.includes("(")?new Function(`return ${l}`).call(this):typeof this[l]=="function"?this[l](m):typeof this.state[l]=="function"&&this.state[l](m)};n.addEventListener(c,u),this._eventBindings.push({element:n,event:c,listener:u})})})}_render(){this.getAttributeNames().forEach(e=>{this.state[e]=this.getAttribute(e)}),this._bindings.forEach(e=>{var s;if(Array.isArray(e)){const{node:n,template:t}=e[0],c={};e.forEach(({key:l})=>{var u;c[l]=(u=this.state[l])!=null?u:""}),n.textContent=this._renderTemplate(t,c)}else{const{node:n,template:t,key:c}=e,l={[c]:(s=this.state[c])!=null?s:""};n.textContent=this._renderTemplate(t,l)}})}_renderTemplate(e,s){return e.replace(/\{\s*([\w.]+)\s*}/g,(n,t)=>{let c=s[t];if(typeof c=="function")try{c=c.call(this)}catch(l){c=""}return c!=null?c:""})}_loadStyles(){const e=document.createElement("style");e.textContent=E,o?this.shadowRoot.appendChild(e):this.appendChild(e)}_loadScript(){return g(this,null,function*(){for(const e of x)if(e.type==="component"){const n=yield(yield fetch(e.src)).text();new Function(n).call(this)}else yield new Promise((s,n)=>{const t=document.createElement("script");t.src=e.src,e.type&&(t.type=e.type),t.onload=()=>{s()},t.onerror=n,document.head.appendChild(t)});C.forEach(e=>{var s;if(e.type==="module"){const n=document.createElement("script");n.type="module",n.textContent=e.content,((s=this.shadowRoot)!=null?s:this).appendChild(n)}else{const n=/(?:const|let|var)\s+([a-zA-Z_$][0-9a-zA-Z_$]*)\s*=\s*([^;]+)/g;let t;for(;(t=n.exec(e.content))!==null;){const c=t[1],l=t[2].trim();let u;try{u=new Function(`return (${l});`).call(this)}catch(m){u=l}this._bindings.some(m=>Array.isArray(m)?m.some(({key:R})=>R===c):m.key===c)&&(this.state[c]=u)}new Function(e.content).call(this)}}),this._render()})}setState(e){Object.assign(this.state,e),this._render()}querySelector(e){return console.log("querySelector",e),o?this.shadowRoot.querySelector(e):this.querySelector(e)}querySelectorAll(e){return o?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e)}}customElements.define(h,w),r.log(`Web component defined: <${h}></${h}>`)}},Symbol.toStringTag,{value:"Module"}));i.ladrillos=T,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var b=r=>{throw TypeError(r)};var q=(r,e,t)=>e.has(r)||b("Cannot "+t);var y=(r,e,t)=>(q(r,e,"read from private field"),t?t.call(r):e.get(r)),m=(r,e,t)=>e.has(r)?b("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var v=(r,e,t)=>(q(r,e,"access private method"),t);var p=(r,e,t)=>new Promise((i,l)=>{var g=o=>{try{n(t.next(o))}catch(c){l(c)}},u=o=>{try{n(t.throw(o))}catch(c){l(c)}},n=o=>o.done?i(o.value):Promise.resolve(o.value).then(g,u);n((t=t.apply(r,e)).next())});const h={log(r,...e){},error(r,...e){console.error(r,...e)},warn(r,...e){}};var f,w,d,F;const C=class C{constructor(){m(this,f,new Map);m(this,w,new DOMParser);this.components={}}registerComponent(e,t,i=!0){return p(this,null,function*(){var l,g,u;if(this.components[e]){h.log(`Component ${e} already registered.`);return}this.components[e]={__registering:!0};try{const n=yield p(this,null,function*(){const s=y(this,f).get(t);if(s)return s;const $=yield(yield fetch(t)).text();return y(this,f).set(t,$),$}),o=y(this,w).parseFromString(n.replace(/<!--[\s\S]*?-->/g,""),"text/html"),c=[],S=[];for(const s of o.querySelectorAll("script"))s.src?S.push({src:s.src,type:(l=s.type)!=null?l:null}):s.textContent&&c.push({content:s.textContent.trim(),type:(g=s.type)!=null?g:null}),s.remove();let a="";for(const s of o.querySelectorAll("link[rel='stylesheet']"))a+=`
|
|
2
|
+
`+(yield v(u=C,d,F).call(u,`${s.href}?raw`)),s.remove();for(const s of o.querySelectorAll("style"))s.textContent&&(a+=`
|
|
3
|
+
`+s.textContent.trim()),s.remove();a=a.trim(),this.components[e]={tagName:e,template:o.body.innerHTML.trim(),scripts:c,externalScripts:S,style:a},yield this._defineWebComponent(e,i),h.log(`Component ${e} registered successfully`)}catch(n){h.error(`Failed to register component ${e}:`,n),delete this.components[e]}})}_defineWebComponent(e,t){return p(this,null,function*(){const{defineWebComponent:i}=yield Promise.resolve().then(()=>require("./webcomponent-D2l14_jr.js"));i(this.components[e],t)})}};f=new WeakMap,w=new WeakMap,d=new WeakSet,F=function(e){return p(this,null,function*(){try{const t=yield fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}`);return yield t.text()}catch(t){return h.error(`Failed to fetch resource at ${e}:`,t),""}})},m(C,d);let x=C;const k=new x;exports.ladrillos=k;exports.logger=h;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var b = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
|
+
};
|
|
4
|
+
var F = (r, t, e) => t.has(r) || b("Cannot " + e);
|
|
5
|
+
var g = (r, t, e) => (F(r, t, "read from private field"), e ? e.call(r) : t.get(r)), m = (r, t, e) => t.has(r) ? b("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e);
|
|
6
|
+
var k = (r, t, e) => (F(r, t, "access private method"), e);
|
|
7
|
+
var p = (r, t, e) => new Promise((i, a) => {
|
|
8
|
+
var f = (o) => {
|
|
9
|
+
try {
|
|
10
|
+
n(e.next(o));
|
|
11
|
+
} catch (c) {
|
|
12
|
+
a(c);
|
|
13
|
+
}
|
|
14
|
+
}, y = (o) => {
|
|
15
|
+
try {
|
|
16
|
+
n(e.throw(o));
|
|
17
|
+
} catch (c) {
|
|
18
|
+
a(c);
|
|
19
|
+
}
|
|
20
|
+
}, n = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(f, y);
|
|
21
|
+
n((e = e.apply(r, t)).next());
|
|
22
|
+
});
|
|
23
|
+
const u = {
|
|
24
|
+
/**
|
|
25
|
+
* Log a message only in development mode
|
|
26
|
+
* @param {string} message - The message to log
|
|
27
|
+
* @param {any[]} args - Additional arguments to log
|
|
28
|
+
*/
|
|
29
|
+
log(r, ...t) {
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Log an error (always logs in both dev and production)
|
|
33
|
+
* @param {string} message - The error message
|
|
34
|
+
* @param {any[]} args - Additional arguments to log
|
|
35
|
+
*/
|
|
36
|
+
error(r, ...t) {
|
|
37
|
+
console.error(r, ...t);
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Log a warning only in development mode
|
|
41
|
+
* @param {string} message - The warning message
|
|
42
|
+
* @param {any[]} args - Additional arguments to log
|
|
43
|
+
*/
|
|
44
|
+
warn(r, ...t) {
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var h, w, d, q;
|
|
48
|
+
const x = class x {
|
|
49
|
+
constructor() {
|
|
50
|
+
m(this, h, /* @__PURE__ */ new Map());
|
|
51
|
+
m(this, w, new DOMParser());
|
|
52
|
+
this.components = {};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Registers a web‐component by fetching its HTML, scripts, and styles.
|
|
56
|
+
* @param {string} name
|
|
57
|
+
* @param {string} path
|
|
58
|
+
* @param {boolean} [useShadowDOM=true]
|
|
59
|
+
*/
|
|
60
|
+
registerComponent(t, e, i = !0) {
|
|
61
|
+
return p(this, null, function* () {
|
|
62
|
+
var a, f, y;
|
|
63
|
+
if (this.components[t]) {
|
|
64
|
+
u.log(`Component ${t} already registered.`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.components[t] = { __registering: !0 };
|
|
68
|
+
try {
|
|
69
|
+
const n = yield p(this, null, function* () {
|
|
70
|
+
const s = g(this, h).get(e);
|
|
71
|
+
if (s) return s;
|
|
72
|
+
const $ = yield (yield fetch(e)).text();
|
|
73
|
+
return g(this, h).set(e, $), $;
|
|
74
|
+
}), o = g(this, w).parseFromString(
|
|
75
|
+
n.replace(/<!--[\s\S]*?-->/g, ""),
|
|
76
|
+
"text/html"
|
|
77
|
+
), c = [], S = [];
|
|
78
|
+
for (const s of o.querySelectorAll("script"))
|
|
79
|
+
s.src ? S.push({ src: s.src, type: (a = s.type) != null ? a : null }) : s.textContent && c.push({
|
|
80
|
+
content: s.textContent.trim(),
|
|
81
|
+
type: (f = s.type) != null ? f : null
|
|
82
|
+
}), s.remove();
|
|
83
|
+
let l = "";
|
|
84
|
+
for (const s of o.querySelectorAll("link[rel='stylesheet']"))
|
|
85
|
+
l += `
|
|
86
|
+
` + (yield k(y = x, d, q).call(y, `${s.href}?raw`)), s.remove();
|
|
87
|
+
for (const s of o.querySelectorAll("style"))
|
|
88
|
+
s.textContent && (l += `
|
|
89
|
+
` + s.textContent.trim()), s.remove();
|
|
90
|
+
l = l.trim(), this.components[t] = {
|
|
91
|
+
tagName: t,
|
|
92
|
+
template: o.body.innerHTML.trim(),
|
|
93
|
+
scripts: c,
|
|
94
|
+
externalScripts: S,
|
|
95
|
+
style: l
|
|
96
|
+
}, yield this._defineWebComponent(t, i), u.log(`Component ${t} registered successfully`);
|
|
97
|
+
} catch (n) {
|
|
98
|
+
u.error(`Failed to register component ${t}:`, n), delete this.components[t];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/** @private */
|
|
103
|
+
_defineWebComponent(t, e) {
|
|
104
|
+
return p(this, null, function* () {
|
|
105
|
+
const { defineWebComponent: i } = yield import("./webcomponent-Dw20JVmS.mjs");
|
|
106
|
+
i(this.components[t], e);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
h = new WeakMap(), w = new WeakMap(), d = new WeakSet(), q = function(t) {
|
|
111
|
+
return p(this, null, function* () {
|
|
112
|
+
try {
|
|
113
|
+
const e = yield fetch(t);
|
|
114
|
+
if (!e.ok) throw new Error(`HTTP ${e.status}`);
|
|
115
|
+
return yield e.text();
|
|
116
|
+
} catch (e) {
|
|
117
|
+
return u.error(`Failed to fetch resource at ${t}:`, e), "";
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}, m(x, d);
|
|
121
|
+
let C = x;
|
|
122
|
+
const M = new C();
|
|
123
|
+
export {
|
|
124
|
+
M as a,
|
|
125
|
+
u as l
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _=(p,c,a)=>new Promise((u,m)=>{var f=l=>{try{d(a.next(l))}catch(e){m(e)}},y=l=>{try{d(a.throw(l))}catch(e){m(e)}},d=l=>l.done?u(l.value):Promise.resolve(l.value).then(f,y);d((a=a.apply(p,c)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./main-C0peSxBK.js"),b=(p,c)=>{const{tagName:a,template:u,scripts:m,externalScripts:f,style:y}=p;class d extends HTMLElement{constructor(){super(),c&&this.attachShadow({mode:"open"}),this.state={},this._bindings=[],this._eventBindings=[],this.observer=new MutationObserver(e=>{e.forEach(n=>{if(n.type==="attributes"){const t=n.attributeName,s=this.getAttribute(t);this.handleAttributeChange(t,s)}})}),this.observer.observe(this,{attributes:!0,attributeOldValue:!0}),this._render()}connectedCallback(){this._loadTemplate(),this._loadStyles(),this._loadScript(),this._render()}handleAttributeChange(e,n){this._render()}disconnectedCallback(){this.observer.disconnect(),this._eventBindings.forEach(({element:e,event:n,listener:t})=>{e.removeEventListener(n,t)}),this._eventBindings=[]}_loadTemplate(){c?this.shadowRoot.innerHTML=u:this.innerHTML=u,this._scanBindings()}_scanBindings(){const e=document.createTreeWalker(this.shadowRoot,NodeFilter.SHOW_TEXT,null,!1);let n;for(;n=e.nextNode();){const t=[...n.textContent.matchAll(/{([^}]+)}/g)];if(t.length){const s=t.map(([,i])=>({node:n,template:n.textContent,key:i.trim()}));this._bindings.push(s)}}this._getEventBindings()}_getEventBindings(){var n;((n=this.shadowRoot)!=null?n:this).querySelectorAll("*").forEach(t=>{Array.from(t.attributes).forEach(s=>{if(!s.name.startsWith("on"))return;const i=s.name.slice(2),r=s.value;t.removeAttribute(s.name);const o=h=>{r.includes("(")?new Function(`return ${r}`).call(this):typeof this[r]=="function"?this[r](h):typeof this.state[r]=="function"&&this.state[r](h)};t.addEventListener(i,o),this._eventBindings.push({element:t,event:i,listener:o})})})}_render(){this.getAttributeNames().forEach(e=>{this.state[e]=this.getAttribute(e)}),this._bindings.forEach(e=>{var n;if(Array.isArray(e)){const{node:t,template:s}=e[0],i={};e.forEach(({key:r})=>{var o;i[r]=(o=this.state[r])!=null?o:""}),t.textContent=this._renderTemplate(s,i)}else{const{node:t,template:s,key:i}=e,r={[i]:(n=this.state[i])!=null?n:""};t.textContent=this._renderTemplate(s,r)}})}_renderTemplate(e,n){return e.replace(/\{\s*([\w.]+)\s*}/g,(t,s)=>{let i=n[s];if(typeof i=="function")try{i=i.call(this)}catch(r){i=""}return i!=null?i:""})}_loadStyles(){const e=document.createElement("style");e.textContent=y,c?this.shadowRoot.appendChild(e):this.appendChild(e)}_loadScript(){return _(this,null,function*(){for(const e of f)if(e.type==="component"){const t=yield(yield fetch(e.src)).text();new Function(t).call(this)}else yield new Promise((n,t)=>{const s=document.createElement("script");s.src=e.src,e.type&&(s.type=e.type),s.onload=()=>{n()},s.onerror=t,document.head.appendChild(s)});m.forEach(e=>{var n;if(e.type==="module"){const t=document.createElement("script");t.type="module",t.textContent=e.content,((n=this.shadowRoot)!=null?n:this).appendChild(t)}else{const t=/(?:const|let|var)\s+([a-zA-Z_$][0-9a-zA-Z_$]*)\s*=\s*([^;]+)/g;let s;for(;(s=t.exec(e.content))!==null;){const i=s[1],r=s[2].trim();let o;try{o=new Function(`return (${r});`).call(this)}catch(h){o=r}this._bindings.some(h=>Array.isArray(h)?h.some(({key:g})=>g===i):h.key===i)&&(this.state[i]=o)}new Function(e.content).call(this)}}),this._render()})}setState(e){Object.assign(this.state,e),this._render()}querySelector(e){return console.log("querySelector",e),c?this.shadowRoot.querySelector(e):this.querySelector(e)}querySelectorAll(e){return c?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e)}}customElements.define(a,d),v.logger.log(`Web component defined: <${a}></${a}>`)};exports.defineWebComponent=b;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var _ = (p, c, a) => new Promise((u, m) => {
|
|
2
|
+
var f = (l) => {
|
|
3
|
+
try {
|
|
4
|
+
d(a.next(l));
|
|
5
|
+
} catch (t) {
|
|
6
|
+
m(t);
|
|
7
|
+
}
|
|
8
|
+
}, y = (l) => {
|
|
9
|
+
try {
|
|
10
|
+
d(a.throw(l));
|
|
11
|
+
} catch (t) {
|
|
12
|
+
m(t);
|
|
13
|
+
}
|
|
14
|
+
}, d = (l) => l.done ? u(l.value) : Promise.resolve(l.value).then(f, y);
|
|
15
|
+
d((a = a.apply(p, c)).next());
|
|
16
|
+
});
|
|
17
|
+
import { l as v } from "./main-CS7d-nps.mjs";
|
|
18
|
+
const w = (p, c) => {
|
|
19
|
+
const { tagName: a, template: u, scripts: m, externalScripts: f, style: y } = p;
|
|
20
|
+
class d extends HTMLElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(), c && this.attachShadow({ mode: "open" }), this.state = {}, this._bindings = [], this._eventBindings = [], this.observer = new MutationObserver((t) => {
|
|
23
|
+
t.forEach((n) => {
|
|
24
|
+
if (n.type === "attributes") {
|
|
25
|
+
const e = n.attributeName, s = this.getAttribute(e);
|
|
26
|
+
this.handleAttributeChange(e, s);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}), this.observer.observe(this, {
|
|
30
|
+
attributes: !0,
|
|
31
|
+
// Watch for attribute changes
|
|
32
|
+
attributeOldValue: !0
|
|
33
|
+
// Track old values too
|
|
34
|
+
}), this._render();
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
this._loadTemplate(), this._loadStyles(), this._loadScript(), this._render();
|
|
38
|
+
}
|
|
39
|
+
handleAttributeChange(t, n) {
|
|
40
|
+
this._render();
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
this.observer.disconnect(), this._eventBindings.forEach(({ element: t, event: n, listener: e }) => {
|
|
44
|
+
t.removeEventListener(n, e);
|
|
45
|
+
}), this._eventBindings = [];
|
|
46
|
+
}
|
|
47
|
+
_loadTemplate() {
|
|
48
|
+
c ? this.shadowRoot.innerHTML = u : this.innerHTML = u, this._scanBindings();
|
|
49
|
+
}
|
|
50
|
+
_scanBindings() {
|
|
51
|
+
const t = document.createTreeWalker(
|
|
52
|
+
this.shadowRoot,
|
|
53
|
+
NodeFilter.SHOW_TEXT,
|
|
54
|
+
null,
|
|
55
|
+
!1
|
|
56
|
+
);
|
|
57
|
+
let n;
|
|
58
|
+
for (; n = t.nextNode(); ) {
|
|
59
|
+
const e = [...n.textContent.matchAll(/{([^}]+)}/g)];
|
|
60
|
+
if (e.length) {
|
|
61
|
+
const s = e.map(([, i]) => ({
|
|
62
|
+
node: n,
|
|
63
|
+
template: n.textContent,
|
|
64
|
+
key: i.trim()
|
|
65
|
+
}));
|
|
66
|
+
this._bindings.push(s);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this._getEventBindings();
|
|
70
|
+
}
|
|
71
|
+
_getEventBindings() {
|
|
72
|
+
var n;
|
|
73
|
+
((n = this.shadowRoot) != null ? n : this).querySelectorAll("*").forEach((e) => {
|
|
74
|
+
Array.from(e.attributes).forEach((s) => {
|
|
75
|
+
if (!s.name.startsWith("on")) return;
|
|
76
|
+
const i = s.name.slice(2), r = s.value;
|
|
77
|
+
e.removeAttribute(s.name);
|
|
78
|
+
const o = (h) => {
|
|
79
|
+
r.includes("(") ? new Function(`return ${r}`).call(this) : typeof this[r] == "function" ? this[r](h) : typeof this.state[r] == "function" && this.state[r](h);
|
|
80
|
+
};
|
|
81
|
+
e.addEventListener(i, o), this._eventBindings.push({ element: e, event: i, listener: o });
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
_render() {
|
|
86
|
+
this.getAttributeNames().forEach((t) => {
|
|
87
|
+
this.state[t] = this.getAttribute(t);
|
|
88
|
+
}), this._bindings.forEach((t) => {
|
|
89
|
+
var n;
|
|
90
|
+
if (Array.isArray(t)) {
|
|
91
|
+
const { node: e, template: s } = t[0], i = {};
|
|
92
|
+
t.forEach(({ key: r }) => {
|
|
93
|
+
var o;
|
|
94
|
+
i[r] = (o = this.state[r]) != null ? o : "";
|
|
95
|
+
}), e.textContent = this._renderTemplate(s, i);
|
|
96
|
+
} else {
|
|
97
|
+
const { node: e, template: s, key: i } = t, r = { [i]: (n = this.state[i]) != null ? n : "" };
|
|
98
|
+
e.textContent = this._renderTemplate(s, r);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
_renderTemplate(t, n) {
|
|
103
|
+
return t.replace(/\{\s*([\w.]+)\s*}/g, (e, s) => {
|
|
104
|
+
let i = n[s];
|
|
105
|
+
if (typeof i == "function")
|
|
106
|
+
try {
|
|
107
|
+
i = i.call(this);
|
|
108
|
+
} catch (r) {
|
|
109
|
+
i = "";
|
|
110
|
+
}
|
|
111
|
+
return i != null ? i : "";
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
_loadStyles() {
|
|
115
|
+
const t = document.createElement("style");
|
|
116
|
+
t.textContent = y, c ? this.shadowRoot.appendChild(t) : this.appendChild(t);
|
|
117
|
+
}
|
|
118
|
+
_loadScript() {
|
|
119
|
+
return _(this, null, function* () {
|
|
120
|
+
for (const t of f)
|
|
121
|
+
if (t.type === "component") {
|
|
122
|
+
const e = yield (yield fetch(t.src)).text();
|
|
123
|
+
new Function(e).call(this);
|
|
124
|
+
} else
|
|
125
|
+
yield new Promise((n, e) => {
|
|
126
|
+
const s = document.createElement("script");
|
|
127
|
+
s.src = t.src, t.type && (s.type = t.type), s.onload = () => {
|
|
128
|
+
n();
|
|
129
|
+
}, s.onerror = e, document.head.appendChild(s);
|
|
130
|
+
});
|
|
131
|
+
m.forEach((t) => {
|
|
132
|
+
var n;
|
|
133
|
+
if (t.type === "module") {
|
|
134
|
+
const e = document.createElement("script");
|
|
135
|
+
e.type = "module", e.textContent = t.content, ((n = this.shadowRoot) != null ? n : this).appendChild(e);
|
|
136
|
+
} else {
|
|
137
|
+
const e = /(?:const|let|var)\s+([a-zA-Z_$][0-9a-zA-Z_$]*)\s*=\s*([^;]+)/g;
|
|
138
|
+
let s;
|
|
139
|
+
for (; (s = e.exec(t.content)) !== null; ) {
|
|
140
|
+
const i = s[1], r = s[2].trim();
|
|
141
|
+
let o;
|
|
142
|
+
try {
|
|
143
|
+
o = new Function(`return (${r});`).call(this);
|
|
144
|
+
} catch (h) {
|
|
145
|
+
o = r;
|
|
146
|
+
}
|
|
147
|
+
this._bindings.some(
|
|
148
|
+
(h) => Array.isArray(h) ? h.some(({ key: g }) => g === i) : h.key === i
|
|
149
|
+
) && (this.state[i] = o);
|
|
150
|
+
}
|
|
151
|
+
new Function(t.content).call(this);
|
|
152
|
+
}
|
|
153
|
+
}), this._render();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// --- public APIs
|
|
157
|
+
setState(t) {
|
|
158
|
+
Object.assign(this.state, t), this._render();
|
|
159
|
+
}
|
|
160
|
+
querySelector(t) {
|
|
161
|
+
return console.log("querySelector", t), c ? this.shadowRoot.querySelector(t) : this.querySelector(t);
|
|
162
|
+
}
|
|
163
|
+
querySelectorAll(t) {
|
|
164
|
+
return c ? this.shadowRoot.querySelectorAll(t) : this.querySelectorAll(t);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
customElements.define(a, d), v.log(`Web component defined: <${a}></${a}>`);
|
|
168
|
+
};
|
|
169
|
+
export {
|
|
170
|
+
w as defineWebComponent
|
|
171
|
+
};
|
package/package.json
CHANGED
package/dist/main-BhrXwJZE.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var C=t=>{throw TypeError(t)};var A=(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)=>A(t,typeof e!="symbol"?e+"":e,r),b=(t,e,r)=>e.has(t)||C("Cannot "+r);var w=(t,e,r)=>(b(t,e,"read from private field"),r?r.call(t):e.get(t)),$=(t,e,r)=>e.has(t)?C("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);var _=(t,e,r)=>new Promise((p,c)=>{var d=o=>{try{a(r.next(o))}catch(g){c(g)}},S=o=>{try{a(r.throw(o))}catch(g){c(g)}},a=o=>o.done?p(o.value):Promise.resolve(o.value).then(d,S);a((r=r.apply(t,e)).next())});const f={log(t,...e){},error(t,...e){console.error(t,...e)},warn(t,...e){}},L=["___vscode_livepreview_injected_script"];var h;class u{constructor(){$(this,h,new Map);this.components={}}registerComponent(e,r,p=!0){return _(this,null,function*(){if(this.components[e]){f.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,""),a=new DOMParser().parseFromString(d,"text/html");let o="";const g=Array.from(a.querySelectorAll("script:not([type='module'])"));for(const n of g){const i=n.getAttribute("src");if(i&&L.some(l=>i.includes(l))){f.log(`Skipping ignored script "${i}"`),n.remove();continue}if(i){let l;try{l=i}catch(s){console.error(`Invalid script URL "${i}" (base "${r}") - skipping:`,s),n.remove();continue}try{const s=yield fetch(l);if(!s.ok)throw new Error(`HTTP ${s.status}`);o+=`
|
|
2
|
-
`+(yield s.text())}catch(s){console.error(`Could not load script at ${l} - skipping:`,s)}}else o+=`
|
|
3
|
-
`+n.textContent;n.remove()}o=o.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trim();let m="";const v=Array.from(a.querySelectorAll("link[rel='stylesheet']"));for(const n of v){const i=n.getAttribute("href");let l;try{l=i+"?raw"}catch(s){console.error(`Invalid stylesheet URL "${i}" (base "${r}") - skipping:`,s),n.remove();continue}try{const s=yield fetch(l);if(!s.ok)throw new Error(`HTTP ${s.status}`);m+=`
|
|
4
|
-
`+(yield s.text())}catch(s){console.error(`Could not load stylesheet at ${l} - skipping:`,s)}n.remove()}const T=Array.from(a.querySelectorAll("style"));for(const n of T)m+=`
|
|
5
|
-
`+n.textContent,n.remove();m=m.trim();const E=document.createElement("template");E.innerHTML=a.body.innerHTML,this.components[e]={tagName:e,template:E,script:o,style:m},this._defineWebComponent(e,p),f.log(`Component ${e} registered successfully`)}catch(c){f.error(`Failed to register component ${e}:`,c)}})}_defineWebComponent(e,r){return _(this,null,function*(){const{defineWebComponent:p}=yield Promise.resolve().then(()=>require("./webcomponent-6erZkQUw.js"));p(this.components[e],r)})}}h=new WeakMap,y(u,"_SCRIPT_ALL",/<script>([\s\S]*?)<\/script>/g),y(u,"_STYLE_ALL",/<style>([\s\S]*?)<\/style>/g),y(u,"_SCRIPT_ONE",/<script>([\s\S]*?)<\/script>/),y(u,"_STYLE_ONE",/<style>([\s\S]*?)<\/style>/);const x=new u;exports.ladrillos=x;exports.logger=f;
|
package/dist/main-Bw2tFs_l.mjs
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
var k = Object.defineProperty;
|
|
2
|
-
var C = (t) => {
|
|
3
|
-
throw TypeError(t);
|
|
4
|
-
};
|
|
5
|
-
var A = (t, e, r) => e in t ? k(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
6
|
-
var y = (t, e, r) => A(t, typeof e != "symbol" ? e + "" : e, r), b = (t, e, r) => e.has(t) || C("Cannot " + r);
|
|
7
|
-
var w = (t, e, r) => (b(t, e, "read from private field"), r ? r.call(t) : e.get(t)), $ = (t, e, r) => e.has(t) ? C("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r);
|
|
8
|
-
var _ = (t, e, r) => new Promise((p, c) => {
|
|
9
|
-
var d = (o) => {
|
|
10
|
-
try {
|
|
11
|
-
a(r.next(o));
|
|
12
|
-
} catch (g) {
|
|
13
|
-
c(g);
|
|
14
|
-
}
|
|
15
|
-
}, S = (o) => {
|
|
16
|
-
try {
|
|
17
|
-
a(r.throw(o));
|
|
18
|
-
} catch (g) {
|
|
19
|
-
c(g);
|
|
20
|
-
}
|
|
21
|
-
}, a = (o) => o.done ? p(o.value) : Promise.resolve(o.value).then(d, S);
|
|
22
|
-
a((r = r.apply(t, e)).next());
|
|
23
|
-
});
|
|
24
|
-
const h = {
|
|
25
|
-
/**
|
|
26
|
-
* Log a message only in development mode
|
|
27
|
-
* @param {string} message - The message to log
|
|
28
|
-
* @param {any[]} args - Additional arguments to log
|
|
29
|
-
*/
|
|
30
|
-
log(t, ...e) {
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Log an error (always logs in both dev and production)
|
|
34
|
-
* @param {string} message - The error message
|
|
35
|
-
* @param {any[]} args - Additional arguments to log
|
|
36
|
-
*/
|
|
37
|
-
error(t, ...e) {
|
|
38
|
-
console.error(t, ...e);
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Log a warning only in development mode
|
|
42
|
-
* @param {string} message - The warning message
|
|
43
|
-
* @param {any[]} args - Additional arguments to log
|
|
44
|
-
*/
|
|
45
|
-
warn(t, ...e) {
|
|
46
|
-
}
|
|
47
|
-
}, x = ["___vscode_livepreview_injected_script"];
|
|
48
|
-
var u;
|
|
49
|
-
class f {
|
|
50
|
-
constructor() {
|
|
51
|
-
$(this, u, /* @__PURE__ */ new Map());
|
|
52
|
-
this.components = {};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @param {string} name
|
|
56
|
-
* @param {string} path
|
|
57
|
-
* @param {boolean} [useShadowDOM=true]
|
|
58
|
-
* @returns {Promise<void>}
|
|
59
|
-
*/
|
|
60
|
-
registerComponent(e, r, p = !0) {
|
|
61
|
-
return _(this, null, function* () {
|
|
62
|
-
if (this.components[e]) {
|
|
63
|
-
h.log(`Component ${e} already registered, skipping.`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
let c = w(this, u).get(r);
|
|
68
|
-
c || (c = yield (yield fetch(r)).text(), w(this, u).set(r, c));
|
|
69
|
-
const d = c.replace(/<!--[\s\S]*?-->/g, ""), a = new DOMParser().parseFromString(d, "text/html");
|
|
70
|
-
let o = "";
|
|
71
|
-
const g = Array.from(
|
|
72
|
-
a.querySelectorAll("script:not([type='module'])")
|
|
73
|
-
);
|
|
74
|
-
for (const n of g) {
|
|
75
|
-
const i = n.getAttribute("src");
|
|
76
|
-
if (i && x.some((l) => i.includes(l))) {
|
|
77
|
-
h.log(`Skipping ignored script "${i}"`), n.remove();
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (i) {
|
|
81
|
-
let l;
|
|
82
|
-
try {
|
|
83
|
-
l = i;
|
|
84
|
-
} catch (s) {
|
|
85
|
-
console.error(
|
|
86
|
-
`Invalid script URL "${i}" (base "${r}") - skipping:`,
|
|
87
|
-
s
|
|
88
|
-
), n.remove();
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
const s = yield fetch(l);
|
|
93
|
-
if (!s.ok) throw new Error(`HTTP ${s.status}`);
|
|
94
|
-
o += `
|
|
95
|
-
` + (yield s.text());
|
|
96
|
-
} catch (s) {
|
|
97
|
-
console.error(
|
|
98
|
-
`Could not load script at ${l} - skipping:`,
|
|
99
|
-
s
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
} else
|
|
103
|
-
o += `
|
|
104
|
-
` + n.textContent;
|
|
105
|
-
n.remove();
|
|
106
|
-
}
|
|
107
|
-
o = o.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").trim();
|
|
108
|
-
let m = "";
|
|
109
|
-
const v = Array.from(
|
|
110
|
-
a.querySelectorAll("link[rel='stylesheet']")
|
|
111
|
-
);
|
|
112
|
-
for (const n of v) {
|
|
113
|
-
const i = n.getAttribute("href");
|
|
114
|
-
let l;
|
|
115
|
-
try {
|
|
116
|
-
l = i + "?raw";
|
|
117
|
-
} catch (s) {
|
|
118
|
-
console.error(
|
|
119
|
-
`Invalid stylesheet URL "${i}" (base "${r}") - skipping:`,
|
|
120
|
-
s
|
|
121
|
-
), n.remove();
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
const s = yield fetch(l);
|
|
126
|
-
if (!s.ok) throw new Error(`HTTP ${s.status}`);
|
|
127
|
-
m += `
|
|
128
|
-
` + (yield s.text());
|
|
129
|
-
} catch (s) {
|
|
130
|
-
console.error(
|
|
131
|
-
`Could not load stylesheet at ${l} - skipping:`,
|
|
132
|
-
s
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
n.remove();
|
|
136
|
-
}
|
|
137
|
-
const T = Array.from(a.querySelectorAll("style"));
|
|
138
|
-
for (const n of T)
|
|
139
|
-
m += `
|
|
140
|
-
` + n.textContent, n.remove();
|
|
141
|
-
m = m.trim();
|
|
142
|
-
const E = document.createElement("template");
|
|
143
|
-
E.innerHTML = a.body.innerHTML, this.components[e] = {
|
|
144
|
-
tagName: e,
|
|
145
|
-
template: E,
|
|
146
|
-
script: o,
|
|
147
|
-
style: m
|
|
148
|
-
}, this._defineWebComponent(e, p), h.log(`Component ${e} registered successfully`);
|
|
149
|
-
} catch (c) {
|
|
150
|
-
h.error(`Failed to register component ${e}:`, c);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* @private
|
|
156
|
-
* @param {string} name
|
|
157
|
-
* @param {boolean} useShadowDOM
|
|
158
|
-
*/
|
|
159
|
-
_defineWebComponent(e, r) {
|
|
160
|
-
return _(this, null, function* () {
|
|
161
|
-
const { defineWebComponent: p } = yield import("./webcomponent-BGHBTfQy.mjs");
|
|
162
|
-
p(this.components[e], r);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
u = 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>/);
|
|
167
|
-
const H = new f();
|
|
168
|
-
export {
|
|
169
|
-
H as a,
|
|
170
|
-
h as l
|
|
171
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./main-BhrXwJZE.js");function C(a,u={}){return new Proxy(u,{set(h,r,l){const g=h[r];return h[r]=l,g!==l&&!a._initializing&&(typeof a._updateBinding=="function"?a._updateBinding(r,l):a._update()),!0},get(h,r){return h[r]}})}const b=(a,u)=>{if(!a){c.logger.error("Component is not defined or invalid.");return}if(customElements.get(a.tagName)){c.logger.warn(`Component ${a.tagName} is already defined.`);return}const{tagName:h,template:r,script:l,style:g}=a,m=(d=>{const t=/{(.*?)}/g,i=new Set;let e;for(;(e=t.exec(d.innerHTML))!==null;)i.add(e[1].trim().toLowerCase());return Array.from(i)})(r),_=l.replace(/\b(?:const|let|var)\s+([\w$]+)\s*=/g,"state.$1 =").replace(/function\s+([\w$]+)\s*\(/g,"state.$1 = function ("),x=l?new Function("state",`with(state){${_}}`):()=>{},f=[];r.content.querySelectorAll("*").forEach(d=>{Array.from(d.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 s=e[1];d.dataset._evtIndex=f.length,f.push({evt:i,fnName:s}),d.removeAttribute(t.name)})});class w 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,this._hasConnected=!1,this._isUpdating=!1,this._isBinding=!1}connectedCallback(){if(this._hasConnected)return;this._hasConnected=!0,this._textBindings={},this._origText=new Map;const t=r.content.cloneNode(!0);this.shadowRoot?this.shadowRoot.innerHTML="":this.innerHTML="",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{x.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 s=e.textContent;s.includes("{")&&s.includes("}")&&(this._origText.set(e,s),e.textContent=s.replace(/{([^}]+)}/g,(n,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]:n)))}),f.forEach((e,s)=>{const n=t.querySelector(`[data-_evt-index="${s}"]`);n.removeAttribute("data-_evt-index"),n.addEventListener(e.evt,o=>{const p=this.state[e.fnName];typeof p=="function"&&p.call(n,o)})})}_getAllTextNodes(t){const i=[],e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let s;for(;s=e.nextNode();)i.push(s);return i}_update(){if(!this._isUpdating){this._isUpdating=!0;try{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))}finally{this._isUpdating=!1}}}_updateBinding(t){if(!this._isBinding){this._isBinding=!0;try{(this._textBindings[t]||[]).forEach(i=>{const e=this._origText.get(i)||"";i.textContent=e.replace(/{([^}]+)}/g,(s,n)=>(n=n.trim(),this.hasAttribute(n)?this.getAttribute(n):this.state[n]))})}finally{this._isBinding=!1}}}disconnectedCallback(){this._hasConnected=!1,c.logger.log("disconnectedCallback",this)}static get observedAttributes(){return m}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(h,w),c.logger.log(`Web component defined: <${h}></${h}>`)};exports.defineWebComponent=b;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { l as c } from "./main-Bw2tFs_l.mjs";
|
|
2
|
-
function C(a, u = {}) {
|
|
3
|
-
return new Proxy(u, {
|
|
4
|
-
set(h, r, l) {
|
|
5
|
-
const f = h[r];
|
|
6
|
-
return h[r] = l, f !== l && !a._initializing && (typeof a._updateBinding == "function" ? a._updateBinding(r, l) : a._update()), !0;
|
|
7
|
-
},
|
|
8
|
-
get(h, r) {
|
|
9
|
-
return h[r];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
const y = (a, u) => {
|
|
14
|
-
if (!a) {
|
|
15
|
-
c.error("Component is not defined or invalid.");
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (customElements.get(a.tagName)) {
|
|
19
|
-
c.warn(`Component ${a.tagName} is already defined.`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const { tagName: h, template: r, script: l, style: f } = a, m = ((d) => {
|
|
23
|
-
const t = /{(.*?)}/g, i = /* @__PURE__ */ new Set();
|
|
24
|
-
let e;
|
|
25
|
-
for (; (e = t.exec(d.innerHTML)) !== null; )
|
|
26
|
-
i.add(e[1].trim().toLowerCase());
|
|
27
|
-
return Array.from(i);
|
|
28
|
-
})(r), _ = l.replace(/\b(?:const|let|var)\s+([\w$]+)\s*=/g, "state.$1 =").replace(/function\s+([\w$]+)\s*\(/g, "state.$1 = function ("), x = l ? new Function("state", `with(state){${_}}`) : () => {
|
|
29
|
-
}, g = [];
|
|
30
|
-
r.content.querySelectorAll("*").forEach((d) => {
|
|
31
|
-
Array.from(d.attributes).forEach((t) => {
|
|
32
|
-
if (!t.name.startsWith("on")) return;
|
|
33
|
-
const i = t.name.slice(2), e = t.value.match(/{\s*([\w$]+)\(\)\s*}/);
|
|
34
|
-
if (!e) return;
|
|
35
|
-
const s = e[1];
|
|
36
|
-
d.dataset._evtIndex = g.length, g.push({ evt: i, fnName: s }), d.removeAttribute(t.name);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
class w extends HTMLElement {
|
|
40
|
-
constructor() {
|
|
41
|
-
super(), u && this.attachShadow({ mode: "open" }), this.state = {}, this.styleElement = document.createElement("style"), this.styleElement.textContent = f || "", this._textBindings = {}, this._origText = /* @__PURE__ */ new Map(), this._hasConnected = !1, this._isUpdating = !1, this._isBinding = !1;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Called when element is inserted into the DOM.
|
|
45
|
-
* - Initializes reactive state
|
|
46
|
-
* - Runs user script to populate state
|
|
47
|
-
* - Processes template bindings
|
|
48
|
-
* - Appends style + content to (shadow) root
|
|
49
|
-
*/
|
|
50
|
-
connectedCallback() {
|
|
51
|
-
if (this._hasConnected) return;
|
|
52
|
-
this._hasConnected = !0, this._textBindings = {}, this._origText = /* @__PURE__ */ new Map();
|
|
53
|
-
const t = r.content.cloneNode(!0);
|
|
54
|
-
this.shadowRoot ? this.shadowRoot.innerHTML = "" : this.innerHTML = "", 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;
|
|
55
|
-
try {
|
|
56
|
-
x.call(this, this.state);
|
|
57
|
-
} catch (e) {
|
|
58
|
-
console.error("Error initializing component script:", e);
|
|
59
|
-
} finally {
|
|
60
|
-
this._initializing = !1;
|
|
61
|
-
}
|
|
62
|
-
const i = this.shadowRoot || this;
|
|
63
|
-
this._processTemplate(i);
|
|
64
|
-
}
|
|
65
|
-
_processTemplate(t) {
|
|
66
|
-
this._getAllTextNodes(t).forEach((e) => {
|
|
67
|
-
const s = e.textContent;
|
|
68
|
-
s.includes("{") && s.includes("}") && (this._origText.set(e, s), e.textContent = s.replace(/{([^}]+)}/g, (n, 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] : n)));
|
|
69
|
-
}), g.forEach((e, s) => {
|
|
70
|
-
const n = t.querySelector(`[data-_evt-index="${s}"]`);
|
|
71
|
-
n.removeAttribute("data-_evt-index"), n.addEventListener(e.evt, (o) => {
|
|
72
|
-
const p = this.state[e.fnName];
|
|
73
|
-
typeof p == "function" && p.call(n, o);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Retrieve all text nodes under a given root node.
|
|
79
|
-
*
|
|
80
|
-
* @param {Node} node
|
|
81
|
-
* @returns {Text[]}
|
|
82
|
-
*/
|
|
83
|
-
_getAllTextNodes(t) {
|
|
84
|
-
const i = [], e = document.createTreeWalker(
|
|
85
|
-
t,
|
|
86
|
-
NodeFilter.SHOW_TEXT,
|
|
87
|
-
null,
|
|
88
|
-
!1
|
|
89
|
-
);
|
|
90
|
-
let s;
|
|
91
|
-
for (; s = e.nextNode(); )
|
|
92
|
-
i.push(s);
|
|
93
|
-
return i;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* clears previous DOM, re-processes template and styles.
|
|
97
|
-
* Usually called by reactive state on mutation.
|
|
98
|
-
*/
|
|
99
|
-
_update() {
|
|
100
|
-
if (!this._isUpdating) {
|
|
101
|
-
this._isUpdating = !0;
|
|
102
|
-
try {
|
|
103
|
-
const t = r.content.cloneNode(!0);
|
|
104
|
-
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));
|
|
105
|
-
} finally {
|
|
106
|
-
this._isUpdating = !1;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// only update the nodes bound to a single key
|
|
111
|
-
_updateBinding(t) {
|
|
112
|
-
if (!this._isBinding) {
|
|
113
|
-
this._isBinding = !0;
|
|
114
|
-
try {
|
|
115
|
-
(this._textBindings[t] || []).forEach((i) => {
|
|
116
|
-
const e = this._origText.get(i) || "";
|
|
117
|
-
i.textContent = e.replace(/{([^}]+)}/g, (s, n) => (n = n.trim(), this.hasAttribute(n) ? this.getAttribute(n) : this.state[n]));
|
|
118
|
-
});
|
|
119
|
-
} finally {
|
|
120
|
-
this._isBinding = !1;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Called when the element is removed from the DOM
|
|
126
|
-
*/
|
|
127
|
-
disconnectedCallback() {
|
|
128
|
-
this._hasConnected = !1, c.log("disconnectedCallback", this);
|
|
129
|
-
}
|
|
130
|
-
// property
|
|
131
|
-
static get observedAttributes() {
|
|
132
|
-
return m;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Called when one of the observed attributes changes.
|
|
136
|
-
* Updates state and triggers a re-render via the reactive proxy.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} name
|
|
139
|
-
* @param {string} oldVal
|
|
140
|
-
* @param {string} newVal
|
|
141
|
-
*/
|
|
142
|
-
attributeChangedCallback(t, i, e) {
|
|
143
|
-
i !== e && (this.state[t] = e);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Dispatch a custom event from the component.
|
|
147
|
-
*
|
|
148
|
-
* @param {string} name Event name
|
|
149
|
-
* @param {*} [detail] Payload; defaults to full component state
|
|
150
|
-
*/
|
|
151
|
-
emit(t, i) {
|
|
152
|
-
const e = i != null ? i : this.state;
|
|
153
|
-
this.dispatchEvent(
|
|
154
|
-
new CustomEvent(t, {
|
|
155
|
-
detail: e,
|
|
156
|
-
bubbles: !0
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
querySelector(t) {
|
|
161
|
-
return this.shadowRoot ? this.shadowRoot.querySelector(t) : super.querySelector(t);
|
|
162
|
-
}
|
|
163
|
-
querySelectorAll(t) {
|
|
164
|
-
return this.shadowRoot ? this.shadowRoot.querySelectorAll(t) : super.querySelectorAll(t);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
customElements.define(h, w), c.log(`Web component defined: <${h}></${h}>`);
|
|
168
|
-
};
|
|
169
|
-
export {
|
|
170
|
-
y as defineWebComponent
|
|
171
|
-
};
|