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.
- package/dist/core/componentParser.d.ts +9 -2
- package/dist/{index-BcPgsuUl.mjs → index-D3ODIub3.mjs} +222 -226
- package/dist/index-D3ODIub3.mjs.map +1 -0
- package/dist/index-jXCF8DaA.js +68 -0
- package/dist/index-jXCF8DaA.js.map +1 -0
- package/dist/index.d.ts +0 -94
- package/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +10 -14
- package/dist/ladrillosjs.umd.js +16 -16
- package/dist/ladrillosjs.umd.js.map +1 -1
- package/dist/{webcomponent-BbbpAvoT.js → webcomponent-BV2KhfNU.js} +2 -2
- package/dist/{webcomponent-BbbpAvoT.js.map → webcomponent-BV2KhfNU.js.map} +1 -1
- package/dist/{webcomponent-Dt-f2pQx.mjs → webcomponent-Crc7LIeF.mjs} +2 -2
- package/dist/{webcomponent-Dt-f2pQx.mjs.map → webcomponent-Crc7LIeF.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BcPgsuUl.mjs.map +0 -1
- package/dist/index-FW6ZH_yR.js +0 -68
- package/dist/index-FW6ZH_yR.js.map +0 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var q = Object.defineProperty, W = Object.defineProperties;
|
|
2
|
+
var B = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var P = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
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,
|
|
9
|
-
for (var
|
|
10
|
-
|
|
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
|
|
13
|
-
|
|
12
|
+
for (var s of P(e))
|
|
13
|
+
O.call(e, s) && _(t, s, e[s]);
|
|
14
14
|
return t;
|
|
15
|
-
}, w = (t, e) =>
|
|
16
|
-
var
|
|
17
|
-
var L = (t, e,
|
|
18
|
-
var
|
|
19
|
-
var p = (t, e,
|
|
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(
|
|
22
|
+
l(s.next(c));
|
|
23
23
|
} catch (d) {
|
|
24
24
|
o(d);
|
|
25
25
|
}
|
|
26
26
|
}, a = (c) => {
|
|
27
27
|
try {
|
|
28
|
-
l(
|
|
28
|
+
l(s.throw(c));
|
|
29
29
|
} catch (d) {
|
|
30
30
|
o(d);
|
|
31
31
|
}
|
|
32
|
-
}, l = (c) => c.done ?
|
|
33
|
-
l((
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
64
|
+
j() && console.warn(t, ...e);
|
|
65
65
|
}
|
|
66
|
-
},
|
|
67
|
-
const
|
|
68
|
-
return e && (e.componentName &&
|
|
69
|
-
Component: <${e.componentName}>`), e.componentPath &&
|
|
70
|
-
File: ${e.componentPath}`), e.expression &&
|
|
71
|
-
Expression: ${e.expression}`), e.attributeName &&
|
|
72
|
-
Attribute: ${e.attributeName}`), e.eventType &&
|
|
73
|
-
Event: ${e.eventType}`), e.elementTag &&
|
|
74
|
-
Element: <${e.elementTag}>`), e.lineHint &&
|
|
75
|
-
Location: ${e.lineHint}`)),
|
|
76
|
-
},
|
|
77
|
-
const
|
|
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({},
|
|
79
|
+
w(h({}, s), {
|
|
80
80
|
expression: t,
|
|
81
|
-
lineHint: (
|
|
81
|
+
lineHint: (s == null ? void 0 : s.lineHint) || "Template binding expression"
|
|
82
82
|
})
|
|
83
83
|
);
|
|
84
|
-
n.error(
|
|
85
|
-
}, fe = (t, e,
|
|
86
|
-
const o =
|
|
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({},
|
|
88
|
+
w(h({}, r), {
|
|
89
89
|
eventType: t,
|
|
90
90
|
expression: e,
|
|
91
|
-
lineHint: (
|
|
91
|
+
lineHint: (r == null ? void 0 : r.lineHint) || `on${t} handler`
|
|
92
92
|
})
|
|
93
93
|
);
|
|
94
|
-
n.error(o), n.error(` Error details: ${
|
|
95
|
-
},
|
|
96
|
-
const
|
|
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({},
|
|
98
|
+
w(h({}, s), {
|
|
99
99
|
expression: t,
|
|
100
|
-
lineHint: (
|
|
100
|
+
lineHint: (s == null ? void 0 : s.lineHint) || "$if/$else-if condition"
|
|
101
101
|
})
|
|
102
102
|
);
|
|
103
|
-
n.error(
|
|
104
|
-
},
|
|
105
|
-
const
|
|
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({},
|
|
107
|
+
w(h({}, s), {
|
|
108
108
|
expression: t,
|
|
109
|
-
lineHint: (
|
|
109
|
+
lineHint: (s == null ? void 0 : s.lineHint) || "$for loop expression"
|
|
110
110
|
})
|
|
111
111
|
);
|
|
112
|
-
n.error(
|
|
113
|
-
},
|
|
114
|
-
const
|
|
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(
|
|
122
|
-
}, N = (t, e,
|
|
123
|
-
const
|
|
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({},
|
|
125
|
+
w(h({}, s), {
|
|
126
126
|
componentPath: t
|
|
127
127
|
})
|
|
128
128
|
);
|
|
129
|
-
n.error(
|
|
129
|
+
n.error(r), n.error(` Error details: ${e.message}`);
|
|
130
130
|
}, x = (t, e) => {
|
|
131
|
-
const
|
|
131
|
+
const s = f(
|
|
132
132
|
`⚠️ Parse Error: ${t}`,
|
|
133
133
|
e
|
|
134
134
|
);
|
|
135
|
-
n.error(
|
|
136
|
-
},
|
|
137
|
-
const
|
|
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(
|
|
142
|
-
},
|
|
143
|
-
const
|
|
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({},
|
|
145
|
+
w(h({}, s), {
|
|
146
146
|
expression: t,
|
|
147
|
-
lineHint: (
|
|
147
|
+
lineHint: (s == null ? void 0 : s.lineHint) || "$model binding"
|
|
148
148
|
})
|
|
149
149
|
);
|
|
150
|
-
n.error(
|
|
150
|
+
n.error(r), n.error(` Error details: ${e.message}`);
|
|
151
151
|
}, Ce = (t, e) => {
|
|
152
|
-
var
|
|
152
|
+
var s;
|
|
153
153
|
return h({
|
|
154
|
-
componentName: (t == null ? void 0 : t.tagName) || ((
|
|
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
|
-
},
|
|
158
|
-
const e =
|
|
159
|
-
return 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 (
|
|
162
|
-
|
|
163
|
-
else if (
|
|
164
|
-
const
|
|
165
|
-
|
|
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
|
-
|
|
168
|
-
},
|
|
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
|
|
175
|
-
if (!
|
|
174
|
+
const s = yield fetch(t);
|
|
175
|
+
if (!s.ok)
|
|
176
176
|
throw new Error(
|
|
177
|
-
`Failed to fetch component from ${t}: ${
|
|
177
|
+
`Failed to fetch component from ${t}: ${s.statusText}`
|
|
178
178
|
);
|
|
179
|
-
const
|
|
180
|
-
return Q(t,
|
|
181
|
-
} catch (
|
|
182
|
-
N(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(),
|
|
200
|
-
const r = Y(t), { scripts:
|
|
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:
|
|
204
|
-
scripts:
|
|
205
|
-
externalScripts:
|
|
206
|
-
styles:
|
|
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((
|
|
227
|
-
var
|
|
228
|
-
const e = [],
|
|
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
|
-
|
|
236
|
+
s.push({
|
|
237
237
|
src: i.getAttribute("src") || i.src,
|
|
238
238
|
// Use getAttribute to preserve relative paths
|
|
239
|
-
type: (
|
|
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:
|
|
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
|
|
259
|
-
return
|
|
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
|
-
},
|
|
265
|
-
let
|
|
280
|
+
}, se = (t, e) => p(null, null, function* () {
|
|
281
|
+
let s = "";
|
|
266
282
|
const r = t.querySelectorAll("style, link[rel='stylesheet']");
|
|
267
|
-
for (const
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
298
|
+
o.remove();
|
|
281
299
|
}
|
|
282
|
-
return
|
|
300
|
+
return s.trim();
|
|
283
301
|
});
|
|
284
|
-
var
|
|
285
|
-
class
|
|
302
|
+
var S, T, H;
|
|
303
|
+
class re {
|
|
286
304
|
constructor() {
|
|
287
|
-
L(this,
|
|
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,
|
|
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),
|
|
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
|
|
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:
|
|
326
|
+
sourcePath: s,
|
|
309
327
|
lazy: !1
|
|
310
|
-
}, n.log(`Component ${e} registered successfully`), yield
|
|
328
|
+
}, n.log(`Component ${e} registered successfully`), yield $(this, S, H).call(this, e, r);
|
|
311
329
|
} catch (i) {
|
|
312
|
-
|
|
330
|
+
z(e, s, i);
|
|
313
331
|
return;
|
|
314
332
|
}
|
|
315
333
|
});
|
|
316
334
|
}
|
|
317
335
|
}
|
|
318
|
-
|
|
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,
|
|
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,
|
|
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),
|
|
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:
|
|
401
|
+
componentPath: s
|
|
384
402
|
});
|
|
385
403
|
return;
|
|
386
404
|
}
|
|
387
|
-
const c = yield
|
|
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:
|
|
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:
|
|
402
|
-
|
|
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:
|
|
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((
|
|
416
|
-
|
|
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,
|
|
441
|
+
}, H = function(e, s) {
|
|
424
442
|
return p(this, null, function* () {
|
|
425
|
-
const { defineWebComponent:
|
|
426
|
-
this.components[e] &&
|
|
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
|
|
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,
|
|
441
|
-
const
|
|
442
|
-
detail:
|
|
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(
|
|
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(
|
|
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,
|
|
470
|
-
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(
|
|
471
|
-
this.off(e,
|
|
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,
|
|
480
|
-
const
|
|
481
|
-
|
|
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
|
|
497
|
-
return (
|
|
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
|
|
505
|
-
const
|
|
506
|
-
if (
|
|
507
|
-
yield I(
|
|
508
|
-
else if (
|
|
509
|
-
let o = yield u.readFile(
|
|
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(
|
|
589
|
+
), yield u.writeFile(r, o);
|
|
572
590
|
}
|
|
573
591
|
}
|
|
574
592
|
});
|
|
575
593
|
}
|
|
576
|
-
function
|
|
594
|
+
function ve(t = {}) {
|
|
577
595
|
const {
|
|
578
596
|
src: e = "components",
|
|
579
|
-
dest:
|
|
580
|
-
copyOnDev:
|
|
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:
|
|
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",
|
|
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,
|
|
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:
|
|
632
|
+
({ name: e, path: s, useShadowDOM: r, lazy: o }) => A.registerComponent(e, s, r, o)
|
|
615
633
|
)
|
|
616
634
|
);
|
|
617
|
-
}),
|
|
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
|
|
622
|
-
window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(
|
|
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
|
-
},
|
|
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
|
-
},
|
|
638
|
-
E({ [t]:
|
|
639
|
-
}),
|
|
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
|
|
643
|
-
if (
|
|
644
|
-
const
|
|
645
|
-
if (
|
|
646
|
-
const o =
|
|
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
|
-
},
|
|
669
|
+
}, ue = (t, e) => {
|
|
652
670
|
if (e)
|
|
653
671
|
return e.querySelectorAll(t);
|
|
654
|
-
const
|
|
655
|
-
if (
|
|
656
|
-
const
|
|
657
|
-
if (
|
|
658
|
-
const o =
|
|
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:
|
|
667
|
-
}, window.$listen =
|
|
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
|
-
|
|
687
|
+
le as $,
|
|
688
688
|
b as R,
|
|
689
689
|
$e as _,
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
ge as a,
|
|
691
|
+
we as b,
|
|
692
692
|
Ce as c,
|
|
693
|
-
|
|
693
|
+
he as d,
|
|
694
694
|
fe as e,
|
|
695
695
|
R as f,
|
|
696
|
-
|
|
696
|
+
ye as g,
|
|
697
697
|
n as h,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
698
|
+
Se as i,
|
|
699
|
+
ie as j,
|
|
700
|
+
ae as k,
|
|
701
701
|
x as l,
|
|
702
|
-
|
|
702
|
+
ce as m,
|
|
703
703
|
E as n,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
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-
|
|
710
|
+
//# sourceMappingURL=index-D3ODIub3.mjs.map
|