ladrillosjs 2.0.0-beta.2.2 → 2.0.0-beta.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/main.d.ts +5 -1
- package/dist/index-DmNz8gcU.mjs +580 -0
- package/dist/index-DmNz8gcU.mjs.map +1 -0
- package/dist/index-t-QQBc-6.js +19 -0
- package/dist/index-t-QQBc-6.js.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-UsabEy9d.mjs → webcomponent-CC0mzBGb.mjs} +322 -290
- package/dist/webcomponent-CC0mzBGb.mjs.map +1 -0
- package/dist/webcomponent-DoE_UClU.js +79 -0
- package/dist/webcomponent-DoE_UClU.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-CMmTngHq.js +0 -8
- package/dist/index-CMmTngHq.js.map +0 -1
- package/dist/index-CrzikOU3.mjs +0 -361
- package/dist/index-CrzikOU3.mjs.map +0 -1
- package/dist/webcomponent-BJpmLRdd.js +0 -79
- package/dist/webcomponent-BJpmLRdd.js.map +0 -1
- package/dist/webcomponent-UsabEy9d.mjs.map +0 -1
package/dist/core/main.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ import { LadrillosComponent } from "../types/LadrilloTypes";
|
|
|
2
2
|
declare class Ladrillos {
|
|
3
3
|
#private;
|
|
4
4
|
components: Record<string, LadrillosComponent>;
|
|
5
|
+
private lazyComponents;
|
|
6
|
+
private intersectionObserver;
|
|
7
|
+
private lazyLoadingInProgress;
|
|
8
|
+
private lazyComponentsLoaded;
|
|
5
9
|
constructor();
|
|
6
|
-
registerComponent(name: string, path: string, useShadowDOM?: boolean): Promise<void>;
|
|
10
|
+
registerComponent(name: string, path: string, useShadowDOM?: boolean, lazy?: boolean): Promise<void>;
|
|
7
11
|
}
|
|
8
12
|
export declare const ladrillos: Ladrillos;
|
|
9
13
|
export {};
|
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
var q = Object.defineProperty, I = Object.defineProperties;
|
|
2
|
+
var B = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var j = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var k = (t) => {
|
|
6
|
+
throw TypeError(t);
|
|
7
|
+
};
|
|
8
|
+
var P = (t, e, r) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e) => {
|
|
9
|
+
for (var r in e || (e = {}))
|
|
10
|
+
j.call(e, r) && P(t, r, e[r]);
|
|
11
|
+
if (v)
|
|
12
|
+
for (var r of v(e))
|
|
13
|
+
W.call(e, r) && P(t, r, e[r]);
|
|
14
|
+
return t;
|
|
15
|
+
}, f = (t, e) => I(t, B(e));
|
|
16
|
+
var D = (t, e, r) => e.has(t) || k("Cannot " + r);
|
|
17
|
+
var z = (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 $ = (t, e, r) => (D(t, e, "access private method"), r);
|
|
19
|
+
var p = (t, e, r) => new Promise((s, o) => {
|
|
20
|
+
var i = (c) => {
|
|
21
|
+
try {
|
|
22
|
+
a(r.next(c));
|
|
23
|
+
} catch (d) {
|
|
24
|
+
o(d);
|
|
25
|
+
}
|
|
26
|
+
}, l = (c) => {
|
|
27
|
+
try {
|
|
28
|
+
a(r.throw(c));
|
|
29
|
+
} catch (d) {
|
|
30
|
+
o(d);
|
|
31
|
+
}
|
|
32
|
+
}, a = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, l);
|
|
33
|
+
a((r = r.apply(t, e)).next());
|
|
34
|
+
});
|
|
35
|
+
const L = () => {
|
|
36
|
+
try {
|
|
37
|
+
return !1;
|
|
38
|
+
} catch (t) {
|
|
39
|
+
return process.env.NODE_ENV === "development";
|
|
40
|
+
}
|
|
41
|
+
}, n = {
|
|
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
|
+
L() && 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
|
+
L() && console.warn(t, ...e);
|
|
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
|
+
}, pe = (t, e, r) => {
|
|
77
|
+
const s = g(
|
|
78
|
+
"⚠️ Binding Error: Failed to evaluate expression",
|
|
79
|
+
f(h({}, r), {
|
|
80
|
+
expression: t,
|
|
81
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "Template binding expression"
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
85
|
+
}, ue = (t, e, r, s) => {
|
|
86
|
+
const o = g(
|
|
87
|
+
"⚠️ Event Handler Error: Failed to execute handler",
|
|
88
|
+
f(h({}, s), {
|
|
89
|
+
eventType: t,
|
|
90
|
+
expression: e,
|
|
91
|
+
lineHint: (s == null ? void 0 : s.lineHint) || `on${t} handler`
|
|
92
|
+
})
|
|
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(
|
|
97
|
+
"⚠️ Conditional Error: Failed to evaluate condition",
|
|
98
|
+
f(h({}, r), {
|
|
99
|
+
expression: t,
|
|
100
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "$if/$else-if condition"
|
|
101
|
+
})
|
|
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(
|
|
106
|
+
"⚠️ Loop Error: Failed to process loop",
|
|
107
|
+
f(h({}, r), {
|
|
108
|
+
expression: t,
|
|
109
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "$for loop expression"
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
113
|
+
}, _ = (t, e, r) => {
|
|
114
|
+
const s = g(
|
|
115
|
+
"⚠️ Registration Error: Failed to register component",
|
|
116
|
+
{
|
|
117
|
+
componentName: t,
|
|
118
|
+
componentPath: e
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
n.error(s), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
|
|
122
|
+
}, H = (t, e, r) => {
|
|
123
|
+
const s = g(
|
|
124
|
+
"⚠️ Fetch Error: Failed to load resource",
|
|
125
|
+
f(h({}, r), {
|
|
126
|
+
componentPath: t
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
n.error(s), n.error(` Error details: ${e.message}`);
|
|
130
|
+
}, M = (t, e) => {
|
|
131
|
+
const r = g(
|
|
132
|
+
`⚠️ Parse Error: ${t}`,
|
|
133
|
+
e
|
|
134
|
+
);
|
|
135
|
+
n.error(r);
|
|
136
|
+
}, fe = (t, e) => {
|
|
137
|
+
const r = g(
|
|
138
|
+
"⚠️ Script Error: Failed to execute component script",
|
|
139
|
+
e
|
|
140
|
+
);
|
|
141
|
+
n.error(r), n.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
|
|
142
|
+
}, me = (t, e, r) => {
|
|
143
|
+
const s = g(
|
|
144
|
+
"⚠️ Two-Way Binding Error: Failed to setup binding",
|
|
145
|
+
f(h({}, r), {
|
|
146
|
+
expression: t,
|
|
147
|
+
lineHint: (r == null ? void 0 : r.lineHint) || "$model binding"
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
n.error(s), n.error(` Error details: ${e.message}`);
|
|
151
|
+
}, ye = (t, e) => {
|
|
152
|
+
var r;
|
|
153
|
+
return h({
|
|
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(), K = 25, O = (t) => {
|
|
158
|
+
const e = u.get(t);
|
|
159
|
+
return e && (u.delete(t), u.set(t, e)), e;
|
|
160
|
+
}, G = (t, e) => {
|
|
161
|
+
if (u.has(t))
|
|
162
|
+
u.delete(t);
|
|
163
|
+
else if (u.size >= K) {
|
|
164
|
+
const r = u.keys().next().value;
|
|
165
|
+
r && u.delete(r);
|
|
166
|
+
}
|
|
167
|
+
u.set(t, e);
|
|
168
|
+
}, N = (t) => p(null, null, function* () {
|
|
169
|
+
if (!t)
|
|
170
|
+
throw new Error("Path cannot be null or empty");
|
|
171
|
+
const e = O(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 G(t, s), s;
|
|
181
|
+
} catch (r) {
|
|
182
|
+
H(t, r, { componentPath: t });
|
|
183
|
+
}
|
|
184
|
+
}), J = (t) => p(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 H(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
|
+
}, V = new DOMParser(), x = (t, e) => p(null, null, function* () {
|
|
200
|
+
const r = X(t), { scripts: s, externalScripts: o } = Q(r), i = yield Z(r), l = r.body.innerHTML.trim();
|
|
201
|
+
return {
|
|
202
|
+
tagName: e,
|
|
203
|
+
template: l,
|
|
204
|
+
scripts: s,
|
|
205
|
+
externalScripts: o,
|
|
206
|
+
styles: i
|
|
207
|
+
};
|
|
208
|
+
}), X = (t) => V.parseFromString(
|
|
209
|
+
t.replace(b.comments.html, ""),
|
|
210
|
+
"text/html"
|
|
211
|
+
), Y = (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)), Q = (t) => {
|
|
227
|
+
var s, o;
|
|
228
|
+
const e = [], r = [];
|
|
229
|
+
for (const i of t.querySelectorAll("script")) {
|
|
230
|
+
if (i.src) {
|
|
231
|
+
if (Y(i.src)) {
|
|
232
|
+
i.remove();
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const l = i.hasAttribute("external");
|
|
236
|
+
r.push({
|
|
237
|
+
src: i.getAttribute("src") || i.src,
|
|
238
|
+
// Use getAttribute to preserve relative paths
|
|
239
|
+
type: (s = i.type) != null ? s : null,
|
|
240
|
+
external: l
|
|
241
|
+
});
|
|
242
|
+
} else if (i.textContent) {
|
|
243
|
+
let l = i.textContent.trim();
|
|
244
|
+
l = l.replace(b.comments.js, "").trim(), e.push({
|
|
245
|
+
content: l,
|
|
246
|
+
type: (o = i.type) != null ? o : null
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
i.remove();
|
|
250
|
+
}
|
|
251
|
+
return { scripts: e, externalScripts: r };
|
|
252
|
+
}, U = (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") ? (n.warn(
|
|
262
|
+
"CSS file returned JavaScript module format. CSS may not load correctly."
|
|
263
|
+
), "") : t;
|
|
264
|
+
}, Z = (t) => p(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 i = yield J(s.href), l = U(i);
|
|
270
|
+
l && (e += `
|
|
271
|
+
` + l);
|
|
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;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
s.remove();
|
|
281
|
+
}
|
|
282
|
+
return e.trim();
|
|
283
|
+
});
|
|
284
|
+
var w, T, A;
|
|
285
|
+
class ee {
|
|
286
|
+
constructor() {
|
|
287
|
+
z(this, w);
|
|
288
|
+
this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null, this.lazyLoadingInProgress = /* @__PURE__ */ new Map(), this.lazyComponentsLoaded = /* @__PURE__ */ new Set();
|
|
289
|
+
}
|
|
290
|
+
registerComponent(e, r, s = !0, o = !1) {
|
|
291
|
+
return p(this, null, function* () {
|
|
292
|
+
if (this.components[e]) {
|
|
293
|
+
n.warn(`Component with name "${e}" is already registered.`);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (o) {
|
|
297
|
+
this.lazyComponents.add(e), $(this, w, T).call(this, e, r, s), n.log(`Component ${e} registered as lazy-loaded`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
try {
|
|
301
|
+
const i = yield N(r), l = yield x(i, 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
|
+
}, n.log(`Component ${e} registered successfully`), yield $(this, w, A).call(this, e, s);
|
|
311
|
+
} catch (i) {
|
|
312
|
+
_(e, r, i);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
w = 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
|
+
T = function(e, r, s) {
|
|
325
|
+
const o = this;
|
|
326
|
+
class i 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 p(this, null, function* () {
|
|
358
|
+
try {
|
|
359
|
+
if (o.lazyComponentsLoaded.has(e)) {
|
|
360
|
+
n.log(
|
|
361
|
+
`Component ${e} already loaded, upgrading placeholder...`
|
|
362
|
+
), this.upgradePlaceholder();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (o.lazyLoadingInProgress.has(e)) {
|
|
366
|
+
n.log(`Component ${e} is already loading, waiting...`), yield o.lazyLoadingInProgress.get(e), this.upgradePlaceholder();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const a = this.performLoad();
|
|
370
|
+
o.lazyLoadingInProgress.set(e, a), yield a, o.lazyLoadingInProgress.delete(e), o.lazyComponentsLoaded.add(e), o.lazyComponents.delete(e), n.log(`Component ${e} lazy-loaded successfully`);
|
|
371
|
+
} catch (a) {
|
|
372
|
+
o.lazyLoadingInProgress.delete(e), _(e, r, a);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
performLoad() {
|
|
377
|
+
return p(this, null, function* () {
|
|
378
|
+
n.log(`Lazy loading component: ${e}`);
|
|
379
|
+
const a = this.parentNode;
|
|
380
|
+
if (this.nextSibling, !a) {
|
|
381
|
+
M(`Placeholder for ${e} has no parent node`, {
|
|
382
|
+
componentName: e,
|
|
383
|
+
componentPath: r
|
|
384
|
+
});
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const c = yield N(r), d = yield x(c, e);
|
|
388
|
+
n.log(`Component ${e} parsed successfully`), o.components[e] = {
|
|
389
|
+
tagName: e,
|
|
390
|
+
template: d.template,
|
|
391
|
+
scripts: d.scripts,
|
|
392
|
+
externalScripts: d.externalScripts,
|
|
393
|
+
styles: d.styles,
|
|
394
|
+
sourcePath: r,
|
|
395
|
+
lazy: !0
|
|
396
|
+
};
|
|
397
|
+
const m = `${e}-real`;
|
|
398
|
+
n.log(`Defining real component with temp name: ${m}`);
|
|
399
|
+
const y = o.components[e].tagName;
|
|
400
|
+
o.components[e].tagName = m;
|
|
401
|
+
const { defineWebComponent: C } = yield import("./webcomponent-CC0mzBGb.mjs");
|
|
402
|
+
C(o.components[e], s), n.log(`Real component ${m} defined`), o.components[e].tagName = y, this.upgradePlaceholder();
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
upgradePlaceholder() {
|
|
406
|
+
const a = this, c = this.parentNode, d = this.nextSibling;
|
|
407
|
+
if (!c) {
|
|
408
|
+
M(`Placeholder for ${e} has no parent node`, {
|
|
409
|
+
componentName: e,
|
|
410
|
+
componentPath: r
|
|
411
|
+
});
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const m = `${e}-real`, y = document.createElement(m);
|
|
415
|
+
for (n.log(`Created real component instance: ${m}`), Array.from(a.attributes).forEach((C) => {
|
|
416
|
+
C.name !== "eager" && y.setAttribute(C.name, C.value);
|
|
417
|
+
}); a.firstChild; )
|
|
418
|
+
y.appendChild(a.firstChild);
|
|
419
|
+
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(a), n.log("Removed placeholder element");
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
customElements.get(e) || customElements.define(e, i);
|
|
423
|
+
}, A = function(e, r) {
|
|
424
|
+
return p(this, null, function* () {
|
|
425
|
+
const { defineWebComponent: s } = yield import("./webcomponent-CC0mzBGb.mjs");
|
|
426
|
+
this.components[e] && s(this.components[e], r);
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
const F = new ee();
|
|
430
|
+
class te {
|
|
431
|
+
constructor() {
|
|
432
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Emit an event with optional data
|
|
436
|
+
* @param eventName - The name of the event to emit
|
|
437
|
+
* @param data - Optional data to pass to listeners
|
|
438
|
+
* @returns Promise that resolves when all listeners have been called
|
|
439
|
+
*/
|
|
440
|
+
emit(e, r) {
|
|
441
|
+
const s = new CustomEvent(e, {
|
|
442
|
+
detail: r,
|
|
443
|
+
bubbles: !0,
|
|
444
|
+
composed: !0
|
|
445
|
+
});
|
|
446
|
+
document.dispatchEvent(s);
|
|
447
|
+
const o = this.listeners.get(e);
|
|
448
|
+
if (!o || o.size === 0)
|
|
449
|
+
return Promise.resolve();
|
|
450
|
+
const i = [];
|
|
451
|
+
return o.forEach((l) => {
|
|
452
|
+
try {
|
|
453
|
+
const a = l(r);
|
|
454
|
+
a instanceof Promise && i.push(a);
|
|
455
|
+
} catch (a) {
|
|
456
|
+
n.error(
|
|
457
|
+
`⚠️ Event Bus Error: Failed to execute listener for "${e}"`
|
|
458
|
+
), n.error(` Error details: ${a.message}`), i.push(Promise.reject(a));
|
|
459
|
+
}
|
|
460
|
+
}), i.length > 0 ? Promise.all(i).then(() => {
|
|
461
|
+
}) : Promise.resolve();
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Listen to an event
|
|
465
|
+
* @param eventName - The name of the event to listen for
|
|
466
|
+
* @param callback - Function to call when event is emitted
|
|
467
|
+
* @returns Function to remove the listener
|
|
468
|
+
*/
|
|
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);
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Remove a specific event listener
|
|
476
|
+
* @param eventName - The name of the event
|
|
477
|
+
* @param callback - The callback to remove
|
|
478
|
+
*/
|
|
479
|
+
off(e, r) {
|
|
480
|
+
const s = this.listeners.get(e);
|
|
481
|
+
s && (s.delete(r), s.size === 0 && this.listeners.delete(e));
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Remove all listeners for an event, or all listeners if no event specified
|
|
485
|
+
* @param eventName - Optional event name to clear listeners for
|
|
486
|
+
*/
|
|
487
|
+
clear(e) {
|
|
488
|
+
e ? this.listeners.delete(e) : this.listeners.clear();
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Get count of listeners for an event
|
|
492
|
+
* @param eventName - The event name
|
|
493
|
+
* @returns Number of listeners
|
|
494
|
+
*/
|
|
495
|
+
listenerCount(e) {
|
|
496
|
+
var r, s;
|
|
497
|
+
return (s = (r = this.listeners.get(e)) == null ? void 0 : r.size) != null ? s : 0;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const R = new te(), re = (t, e, r, s) => F.registerComponent(t, e, r, s), se = (t) => p(null, null, function* () {
|
|
501
|
+
yield Promise.all(
|
|
502
|
+
t.map(
|
|
503
|
+
({ name: e, path: r, useShadowDOM: s, lazy: o }) => F.registerComponent(e, r, s, o)
|
|
504
|
+
)
|
|
505
|
+
);
|
|
506
|
+
}), oe = (t, e) => R.listen(t, e), ne = (t, e) => {
|
|
507
|
+
R.emit(t, e);
|
|
508
|
+
}, we = (t, e) => {
|
|
509
|
+
if (e) {
|
|
510
|
+
const r = e.tagName.toLowerCase();
|
|
511
|
+
window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(r, { shadowRoot: t, element: e });
|
|
512
|
+
}
|
|
513
|
+
}, E = () => {
|
|
514
|
+
const t = window.__ladrilloContexts;
|
|
515
|
+
if (t && t.size > 0) {
|
|
516
|
+
const e = Array.from(t.values());
|
|
517
|
+
return e[e.length - 1];
|
|
518
|
+
}
|
|
519
|
+
return null;
|
|
520
|
+
}, ie = () => {
|
|
521
|
+
const t = E();
|
|
522
|
+
return t && t.element ? t.element.state || {} : {};
|
|
523
|
+
}, S = (t) => {
|
|
524
|
+
const e = E();
|
|
525
|
+
e && e.setState && e.setState(t);
|
|
526
|
+
}, ae = (t, e) => (S({ [t]: e }), (r) => {
|
|
527
|
+
S({ [t]: r });
|
|
528
|
+
}), le = (t, e) => {
|
|
529
|
+
if (e)
|
|
530
|
+
return e.querySelector(t);
|
|
531
|
+
const r = E();
|
|
532
|
+
if (r) {
|
|
533
|
+
const s = r.shadowRoot || r.element;
|
|
534
|
+
if (s) {
|
|
535
|
+
const o = s.querySelector(t);
|
|
536
|
+
if (o) return o;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return document.querySelector(t);
|
|
540
|
+
}, ce = (t, e) => {
|
|
541
|
+
if (e)
|
|
542
|
+
return e.querySelectorAll(t);
|
|
543
|
+
const r = E();
|
|
544
|
+
if (r) {
|
|
545
|
+
const s = r.shadowRoot || r.element;
|
|
546
|
+
if (s) {
|
|
547
|
+
const o = s.querySelectorAll(t);
|
|
548
|
+
if (o.length > 0) return o;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return document.querySelectorAll(t);
|
|
552
|
+
};
|
|
553
|
+
typeof window != "undefined" && (window.ladrillosjs = {
|
|
554
|
+
registerComponent: re,
|
|
555
|
+
registerComponents: se
|
|
556
|
+
}, window.$listen = oe, window.$emit = ne, window.$querySelector = le, window.$querySelectorAll = ce, window.$reactive = ae, window.$setState = S, window.$getState = ie);
|
|
557
|
+
export {
|
|
558
|
+
oe as $,
|
|
559
|
+
b as R,
|
|
560
|
+
we as _,
|
|
561
|
+
pe as a,
|
|
562
|
+
he as b,
|
|
563
|
+
ye as c,
|
|
564
|
+
ge as d,
|
|
565
|
+
ue as e,
|
|
566
|
+
R as f,
|
|
567
|
+
fe as g,
|
|
568
|
+
n as h,
|
|
569
|
+
me as i,
|
|
570
|
+
se as j,
|
|
571
|
+
ne as k,
|
|
572
|
+
M as l,
|
|
573
|
+
ie as m,
|
|
574
|
+
S as n,
|
|
575
|
+
ae as o,
|
|
576
|
+
le as p,
|
|
577
|
+
ce as q,
|
|
578
|
+
re as r
|
|
579
|
+
};
|
|
580
|
+
//# sourceMappingURL=index-DmNz8gcU.mjs.map
|