ladrillosjs 2.0.0-beta.2.1 → 2.0.0-beta.3
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/core/js/scriptParser.d.ts +1 -1
- package/dist/core/main.d.ts +3 -1
- package/dist/index-DZgn4gH2.js +19 -0
- package/dist/index-DZgn4gH2.js.map +1 -0
- package/dist/index-DymB3-NG.mjs +554 -0
- package/dist/index-DymB3-NG.mjs.map +1 -0
- package/dist/index.d.ts +3 -6
- package/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +7 -7
- package/dist/ladrillosjs.umd.js +30 -19
- package/dist/ladrillosjs.umd.js.map +1 -1
- package/dist/types/LadrilloTypes.d.ts +7 -0
- package/dist/utils/devErrors.d.ts +60 -0
- package/dist/webcomponent-BQLjYvOH.js +79 -0
- package/dist/webcomponent-BQLjYvOH.js.map +1 -0
- package/dist/webcomponent-DrCSyWrI.mjs +1059 -0
- package/dist/webcomponent-DrCSyWrI.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/index-BvTcGGey.mjs +0 -361
- package/dist/index-BvTcGGey.mjs.map +0 -1
- package/dist/index-Dt9D0x_j.js +0 -8
- package/dist/index-Dt9D0x_j.js.map +0 -1
- package/dist/webcomponent-CVriFNfb.js +0 -79
- package/dist/webcomponent-CVriFNfb.js.map +0 -1
- package/dist/webcomponent-G5lefoR-.mjs +0 -1016
- package/dist/webcomponent-G5lefoR-.mjs.map +0 -1
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
var W = Object.defineProperty, I = Object.defineProperties;
|
|
2
|
+
var D = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var k = Object.getOwnPropertySymbols;
|
|
4
|
+
var K = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var _ = (t) => {
|
|
6
|
+
throw TypeError(t);
|
|
7
|
+
};
|
|
8
|
+
var P = (t, e, r) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, m = (t, e) => {
|
|
9
|
+
for (var r in e || (e = {}))
|
|
10
|
+
K.call(e, r) && P(t, r, e[r]);
|
|
11
|
+
if (k)
|
|
12
|
+
for (var r of k(e))
|
|
13
|
+
O.call(e, r) && P(t, r, e[r]);
|
|
14
|
+
return t;
|
|
15
|
+
}, g = (t, e) => I(t, D(e));
|
|
16
|
+
var G = (t, e, r) => e.has(t) || _("Cannot " + r);
|
|
17
|
+
var H = (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);
|
|
18
|
+
var S = (t, e, r) => (G(t, e, "access private method"), r);
|
|
19
|
+
var d = (t, e, r) => new Promise((s, o) => {
|
|
20
|
+
var n = (c) => {
|
|
21
|
+
try {
|
|
22
|
+
a(r.next(c));
|
|
23
|
+
} catch (f) {
|
|
24
|
+
o(f);
|
|
25
|
+
}
|
|
26
|
+
}, l = (c) => {
|
|
27
|
+
try {
|
|
28
|
+
a(r.throw(c));
|
|
29
|
+
} catch (f) {
|
|
30
|
+
o(f);
|
|
31
|
+
}
|
|
32
|
+
}, a = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, l);
|
|
33
|
+
a((r = r.apply(t, e)).next());
|
|
34
|
+
});
|
|
35
|
+
const M = () => {
|
|
36
|
+
try {
|
|
37
|
+
return !1;
|
|
38
|
+
} catch (t) {
|
|
39
|
+
return process.env.NODE_ENV === "development";
|
|
40
|
+
}
|
|
41
|
+
}, i = {
|
|
42
|
+
/**
|
|
43
|
+
* Log a message only in development mode
|
|
44
|
+
* @param message - The message to log
|
|
45
|
+
* @param args - Additional arguments to log
|
|
46
|
+
*/
|
|
47
|
+
log(t, ...e) {
|
|
48
|
+
M() && console.log(t, ...e);
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Log an error (always logs in both dev and production)
|
|
52
|
+
* @param message - The error message
|
|
53
|
+
* @param args - Additional arguments to log
|
|
54
|
+
*/
|
|
55
|
+
error(t, ...e) {
|
|
56
|
+
console.error(t, ...e);
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Log a warning only in development mode
|
|
60
|
+
* @param message - The warning message
|
|
61
|
+
* @param args - Additional arguments to log
|
|
62
|
+
*/
|
|
63
|
+
warn(t, ...e) {
|
|
64
|
+
M() && console.warn(t, ...e);
|
|
65
|
+
}
|
|
66
|
+
}, p = (t, e) => {
|
|
67
|
+
const r = [t];
|
|
68
|
+
return e && (e.componentName && r.push(`
|
|
69
|
+
Component: <${e.componentName}>`), e.componentPath && r.push(`
|
|
70
|
+
File: ${e.componentPath}`), e.expression && r.push(`
|
|
71
|
+
Expression: ${e.expression}`), e.attributeName && r.push(`
|
|
72
|
+
Attribute: ${e.attributeName}`), e.eventType && r.push(`
|
|
73
|
+
Event: ${e.eventType}`), e.elementTag && r.push(`
|
|
74
|
+
Element: <${e.elementTag}>`), e.lineHint && r.push(`
|
|
75
|
+
Location: ${e.lineHint}`)), r.join("");
|
|
76
|
+
}, fe = (t, e, r) => {
|
|
77
|
+
const s = p(
|
|
78
|
+
"⚠️ Binding Error: Failed to evaluate expression",
|
|
79
|
+
g(m({}, r), {
|
|
80
|
+
expression: t,
|
|
81
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "Template binding expression"
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
i.error(s), i.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
85
|
+
}, he = (t, e, r, s) => {
|
|
86
|
+
const o = p(
|
|
87
|
+
"⚠️ Event Handler Error: Failed to execute handler",
|
|
88
|
+
g(m({}, s), {
|
|
89
|
+
eventType: t,
|
|
90
|
+
expression: e,
|
|
91
|
+
lineHint: (s == null ? void 0 : s.lineHint) || `on${t} handler`
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
i.error(o), i.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
|
|
95
|
+
}, we = (t, e, r) => {
|
|
96
|
+
const s = p(
|
|
97
|
+
"⚠️ Conditional Error: Failed to evaluate condition",
|
|
98
|
+
g(m({}, r), {
|
|
99
|
+
expression: t,
|
|
100
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "$if/$else-if condition"
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
i.error(s), i.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
104
|
+
}, ye = (t, e, r) => {
|
|
105
|
+
const s = p(
|
|
106
|
+
"⚠️ Loop Error: Failed to process loop",
|
|
107
|
+
g(m({}, r), {
|
|
108
|
+
expression: t,
|
|
109
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "$for loop expression"
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
i.error(s), i.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
113
|
+
}, x = (t, e, r) => {
|
|
114
|
+
const s = p(
|
|
115
|
+
"⚠️ Registration Error: Failed to register component",
|
|
116
|
+
{
|
|
117
|
+
componentName: t,
|
|
118
|
+
componentPath: e
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
i.error(s), i.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
|
|
122
|
+
}, z = (t, e, r) => {
|
|
123
|
+
const s = p(
|
|
124
|
+
"⚠️ Fetch Error: Failed to load resource",
|
|
125
|
+
g(m({}, r), {
|
|
126
|
+
componentPath: t
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
i.error(s), i.error(` Error details: ${e.message}`);
|
|
130
|
+
}, J = (t, e) => {
|
|
131
|
+
const r = p(
|
|
132
|
+
`⚠️ Parse Error: ${t}`,
|
|
133
|
+
e
|
|
134
|
+
);
|
|
135
|
+
i.error(r);
|
|
136
|
+
}, Ee = (t, e) => {
|
|
137
|
+
const r = p(
|
|
138
|
+
"⚠️ Script Error: Failed to execute component script",
|
|
139
|
+
e
|
|
140
|
+
);
|
|
141
|
+
i.error(r), i.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
|
|
142
|
+
}, Ce = (t, e, r) => {
|
|
143
|
+
const s = p(
|
|
144
|
+
"⚠️ Two-Way Binding Error: Failed to setup binding",
|
|
145
|
+
g(m({}, r), {
|
|
146
|
+
expression: t,
|
|
147
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "$model binding"
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
i.error(s), i.error(` Error details: ${e.message}`);
|
|
151
|
+
}, Se = (t, e) => {
|
|
152
|
+
var r;
|
|
153
|
+
return m({
|
|
154
|
+
componentName: (t == null ? void 0 : t.tagName) || ((r = t == null ? void 0 : t.constructor) == null ? void 0 : r.name),
|
|
155
|
+
componentPath: (t == null ? void 0 : t.sourcePath) || (t == null ? void 0 : t._sourcePath)
|
|
156
|
+
}, e);
|
|
157
|
+
}, u = /* @__PURE__ */ new Map(), V = 25, X = (t) => {
|
|
158
|
+
const e = u.get(t);
|
|
159
|
+
return e && (u.delete(t), u.set(t, e)), e;
|
|
160
|
+
}, Y = (t, e) => {
|
|
161
|
+
if (u.has(t))
|
|
162
|
+
u.delete(t);
|
|
163
|
+
else if (u.size >= V) {
|
|
164
|
+
const r = u.keys().next().value;
|
|
165
|
+
r && u.delete(r);
|
|
166
|
+
}
|
|
167
|
+
u.set(t, e);
|
|
168
|
+
}, N = (t) => d(null, null, function* () {
|
|
169
|
+
if (!t)
|
|
170
|
+
throw new Error("Path cannot be null or empty");
|
|
171
|
+
const e = X(t);
|
|
172
|
+
if (e) return e;
|
|
173
|
+
try {
|
|
174
|
+
const r = yield fetch(t);
|
|
175
|
+
if (!r.ok)
|
|
176
|
+
throw new Error(
|
|
177
|
+
`Failed to fetch component from ${t}: ${r.statusText}`
|
|
178
|
+
);
|
|
179
|
+
const s = yield r.text();
|
|
180
|
+
return Y(t, s), s;
|
|
181
|
+
} catch (r) {
|
|
182
|
+
z(t, r, { componentPath: t });
|
|
183
|
+
}
|
|
184
|
+
}), Q = (t) => d(null, null, function* () {
|
|
185
|
+
try {
|
|
186
|
+
const e = yield fetch(t);
|
|
187
|
+
if (!e.ok) throw new Error(`HTTP ${e.status}`);
|
|
188
|
+
return yield e.text();
|
|
189
|
+
} catch (e) {
|
|
190
|
+
return z(t, e), "";
|
|
191
|
+
}
|
|
192
|
+
}), b = {
|
|
193
|
+
bindings: /{([^}]+)}/g,
|
|
194
|
+
comments: {
|
|
195
|
+
js: /\/\*[\s\S]*?\*\/|\/\/.*$/gm,
|
|
196
|
+
css: /\/\*[\s\S]*?\*\//g,
|
|
197
|
+
html: /<!--[\s\S]*?-->/g
|
|
198
|
+
}
|
|
199
|
+
}, U = new DOMParser(), T = (t, e) => d(null, null, function* () {
|
|
200
|
+
const r = Z(t), { scripts: s, externalScripts: o } = te(r), n = yield se(r), l = r.body.innerHTML.trim();
|
|
201
|
+
return {
|
|
202
|
+
tagName: e,
|
|
203
|
+
template: l,
|
|
204
|
+
scripts: s,
|
|
205
|
+
externalScripts: o,
|
|
206
|
+
styles: n
|
|
207
|
+
};
|
|
208
|
+
}), Z = (t) => U.parseFromString(
|
|
209
|
+
t.replace(b.comments.html, ""),
|
|
210
|
+
"text/html"
|
|
211
|
+
), ee = (t) => [
|
|
212
|
+
"/@vite/",
|
|
213
|
+
// Vite dev client
|
|
214
|
+
"/__vite",
|
|
215
|
+
// Vite internal
|
|
216
|
+
"/webpack-dev-server",
|
|
217
|
+
// Webpack dev server
|
|
218
|
+
"/hot-update",
|
|
219
|
+
// Webpack HMR
|
|
220
|
+
"/__webpack_hmr",
|
|
221
|
+
// Webpack HMR
|
|
222
|
+
"/browser-sync/",
|
|
223
|
+
// Browser Sync
|
|
224
|
+
"/livereload.js"
|
|
225
|
+
// LiveReload
|
|
226
|
+
].some((r) => t.includes(r)), te = (t) => {
|
|
227
|
+
var s, o;
|
|
228
|
+
const e = [], r = [];
|
|
229
|
+
for (const n of t.querySelectorAll("script")) {
|
|
230
|
+
if (n.src) {
|
|
231
|
+
if (ee(n.src)) {
|
|
232
|
+
n.remove();
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const l = n.hasAttribute("external");
|
|
236
|
+
r.push({
|
|
237
|
+
src: n.getAttribute("src") || n.src,
|
|
238
|
+
// Use getAttribute to preserve relative paths
|
|
239
|
+
type: (s = n.type) != null ? s : null,
|
|
240
|
+
external: l
|
|
241
|
+
});
|
|
242
|
+
} else if (n.textContent) {
|
|
243
|
+
let l = n.textContent.trim();
|
|
244
|
+
l = l.replace(b.comments.js, "").trim(), e.push({
|
|
245
|
+
content: l,
|
|
246
|
+
type: (o = n.type) != null ? o : null
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
n.remove();
|
|
250
|
+
}
|
|
251
|
+
return { scripts: e, externalScripts: r };
|
|
252
|
+
}, re = (t) => {
|
|
253
|
+
const e = t.match(/const __vite__css = "((?:[^"\\]|\\.)*)"/);
|
|
254
|
+
if (e && e[1])
|
|
255
|
+
return e[1].replace(/\\r\\n/g, `
|
|
256
|
+
`).replace(/\\n/g, `
|
|
257
|
+
`).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
258
|
+
const r = t.match(/export\s+default\s+"((?:[^"\\]|\\.)*)"/);
|
|
259
|
+
return r && r[1] ? r[1].replace(/\\r\\n/g, `
|
|
260
|
+
`).replace(/\\n/g, `
|
|
261
|
+
`).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : t.includes("import") || t.includes("export") ? (i.warn(
|
|
262
|
+
"CSS file returned JavaScript module format. CSS may not load correctly."
|
|
263
|
+
), "") : t;
|
|
264
|
+
}, se = (t) => d(null, null, function* () {
|
|
265
|
+
let e = "";
|
|
266
|
+
const r = t.querySelectorAll("style, link[rel='stylesheet']");
|
|
267
|
+
for (const s of r) {
|
|
268
|
+
if (s.tagName === "LINK") {
|
|
269
|
+
const n = yield Q(s.href), l = re(n);
|
|
270
|
+
l && (e += `
|
|
271
|
+
` + l);
|
|
272
|
+
} else if (s.tagName === "STYLE") {
|
|
273
|
+
const o = s;
|
|
274
|
+
if (o.textContent) {
|
|
275
|
+
let n = o.textContent.trim();
|
|
276
|
+
n = n.replace(b.comments.css, "").trim(), e += `
|
|
277
|
+
` + n;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
s.remove();
|
|
281
|
+
}
|
|
282
|
+
return e.trim();
|
|
283
|
+
});
|
|
284
|
+
var h, A, F;
|
|
285
|
+
class oe {
|
|
286
|
+
constructor() {
|
|
287
|
+
H(this, h);
|
|
288
|
+
this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null;
|
|
289
|
+
}
|
|
290
|
+
registerComponent(e, r, s = !0, o = !1) {
|
|
291
|
+
return d(this, null, function* () {
|
|
292
|
+
if (this.components[e]) {
|
|
293
|
+
i.warn(`Component with name "${e}" is already registered.`);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (o) {
|
|
297
|
+
this.lazyComponents.add(e), S(this, h, A).call(this, e, r, s), i.log(`Component ${e} registered as lazy-loaded`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
try {
|
|
301
|
+
const n = yield N(r), l = yield T(n, e);
|
|
302
|
+
this.components[e] = {
|
|
303
|
+
tagName: e,
|
|
304
|
+
template: l.template,
|
|
305
|
+
scripts: l.scripts,
|
|
306
|
+
externalScripts: l.externalScripts,
|
|
307
|
+
styles: l.styles,
|
|
308
|
+
sourcePath: r,
|
|
309
|
+
lazy: !1
|
|
310
|
+
}, i.log(`Component ${e} registered successfully`), yield S(this, h, F).call(this, e, s);
|
|
311
|
+
} catch (n) {
|
|
312
|
+
x(e, r, n);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
h = new WeakSet(), /**
|
|
319
|
+
* Defines a lazy-loading placeholder component
|
|
320
|
+
* @param name - Component name
|
|
321
|
+
* @param path - Component path
|
|
322
|
+
* @param useShadowDOM - Whether to use Shadow DOM
|
|
323
|
+
*/
|
|
324
|
+
A = function(e, r, s) {
|
|
325
|
+
const o = this;
|
|
326
|
+
class n extends HTMLElement {
|
|
327
|
+
constructor() {
|
|
328
|
+
super(), this.loaded = !1, this.observer = null, s && (this.attachShadow({ mode: "open" }), this.shadowRoot && (this.shadowRoot.innerHTML = `
|
|
329
|
+
<style>
|
|
330
|
+
:host { display: block; min-height: 1px; }
|
|
331
|
+
</style>
|
|
332
|
+
`));
|
|
333
|
+
}
|
|
334
|
+
connectedCallback() {
|
|
335
|
+
if (!this.loaded) {
|
|
336
|
+
if (this.hasAttribute("eager")) {
|
|
337
|
+
this.loaded = !0, this.loadComponent();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
this.observer = new IntersectionObserver(
|
|
341
|
+
(a) => {
|
|
342
|
+
a.forEach((c) => {
|
|
343
|
+
c.isIntersecting && !this.loaded && (this.loaded = !0, this.loadComponent());
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
rootMargin: "50px"
|
|
348
|
+
// Load 50px before entering viewport
|
|
349
|
+
}
|
|
350
|
+
), this.observer.observe(this);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
disconnectedCallback() {
|
|
354
|
+
this.observer && (this.observer.disconnect(), this.observer = null);
|
|
355
|
+
}
|
|
356
|
+
loadComponent() {
|
|
357
|
+
return d(this, null, function* () {
|
|
358
|
+
try {
|
|
359
|
+
i.log(`Lazy loading component: ${e}`);
|
|
360
|
+
const a = this, c = this.parentNode, f = this.nextSibling;
|
|
361
|
+
if (!c) {
|
|
362
|
+
J(`Placeholder for ${e} has no parent node`, {
|
|
363
|
+
componentName: e,
|
|
364
|
+
componentPath: r
|
|
365
|
+
});
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const q = yield N(r), y = yield T(q, e);
|
|
369
|
+
i.log(`Component ${e} parsed successfully`), o.components[e] = {
|
|
370
|
+
tagName: e,
|
|
371
|
+
template: y.template,
|
|
372
|
+
scripts: y.scripts,
|
|
373
|
+
externalScripts: y.externalScripts,
|
|
374
|
+
styles: y.styles,
|
|
375
|
+
sourcePath: r,
|
|
376
|
+
lazy: !0
|
|
377
|
+
};
|
|
378
|
+
const w = `${e}-real`;
|
|
379
|
+
i.log(`Defining real component with temp name: ${w}`);
|
|
380
|
+
const B = o.components[e].tagName;
|
|
381
|
+
o.components[e].tagName = w;
|
|
382
|
+
const { defineWebComponent: j } = yield import("./webcomponent-DrCSyWrI.mjs");
|
|
383
|
+
j(o.components[e], s), i.log(`Real component ${w} defined`), o.components[e].tagName = B;
|
|
384
|
+
const E = document.createElement(w);
|
|
385
|
+
for (i.log(`Created real component instance: ${w}`), Array.from(a.attributes).forEach((v) => {
|
|
386
|
+
E.setAttribute(v.name, v.value);
|
|
387
|
+
}); a.firstChild; )
|
|
388
|
+
E.appendChild(a.firstChild);
|
|
389
|
+
f ? (c.insertBefore(E, f), i.log("Inserted real component before next sibling")) : (c.appendChild(E), i.log("Appended real component to parent")), c.removeChild(a), i.log("Removed placeholder element"), o.lazyComponents.delete(e), i.log(`Component ${e} lazy-loaded successfully`);
|
|
390
|
+
} catch (a) {
|
|
391
|
+
x(e, r, a);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
customElements.get(e) || customElements.define(e, n);
|
|
397
|
+
}, F = function(e, r) {
|
|
398
|
+
return d(this, null, function* () {
|
|
399
|
+
const { defineWebComponent: s } = yield import("./webcomponent-DrCSyWrI.mjs");
|
|
400
|
+
this.components[e] && s(this.components[e], r);
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
const L = new oe();
|
|
404
|
+
class ne {
|
|
405
|
+
constructor() {
|
|
406
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Emit an event with optional data
|
|
410
|
+
* @param eventName - The name of the event to emit
|
|
411
|
+
* @param data - Optional data to pass to listeners
|
|
412
|
+
* @returns Promise that resolves when all listeners have been called
|
|
413
|
+
*/
|
|
414
|
+
emit(e, r) {
|
|
415
|
+
const s = new CustomEvent(e, {
|
|
416
|
+
detail: r,
|
|
417
|
+
bubbles: !0,
|
|
418
|
+
composed: !0
|
|
419
|
+
});
|
|
420
|
+
document.dispatchEvent(s);
|
|
421
|
+
const o = this.listeners.get(e);
|
|
422
|
+
if (!o || o.size === 0)
|
|
423
|
+
return Promise.resolve();
|
|
424
|
+
const n = [];
|
|
425
|
+
return o.forEach((l) => {
|
|
426
|
+
try {
|
|
427
|
+
const a = l(r);
|
|
428
|
+
a instanceof Promise && n.push(a);
|
|
429
|
+
} catch (a) {
|
|
430
|
+
i.error(
|
|
431
|
+
`⚠️ Event Bus Error: Failed to execute listener for "${e}"`
|
|
432
|
+
), i.error(` Error details: ${a.message}`), n.push(Promise.reject(a));
|
|
433
|
+
}
|
|
434
|
+
}), n.length > 0 ? Promise.all(n).then(() => {
|
|
435
|
+
}) : Promise.resolve();
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Listen to an event
|
|
439
|
+
* @param eventName - The name of the event to listen for
|
|
440
|
+
* @param callback - Function to call when event is emitted
|
|
441
|
+
* @returns Function to remove the listener
|
|
442
|
+
*/
|
|
443
|
+
listen(e, r) {
|
|
444
|
+
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r), () => {
|
|
445
|
+
this.off(e, r);
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Remove a specific event listener
|
|
450
|
+
* @param eventName - The name of the event
|
|
451
|
+
* @param callback - The callback to remove
|
|
452
|
+
*/
|
|
453
|
+
off(e, r) {
|
|
454
|
+
const s = this.listeners.get(e);
|
|
455
|
+
s && (s.delete(r), s.size === 0 && this.listeners.delete(e));
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Remove all listeners for an event, or all listeners if no event specified
|
|
459
|
+
* @param eventName - Optional event name to clear listeners for
|
|
460
|
+
*/
|
|
461
|
+
clear(e) {
|
|
462
|
+
e ? this.listeners.delete(e) : this.listeners.clear();
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Get count of listeners for an event
|
|
466
|
+
* @param eventName - The event name
|
|
467
|
+
* @returns Number of listeners
|
|
468
|
+
*/
|
|
469
|
+
listenerCount(e) {
|
|
470
|
+
var r, s;
|
|
471
|
+
return (s = (r = this.listeners.get(e)) == null ? void 0 : r.size) != null ? s : 0;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const R = new ne(), ie = (t, e, r, s) => L.registerComponent(t, e, r, s), le = (t) => d(null, null, function* () {
|
|
475
|
+
yield Promise.all(
|
|
476
|
+
t.map(
|
|
477
|
+
({ name: e, path: r, useShadowDOM: s, lazy: o }) => L.registerComponent(e, r, s, o)
|
|
478
|
+
)
|
|
479
|
+
);
|
|
480
|
+
}), ae = (t, e) => R.listen(t, e), ce = (t, e) => {
|
|
481
|
+
R.emit(t, e);
|
|
482
|
+
}, $e = (t, e) => {
|
|
483
|
+
if (e) {
|
|
484
|
+
const r = e.tagName.toLowerCase();
|
|
485
|
+
window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(r, { shadowRoot: t, element: e });
|
|
486
|
+
}
|
|
487
|
+
}, C = () => {
|
|
488
|
+
const t = window.__ladrilloContexts;
|
|
489
|
+
if (t && t.size > 0) {
|
|
490
|
+
const e = Array.from(t.values());
|
|
491
|
+
return e[e.length - 1];
|
|
492
|
+
}
|
|
493
|
+
return null;
|
|
494
|
+
}, de = () => {
|
|
495
|
+
const t = C();
|
|
496
|
+
return t && t.element ? t.element.state || {} : {};
|
|
497
|
+
}, $ = (t) => {
|
|
498
|
+
const e = C();
|
|
499
|
+
e && e.setState && e.setState(t);
|
|
500
|
+
}, ue = (t, e) => ($({ [t]: e }), (r) => {
|
|
501
|
+
$({ [t]: r });
|
|
502
|
+
}), pe = (t, e) => {
|
|
503
|
+
if (e)
|
|
504
|
+
return e.querySelector(t);
|
|
505
|
+
const r = C();
|
|
506
|
+
if (r) {
|
|
507
|
+
const s = r.shadowRoot || r.element;
|
|
508
|
+
if (s) {
|
|
509
|
+
const o = s.querySelector(t);
|
|
510
|
+
if (o) return o;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return document.querySelector(t);
|
|
514
|
+
}, me = (t, e) => {
|
|
515
|
+
if (e)
|
|
516
|
+
return e.querySelectorAll(t);
|
|
517
|
+
const r = C();
|
|
518
|
+
if (r) {
|
|
519
|
+
const s = r.shadowRoot || r.element;
|
|
520
|
+
if (s) {
|
|
521
|
+
const o = s.querySelectorAll(t);
|
|
522
|
+
if (o.length > 0) return o;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return document.querySelectorAll(t);
|
|
526
|
+
};
|
|
527
|
+
typeof window != "undefined" && (window.ladrillosjs = {
|
|
528
|
+
registerComponent: ie,
|
|
529
|
+
registerComponents: le
|
|
530
|
+
}, window.$listen = ae, window.$emit = ce, window.$querySelector = pe, window.$querySelectorAll = me, window.$reactive = ue, window.$setState = $, window.$getState = de);
|
|
531
|
+
export {
|
|
532
|
+
ae as $,
|
|
533
|
+
b as R,
|
|
534
|
+
$e as _,
|
|
535
|
+
fe as a,
|
|
536
|
+
ye as b,
|
|
537
|
+
Se as c,
|
|
538
|
+
we as d,
|
|
539
|
+
he as e,
|
|
540
|
+
R as f,
|
|
541
|
+
Ee as g,
|
|
542
|
+
i as h,
|
|
543
|
+
Ce as i,
|
|
544
|
+
le as j,
|
|
545
|
+
ce as k,
|
|
546
|
+
J as l,
|
|
547
|
+
de as m,
|
|
548
|
+
$ as n,
|
|
549
|
+
ue as o,
|
|
550
|
+
pe as p,
|
|
551
|
+
me as q,
|
|
552
|
+
ie as r
|
|
553
|
+
};
|
|
554
|
+
//# sourceMappingURL=index-DymB3-NG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DymB3-NG.mjs","sources":["../src/utils/logger.ts","../src/utils/devErrors.ts","../src/cache/index.ts","../src/core/componentSource.ts","../src/utils/regex.ts","../src/core/componentParser.ts","../src/core/main.ts","../src/core/eventBus.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Utility for conditional logging based on environment\r\n */\r\n\r\n// Type guard for Vite environment\r\nconst isDevelopment = (): boolean => {\r\n try {\r\n return (import.meta as any).env?.DEV === true;\r\n } catch {\r\n return process.env.NODE_ENV === 'development';\r\n }\r\n};\r\n\r\nexport const logger = {\r\n /**\r\n * Log a message only in development mode\r\n * @param message - The message to log\r\n * @param args - Additional arguments to log\r\n */\r\n log(message: string, ...args: any[]): void {\r\n if (isDevelopment()) {\r\n console.log(message, ...args);\r\n }\r\n },\r\n\r\n /**\r\n * Log an error (always logs in both dev and production)\r\n * @param message - The error message\r\n * @param args - Additional arguments to log\r\n */\r\n error(message: string, ...args: any[]): void {\r\n console.error(message, ...args);\r\n },\r\n\r\n /**\r\n * Log a warning only in development mode\r\n * @param message - The warning message\r\n * @param args - Additional arguments to log\r\n */\r\n warn(message: string, ...args: any[]): void {\r\n if (isDevelopment()) {\r\n console.warn(message, ...args);\r\n }\r\n },\r\n};\r\n","/**\r\n * Developer-friendly error handling utilities\r\n * Provides contextual error messages with component names, file paths, and code references\r\n */\r\n\r\nimport { logger } from \"./logger\";\r\n\r\nexport type ErrorContext = {\r\n componentName?: string;\r\n componentPath?: string;\r\n expression?: string;\r\n attributeName?: string;\r\n eventType?: string;\r\n elementTag?: string;\r\n lineHint?: string;\r\n};\r\n\r\nexport class LadrillosError extends Error {\r\n public readonly componentName?: string;\r\n public readonly componentPath?: string;\r\n public readonly expression?: string;\r\n public readonly context?: ErrorContext;\r\n\r\n constructor(message: string, context?: ErrorContext) {\r\n super(message);\r\n this.name = \"LadrillosError\";\r\n this.componentName = context?.componentName;\r\n this.componentPath = context?.componentPath;\r\n this.expression = context?.expression;\r\n this.context = context;\r\n\r\n // Maintain proper stack trace for where error was thrown\r\n if (Error.captureStackTrace) {\r\n Error.captureStackTrace(this, LadrillosError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Formats an error message with component context for developers\r\n */\r\nconst formatErrorMessage = (\r\n message: string,\r\n context?: ErrorContext\r\n): string => {\r\n const parts: string[] = [message];\r\n\r\n if (context) {\r\n if (context.componentName) {\r\n parts.push(`\\n Component: <${context.componentName}>`);\r\n }\r\n\r\n if (context.componentPath) {\r\n parts.push(`\\n File: ${context.componentPath}`);\r\n }\r\n\r\n if (context.expression) {\r\n parts.push(`\\n Expression: ${context.expression}`);\r\n }\r\n\r\n if (context.attributeName) {\r\n parts.push(`\\n Attribute: ${context.attributeName}`);\r\n }\r\n\r\n if (context.eventType) {\r\n parts.push(`\\n Event: ${context.eventType}`);\r\n }\r\n\r\n if (context.elementTag) {\r\n parts.push(`\\n Element: <${context.elementTag}>`);\r\n }\r\n\r\n if (context.lineHint) {\r\n parts.push(`\\n Location: ${context.lineHint}`);\r\n }\r\n }\r\n\r\n return parts.join(\"\");\r\n};\r\n\r\n/**\r\n * Logs a binding error with component context\r\n */\r\nexport const logBindingError = (\r\n expression: string,\r\n error: Error,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Binding Error: Failed to evaluate expression`,\r\n {\r\n ...context,\r\n expression,\r\n lineHint: context?.lineHint || \"Template binding expression\",\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n\r\n // Log stack trace in development for debugging\r\n if (error.stack) {\r\n console.debug(\" Stack trace:\", error.stack);\r\n }\r\n};\r\n\r\n/**\r\n * Logs an event handler error with component context\r\n */\r\nexport const logEventHandlerError = (\r\n eventType: string,\r\n handlerCode: string,\r\n error: Error,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Event Handler Error: Failed to execute handler`,\r\n {\r\n ...context,\r\n eventType,\r\n expression: handlerCode,\r\n lineHint: context?.lineHint || `on${eventType} handler`,\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n\r\n if (error.stack) {\r\n console.debug(\" Stack trace:\", error.stack);\r\n }\r\n};\r\n\r\n/**\r\n * Logs a conditional rendering error with component context\r\n */\r\nexport const logConditionalError = (\r\n condition: string,\r\n error: Error,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Conditional Error: Failed to evaluate condition`,\r\n {\r\n ...context,\r\n expression: condition,\r\n lineHint: context?.lineHint || \"$if/$else-if condition\",\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n\r\n if (error.stack) {\r\n console.debug(\" Stack trace:\", error.stack);\r\n }\r\n};\r\n\r\n/**\r\n * Logs a loop rendering error with component context\r\n */\r\nexport const logLoopError = (\r\n loopExpression: string,\r\n error: Error,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Loop Error: Failed to process loop`,\r\n {\r\n ...context,\r\n expression: loopExpression,\r\n lineHint: context?.lineHint || \"$for loop expression\",\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n\r\n if (error.stack) {\r\n console.debug(\" Stack trace:\", error.stack);\r\n }\r\n};\r\n\r\n/**\r\n * Logs a component registration error\r\n */\r\nexport const logRegistrationError = (\r\n componentName: string,\r\n componentPath: string,\r\n error: Error\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Registration Error: Failed to register component`,\r\n {\r\n componentName,\r\n componentPath,\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n\r\n if (error.stack) {\r\n console.debug(\" Stack trace:\", error.stack);\r\n }\r\n};\r\n\r\n/**\r\n * Logs a fetch error with context\r\n */\r\nexport const logFetchError = (\r\n url: string,\r\n error: Error,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Fetch Error: Failed to load resource`,\r\n {\r\n ...context,\r\n componentPath: url,\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n};\r\n\r\n/**\r\n * Logs a parsing error with context\r\n */\r\nexport const logParseError = (\r\n message: string,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Parse Error: ${message}`,\r\n context\r\n );\r\n\r\n logger.error(errorMessage);\r\n};\r\n\r\n/**\r\n * Logs a script execution error\r\n */\r\nexport const logScriptError = (error: Error, context?: ErrorContext): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Script Error: Failed to execute component script`,\r\n context\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n\r\n if (error.stack) {\r\n console.debug(\" Stack trace:\", error.stack);\r\n }\r\n};\r\n\r\n/**\r\n * Logs a two-way binding error\r\n */\r\nexport const logTwoWayBindingError = (\r\n expression: string,\r\n error: Error,\r\n context?: ErrorContext\r\n): void => {\r\n const errorMessage = formatErrorMessage(\r\n `⚠️ Two-Way Binding Error: Failed to setup binding`,\r\n {\r\n ...context,\r\n expression,\r\n lineHint: context?.lineHint || \"$model binding\",\r\n }\r\n );\r\n\r\n logger.error(errorMessage);\r\n logger.error(` Error details: ${error.message}`);\r\n};\r\n\r\n/**\r\n * Creates an error context from component metadata\r\n */\r\nexport const createErrorContext = (\r\n component: any,\r\n additionalContext?: Partial<ErrorContext>\r\n): ErrorContext => {\r\n return {\r\n componentName: component?.tagName || component?.constructor?.name,\r\n componentPath: component?.sourcePath || component?._sourcePath,\r\n ...additionalContext,\r\n };\r\n};\r\n","const cache = new Map<string, string>();\r\nconst maxCacheSize = 25; // TODO: make configurable for developer to set\r\n\r\n/**\r\n * LRU Cache: Gets cached content and marks it as recently used\r\n * Moves the accessed item to the end of the Map (most recently used position)\r\n * This ensures frequently accessed components stay in cache longer\r\n * @param path - The file path to retrieve from cache\r\n * @returns The cached content or undefined if not found\r\n */\r\nexport const getCached = (path: string): string | undefined => {\r\n const cached = cache.get(path);\r\n if (cached) {\r\n // LRU: Move to end (most recently used position)\r\n cache.delete(path);\r\n cache.set(path, cached);\r\n }\r\n return cached;\r\n};\r\n\r\n/**\r\n * LRU Cache: Stores content with automatic eviction of least recently used items\r\n * Maintains cache size limit by removing oldest items when full\r\n * Updates existing items without affecting cache size\r\n * @param path - The file path to cache\r\n * @param content - The content to store\r\n */\r\nexport const setCache = (path: string, content: string): void => {\r\n if (cache.has(path)) {\r\n // Update existing: remove and re-add to mark as most recent\r\n cache.delete(path);\r\n } else if (cache.size >= maxCacheSize) {\r\n // Cache full: remove least recently used (first item in Map)\r\n const firstKey = cache.keys().next().value;\r\n if (firstKey) {\r\n cache.delete(firstKey);\r\n }\r\n }\r\n // Add/update as most recently used (end of Map)\r\n cache.set(path, content);\r\n};\r\n","import { getCached, setCache } from \"../cache\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { logFetchError } from \"../utils/devErrors\";\r\n\r\n/**\r\n * Fetches component source with caching support\r\n * @param path - The file path to fetch\r\n * @returns The component source content\r\n */\r\nexport const fetchComponentSource = async (\r\n path: string\r\n): Promise<string | undefined> => {\r\n if (!path) {\r\n throw new Error(\"Path cannot be null or empty\");\r\n }\r\n\r\n const cached = getCached(path);\r\n if (cached) return cached;\r\n\r\n // fetch and cache\r\n try {\r\n const response = await fetch(path);\r\n\r\n if (!response.ok) {\r\n throw new Error(\r\n `Failed to fetch component from ${path}: ${response.statusText}`\r\n );\r\n }\r\n\r\n const text = await response.text();\r\n setCache(path, text);\r\n\r\n return text;\r\n } catch (error) {\r\n logFetchError(path, error as Error, { componentPath: path });\r\n }\r\n};\r\n\r\n/**\r\n * Safe fetch helper that returns empty string on error\r\n * @param url - The URL to fetch\r\n * @returns The fetched content or empty string\r\n */\r\nexport const safeFetch = async (url: string): Promise<string> => {\r\n try {\r\n const res = await fetch(url);\r\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\r\n return await res.text();\r\n } catch (err) {\r\n logFetchError(url, err as Error);\r\n return \"\";\r\n }\r\n};\r\n","import { RegexPatterns } from \"../types/LadrilloTypes\";\r\n\r\nexport const REGEX_PATTERNS: RegexPatterns = {\r\n bindings: /{([^}]+)}/g,\r\n comments: {\r\n js: /\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*$/gm,\r\n css: /\\/\\*[\\s\\S]*?\\*\\//g,\r\n html: /<!--[\\s\\S]*?-->/g,\r\n },\r\n};\r\n","import {\r\n ExternalScriptElement,\r\n LadrillosComponent,\r\n ScriptElement,\r\n} from \"../types/LadrilloTypes\";\r\nimport { REGEX_PATTERNS } from \"../utils/regex\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { safeFetch } from \"./componentSource\";\r\n\r\nconst parser = new DOMParser();\r\n\r\n/**\r\n * Parses component HTML and extracts scripts and styles\r\n * @param source - The HTML source of the component\r\n * @param name - The name of the component\r\n * @returns Parsed component object\r\n */\r\nexport const parseComponent = async (\r\n source: string,\r\n name: string\r\n): Promise<LadrillosComponent> => {\r\n const doc = parseComponentHTML(source);\r\n const { scripts, externalScripts } = extractScripts(doc);\r\n const styles = await extractStyles(doc);\r\n const template = doc.body.innerHTML.trim();\r\n\r\n return {\r\n tagName: name,\r\n template,\r\n scripts,\r\n externalScripts,\r\n styles,\r\n };\r\n};\r\n\r\n/**\r\n * Parses HTML content and removes comments\r\n * @param source - The HTML source to parse\r\n * @returns Parsed DOM document\r\n */\r\nexport const parseComponentHTML = (source: string): Document => {\r\n return parser.parseFromString(\r\n source.replace(REGEX_PATTERNS.comments.html, \"\"),\r\n \"text/html\"\r\n );\r\n};\r\n\r\n/**\r\n * Checks if a script URL is a development server script that should be ignored.\r\n * Dev server scripts (Vite, Webpack HMR, etc.) are injected by the dev environment\r\n * and should not be processed as part of the component.\r\n */\r\nconst isDevServerScript = (src: string): boolean => {\r\n const devPatterns = [\r\n \"/@vite/\", // Vite dev client\r\n \"/__vite\", // Vite internal\r\n \"/webpack-dev-server\", // Webpack dev server\r\n \"/hot-update\", // Webpack HMR\r\n \"/__webpack_hmr\", // Webpack HMR\r\n \"/browser-sync/\", // Browser Sync\r\n \"/livereload.js\", // LiveReload\r\n ];\r\n\r\n return devPatterns.some((pattern) => src.includes(pattern));\r\n};\r\n\r\n/**\r\n * Extracts and processes script elements from the document\r\n * @param doc - The parsed document\r\n * @returns Object containing scripts and external scripts\r\n */\r\nexport const extractScripts = (\r\n doc: Document\r\n): {\r\n scripts: ScriptElement[];\r\n externalScripts: ExternalScriptElement[];\r\n} => {\r\n const scripts: ScriptElement[] = [];\r\n const externalScripts: ExternalScriptElement[] = [];\r\n\r\n for (const el of doc.querySelectorAll(\"script\")) {\r\n if (el.src) {\r\n // Skip dev server scripts (Vite, Webpack, etc.)\r\n if (isDevServerScript(el.src)) {\r\n el.remove();\r\n continue;\r\n }\r\n\r\n // Only mark as external if the 'external' attribute is explicitly present\r\n const isExternal = el.hasAttribute(\"external\");\r\n\r\n externalScripts.push({\r\n src: el.getAttribute(\"src\") || el.src, // Use getAttribute to preserve relative paths\r\n type: el.type ?? null,\r\n external: isExternal,\r\n });\r\n } else if (el.textContent) {\r\n let content = el.textContent.trim();\r\n // strip JavaScript comments (single‑line and block)\r\n content = content.replace(REGEX_PATTERNS.comments.js, \"\").trim();\r\n scripts.push({\r\n content,\r\n type: el.type ?? null,\r\n });\r\n }\r\n el.remove();\r\n }\r\n\r\n return { scripts, externalScripts };\r\n};\r\n\r\n/**\r\n * Extracts CSS content from various response formats\r\n * Handles:\r\n * - Vite dev server (wrapped in __vite__css variable)\r\n * - Plain CSS files (production/CDN)\r\n * - Other build tool formats\r\n */\r\nconst extractCSSFromResponse = (response: string): string => {\r\n // Check if this is a Vite HMR response (contains __vite__css)\r\n // Use a regex that properly handles escaped quotes within the string\r\n const viteMatch = response.match(/const __vite__css = \"((?:[^\"\\\\]|\\\\.)*)\"/);\r\n if (viteMatch && viteMatch[1]) {\r\n // Unescape the CSS string\r\n return viteMatch[1]\r\n .replace(/\\\\r\\\\n/g, \"\\n\")\r\n .replace(/\\\\n/g, \"\\n\")\r\n .replace(/\\\\t/g, \"\\t\")\r\n .replace(/\\\\\"/g, '\"')\r\n .replace(/\\\\\\\\/g, \"\\\\\");\r\n }\r\n\r\n // Check for other module formats (e.g., \"export default ...\")\r\n const exportMatch = response.match(/export\\s+default\\s+\"((?:[^\"\\\\]|\\\\.)*)\"/);\r\n if (exportMatch && exportMatch[1]) {\r\n return exportMatch[1]\r\n .replace(/\\\\r\\\\n/g, \"\\n\")\r\n .replace(/\\\\n/g, \"\\n\")\r\n .replace(/\\\\t/g, \"\\t\")\r\n .replace(/\\\\\"/g, '\"')\r\n .replace(/\\\\\\\\/g, \"\\\\\");\r\n }\r\n\r\n // If it looks like JavaScript (not CSS), warn and return empty\r\n if (response.includes(\"import\") || response.includes(\"export\")) {\r\n logger.warn(\r\n \"CSS file returned JavaScript module format. CSS may not load correctly.\"\r\n );\r\n return \"\";\r\n }\r\n\r\n // If not a module format, assume it's plain CSS (production or direct file)\r\n return response;\r\n};\r\n\r\n/**\r\n * Extracts and processes style elements from the document\r\n * @param doc - The parsed document\r\n * @returns Concatenated CSS content\r\n */\r\nexport const extractStyles = async (doc: Document): Promise<string> => {\r\n let style = \"\";\r\n\r\n // Process styles in document order (inline styles and external stylesheets)\r\n const styleElements = doc.querySelectorAll(\"style, link[rel='stylesheet']\");\r\n\r\n for (const element of styleElements) {\r\n if (element.tagName === \"LINK\") {\r\n const linkElement = element as HTMLLinkElement;\r\n const response = await safeFetch(linkElement.href);\r\n const cssContent = extractCSSFromResponse(response);\r\n if (cssContent) {\r\n style += \"\\n\" + cssContent;\r\n }\r\n } else if (element.tagName === \"STYLE\") {\r\n const styleEl = element as HTMLStyleElement;\r\n if (styleEl.textContent) {\r\n let css = styleEl.textContent.trim();\r\n // strip CSS comments\r\n css = css.replace(REGEX_PATTERNS.comments.css, \"\").trim();\r\n style += \"\\n\" + css;\r\n }\r\n }\r\n element.remove();\r\n }\r\n\r\n return style.trim();\r\n};\r\n","import { LadrillosComponent } from \"../types/LadrilloTypes\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { logRegistrationError, logParseError } from \"../utils/devErrors\";\r\nimport { fetchComponentSource } from \"./componentSource\";\r\nimport { parseComponent } from \"./componentParser\";\r\n\r\nclass Ladrillos {\r\n // properties\r\n components: Record<string, LadrillosComponent>;\r\n private lazyComponents: Set<string>;\r\n private intersectionObserver: IntersectionObserver | null;\r\n\r\n constructor() {\r\n // Initialize the Ladrillos instance\r\n this.components = {};\r\n this.lazyComponents = new Set();\r\n this.intersectionObserver = null;\r\n }\r\n\r\n async registerComponent(\r\n name: string,\r\n path: string,\r\n useShadowDOM: boolean = true,\r\n lazy: boolean = false\r\n ): Promise<void> {\r\n if (this.components[name]) {\r\n logger.warn(`Component with name \"${name}\" is already registered.`);\r\n return;\r\n }\r\n\r\n // For lazy components, register a placeholder and defer actual loading\r\n if (lazy) {\r\n this.lazyComponents.add(name);\r\n this.#defineLazyPlaceholder(name, path, useShadowDOM);\r\n logger.log(`Component ${name} registered as lazy-loaded`);\r\n return;\r\n }\r\n\r\n try {\r\n const source = await fetchComponentSource(path);\r\n const component = await parseComponent(source!, name);\r\n\r\n this.components[name] = {\r\n tagName: name,\r\n template: component.template,\r\n scripts: component.scripts,\r\n externalScripts: component.externalScripts,\r\n styles: component.styles,\r\n sourcePath: path,\r\n lazy: false,\r\n };\r\n\r\n // Define the web component\r\n logger.log(`Component ${name} registered successfully`);\r\n await this.#defineWebComponent(name, useShadowDOM);\r\n } catch (error) {\r\n logRegistrationError(name, path, error as Error);\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Defines a lazy-loading placeholder component\r\n * @param name - Component name\r\n * @param path - Component path\r\n * @param useShadowDOM - Whether to use Shadow DOM\r\n */\r\n #defineLazyPlaceholder(\r\n name: string,\r\n path: string,\r\n useShadowDOM: boolean\r\n ): void {\r\n const self = this;\r\n\r\n class LazyPlaceholder extends HTMLElement {\r\n private loaded = false;\r\n private observer: IntersectionObserver | null = null;\r\n\r\n constructor() {\r\n super();\r\n\r\n // Show a minimal loading indicator\r\n if (useShadowDOM) {\r\n this.attachShadow({ mode: \"open\" });\r\n if (this.shadowRoot) {\r\n this.shadowRoot.innerHTML = `\r\n <style>\r\n :host { display: block; min-height: 1px; }\r\n </style>\r\n `;\r\n }\r\n }\r\n }\r\n\r\n connectedCallback() {\r\n if (this.loaded) return;\r\n\r\n // Check if 'eager' attribute is present - if so, load immediately\r\n if (this.hasAttribute(\"eager\")) {\r\n this.loaded = true;\r\n this.loadComponent();\r\n return;\r\n }\r\n\r\n // Set up intersection observer for lazy loading\r\n this.observer = new IntersectionObserver(\r\n (entries) => {\r\n entries.forEach((entry) => {\r\n if (entry.isIntersecting && !this.loaded) {\r\n this.loaded = true;\r\n this.loadComponent();\r\n }\r\n });\r\n },\r\n {\r\n rootMargin: \"50px\", // Load 50px before entering viewport\r\n }\r\n );\r\n\r\n this.observer.observe(this);\r\n }\r\n\r\n disconnectedCallback() {\r\n if (this.observer) {\r\n this.observer.disconnect();\r\n this.observer = null;\r\n }\r\n }\r\n\r\n async loadComponent() {\r\n try {\r\n logger.log(`Lazy loading component: ${name}`);\r\n\r\n // Store reference to this placeholder element\r\n const placeholder = this;\r\n const parent = this.parentNode;\r\n const nextSibling = this.nextSibling;\r\n\r\n if (!parent) {\r\n logParseError(`Placeholder for ${name} has no parent node`, {\r\n componentName: name,\r\n componentPath: path,\r\n });\r\n return;\r\n }\r\n\r\n // Fetch and parse the component\r\n const source = await fetchComponentSource(path);\r\n const component = await parseComponent(source!, name);\r\n\r\n logger.log(`Component ${name} parsed successfully`);\r\n\r\n self.components[name] = {\r\n tagName: name,\r\n template: component.template,\r\n scripts: component.scripts,\r\n externalScripts: component.externalScripts,\r\n styles: component.styles,\r\n sourcePath: path,\r\n lazy: true,\r\n };\r\n\r\n // Create a unique temporary name for the real component\r\n const tempName = `${name}-real`;\r\n\r\n logger.log(`Defining real component with temp name: ${tempName}`);\r\n\r\n // Store original name and temporarily use temp name\r\n const originalTagName = self.components[name].tagName;\r\n self.components[name].tagName = tempName;\r\n\r\n // Import and define the real component with temp name\r\n const { defineWebComponent } = await import(\"./webcomponent\");\r\n defineWebComponent(self.components[name], useShadowDOM);\r\n\r\n logger.log(`Real component ${tempName} defined`);\r\n\r\n // Restore original tag name\r\n self.components[name].tagName = originalTagName;\r\n\r\n // Create instance of the real component\r\n const realComponent = document.createElement(tempName);\r\n\r\n logger.log(`Created real component instance: ${tempName}`);\r\n\r\n // Copy attributes from placeholder to real component\r\n Array.from(placeholder.attributes).forEach((attr) => {\r\n realComponent.setAttribute(attr.name, attr.value);\r\n });\r\n\r\n // Copy child nodes (slot content)\r\n while (placeholder.firstChild) {\r\n realComponent.appendChild(placeholder.firstChild);\r\n }\r\n\r\n // Replace placeholder in DOM\r\n if (nextSibling) {\r\n parent.insertBefore(realComponent, nextSibling);\r\n logger.log(`Inserted real component before next sibling`);\r\n } else {\r\n parent.appendChild(realComponent);\r\n logger.log(`Appended real component to parent`);\r\n }\r\n\r\n parent.removeChild(placeholder);\r\n logger.log(`Removed placeholder element`);\r\n\r\n self.lazyComponents.delete(name);\r\n logger.log(`Component ${name} lazy-loaded successfully`);\r\n } catch (error) {\r\n logRegistrationError(name, path, error as Error);\r\n }\r\n }\r\n }\r\n\r\n // Define the placeholder component\r\n if (!customElements.get(name)) {\r\n customElements.define(name, LazyPlaceholder);\r\n }\r\n }\r\n\r\n /**\r\n * Defines the web component using the webcomponent module\r\n * @param name - Component name\r\n * @param useShadowDOM - Whether to use Shadow DOM\r\n */\r\n async #defineWebComponent(\r\n name: string,\r\n useShadowDOM: boolean\r\n ): Promise<void> {\r\n const { defineWebComponent } = await import(\"./webcomponent\");\r\n\r\n // safety check\r\n if (this.components[name]) {\r\n defineWebComponent(this.components[name], useShadowDOM);\r\n }\r\n }\r\n}\r\n\r\nexport const ladrillos = new Ladrillos();\r\n","/**\r\n * Global Event Bus for component-to-component communication\r\n * Allows components to emit events and listen to events from other components\r\n */\r\n\r\nimport { logger } from \"../utils/logger\";\r\n\r\ntype EventCallback = (data?: any) => void | Promise<void>;\r\ntype EventListeners = Map<string, Set<EventCallback>>;\r\n\r\nclass EventBus {\r\n private listeners: EventListeners = new Map();\r\n\r\n /**\r\n * Emit an event with optional data\r\n * @param eventName - The name of the event to emit\r\n * @param data - Optional data to pass to listeners\r\n * @returns Promise that resolves when all listeners have been called\r\n */\r\n emit(eventName: string, data?: any): Promise<void> {\r\n // Also dispatch as a native DOM CustomEvent so document.addEventListener works\r\n const customEvent = new CustomEvent(eventName, {\r\n detail: data,\r\n bubbles: true,\r\n composed: true,\r\n });\r\n document.dispatchEvent(customEvent);\r\n\r\n const callbacks = this.listeners.get(eventName);\r\n\r\n if (!callbacks || callbacks.size === 0) {\r\n // No listeners, resolve immediately\r\n return Promise.resolve();\r\n }\r\n\r\n // Execute all callbacks and collect promises\r\n const promises: Promise<void>[] = [];\r\n\r\n callbacks.forEach((callback) => {\r\n try {\r\n const result = callback(data);\r\n // If callback returns a promise, add it to promises array\r\n if (result instanceof Promise) {\r\n promises.push(result);\r\n }\r\n } catch (error) {\r\n logger.error(\r\n `⚠️ Event Bus Error: Failed to execute listener for \"${eventName}\"`\r\n );\r\n logger.error(` Error details: ${(error as Error).message}`);\r\n promises.push(Promise.reject(error));\r\n }\r\n });\r\n\r\n // If any callbacks returned promises, wait for all of them\r\n if (promises.length > 0) {\r\n return Promise.all(promises).then(() => undefined);\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Listen to an event\r\n * @param eventName - The name of the event to listen for\r\n * @param callback - Function to call when event is emitted\r\n * @returns Function to remove the listener\r\n */\r\n listen(eventName: string, callback: EventCallback): () => void {\r\n if (!this.listeners.has(eventName)) {\r\n this.listeners.set(eventName, new Set());\r\n }\r\n\r\n this.listeners.get(eventName)!.add(callback);\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n this.off(eventName, callback);\r\n };\r\n }\r\n\r\n /**\r\n * Remove a specific event listener\r\n * @param eventName - The name of the event\r\n * @param callback - The callback to remove\r\n */\r\n off(eventName: string, callback: EventCallback): void {\r\n const callbacks = this.listeners.get(eventName);\r\n if (callbacks) {\r\n callbacks.delete(callback);\r\n // Clean up empty sets\r\n if (callbacks.size === 0) {\r\n this.listeners.delete(eventName);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove all listeners for an event, or all listeners if no event specified\r\n * @param eventName - Optional event name to clear listeners for\r\n */\r\n clear(eventName?: string): void {\r\n if (eventName) {\r\n this.listeners.delete(eventName);\r\n } else {\r\n this.listeners.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Get count of listeners for an event\r\n * @param eventName - The event name\r\n * @returns Number of listeners\r\n */\r\n listenerCount(eventName: string): number {\r\n return this.listeners.get(eventName)?.size ?? 0;\r\n }\r\n}\r\n\r\n// Export singleton instance\r\nexport const eventBus = new EventBus();\r\n","import { ladrillos } from \"./core/main.js\";\r\nimport { eventBus } from \"./core/eventBus.js\";\r\nimport { ComponentRegistration } from \"./types/LadrilloTypes.js\";\r\n\r\ndeclare global {\r\n interface Window {\r\n ladrillosjs: {\r\n registerComponent: typeof registerComponent;\r\n registerComponents: typeof registerComponents;\r\n };\r\n $listen: typeof $listen;\r\n $emit: typeof $emit;\r\n $querySelector: typeof $querySelector;\r\n $querySelectorAll: typeof $querySelectorAll;\r\n $reactive: typeof $reactive;\r\n $setState: typeof $setState;\r\n $getState: typeof $getState;\r\n }\r\n}\r\n\r\nexport const registerComponent = (\r\n name: string,\r\n path: string,\r\n useShadowDOM?: boolean,\r\n lazy?: boolean\r\n) => ladrillos.registerComponent(name, path, useShadowDOM, lazy);\r\n\r\nexport const registerComponents = async (\r\n components: ComponentRegistration[]\r\n): Promise<void> => {\r\n await Promise.all(\r\n components.map(({ name, path, useShadowDOM, lazy }) =>\r\n ladrillos.registerComponent(name, path, useShadowDOM, lazy)\r\n )\r\n );\r\n};\r\n\r\n// Event bus helper functions\r\nexport const $listen = (event: string, callback: (data?: any) => void) => {\r\n return eventBus.listen(event, callback);\r\n};\r\n\r\nexport const $emit = (event: string, data?: any) => {\r\n eventBus.emit(event, data);\r\n};\r\n\r\n// Component context management\r\n// Maps script URLs to their component contexts for persistent association\r\nconst scriptContextMap = new Map<\r\n string,\r\n { shadowRoot?: ShadowRoot; element?: HTMLElement }\r\n>();\r\nconst activeContext: { shadowRoot?: ShadowRoot; element?: HTMLElement } | null =\r\n null;\r\n\r\n/**\r\n * Internal: Set component context for a script\r\n * Called by the framework when loading scripts from components\r\n */\r\nexport const __setComponentContext = (\r\n shadowRoot?: ShadowRoot,\r\n element?: HTMLElement\r\n) => {\r\n // Store in the global registry by component tag name\r\n if (element) {\r\n const tagName = element.tagName.toLowerCase();\r\n if (!(window as any).__ladrilloContexts) {\r\n (window as any).__ladrilloContexts = new Map();\r\n }\r\n (window as any).__ladrilloContexts.set(tagName, { shadowRoot, element });\r\n }\r\n};\r\n\r\n/**\r\n * Internal: Get component context for the current script\r\n */\r\nconst getComponentContext = () => {\r\n const registry = (window as any).__ladrilloContexts as Map<string, any>;\r\n if (registry && registry.size > 0) {\r\n // For now, return the last registered context\r\n // TODO: In the future, we could track which script belongs to which component\r\n const contexts = Array.from(registry.values());\r\n return contexts[contexts.length - 1];\r\n }\r\n return null;\r\n};\r\n\r\n/**\r\n * Get the component's reactive state\r\n * Returns a Proxy that allows direct property access to component.state\r\n * @returns Proxy to component state or empty object if no component context\r\n */\r\nexport const $getState = (): any => {\r\n const ctx = getComponentContext();\r\n if (ctx && ctx.element) {\r\n return (ctx.element as any).state || {};\r\n }\r\n return {};\r\n};\r\n\r\n/**\r\n * Set component state\r\n * @param updates - Object with state updates\r\n */\r\nexport const $setState = (updates: any) => {\r\n const ctx = getComponentContext();\r\n if (ctx && ctx.setState) {\r\n ctx.setState(updates);\r\n }\r\n};\r\n\r\n/**\r\n * Creates a reactive variable that automatically updates the component when changed.\r\n * For use in ES module scripts with the bind attribute.\r\n * @param name - The variable name (must match the binding in the template)\r\n * @param initialValue - The initial value\r\n * @returns A setter function to update the value\r\n *\r\n * @example\r\n * ```javascript\r\n * import { $reactive } from 'ladrillosjs';\r\n *\r\n * // In your module script:\r\n * const setBeers = $reactive('beers', 'loading...');\r\n *\r\n * // Later, update it:\r\n * setBeers('<card>...</card>');\r\n * ```\r\n */\r\nexport const $reactive = <T = any>(\r\n name: string,\r\n initialValue: T\r\n): ((value: T) => void) => {\r\n // Initialize the state\r\n $setState({ [name]: initialValue });\r\n\r\n // Return a setter function\r\n return (value: T) => {\r\n $setState({ [name]: value });\r\n };\r\n};\r\n\r\n// DOM query helpers with smart component context detection\r\n// Automatically searches within component context when appropriate\r\nexport const $querySelector = (\r\n selector: string,\r\n root?: Element | Document | ShadowRoot\r\n): Element | null => {\r\n if (root) {\r\n return root.querySelector(selector);\r\n }\r\n\r\n // Try to get component context\r\n const ctx = getComponentContext();\r\n if (ctx) {\r\n const searchRoot = ctx.shadowRoot || ctx.element;\r\n if (searchRoot) {\r\n const result = searchRoot.querySelector(selector);\r\n if (result) return result;\r\n }\r\n }\r\n\r\n // Fallback to document\r\n return document.querySelector(selector);\r\n};\r\n\r\nexport const $querySelectorAll = (\r\n selector: string,\r\n root?: Element | Document | ShadowRoot\r\n): NodeListOf<Element> => {\r\n if (root) {\r\n return root.querySelectorAll(selector);\r\n }\r\n\r\n // Try to get component context\r\n const ctx = getComponentContext();\r\n if (ctx) {\r\n const searchRoot = ctx.shadowRoot || ctx.element;\r\n if (searchRoot) {\r\n const result = searchRoot.querySelectorAll(selector);\r\n if (result.length > 0) return result;\r\n }\r\n }\r\n\r\n // Fallback to document\r\n return document.querySelectorAll(selector);\r\n};\r\n\r\n// for a browser‑global via <script src=\"…ladrillosjs.js\"></script>\r\nif (typeof window !== \"undefined\") {\r\n window.ladrillosjs = {\r\n registerComponent,\r\n registerComponents,\r\n };\r\n\r\n // Expose helper functions globally for non-module scripts\r\n window.$listen = $listen;\r\n window.$emit = $emit;\r\n window.$querySelector = $querySelector;\r\n window.$querySelectorAll = $querySelectorAll;\r\n window.$reactive = $reactive;\r\n window.$setState = $setState;\r\n window.$getState = $getState;\r\n}\r\n"],"names":["isDevelopment","e","logger","message","args","formatErrorMessage","context","parts","logBindingError","expression","error","errorMessage","__spreadProps","__spreadValues","logEventHandlerError","eventType","handlerCode","logConditionalError","condition","logLoopError","loopExpression","logRegistrationError","componentName","componentPath","logFetchError","url","logParseError","logScriptError","logTwoWayBindingError","createErrorContext","component","additionalContext","_a","cache","maxCacheSize","getCached","path","cached","setCache","content","firstKey","fetchComponentSource","__async","response","text","safeFetch","res","err","REGEX_PATTERNS","parser","parseComponent","source","name","doc","parseComponentHTML","scripts","externalScripts","extractScripts","styles","extractStyles","template","isDevServerScript","src","pattern","_b","el","isExternal","extractCSSFromResponse","viteMatch","exportMatch","style","styleElements","element","cssContent","styleEl","css","_Ladrillos_instances","defineLazyPlaceholder_fn","defineWebComponent_fn","Ladrillos","__privateAdd","useShadowDOM","lazy","__privateMethod","self","LazyPlaceholder","entries","entry","placeholder","parent","nextSibling","tempName","originalTagName","defineWebComponent","realComponent","attr","ladrillos","EventBus","eventName","data","customEvent","callbacks","promises","callback","result","eventBus","registerComponent","registerComponents","components","$listen","event","$emit","__setComponentContext","shadowRoot","tagName","getComponentContext","registry","contexts","$getState","ctx","$setState","updates","$reactive","initialValue","value","$querySelector","selector","root","searchRoot","$querySelectorAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,IAAgB,MAAe;AACnC,MAAI;AACF,WAAQ;AAAA,EACV,SAAQC,GAAA;AACN,WAAO,QAAQ,IAAI,aAAa;AAAA,EAClC;AACF,GAEaC,IAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,IA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