ladrillosjs 2.0.0-beta.3.7 → 2.0.0-beta.4.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.
@@ -1,21 +1,21 @@
1
- var I = Object.defineProperty, B = Object.defineProperties;
2
- var D = Object.getOwnPropertyDescriptors;
1
+ var D = Object.defineProperty, B = Object.defineProperties;
2
+ var W = Object.getOwnPropertyDescriptors;
3
3
  var P = Object.getOwnPropertySymbols;
4
- var W = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
4
+ var O = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable;
5
5
  var k = (t) => {
6
6
  throw TypeError(t);
7
7
  };
8
- var _ = (t, e, r) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e) => {
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
9
  for (var r in e || (e = {}))
10
- W.call(e, r) && _(t, r, e[r]);
10
+ O.call(e, r) && _(t, r, e[r]);
11
11
  if (P)
12
12
  for (var r of P(e))
13
- O.call(e, r) && _(t, r, e[r]);
13
+ J.call(e, r) && _(t, r, e[r]);
14
14
  return t;
15
- }, w = (t, e) => B(t, D(e));
16
- var J = (t, e, r) => e.has(t) || k("Cannot " + r);
15
+ }, w = (t, e) => B(t, W(e));
16
+ var K = (t, e, r) => e.has(t) || k("Cannot " + r);
17
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 E = (t, e, r) => (J(t, e, "access private method"), r);
18
+ var v = (t, e, r) => (K(t, e, "access private method"), r);
19
19
  var p = (t, e, r) => new Promise((s, o) => {
20
20
  var i = (c) => {
21
21
  try {
@@ -32,7 +32,7 @@ var p = (t, e, r) => new Promise((s, o) => {
32
32
  }, l = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, a);
33
33
  l((r = r.apply(t, e)).next());
34
34
  });
35
- const j = () => {
35
+ const z = () => {
36
36
  try {
37
37
  return !1;
38
38
  } catch (t) {
@@ -45,7 +45,7 @@ const j = () => {
45
45
  * @param args - Additional arguments to log
46
46
  */
47
47
  log(t, ...e) {
48
- j() && console.log(t, ...e);
48
+ z() && console.log(t, ...e);
49
49
  },
50
50
  /**
51
51
  * Log an error (always logs in both dev and production)
@@ -61,9 +61,9 @@ const j = () => {
61
61
  * @param args - Additional arguments to log
62
62
  */
63
63
  warn(t, ...e) {
64
- j() && console.warn(t, ...e);
64
+ z() && console.warn(t, ...e);
65
65
  }
66
- }, f = (t, e) => {
66
+ }, g = (t, e) => {
67
67
  const r = [t];
68
68
  return e && (e.componentName && r.push(`
69
69
  Component: <${e.componentName}>`), e.componentPath && r.push(`
@@ -74,7 +74,7 @@ const j = () => {
74
74
  Element: <${e.elementTag}>`), e.lineHint && r.push(`
75
75
  Location: ${e.lineHint}`)), r.join("");
76
76
  }, me = (t, e, r) => {
77
- const s = f(
77
+ const s = g(
78
78
  "⚠️ Binding Error: Failed to evaluate expression",
79
79
  w(h({}, r), {
80
80
  expression: t,
@@ -82,8 +82,8 @@ const j = () => {
82
82
  })
83
83
  );
84
84
  n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
85
- }, ge = (t, e, r, s) => {
86
- const o = f(
85
+ }, fe = (t, e, r, s) => {
86
+ const o = g(
87
87
  "⚠️ Event Handler Error: Failed to execute handler",
88
88
  w(h({}, s), {
89
89
  eventType: t,
@@ -92,8 +92,8 @@ const j = () => {
92
92
  })
93
93
  );
94
94
  n.error(o), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
95
- }, fe = (t, e, r) => {
96
- const s = f(
95
+ }, ge = (t, e, r) => {
96
+ const s = g(
97
97
  "⚠️ Conditional Error: Failed to evaluate condition",
98
98
  w(h({}, r), {
99
99
  expression: t,
@@ -102,7 +102,7 @@ const j = () => {
102
102
  );
103
103
  n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
104
104
  }, he = (t, e, r) => {
105
- const s = f(
105
+ const s = g(
106
106
  "⚠️ Loop Error: Failed to process loop",
107
107
  w(h({}, r), {
108
108
  expression: t,
@@ -110,8 +110,8 @@ const j = () => {
110
110
  })
111
111
  );
112
112
  n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
113
- }, z = (t, e, r) => {
114
- const s = f(
113
+ }, j = (t, e, r) => {
114
+ const s = g(
115
115
  "⚠️ Registration Error: Failed to register component",
116
116
  {
117
117
  componentName: t,
@@ -120,7 +120,7 @@ const j = () => {
120
120
  );
121
121
  n.error(s), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
122
122
  }, N = (t, e, r) => {
123
- const s = f(
123
+ const s = g(
124
124
  "⚠️ Fetch Error: Failed to load resource",
125
125
  w(h({}, r), {
126
126
  componentPath: t
@@ -128,19 +128,19 @@ const j = () => {
128
128
  );
129
129
  n.error(s), n.error(` Error details: ${e.message}`);
130
130
  }, x = (t, e) => {
131
- const r = f(
131
+ const r = g(
132
132
  `⚠️ Parse Error: ${t}`,
133
133
  e
134
134
  );
135
135
  n.error(r);
136
136
  }, we = (t, e) => {
137
- const r = f(
137
+ const r = g(
138
138
  "⚠️ Script Error: Failed to execute component script",
139
139
  e
140
140
  );
141
141
  n.error(r), n.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
142
142
  }, ye = (t, e, r) => {
143
- const s = f(
143
+ const s = g(
144
144
  "⚠️ Two-Way Binding Error: Failed to setup binding",
145
145
  w(h({}, r), {
146
146
  expression: t,
@@ -154,21 +154,21 @@ const j = () => {
154
154
  componentName: (t == null ? void 0 : t.tagName) || ((r = t == null ? void 0 : t.constructor) == null ? void 0 : r.name),
155
155
  componentPath: (t == null ? void 0 : t.sourcePath) || (t == null ? void 0 : t._sourcePath)
156
156
  }, e);
157
- }, g = /* @__PURE__ */ new Map(), K = 25, U = (t) => {
158
- const e = g.get(t);
159
- return e && (g.delete(t), g.set(t, e)), e;
160
- }, G = (t, e) => {
161
- if (g.has(t))
162
- g.delete(t);
163
- else if (g.size >= K) {
164
- const r = g.keys().next().value;
165
- r && g.delete(r);
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;
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);
166
166
  }
167
- g.set(t, e);
168
- }, F = (t) => p(null, null, function* () {
167
+ f.set(t, e);
168
+ }, M = (t) => p(null, null, function* () {
169
169
  if (!t)
170
170
  throw new Error("Path cannot be null or empty");
171
- const e = U(t);
171
+ const e = G(t);
172
172
  if (e) return e;
173
173
  try {
174
174
  const r = yield fetch(t);
@@ -177,11 +177,11 @@ const j = () => {
177
177
  `Failed to fetch component from ${t}: ${r.statusText}`
178
178
  );
179
179
  const s = yield r.text();
180
- return G(t, s), s;
180
+ return Q(t, s), s;
181
181
  } catch (r) {
182
182
  N(t, r, { componentPath: t });
183
183
  }
184
- }), Q = (t) => p(null, null, function* () {
184
+ }), V = (t) => p(null, null, function* () {
185
185
  try {
186
186
  const e = yield fetch(t);
187
187
  if (!e.ok) throw new Error(`HTTP ${e.status}`);
@@ -196,8 +196,8 @@ const j = () => {
196
196
  css: /\/\*[\s\S]*?\*\//g,
197
197
  html: /<!--[\s\S]*?-->/g
198
198
  }
199
- }, V = new DOMParser(), M = (t, e) => p(null, null, function* () {
200
- const r = X(t), { scripts: s, externalScripts: o } = Z(r), i = yield te(r), a = r.body.innerHTML.trim();
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();
201
201
  return {
202
202
  tagName: e,
203
203
  template: a,
@@ -205,10 +205,10 @@ const j = () => {
205
205
  externalScripts: o,
206
206
  styles: i
207
207
  };
208
- }), X = (t) => V.parseFromString(
208
+ }), Y = (t) => X.parseFromString(
209
209
  t.replace(b.comments.html, ""),
210
210
  "text/html"
211
- ), Y = (t) => [
211
+ ), Z = (t) => [
212
212
  "/@vite/",
213
213
  // Vite dev client
214
214
  "/__vite",
@@ -223,12 +223,12 @@ const j = () => {
223
223
  // Browser Sync
224
224
  "/livereload.js"
225
225
  // LiveReload
226
- ].some((r) => t.includes(r)), Z = (t) => {
226
+ ].some((r) => t.includes(r)), ee = (t) => {
227
227
  var s, o;
228
228
  const e = [], r = [];
229
229
  for (const i of t.querySelectorAll("script")) {
230
230
  if (i.src) {
231
- if (Y(i.src)) {
231
+ if (Z(i.src)) {
232
232
  i.remove();
233
233
  continue;
234
234
  }
@@ -249,7 +249,7 @@ const j = () => {
249
249
  i.remove();
250
250
  }
251
251
  return { scripts: e, externalScripts: r };
252
- }, ee = (t) => {
252
+ }, te = (t) => {
253
253
  const e = t.match(/const __vite__css = "((?:[^"\\]|\\.)*)"/);
254
254
  if (e && e[1])
255
255
  return e[1].replace(/\\r\\n/g, `
@@ -261,12 +261,12 @@ const j = () => {
261
261
  `).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : t.includes("import") || t.includes("export") ? (n.warn(
262
262
  "CSS file returned JavaScript module format. CSS may not load correctly."
263
263
  ), "") : t;
264
- }, te = (t) => p(null, null, function* () {
264
+ }, re = (t) => p(null, null, function* () {
265
265
  let e = "";
266
266
  const r = t.querySelectorAll("style, link[rel='stylesheet']");
267
267
  for (const s of r) {
268
268
  if (s.tagName === "LINK") {
269
- const i = yield Q(s.href), a = ee(i);
269
+ const i = yield V(s.href), a = te(i);
270
270
  a && (e += `
271
271
  ` + a);
272
272
  } else if (s.tagName === "STYLE") {
@@ -282,7 +282,7 @@ const j = () => {
282
282
  return e.trim();
283
283
  });
284
284
  var C, T, H;
285
- class re {
285
+ class se {
286
286
  constructor() {
287
287
  L(this, C);
288
288
  this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null, this.lazyLoadingInProgress = /* @__PURE__ */ new Map(), this.lazyComponentsLoaded = /* @__PURE__ */ new Set();
@@ -294,11 +294,11 @@ class re {
294
294
  return;
295
295
  }
296
296
  if (o) {
297
- this.lazyComponents.add(e), E(this, C, T).call(this, e, r, s), n.log(`Component ${e} registered as lazy-loaded`);
297
+ this.lazyComponents.add(e), v(this, C, T).call(this, e, r, s), n.log(`Component ${e} registered as lazy-loaded`);
298
298
  return;
299
299
  }
300
300
  try {
301
- const i = yield F(r), a = yield M(i, e);
301
+ const i = yield M(r), a = yield F(i, e);
302
302
  this.components[e] = {
303
303
  tagName: e,
304
304
  template: a.template,
@@ -307,9 +307,9 @@ class re {
307
307
  styles: a.styles,
308
308
  sourcePath: r,
309
309
  lazy: !1
310
- }, n.log(`Component ${e} registered successfully`), yield E(this, C, H).call(this, e, s);
310
+ }, n.log(`Component ${e} registered successfully`), yield v(this, C, H).call(this, e, s);
311
311
  } catch (i) {
312
- z(e, r, i);
312
+ j(e, r, i);
313
313
  return;
314
314
  }
315
315
  });
@@ -369,7 +369,7 @@ T = function(e, r, s) {
369
369
  const l = this.performLoad();
370
370
  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
371
  } catch (l) {
372
- o.lazyLoadingInProgress.delete(e), z(e, r, l);
372
+ o.lazyLoadingInProgress.delete(e), j(e, r, l);
373
373
  }
374
374
  });
375
375
  }
@@ -384,7 +384,7 @@ T = function(e, r, s) {
384
384
  });
385
385
  return;
386
386
  }
387
- const c = yield F(r), d = yield M(c, e);
387
+ const c = yield M(r), d = yield F(c, e);
388
388
  n.log(`Component ${e} parsed successfully`), o.components[e] = {
389
389
  tagName: e,
390
390
  template: d.template,
@@ -398,7 +398,7 @@ T = function(e, r, s) {
398
398
  n.log(`Defining real component with temp name: ${m}`);
399
399
  const y = o.components[e].tagName;
400
400
  o.components[e].tagName = m;
401
- const { defineWebComponent: S } = yield import("./webcomponent-DyrhK3aa.mjs");
401
+ const { defineWebComponent: S } = yield import("./webcomponent-Dt-f2pQx.mjs");
402
402
  S(o.components[e], s), n.log(`Real component ${m} defined`), o.components[e].tagName = y, this.upgradePlaceholder();
403
403
  });
404
404
  }
@@ -422,12 +422,12 @@ T = function(e, r, s) {
422
422
  customElements.get(e) || customElements.define(e, i);
423
423
  }, H = function(e, r) {
424
424
  return p(this, null, function* () {
425
- const { defineWebComponent: s } = yield import("./webcomponent-DyrhK3aa.mjs");
425
+ const { defineWebComponent: s } = yield import("./webcomponent-Dt-f2pQx.mjs");
426
426
  this.components[e] && s(this.components[e], r);
427
427
  });
428
428
  };
429
- const A = new re();
430
- class se {
429
+ const A = new se();
430
+ class oe {
431
431
  constructor() {
432
432
  this.listeners = /* @__PURE__ */ new Map();
433
433
  }
@@ -497,14 +497,14 @@ class se {
497
497
  return (s = (r = this.listeners.get(e)) == null ? void 0 : r.size) != null ? s : 0;
498
498
  }
499
499
  }
500
- const R = new se(), u = {};
501
- function q(t) {
500
+ const R = new oe(), u = {};
501
+ function I(t) {
502
502
  return p(this, null, function* () {
503
503
  const e = yield u.readdir(t, { withFileTypes: !0 });
504
504
  for (const r of e) {
505
505
  const s = u.resolve(t, r.name);
506
506
  if (r.isDirectory())
507
- yield q(s);
507
+ yield I(s);
508
508
  else if (r.name.endsWith(".html")) {
509
509
  let o = yield u.readFile(s, "utf-8");
510
510
  o = o.replace(
@@ -595,7 +595,7 @@ function Se(t = {}) {
595
595
  try {
596
596
  u.existsSync(d) && u.rmSync(d, { recursive: !0, force: !0 }), u.cpSync(c, d, { recursive: !0 }), console.log(
597
597
  `[ladrillosjs:copy-components] Copied components from ${c} to ${d}`
598
- ), o && (yield q(d), console.log(
598
+ ), o && (yield I(d), console.log(
599
599
  `[ladrillosjs:copy-components] Processed component scripts in ${d}`
600
600
  ));
601
601
  } catch (m) {
@@ -608,7 +608,7 @@ function Se(t = {}) {
608
608
  }
609
609
  };
610
610
  }
611
- const oe = (t, e, r, s) => A.registerComponent(t, e, r, s), ne = (t) => p(null, null, function* () {
611
+ const ne = (t, e, r, s) => A.registerComponent(t, e, r, s), q = (t) => p(null, null, function* () {
612
612
  yield Promise.all(
613
613
  t.map(
614
614
  ({ name: e, path: r, useShadowDOM: s, lazy: o }) => A.registerComponent(e, r, s, o)
@@ -631,11 +631,11 @@ const oe = (t, e, r, s) => A.registerComponent(t, e, r, s), ne = (t) => p(null,
631
631
  }, ae = () => {
632
632
  const t = $();
633
633
  return t && t.element ? t.element.state || {} : {};
634
- }, v = (t) => {
634
+ }, E = (t) => {
635
635
  const e = $();
636
636
  e && e.setState && e.setState(t);
637
- }, ce = (t, e) => (v({ [t]: e }), (r) => {
638
- v({ [t]: r });
637
+ }, ce = (t, e) => (E({ [t]: e }), (r) => {
638
+ E({ [t]: r });
639
639
  }), de = (t, e) => {
640
640
  if (e)
641
641
  return e.querySelector(t);
@@ -662,9 +662,27 @@ const oe = (t, e, r, s) => A.registerComponent(t, e, r, s), ne = (t) => p(null,
662
662
  return document.querySelectorAll(t);
663
663
  };
664
664
  typeof window != "undefined" && (window.ladrillosjs = {
665
- registerComponent: oe,
666
- registerComponents: ne
667
- }, window.$listen = ie, window.$emit = le, window.$querySelector = de, window.$querySelectorAll = pe, window.$reactive = ce, window.$setState = v, window.$getState = ae);
665
+ 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
+ });
668
686
  export {
669
687
  ie as $,
670
688
  b as R,
@@ -672,21 +690,25 @@ export {
672
690
  me as a,
673
691
  he as b,
674
692
  Ce as c,
675
- fe as d,
676
- ge as e,
693
+ ge as d,
694
+ fe as e,
677
695
  R as f,
678
696
  we as g,
679
697
  n as h,
680
698
  ye as i,
681
- ne as j,
699
+ q as j,
682
700
  le as k,
683
701
  x as l,
684
702
  ae as m,
685
- v as n,
703
+ E as n,
686
704
  ce as o,
687
705
  de as p,
688
706
  pe as q,
689
- oe as r,
690
- Se as s
707
+ ne as r,
708
+ ve as s,
709
+ Ee as t,
710
+ be as u,
711
+ Pe as v,
712
+ Se as w
691
713
  };
692
- //# sourceMappingURL=index-DZqKSX8_.mjs.map
714
+ //# sourceMappingURL=index-BcPgsuUl.mjs.map