ladrillosjs 2.0.0-beta.4.2 → 2.0.0-beta.4.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.
@@ -1,38 +1,38 @@
1
- var D = Object.defineProperty, B = Object.defineProperties;
2
- var W = Object.getOwnPropertyDescriptors;
1
+ var q = Object.defineProperty, W = Object.defineProperties;
2
+ var B = Object.getOwnPropertyDescriptors;
3
3
  var P = Object.getOwnPropertySymbols;
4
- var O = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable;
4
+ var D = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
5
5
  var k = (t) => {
6
6
  throw TypeError(t);
7
7
  };
8
- var _ = (t, e, r) => e in t ? D(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e) => {
9
- for (var r in e || (e = {}))
10
- O.call(e, r) && _(t, r, e[r]);
8
+ var _ = (t, e, s) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, h = (t, e) => {
9
+ for (var s in e || (e = {}))
10
+ D.call(e, s) && _(t, s, e[s]);
11
11
  if (P)
12
- for (var r of P(e))
13
- J.call(e, r) && _(t, r, e[r]);
12
+ for (var s of P(e))
13
+ O.call(e, s) && _(t, s, e[s]);
14
14
  return t;
15
- }, w = (t, e) => B(t, W(e));
16
- var K = (t, e, r) => e.has(t) || k("Cannot " + r);
17
- var L = (t, e, r) => e.has(t) ? k("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r);
18
- var v = (t, e, r) => (K(t, e, "access private method"), r);
19
- var p = (t, e, r) => new Promise((s, o) => {
15
+ }, w = (t, e) => W(t, B(e));
16
+ var J = (t, e, s) => e.has(t) || k("Cannot " + s);
17
+ var L = (t, e, s) => e.has(t) ? k("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s);
18
+ var $ = (t, e, s) => (J(t, e, "access private method"), s);
19
+ var p = (t, e, s) => new Promise((r, o) => {
20
20
  var i = (c) => {
21
21
  try {
22
- l(r.next(c));
22
+ l(s.next(c));
23
23
  } catch (d) {
24
24
  o(d);
25
25
  }
26
26
  }, a = (c) => {
27
27
  try {
28
- l(r.throw(c));
28
+ l(s.throw(c));
29
29
  } catch (d) {
30
30
  o(d);
31
31
  }
32
- }, l = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, a);
33
- l((r = r.apply(t, e)).next());
32
+ }, l = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(i, a);
33
+ l((s = s.apply(t, e)).next());
34
34
  });
35
- const z = () => {
35
+ const j = () => {
36
36
  try {
37
37
  return !1;
38
38
  } catch (t) {
@@ -45,7 +45,7 @@ const z = () => {
45
45
  * @param args - Additional arguments to log
46
46
  */
47
47
  log(t, ...e) {
48
- z() && console.log(t, ...e);
48
+ j() && console.log(t, ...e);
49
49
  },
50
50
  /**
51
51
  * Log an error (always logs in both dev and production)
@@ -61,125 +61,125 @@ const z = () => {
61
61
  * @param args - Additional arguments to log
62
62
  */
63
63
  warn(t, ...e) {
64
- z() && console.warn(t, ...e);
64
+ j() && console.warn(t, ...e);
65
65
  }
66
- }, g = (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
- }, me = (t, e, r) => {
77
- const s = g(
66
+ }, f = (t, e) => {
67
+ const s = [t];
68
+ return e && (e.componentName && s.push(`
69
+ Component: <${e.componentName}>`), e.componentPath && s.push(`
70
+ File: ${e.componentPath}`), e.expression && s.push(`
71
+ Expression: ${e.expression}`), e.attributeName && s.push(`
72
+ Attribute: ${e.attributeName}`), e.eventType && s.push(`
73
+ Event: ${e.eventType}`), e.elementTag && s.push(`
74
+ Element: <${e.elementTag}>`), e.lineHint && s.push(`
75
+ Location: ${e.lineHint}`)), s.join("");
76
+ }, ge = (t, e, s) => {
77
+ const r = f(
78
78
  "⚠️ Binding Error: Failed to evaluate expression",
79
- w(h({}, r), {
79
+ w(h({}, s), {
80
80
  expression: t,
81
- lineHint: (r == null ? void 0 : r.lineHint) || "Template binding expression"
81
+ lineHint: (s == null ? void 0 : s.lineHint) || "Template binding expression"
82
82
  })
83
83
  );
84
- n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
85
- }, fe = (t, e, r, s) => {
86
- const o = g(
84
+ n.error(r), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
85
+ }, fe = (t, e, s, r) => {
86
+ const o = f(
87
87
  "⚠️ Event Handler Error: Failed to execute handler",
88
- w(h({}, s), {
88
+ w(h({}, r), {
89
89
  eventType: t,
90
90
  expression: e,
91
- lineHint: (s == null ? void 0 : s.lineHint) || `on${t} handler`
91
+ lineHint: (r == null ? void 0 : r.lineHint) || `on${t} handler`
92
92
  })
93
93
  );
94
- n.error(o), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
95
- }, ge = (t, e, r) => {
96
- const s = g(
94
+ n.error(o), n.error(` Error details: ${s.message}`), s.stack && console.debug(" Stack trace:", s.stack);
95
+ }, he = (t, e, s) => {
96
+ const r = f(
97
97
  "⚠️ Conditional Error: Failed to evaluate condition",
98
- w(h({}, r), {
98
+ w(h({}, s), {
99
99
  expression: t,
100
- lineHint: (r == null ? void 0 : r.lineHint) || "$if/$else-if condition"
100
+ lineHint: (s == null ? void 0 : s.lineHint) || "$if/$else-if condition"
101
101
  })
102
102
  );
103
- n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
104
- }, he = (t, e, r) => {
105
- const s = g(
103
+ n.error(r), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
104
+ }, we = (t, e, s) => {
105
+ const r = f(
106
106
  "⚠️ Loop Error: Failed to process loop",
107
- w(h({}, r), {
107
+ w(h({}, s), {
108
108
  expression: t,
109
- lineHint: (r == null ? void 0 : r.lineHint) || "$for loop expression"
109
+ lineHint: (s == null ? void 0 : s.lineHint) || "$for loop expression"
110
110
  })
111
111
  );
112
- n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
113
- }, j = (t, e, r) => {
114
- const s = g(
112
+ n.error(r), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
113
+ }, z = (t, e, s) => {
114
+ const r = f(
115
115
  "⚠️ Registration Error: Failed to register component",
116
116
  {
117
117
  componentName: t,
118
118
  componentPath: e
119
119
  }
120
120
  );
121
- n.error(s), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
122
- }, N = (t, e, r) => {
123
- const s = g(
121
+ n.error(r), n.error(` Error details: ${s.message}`), s.stack && console.debug(" Stack trace:", s.stack);
122
+ }, N = (t, e, s) => {
123
+ const r = f(
124
124
  "⚠️ Fetch Error: Failed to load resource",
125
- w(h({}, r), {
125
+ w(h({}, s), {
126
126
  componentPath: t
127
127
  })
128
128
  );
129
- n.error(s), n.error(` Error details: ${e.message}`);
129
+ n.error(r), n.error(` Error details: ${e.message}`);
130
130
  }, x = (t, e) => {
131
- const r = g(
131
+ const s = f(
132
132
  `⚠️ Parse Error: ${t}`,
133
133
  e
134
134
  );
135
- n.error(r);
136
- }, we = (t, e) => {
137
- const r = g(
135
+ n.error(s);
136
+ }, ye = (t, e) => {
137
+ const s = f(
138
138
  "⚠️ Script Error: Failed to execute component script",
139
139
  e
140
140
  );
141
- n.error(r), n.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
142
- }, ye = (t, e, r) => {
143
- const s = g(
141
+ n.error(s), n.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
142
+ }, Se = (t, e, s) => {
143
+ const r = f(
144
144
  "⚠️ Two-Way Binding Error: Failed to setup binding",
145
- w(h({}, r), {
145
+ w(h({}, s), {
146
146
  expression: t,
147
- lineHint: (r == null ? void 0 : r.lineHint) || "$model binding"
147
+ lineHint: (s == null ? void 0 : s.lineHint) || "$model binding"
148
148
  })
149
149
  );
150
- n.error(s), n.error(` Error details: ${e.message}`);
150
+ n.error(r), n.error(` Error details: ${e.message}`);
151
151
  }, Ce = (t, e) => {
152
- var r;
152
+ var s;
153
153
  return h({
154
- componentName: (t == null ? void 0 : t.tagName) || ((r = t == null ? void 0 : t.constructor) == null ? void 0 : r.name),
154
+ componentName: (t == null ? void 0 : t.tagName) || ((s = t == null ? void 0 : t.constructor) == null ? void 0 : s.name),
155
155
  componentPath: (t == null ? void 0 : t.sourcePath) || (t == null ? void 0 : t._sourcePath)
156
156
  }, e);
157
- }, f = /* @__PURE__ */ new Map(), U = 25, G = (t) => {
158
- const e = f.get(t);
159
- return e && (f.delete(t), f.set(t, e)), e;
157
+ }, g = /* @__PURE__ */ new Map(), K = 25, G = (t) => {
158
+ const e = g.get(t);
159
+ return e && (g.delete(t), g.set(t, e)), e;
160
160
  }, Q = (t, e) => {
161
- if (f.has(t))
162
- f.delete(t);
163
- else if (f.size >= U) {
164
- const r = f.keys().next().value;
165
- r && f.delete(r);
161
+ if (g.has(t))
162
+ g.delete(t);
163
+ else if (g.size >= K) {
164
+ const s = g.keys().next().value;
165
+ s && g.delete(s);
166
166
  }
167
- f.set(t, e);
168
- }, M = (t) => p(null, null, function* () {
167
+ g.set(t, e);
168
+ }, F = (t) => p(null, null, function* () {
169
169
  if (!t)
170
170
  throw new Error("Path cannot be null or empty");
171
171
  const e = G(t);
172
172
  if (e) return e;
173
173
  try {
174
- const r = yield fetch(t);
175
- if (!r.ok)
174
+ const s = yield fetch(t);
175
+ if (!s.ok)
176
176
  throw new Error(
177
- `Failed to fetch component from ${t}: ${r.statusText}`
177
+ `Failed to fetch component from ${t}: ${s.statusText}`
178
178
  );
179
- const s = yield r.text();
180
- return Q(t, s), s;
181
- } catch (r) {
182
- N(t, r, { componentPath: t });
179
+ const r = yield s.text();
180
+ return Q(t, r), r;
181
+ } catch (s) {
182
+ N(t, s, { componentPath: t });
183
183
  }
184
184
  }), V = (t) => p(null, null, function* () {
185
185
  try {
@@ -196,14 +196,14 @@ const z = () => {
196
196
  css: /\/\*[\s\S]*?\*\//g,
197
197
  html: /<!--[\s\S]*?-->/g
198
198
  }
199
- }, X = new DOMParser(), F = (t, e) => p(null, null, function* () {
200
- const r = Y(t), { scripts: s, externalScripts: o } = ee(r), i = yield re(r), a = r.body.innerHTML.trim();
199
+ }, X = new DOMParser(), M = (t, e, s) => p(null, null, function* () {
200
+ const r = Y(t), { scripts: o, externalScripts: i } = U(r), a = yield se(r, s), l = r.body.innerHTML.trim();
201
201
  return {
202
202
  tagName: e,
203
- template: a,
204
- scripts: s,
205
- externalScripts: o,
206
- styles: i
203
+ template: l,
204
+ scripts: o,
205
+ externalScripts: i,
206
+ styles: a
207
207
  };
208
208
  }), Y = (t) => X.parseFromString(
209
209
  t.replace(b.comments.html, ""),
@@ -223,9 +223,9 @@ const z = () => {
223
223
  // Browser Sync
224
224
  "/livereload.js"
225
225
  // LiveReload
226
- ].some((r) => t.includes(r)), ee = (t) => {
227
- var s, o;
228
- const e = [], r = [];
226
+ ].some((s) => t.includes(s)), U = (t) => {
227
+ var r, o;
228
+ const e = [], s = [];
229
229
  for (const i of t.querySelectorAll("script")) {
230
230
  if (i.src) {
231
231
  if (Z(i.src)) {
@@ -233,10 +233,10 @@ const z = () => {
233
233
  continue;
234
234
  }
235
235
  const a = i.hasAttribute("external");
236
- r.push({
236
+ s.push({
237
237
  src: i.getAttribute("src") || i.src,
238
238
  // Use getAttribute to preserve relative paths
239
- type: (s = i.type) != null ? s : null,
239
+ type: (r = i.type) != null ? r : null,
240
240
  external: a
241
241
  });
242
242
  } else if (i.textContent) {
@@ -248,84 +248,102 @@ const z = () => {
248
248
  }
249
249
  i.remove();
250
250
  }
251
- return { scripts: e, externalScripts: r };
251
+ return { scripts: e, externalScripts: s };
252
+ }, ee = (t, e) => {
253
+ if (t.startsWith("http://") || t.startsWith("https://"))
254
+ return t;
255
+ if (t.startsWith("./") || t.startsWith("../")) {
256
+ if (e)
257
+ try {
258
+ const s = e.endsWith("/") ? e : e.substring(0, e.lastIndexOf("/") + 1);
259
+ return new URL(t, s).href;
260
+ } catch (s) {
261
+ return n.warn(
262
+ `Failed to resolve relative CSS path "${t}" from component "${e}"`
263
+ ), t;
264
+ }
265
+ return t;
266
+ }
267
+ return t.startsWith("/") ? t : "/" + t;
252
268
  }, te = (t) => {
253
269
  const e = t.match(/const __vite__css = "((?:[^"\\]|\\.)*)"/);
254
270
  if (e && e[1])
255
271
  return e[1].replace(/\\r\\n/g, `
256
272
  `).replace(/\\n/g, `
257
273
  `).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, `
274
+ const s = t.match(/export\s+default\s+"((?:[^"\\]|\\.)*)"/);
275
+ return s && s[1] ? s[1].replace(/\\r\\n/g, `
260
276
  `).replace(/\\n/g, `
261
277
  `).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : t.includes("import") || t.includes("export") ? (n.warn(
262
278
  "CSS file returned JavaScript module format. CSS may not load correctly."
263
279
  ), "") : t;
264
- }, re = (t) => p(null, null, function* () {
265
- let e = "";
280
+ }, se = (t, e) => p(null, null, function* () {
281
+ let s = "";
266
282
  const r = t.querySelectorAll("style, link[rel='stylesheet']");
267
- for (const s of r) {
268
- if (s.tagName === "LINK") {
269
- const i = yield V(s.href), a = te(i);
270
- a && (e += `
271
- ` + a);
272
- } else if (s.tagName === "STYLE") {
273
- const o = s;
274
- if (o.textContent) {
275
- let i = o.textContent.trim();
276
- i = i.replace(b.comments.css, "").trim(), e += `
277
- ` + i;
283
+ for (const o of r) {
284
+ if (o.tagName === "LINK") {
285
+ const a = o.getAttribute("href");
286
+ if (!a) continue;
287
+ const l = ee(a, e), c = yield V(l), d = te(c);
288
+ d && (s += `
289
+ ` + d);
290
+ } else if (o.tagName === "STYLE") {
291
+ const i = o;
292
+ if (i.textContent) {
293
+ let a = i.textContent.trim();
294
+ a = a.replace(b.comments.css, "").trim(), s += `
295
+ ` + a;
278
296
  }
279
297
  }
280
- s.remove();
298
+ o.remove();
281
299
  }
282
- return e.trim();
300
+ return s.trim();
283
301
  });
284
- var C, T, H;
285
- class se {
302
+ var S, T, H;
303
+ class re {
286
304
  constructor() {
287
- L(this, C);
305
+ L(this, S);
288
306
  this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null, this.lazyLoadingInProgress = /* @__PURE__ */ new Map(), this.lazyComponentsLoaded = /* @__PURE__ */ new Set();
289
307
  }
290
- registerComponent(e, r, s = !0, o = !1) {
308
+ registerComponent(e, s, r = !0, o = !1) {
291
309
  return p(this, null, function* () {
292
310
  if (this.components[e]) {
293
311
  n.warn(`Component with name "${e}" is already registered.`);
294
312
  return;
295
313
  }
296
314
  if (o) {
297
- this.lazyComponents.add(e), v(this, C, T).call(this, e, r, s), n.log(`Component ${e} registered as lazy-loaded`);
315
+ this.lazyComponents.add(e), $(this, S, T).call(this, e, s, r), n.log(`Component ${e} registered as lazy-loaded`);
298
316
  return;
299
317
  }
300
318
  try {
301
- const i = yield M(r), a = yield F(i, e);
319
+ const i = yield F(s), a = yield M(i, e, s);
302
320
  this.components[e] = {
303
321
  tagName: e,
304
322
  template: a.template,
305
323
  scripts: a.scripts,
306
324
  externalScripts: a.externalScripts,
307
325
  styles: a.styles,
308
- sourcePath: r,
326
+ sourcePath: s,
309
327
  lazy: !1
310
- }, n.log(`Component ${e} registered successfully`), yield v(this, C, H).call(this, e, s);
328
+ }, n.log(`Component ${e} registered successfully`), yield $(this, S, H).call(this, e, r);
311
329
  } catch (i) {
312
- j(e, r, i);
330
+ z(e, s, i);
313
331
  return;
314
332
  }
315
333
  });
316
334
  }
317
335
  }
318
- C = new WeakSet(), /**
336
+ S = new WeakSet(), /**
319
337
  * Defines a lazy-loading placeholder component
320
338
  * @param name - Component name
321
339
  * @param path - Component path
322
340
  * @param useShadowDOM - Whether to use Shadow DOM
323
341
  */
324
- T = function(e, r, s) {
342
+ T = function(e, s, r) {
325
343
  const o = this;
326
344
  class i extends HTMLElement {
327
345
  constructor() {
328
- super(), this.loaded = !1, this.observer = null, s && (this.attachShadow({ mode: "open" }), this.shadowRoot && (this.shadowRoot.innerHTML = `
346
+ super(), this.loaded = !1, this.observer = null, r && (this.attachShadow({ mode: "open" }), this.shadowRoot && (this.shadowRoot.innerHTML = `
329
347
  <style>
330
348
  :host { display: block; min-height: 1px; }
331
349
  </style>
@@ -369,7 +387,7 @@ T = function(e, r, s) {
369
387
  const l = this.performLoad();
370
388
  o.lazyLoadingInProgress.set(e, l), yield l, o.lazyLoadingInProgress.delete(e), o.lazyComponentsLoaded.add(e), o.lazyComponents.delete(e), n.log(`Component ${e} lazy-loaded successfully`);
371
389
  } catch (l) {
372
- o.lazyLoadingInProgress.delete(e), j(e, r, l);
390
+ o.lazyLoadingInProgress.delete(e), z(e, s, l);
373
391
  }
374
392
  });
375
393
  }
@@ -380,26 +398,26 @@ T = function(e, r, s) {
380
398
  if (this.nextSibling, !l) {
381
399
  x(`Placeholder for ${e} has no parent node`, {
382
400
  componentName: e,
383
- componentPath: r
401
+ componentPath: s
384
402
  });
385
403
  return;
386
404
  }
387
- const c = yield M(r), d = yield F(c, e);
405
+ const c = yield F(s), d = yield M(c, e, s);
388
406
  n.log(`Component ${e} parsed successfully`), o.components[e] = {
389
407
  tagName: e,
390
408
  template: d.template,
391
409
  scripts: d.scripts,
392
410
  externalScripts: d.externalScripts,
393
411
  styles: d.styles,
394
- sourcePath: r,
412
+ sourcePath: s,
395
413
  lazy: !0
396
414
  };
397
415
  const m = `${e}-real`;
398
416
  n.log(`Defining real component with temp name: ${m}`);
399
417
  const y = o.components[e].tagName;
400
418
  o.components[e].tagName = m;
401
- const { defineWebComponent: S } = yield import("./webcomponent-Dt-f2pQx.mjs");
402
- S(o.components[e], s), n.log(`Real component ${m} defined`), o.components[e].tagName = y, this.upgradePlaceholder();
419
+ const { defineWebComponent: C } = yield import("./webcomponent-Crc7LIeF.mjs");
420
+ C(o.components[e], r), n.log(`Real component ${m} defined`), o.components[e].tagName = y, this.upgradePlaceholder();
403
421
  });
404
422
  }
405
423
  upgradePlaceholder() {
@@ -407,26 +425,26 @@ T = function(e, r, s) {
407
425
  if (!c) {
408
426
  x(`Placeholder for ${e} has no parent node`, {
409
427
  componentName: e,
410
- componentPath: r
428
+ componentPath: s
411
429
  });
412
430
  return;
413
431
  }
414
432
  const m = `${e}-real`, y = document.createElement(m);
415
- for (n.log(`Created real component instance: ${m}`), Array.from(l.attributes).forEach((S) => {
416
- S.name !== "eager" && y.setAttribute(S.name, S.value);
433
+ for (n.log(`Created real component instance: ${m}`), Array.from(l.attributes).forEach((C) => {
434
+ C.name !== "eager" && y.setAttribute(C.name, C.value);
417
435
  }); l.firstChild; )
418
436
  y.appendChild(l.firstChild);
419
437
  d ? (c.insertBefore(y, d), n.log("Inserted real component before next sibling")) : (c.appendChild(y), n.log("Appended real component to parent")), c.removeChild(l), n.log("Removed placeholder element");
420
438
  }
421
439
  }
422
440
  customElements.get(e) || customElements.define(e, i);
423
- }, H = function(e, r) {
441
+ }, H = function(e, s) {
424
442
  return p(this, null, function* () {
425
- const { defineWebComponent: s } = yield import("./webcomponent-Dt-f2pQx.mjs");
426
- this.components[e] && s(this.components[e], r);
443
+ const { defineWebComponent: r } = yield import("./webcomponent-Crc7LIeF.mjs");
444
+ this.components[e] && r(this.components[e], s);
427
445
  });
428
446
  };
429
- const A = new se();
447
+ const A = new re();
430
448
  class oe {
431
449
  constructor() {
432
450
  this.listeners = /* @__PURE__ */ new Map();
@@ -437,20 +455,20 @@ class oe {
437
455
  * @param data - Optional data to pass to listeners
438
456
  * @returns Promise that resolves when all listeners have been called
439
457
  */
440
- emit(e, r) {
441
- const s = new CustomEvent(e, {
442
- detail: r,
458
+ emit(e, s) {
459
+ const r = new CustomEvent(e, {
460
+ detail: s,
443
461
  bubbles: !0,
444
462
  composed: !0
445
463
  });
446
- document.dispatchEvent(s);
464
+ document.dispatchEvent(r);
447
465
  const o = this.listeners.get(e);
448
466
  if (!o || o.size === 0)
449
467
  return Promise.resolve();
450
468
  const i = [];
451
469
  return o.forEach((a) => {
452
470
  try {
453
- const l = a(r);
471
+ const l = a(s);
454
472
  l instanceof Promise && i.push(l);
455
473
  } catch (l) {
456
474
  n.error(
@@ -466,9 +484,9 @@ class oe {
466
484
  * @param callback - Function to call when event is emitted
467
485
  * @returns Function to remove the listener
468
486
  */
469
- listen(e, r) {
470
- return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r), () => {
471
- this.off(e, r);
487
+ listen(e, s) {
488
+ return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(s), () => {
489
+ this.off(e, s);
472
490
  };
473
491
  }
474
492
  /**
@@ -476,9 +494,9 @@ class oe {
476
494
  * @param eventName - The name of the event
477
495
  * @param callback - The callback to remove
478
496
  */
479
- off(e, r) {
480
- const s = this.listeners.get(e);
481
- s && (s.delete(r), s.size === 0 && this.listeners.delete(e));
497
+ off(e, s) {
498
+ const r = this.listeners.get(e);
499
+ r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
482
500
  }
483
501
  /**
484
502
  * Remove all listeners for an event, or all listeners if no event specified
@@ -493,20 +511,20 @@ class oe {
493
511
  * @returns Number of listeners
494
512
  */
495
513
  listenerCount(e) {
496
- var r, s;
497
- return (s = (r = this.listeners.get(e)) == null ? void 0 : r.size) != null ? s : 0;
514
+ var s, r;
515
+ return (r = (s = this.listeners.get(e)) == null ? void 0 : s.size) != null ? r : 0;
498
516
  }
499
517
  }
500
518
  const R = new oe(), u = {};
501
519
  function I(t) {
502
520
  return p(this, null, function* () {
503
521
  const e = yield u.readdir(t, { withFileTypes: !0 });
504
- for (const r of e) {
505
- const s = u.resolve(t, r.name);
506
- if (r.isDirectory())
507
- yield I(s);
508
- else if (r.name.endsWith(".html")) {
509
- let o = yield u.readFile(s, "utf-8");
522
+ for (const s of e) {
523
+ const r = u.resolve(t, s.name);
524
+ if (s.isDirectory())
525
+ yield I(r);
526
+ else if (s.name.endsWith(".html")) {
527
+ let o = yield u.readFile(r, "utf-8");
510
528
  o = o.replace(
511
529
  /<script type="module">([\s\S]*?)<\/script>/g,
512
530
  (i, a) => `<script>
@@ -568,24 +586,24 @@ ${a.replace(
568
586
  }
569
587
  })();
570
588
  <\/script>`
571
- ), yield u.writeFile(s, o);
589
+ ), yield u.writeFile(r, o);
572
590
  }
573
591
  }
574
592
  });
575
593
  }
576
- function Se(t = {}) {
594
+ function ve(t = {}) {
577
595
  const {
578
596
  src: e = "components",
579
- dest: r = "components",
580
- copyOnDev: s = !1,
597
+ dest: s = "components",
598
+ copyOnDev: r = !1,
581
599
  processScripts: o = !0
582
600
  } = t;
583
601
  return {
584
602
  name: "ladrillosjs:copy-components",
585
- apply: s ? "serve" : "build",
603
+ apply: r ? "serve" : "build",
586
604
  generateBundle(a, l) {
587
605
  return p(this, null, function* () {
588
- const c = u.resolve(process.cwd(), e), d = u.resolve(process.cwd(), "dist", r);
606
+ const c = u.resolve(process.cwd(), e), d = u.resolve(process.cwd(), "dist", s);
589
607
  if (!u.existsSync(c)) {
590
608
  console.warn(
591
609
  `[ladrillosjs:copy-components] Source directory not found: ${c}`
@@ -608,54 +626,54 @@ function Se(t = {}) {
608
626
  }
609
627
  };
610
628
  }
611
- const ne = (t, e, r, s) => A.registerComponent(t, e, r, s), q = (t) => p(null, null, function* () {
629
+ const ne = (t, e, s, r) => A.registerComponent(t, e, s, r), ie = (t) => p(null, null, function* () {
612
630
  yield Promise.all(
613
631
  t.map(
614
- ({ name: e, path: r, useShadowDOM: s, lazy: o }) => A.registerComponent(e, r, s, o)
632
+ ({ name: e, path: s, useShadowDOM: r, lazy: o }) => A.registerComponent(e, s, r, o)
615
633
  )
616
634
  );
617
- }), ie = (t, e) => R.listen(t, e), le = (t, e) => {
635
+ }), le = (t, e) => R.listen(t, e), ae = (t, e) => {
618
636
  R.emit(t, e);
619
637
  }, $e = (t, e) => {
620
638
  if (e) {
621
- const r = e.tagName.toLowerCase();
622
- window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(r, { shadowRoot: t, element: e });
639
+ const s = e.tagName.toLowerCase();
640
+ window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(s, { shadowRoot: t, element: e });
623
641
  }
624
- }, $ = () => {
642
+ }, v = () => {
625
643
  const t = window.__ladrilloContexts;
626
644
  if (t && t.size > 0) {
627
645
  const e = Array.from(t.values());
628
646
  return e[e.length - 1];
629
647
  }
630
648
  return null;
631
- }, ae = () => {
632
- const t = $();
649
+ }, ce = () => {
650
+ const t = v();
633
651
  return t && t.element ? t.element.state || {} : {};
634
652
  }, E = (t) => {
635
- const e = $();
653
+ const e = v();
636
654
  e && e.setState && e.setState(t);
637
- }, ce = (t, e) => (E({ [t]: e }), (r) => {
638
- E({ [t]: r });
639
- }), de = (t, e) => {
655
+ }, de = (t, e) => (E({ [t]: e }), (s) => {
656
+ E({ [t]: s });
657
+ }), pe = (t, e) => {
640
658
  if (e)
641
659
  return e.querySelector(t);
642
- const r = $();
643
- if (r) {
644
- const s = r.shadowRoot || r.element;
645
- if (s) {
646
- const o = s.querySelector(t);
660
+ const s = v();
661
+ if (s) {
662
+ const r = s.shadowRoot || s.element;
663
+ if (r) {
664
+ const o = r.querySelector(t);
647
665
  if (o) return o;
648
666
  }
649
667
  }
650
668
  return document.querySelector(t);
651
- }, pe = (t, e) => {
669
+ }, ue = (t, e) => {
652
670
  if (e)
653
671
  return e.querySelectorAll(t);
654
- const r = $();
655
- if (r) {
656
- const s = r.shadowRoot || r.element;
657
- if (s) {
658
- const o = s.querySelectorAll(t);
672
+ const s = v();
673
+ if (s) {
674
+ const r = s.shadowRoot || s.element;
675
+ if (r) {
676
+ const o = r.querySelectorAll(t);
659
677
  if (o.length > 0) return o;
660
678
  }
661
679
  }
@@ -663,52 +681,30 @@ const ne = (t, e, r, s) => A.registerComponent(t, e, r, s), q = (t) => p(null, n
663
681
  };
664
682
  typeof window != "undefined" && (window.ladrillosjs = {
665
683
  registerComponent: ne,
666
- registerComponents: q
667
- }, window.$listen = ie, window.$emit = le, window.$querySelector = de, window.$querySelectorAll = pe, window.$reactive = ce, window.$setState = E, window.$getState = ae);
668
- const ve = (t) => t, Ee = (t) => {
669
- var e, r;
670
- return {
671
- registration: {
672
- name: t.name,
673
- path: t.path,
674
- useShadowDOM: (e = t.useShadowDOM) != null ? e : !0,
675
- lazy: (r = t.lazy) != null ? r : !1
676
- },
677
- interface: t.interface,
678
- version: t.version,
679
- library: t.library
680
- };
681
- }, be = (t, e) => t ? (e && t.tagName.toLowerCase() !== e.toLowerCase() && console.warn(
682
- `Expected element with tag "${e}", got "${t.tagName.toLowerCase()}"`
683
- ), t) : null, Pe = (t, e) => p(null, null, function* () {
684
- return q(t);
685
- });
684
+ registerComponents: ie
685
+ }, window.$listen = le, window.$emit = ae, window.$querySelector = pe, window.$querySelectorAll = ue, window.$reactive = de, window.$setState = E, window.$getState = ce);
686
686
  export {
687
- ie as $,
687
+ le as $,
688
688
  b as R,
689
689
  $e as _,
690
- me as a,
691
- he as b,
690
+ ge as a,
691
+ we as b,
692
692
  Ce as c,
693
- ge as d,
693
+ he as d,
694
694
  fe as e,
695
695
  R as f,
696
- we as g,
696
+ ye as g,
697
697
  n as h,
698
- ye as i,
699
- q as j,
700
- le as k,
698
+ Se as i,
699
+ ie as j,
700
+ ae as k,
701
701
  x as l,
702
- ae as m,
702
+ ce as m,
703
703
  E as n,
704
- ce as o,
705
- de as p,
706
- pe as q,
704
+ de as o,
705
+ pe as p,
706
+ ue as q,
707
707
  ne as r,
708
- ve as s,
709
- Ee as t,
710
- be as u,
711
- Pe as v,
712
- Se as w
708
+ ve as s
713
709
  };
714
- //# sourceMappingURL=index-BcPgsuUl.mjs.map
710
+ //# sourceMappingURL=index-D3ODIub3.mjs.map