ladrillosjs 2.0.0-beta.3.2 → 2.0.0-beta.3.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/{index-JWdjGiUA.mjs → index-5zcCcI-K.mjs} +3 -3
- package/dist/{index-JWdjGiUA.mjs.map → index-5zcCcI-K.mjs.map} +1 -1
- package/dist/{index-qEisp6n5.js → index-BKUM0X36.js} +2 -2
- package/dist/{index-qEisp6n5.js.map → index-BKUM0X36.js.map} +1 -1
- package/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +1 -1
- package/dist/ladrillosjs.umd.js +20 -20
- package/dist/ladrillosjs.umd.js.map +1 -1
- package/dist/webcomponent-D0F4yQdI.js +79 -0
- package/dist/webcomponent-D0F4yQdI.js.map +1 -0
- package/dist/webcomponent-SSpadLeF.mjs +1154 -0
- package/dist/webcomponent-SSpadLeF.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/webcomponent-B-2Pj2ku.js +0 -79
- package/dist/webcomponent-B-2Pj2ku.js.map +0 -1
- package/dist/webcomponent-DT_kduma.mjs +0 -1059
- package/dist/webcomponent-DT_kduma.mjs.map +0 -1
|
@@ -0,0 +1,1154 @@
|
|
|
1
|
+
var pt = Object.defineProperty, mt = Object.defineProperties;
|
|
2
|
+
var bt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Y = Object.getOwnPropertySymbols;
|
|
4
|
+
var gt = Object.prototype.hasOwnProperty, Et = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var et = (n) => {
|
|
6
|
+
throw TypeError(n);
|
|
7
|
+
};
|
|
8
|
+
var tt = (n, t, e) => t in n ? pt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, k = (n, t) => {
|
|
9
|
+
for (var e in t || (t = {}))
|
|
10
|
+
gt.call(t, e) && tt(n, e, t[e]);
|
|
11
|
+
if (Y)
|
|
12
|
+
for (var e of Y(t))
|
|
13
|
+
Et.call(t, e) && tt(n, e, t[e]);
|
|
14
|
+
return n;
|
|
15
|
+
}, Z = (n, t) => mt(n, bt(t));
|
|
16
|
+
var J = (n, t, e) => t.has(n) || et("Cannot " + e);
|
|
17
|
+
var _ = (n, t, e) => (J(n, t, "read from private field"), e ? e.call(n) : t.get(n)), R = (n, t, e) => t.has(n) ? et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), j = (n, t, e, s) => (J(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), M = (n, t, e) => (J(n, t, "access private method"), e);
|
|
18
|
+
var D = (n, t, e) => new Promise((s, o) => {
|
|
19
|
+
var l = (u) => {
|
|
20
|
+
try {
|
|
21
|
+
r(e.next(u));
|
|
22
|
+
} catch (f) {
|
|
23
|
+
o(f);
|
|
24
|
+
}
|
|
25
|
+
}, i = (u) => {
|
|
26
|
+
try {
|
|
27
|
+
r(e.throw(u));
|
|
28
|
+
} catch (f) {
|
|
29
|
+
o(f);
|
|
30
|
+
}
|
|
31
|
+
}, r = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(l, i);
|
|
32
|
+
r((e = e.apply(n, t)).next());
|
|
33
|
+
});
|
|
34
|
+
import { R as nt, l as wt, a as Q, c as N, b as $t, d as yt, e as vt, f as At, g as xt, h as G, i as _t } from "./index-5zcCcI-K.mjs";
|
|
35
|
+
const St = (n, t, e) => {
|
|
36
|
+
if (!t) return;
|
|
37
|
+
const s = document.createElement("style");
|
|
38
|
+
s.textContent = t, e ? n.appendChild(s) : document.head.appendChild(s);
|
|
39
|
+
}, Ct = (n, t) => {
|
|
40
|
+
n.innerHTML = t;
|
|
41
|
+
const e = Tt(n), s = Lt(n), o = Vt(n), l = Bt(n);
|
|
42
|
+
return { bindings: e, twoWayBindings: s, conditionals: o, loops: l };
|
|
43
|
+
}, st = (n) => {
|
|
44
|
+
const t = [], e = n.match(/\((.*)\)/);
|
|
45
|
+
if (!e) return t;
|
|
46
|
+
const s = e[1].trim();
|
|
47
|
+
return s && s.split(",").map((l) => l.trim()).forEach((l) => {
|
|
48
|
+
if (/^['"]/.test(l) || /^\d+/.test(l)) return;
|
|
49
|
+
const i = l.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
50
|
+
i && t.push(i[1]);
|
|
51
|
+
}), t;
|
|
52
|
+
}, Tt = (n) => {
|
|
53
|
+
const t = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, null), e = [];
|
|
54
|
+
let s;
|
|
55
|
+
const o = (i) => {
|
|
56
|
+
let r = i.parentElement;
|
|
57
|
+
for (; r; ) {
|
|
58
|
+
if (r.hasAttribute && r.hasAttribute("$for"))
|
|
59
|
+
return !0;
|
|
60
|
+
r = r.parentElement;
|
|
61
|
+
}
|
|
62
|
+
return !1;
|
|
63
|
+
};
|
|
64
|
+
for (; s = t.nextNode(); ) {
|
|
65
|
+
if (o(s))
|
|
66
|
+
continue;
|
|
67
|
+
const i = [...s.textContent.matchAll(nt.bindings)];
|
|
68
|
+
if (i.length > 0) {
|
|
69
|
+
const r = s.textContent, u = i.map((f) => {
|
|
70
|
+
const c = f[1].trim(), d = c.includes("(") && c.includes(")"), a = /[+*/%<>=!&|]/.test(c) || // Math or logical operators (excluding hyphen)
|
|
71
|
+
/\s-\s/.test(c), m = /^(!|typeof\s|void\s|delete\s)/.test(c), g = a || m || // Expressions starting with operators
|
|
72
|
+
/\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(c) || // Method calls like name.toLowerCase()
|
|
73
|
+
/\bnew\s+/.test(c) || // Object instantiation like new Date()
|
|
74
|
+
/\b(typeof|instanceof|void|delete)\b/.test(c), p = d ? [c.split("(")[0].trim()] : c.split(".").map((A) => A.trim()), h = d ? st(c) : [];
|
|
75
|
+
return { raw: c, path: p, isFunction: d, isExpression: g, functionArgs: h };
|
|
76
|
+
});
|
|
77
|
+
e.push({ node: s, bindings: u, original: r });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return n.querySelectorAll("*").forEach((i) => {
|
|
81
|
+
if (!(i.hasAttribute("$for") || o(i)))
|
|
82
|
+
for (const r of i.attributes) {
|
|
83
|
+
if (r.name === "$if" || r.name === "$else-if" || r.name === "$else" || r.name === "$bind")
|
|
84
|
+
continue;
|
|
85
|
+
const u = [...r.value.matchAll(nt.bindings)];
|
|
86
|
+
if (u.length > 0) {
|
|
87
|
+
const f = r.value, c = u.map((d) => {
|
|
88
|
+
const a = d[1].trim(), m = a.includes("(") && a.includes(")"), g = /[+*/%<>=!&|]/.test(a) || // Math or logical operators (excluding hyphen)
|
|
89
|
+
/\s-\s/.test(a), p = /^(!|typeof\s|void\s|delete\s)/.test(a), h = g || p || // Expressions starting with operators
|
|
90
|
+
/\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || // Method calls like name.toLowerCase()
|
|
91
|
+
/\bnew\s+/.test(a) || // Object instantiation like new Date()
|
|
92
|
+
/\b(typeof|instanceof|void|delete)\b/.test(a), A = m ? [a.split("(")[0].trim()] : a.split(".").map((L) => L.trim()), w = m ? st(a) : [];
|
|
93
|
+
return { raw: a, path: A, isFunction: m, isExpression: h, functionArgs: w };
|
|
94
|
+
});
|
|
95
|
+
e.push({
|
|
96
|
+
node: i,
|
|
97
|
+
bindings: c,
|
|
98
|
+
original: f,
|
|
99
|
+
isAttribute: !0,
|
|
100
|
+
attributeName: r.name
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}), e;
|
|
105
|
+
}, Lt = (n) => {
|
|
106
|
+
const t = [];
|
|
107
|
+
return n.querySelectorAll("[\\$bind]").forEach((s) => {
|
|
108
|
+
var r;
|
|
109
|
+
const o = s.getAttribute("$bind");
|
|
110
|
+
if (!o) return;
|
|
111
|
+
const l = o.trim(), i = l.split(".").map((u) => u.trim());
|
|
112
|
+
s instanceof HTMLInputElement || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement ? (t.push({
|
|
113
|
+
element: s,
|
|
114
|
+
path: i,
|
|
115
|
+
raw: l,
|
|
116
|
+
isContentEditable: !1,
|
|
117
|
+
initialValue: s.value || ""
|
|
118
|
+
}), s.removeAttribute("$bind")) : s instanceof HTMLElement && s.hasAttribute("contenteditable") && (t.push({
|
|
119
|
+
element: s,
|
|
120
|
+
path: i,
|
|
121
|
+
raw: l,
|
|
122
|
+
isContentEditable: !0,
|
|
123
|
+
initialValue: ((r = s.textContent) == null ? void 0 : r.trim()) || ""
|
|
124
|
+
}), s.removeAttribute("$bind"));
|
|
125
|
+
}), t;
|
|
126
|
+
}, Vt = (n) => {
|
|
127
|
+
const t = [], e = /* @__PURE__ */ new Set();
|
|
128
|
+
return n.querySelectorAll("[\\$if]").forEach((o) => {
|
|
129
|
+
if (e.has(o)) return;
|
|
130
|
+
const l = [];
|
|
131
|
+
let i = o;
|
|
132
|
+
for (; i; ) {
|
|
133
|
+
const r = i.hasAttribute("$if"), u = i.hasAttribute("$else-if"), f = i.hasAttribute("$else");
|
|
134
|
+
if (!r && !u && !f) break;
|
|
135
|
+
e.add(i);
|
|
136
|
+
let c, d = "";
|
|
137
|
+
r ? (c = "if", d = i.getAttribute("$if") || "", i.removeAttribute("$if")) : u ? (c = "else-if", d = i.getAttribute("$else-if") || "", i.removeAttribute("$else-if")) : (c = "else", i.removeAttribute("$else"));
|
|
138
|
+
const a = document.createComment(
|
|
139
|
+
`conditional:${c}:${d}`
|
|
140
|
+
), m = i.parentElement || n, g = i.nextSibling;
|
|
141
|
+
m.insertBefore(a, i);
|
|
142
|
+
const p = {
|
|
143
|
+
element: i,
|
|
144
|
+
condition: d.trim(),
|
|
145
|
+
type: c,
|
|
146
|
+
placeholder: a,
|
|
147
|
+
group: [],
|
|
148
|
+
// Will be set after the group is complete
|
|
149
|
+
originalParent: m,
|
|
150
|
+
nextSibling: g
|
|
151
|
+
};
|
|
152
|
+
l.push(p);
|
|
153
|
+
const h = i.nextElementSibling;
|
|
154
|
+
if (i.remove(), i = h, h && !h.hasAttribute("$else-if") && !h.hasAttribute("$else"))
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
l.forEach((r) => {
|
|
158
|
+
r.group = l;
|
|
159
|
+
}), t.push(l);
|
|
160
|
+
}), t;
|
|
161
|
+
}, kt = (n) => {
|
|
162
|
+
const t = /* @__PURE__ */ new Set();
|
|
163
|
+
return n.forEach((e) => {
|
|
164
|
+
e.forEach((s) => {
|
|
165
|
+
let o = s.condition;
|
|
166
|
+
o = o.replace(/\{([^}]+)\}/g, "$1");
|
|
167
|
+
const l = /\b([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\b/g, i = /* @__PURE__ */ new Set([
|
|
168
|
+
"true",
|
|
169
|
+
"false",
|
|
170
|
+
"null",
|
|
171
|
+
"undefined",
|
|
172
|
+
"typeof",
|
|
173
|
+
"instanceof",
|
|
174
|
+
"new",
|
|
175
|
+
"return",
|
|
176
|
+
"if",
|
|
177
|
+
"else",
|
|
178
|
+
"for",
|
|
179
|
+
"while",
|
|
180
|
+
"do",
|
|
181
|
+
"switch",
|
|
182
|
+
"case",
|
|
183
|
+
"break",
|
|
184
|
+
"continue"
|
|
185
|
+
]);
|
|
186
|
+
let r;
|
|
187
|
+
for (; (r = l.exec(o)) !== null; ) {
|
|
188
|
+
const f = r[1].split(".")[0];
|
|
189
|
+
i.has(f) || t.add(f);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}), t;
|
|
193
|
+
}, Bt = (n) => {
|
|
194
|
+
const t = [];
|
|
195
|
+
return n.querySelectorAll("[\\$for]").forEach((s) => {
|
|
196
|
+
var m;
|
|
197
|
+
const o = s.getAttribute("$for");
|
|
198
|
+
if (!o) return;
|
|
199
|
+
const l = s.getAttribute("$key") || void 0, i = o.match(
|
|
200
|
+
/^\s*(?:\(([^,]+),\s*([^)]+)\)|([^\s]+))\s+(?:in|of)\s+(.+)\s*$/
|
|
201
|
+
);
|
|
202
|
+
if (!i) {
|
|
203
|
+
wt(`Invalid $for expression: "${o}"`, {
|
|
204
|
+
expression: o,
|
|
205
|
+
lineHint: "$for attribute parsing"
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const r = (i[1] || i[3]).trim(), u = (m = i[2]) == null ? void 0 : m.trim(), f = i[4].trim(), c = document.createComment(`loop:${o}`), d = s.parentElement || n;
|
|
210
|
+
d.insertBefore(c, s), s.removeAttribute("$for"), l && s.removeAttribute("$key"), s.remove();
|
|
211
|
+
const a = {
|
|
212
|
+
template: s,
|
|
213
|
+
expression: o,
|
|
214
|
+
itemName: r,
|
|
215
|
+
indexName: u,
|
|
216
|
+
arrayName: f,
|
|
217
|
+
keyAttribute: l,
|
|
218
|
+
placeholder: c,
|
|
219
|
+
renderedElements: [],
|
|
220
|
+
originalParent: d
|
|
221
|
+
};
|
|
222
|
+
t.push(a);
|
|
223
|
+
}), t;
|
|
224
|
+
}, Rt = (n) => {
|
|
225
|
+
const t = /* @__PURE__ */ new Set();
|
|
226
|
+
return n.forEach((e) => {
|
|
227
|
+
const s = e.arrayName.split(".")[0];
|
|
228
|
+
t.add(s);
|
|
229
|
+
}), t;
|
|
230
|
+
}, H = /* @__PURE__ */ new Map(), Ft = 100, z = (n) => {
|
|
231
|
+
const t = H.get(n);
|
|
232
|
+
if (t)
|
|
233
|
+
return H.delete(n), H.set(n, t), t;
|
|
234
|
+
const e = new Function(
|
|
235
|
+
"component",
|
|
236
|
+
`
|
|
237
|
+
const { Date, Array, Math, String, Number, Boolean, Object, JSON, RegExp } = globalThis;
|
|
238
|
+
with(component) {
|
|
239
|
+
return ${n};
|
|
240
|
+
}
|
|
241
|
+
`
|
|
242
|
+
);
|
|
243
|
+
if (H.size >= Ft) {
|
|
244
|
+
const s = H.keys().next().value;
|
|
245
|
+
s && H.delete(s);
|
|
246
|
+
}
|
|
247
|
+
return H.set(n, e), e;
|
|
248
|
+
}, I = (n, t) => t.reduce((e, s) => {
|
|
249
|
+
if (!(e == null || typeof e != "object"))
|
|
250
|
+
return e[s];
|
|
251
|
+
}, n), K = (n, t, e) => {
|
|
252
|
+
if (t.length === 0) return;
|
|
253
|
+
const s = t[t.length - 1], o = t.slice(0, -1);
|
|
254
|
+
let l = n;
|
|
255
|
+
for (const i of o)
|
|
256
|
+
(l[i] === void 0 || l[i] === null) && (l[i] = {}), l = l[i];
|
|
257
|
+
l[s] = e;
|
|
258
|
+
}, ot = (n, t, e) => {
|
|
259
|
+
if (n.length !== 0)
|
|
260
|
+
for (const s of n) {
|
|
261
|
+
let o = s.original, l, i = !1;
|
|
262
|
+
for (const { raw: r, path: u, isFunction: f, isExpression: c } of s.bindings) {
|
|
263
|
+
let d, a = !1;
|
|
264
|
+
if (c || f)
|
|
265
|
+
try {
|
|
266
|
+
d = z(r)(e || t);
|
|
267
|
+
} catch (g) {
|
|
268
|
+
Q(r, g, N(e)), d = void 0, a = !0;
|
|
269
|
+
}
|
|
270
|
+
else
|
|
271
|
+
d = I(t, u), d === void 0 && (a = !0);
|
|
272
|
+
if (a) {
|
|
273
|
+
i = !0;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const m = String(d != null ? d : "");
|
|
277
|
+
l = d, o = o.replace(`{${r}}`, m);
|
|
278
|
+
}
|
|
279
|
+
if (i && s.original, s.node.nodeType === Node.TEXT_NODE) {
|
|
280
|
+
const r = s.node, u = r.parentElement, f = o.trim().startsWith("<") && o.includes(">");
|
|
281
|
+
u && f ? u.innerHTML !== o && (u.innerHTML = o) : r.textContent !== o && (r.textContent = o);
|
|
282
|
+
} else {
|
|
283
|
+
const r = s.node;
|
|
284
|
+
s.isAttribute && s.attributeName && ([
|
|
285
|
+
"disabled",
|
|
286
|
+
"checked",
|
|
287
|
+
"readonly",
|
|
288
|
+
"required",
|
|
289
|
+
"selected",
|
|
290
|
+
"hidden",
|
|
291
|
+
"open",
|
|
292
|
+
"autofocus",
|
|
293
|
+
"autoplay",
|
|
294
|
+
"controls",
|
|
295
|
+
"loop",
|
|
296
|
+
"muted"
|
|
297
|
+
].includes(s.attributeName.toLowerCase()) ? (typeof l == "boolean" ? l : l === "true" || l === "True") ? r.setAttribute(s.attributeName, "") : r.removeAttribute(s.attributeName) : r.setAttribute(s.attributeName, o));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}, Nt = (n, t, e) => {
|
|
301
|
+
if (!n) return !0;
|
|
302
|
+
let s = n.trim();
|
|
303
|
+
s = s.replace(/\{([^}]+)\}/g, "$1");
|
|
304
|
+
try {
|
|
305
|
+
return new Function(
|
|
306
|
+
"context",
|
|
307
|
+
"component",
|
|
308
|
+
`
|
|
309
|
+
with (context) {
|
|
310
|
+
try {
|
|
311
|
+
return Boolean(${s});
|
|
312
|
+
} catch (e) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
`
|
|
317
|
+
)(t, e);
|
|
318
|
+
} catch (o) {
|
|
319
|
+
return yt(
|
|
320
|
+
n,
|
|
321
|
+
o,
|
|
322
|
+
N(e)
|
|
323
|
+
), !1;
|
|
324
|
+
}
|
|
325
|
+
}, at = (n, t) => {
|
|
326
|
+
const e = [
|
|
327
|
+
"click",
|
|
328
|
+
"dblclick",
|
|
329
|
+
"mousedown",
|
|
330
|
+
"mouseup",
|
|
331
|
+
"mouseover",
|
|
332
|
+
"mouseout",
|
|
333
|
+
"mousemove",
|
|
334
|
+
"mouseenter",
|
|
335
|
+
"mouseleave",
|
|
336
|
+
"keydown",
|
|
337
|
+
"keyup",
|
|
338
|
+
"keypress",
|
|
339
|
+
"focus",
|
|
340
|
+
"blur",
|
|
341
|
+
"change",
|
|
342
|
+
"input",
|
|
343
|
+
"submit",
|
|
344
|
+
"reset",
|
|
345
|
+
"scroll",
|
|
346
|
+
"resize",
|
|
347
|
+
"load",
|
|
348
|
+
"unload",
|
|
349
|
+
"touchstart",
|
|
350
|
+
"touchend",
|
|
351
|
+
"touchmove",
|
|
352
|
+
"touchcancel",
|
|
353
|
+
"dragstart",
|
|
354
|
+
"drag",
|
|
355
|
+
"dragend",
|
|
356
|
+
"dragenter",
|
|
357
|
+
"dragover",
|
|
358
|
+
"dragleave",
|
|
359
|
+
"drop"
|
|
360
|
+
];
|
|
361
|
+
[n, ...n.querySelectorAll("*")].forEach((o) => {
|
|
362
|
+
e.forEach((l) => {
|
|
363
|
+
const i = `on${l}`, r = o.getAttribute(i);
|
|
364
|
+
if (r) {
|
|
365
|
+
const u = `__processed_${i}`;
|
|
366
|
+
if (o[u]) return;
|
|
367
|
+
o.removeAttribute(i), o.addEventListener(
|
|
368
|
+
l,
|
|
369
|
+
function(f) {
|
|
370
|
+
try {
|
|
371
|
+
new Function(
|
|
372
|
+
"event",
|
|
373
|
+
"component",
|
|
374
|
+
`
|
|
375
|
+
with(component) {
|
|
376
|
+
${r}
|
|
377
|
+
}
|
|
378
|
+
`
|
|
379
|
+
).call(this, f, t);
|
|
380
|
+
} catch (c) {
|
|
381
|
+
vt(
|
|
382
|
+
l,
|
|
383
|
+
r,
|
|
384
|
+
c,
|
|
385
|
+
N(t, {
|
|
386
|
+
elementTag: o.tagName.toLowerCase()
|
|
387
|
+
})
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
), o[u] = !0;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}, it = (n, t, e) => {
|
|
396
|
+
var s;
|
|
397
|
+
for (const o of n) {
|
|
398
|
+
let l = !1;
|
|
399
|
+
for (const i of o) {
|
|
400
|
+
const { element: r, condition: u, type: f, placeholder: c, originalParent: d } = i;
|
|
401
|
+
let a = !1;
|
|
402
|
+
f === "else" ? a = !l : l || (a = Nt(u, t, e), a && (l = !0));
|
|
403
|
+
const m = r.parentNode !== null;
|
|
404
|
+
a && !m ? ((s = c.parentNode) == null || s.insertBefore(r, c.nextSibling), e && at(r, e)) : !a && m && r.remove();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}, rt = (n, t, e) => {
|
|
408
|
+
var s;
|
|
409
|
+
for (const o of n) {
|
|
410
|
+
const {
|
|
411
|
+
template: l,
|
|
412
|
+
itemName: i,
|
|
413
|
+
indexName: r,
|
|
414
|
+
arrayName: u,
|
|
415
|
+
placeholder: f,
|
|
416
|
+
renderedElements: c
|
|
417
|
+
} = o, d = I(t, u.split("."));
|
|
418
|
+
if (d !== void 0 && !Array.isArray(d)) {
|
|
419
|
+
$t(
|
|
420
|
+
`${i} in ${u}`,
|
|
421
|
+
new Error(`"${u}" is not an array, got: ${typeof d}`),
|
|
422
|
+
N(e, {
|
|
423
|
+
lineHint: "$for loop in template"
|
|
424
|
+
})
|
|
425
|
+
), c.forEach((p) => p.remove()), c.length = 0;
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (!d)
|
|
429
|
+
return;
|
|
430
|
+
const a = d.length, m = c.length;
|
|
431
|
+
if (a === m && a > 0) {
|
|
432
|
+
d.forEach((p, h) => {
|
|
433
|
+
const A = c[h], w = Z(k({}, t), {
|
|
434
|
+
[i]: p
|
|
435
|
+
});
|
|
436
|
+
r && (w[r] = h), ct(A, w, e);
|
|
437
|
+
});
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
a < m && c.splice(a).forEach((h) => h.remove());
|
|
441
|
+
const g = Math.min(a, m);
|
|
442
|
+
for (let p = 0; p < g; p++) {
|
|
443
|
+
const h = d[p], A = c[p], w = Z(k({}, t), {
|
|
444
|
+
[i]: h
|
|
445
|
+
});
|
|
446
|
+
r && (w[r] = p), ct(A, w, e);
|
|
447
|
+
}
|
|
448
|
+
if (a > m) {
|
|
449
|
+
const p = document.createDocumentFragment();
|
|
450
|
+
for (let A = m; A < a; A++) {
|
|
451
|
+
const w = d[A], L = l.cloneNode(!0), O = Z(k({}, t), {
|
|
452
|
+
[i]: w
|
|
453
|
+
});
|
|
454
|
+
r && (O[r] = A), Ot(L, O, e), p.appendChild(L), c.push(L), e && at(L, e);
|
|
455
|
+
}
|
|
456
|
+
const h = c[m - 1] || f;
|
|
457
|
+
(s = h.parentNode) == null || s.insertBefore(p, h.nextSibling);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}, ct = (n, t, e) => {
|
|
461
|
+
const s = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, null);
|
|
462
|
+
let o;
|
|
463
|
+
for (; o = s.nextNode(); ) {
|
|
464
|
+
const i = o.__originalText;
|
|
465
|
+
if (i || o.textContent && o.textContent.includes("{")) {
|
|
466
|
+
const u = i || o.textContent;
|
|
467
|
+
i || (o.__originalText = u);
|
|
468
|
+
let f = u;
|
|
469
|
+
[...u.matchAll(/\{([^}]+)\}/g)].forEach((d) => {
|
|
470
|
+
const a = d[1].trim(), m = a.includes("(") && a.includes(")"), p = /[+*/%<>=!&|]/.test(a) || /\s-\s/.test(a) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || /\bnew\s+/.test(a) || /\b(typeof|instanceof|void|delete)\b/.test(a);
|
|
471
|
+
let h;
|
|
472
|
+
if (p || m)
|
|
473
|
+
try {
|
|
474
|
+
const A = z(a), w = typeof t == "object" && t !== null ? k(k({}, t), e || {}) : e || {};
|
|
475
|
+
h = A(w);
|
|
476
|
+
} catch (A) {
|
|
477
|
+
h = void 0;
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
const A = a.split(".").map((w) => w.trim());
|
|
481
|
+
h = I(t, A);
|
|
482
|
+
}
|
|
483
|
+
h !== void 0 && (f = f.replace(`{${a}}`, String(h != null ? h : "")));
|
|
484
|
+
}), o.textContent !== f && (o.textContent = f);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
[n, ...n.querySelectorAll("*")].forEach((i) => {
|
|
488
|
+
Array.from(i.attributes).forEach((r) => {
|
|
489
|
+
const u = r.__originalValue;
|
|
490
|
+
if (u || r.value.includes("{")) {
|
|
491
|
+
const c = u || r.value;
|
|
492
|
+
u || (r.__originalValue = c);
|
|
493
|
+
let d = c;
|
|
494
|
+
[...c.matchAll(/\{([^}]+)\}/g)].forEach((m) => {
|
|
495
|
+
const g = m[1].trim(), p = g.includes("(") && g.includes(")"), A = /[+*/%<>=!&|]/.test(g) || /\s-\s/.test(g) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(g) || /\bnew\s+/.test(g) || /\b(typeof|instanceof|void|delete)\b/.test(g);
|
|
496
|
+
let w;
|
|
497
|
+
if (A || p)
|
|
498
|
+
try {
|
|
499
|
+
const L = z(g), O = typeof t == "object" && t !== null ? k(k({}, t), e || {}) : e || {};
|
|
500
|
+
w = L(O);
|
|
501
|
+
} catch (L) {
|
|
502
|
+
w = void 0;
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
const L = g.split(".").map((O) => O.trim());
|
|
506
|
+
w = I(t, L);
|
|
507
|
+
}
|
|
508
|
+
w !== void 0 && (d = d.replace(`{${g}}`, String(w != null ? w : "")));
|
|
509
|
+
}), r.value !== d && i.setAttribute(r.name, d);
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
}, Ot = (n, t, e) => {
|
|
514
|
+
const s = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, null);
|
|
515
|
+
let o;
|
|
516
|
+
for (; o = s.nextNode(); )
|
|
517
|
+
if (o.textContent && o.textContent.includes("{")) {
|
|
518
|
+
const i = o.textContent;
|
|
519
|
+
o.__originalText = i;
|
|
520
|
+
let r = i;
|
|
521
|
+
[...i.matchAll(/\{([^}]+)\}/g)].forEach((f) => {
|
|
522
|
+
const c = f[1].trim(), d = c.includes("(") && c.includes(")"), m = /[+*/%<>=!&|]/.test(c) || /\s-\s/.test(c) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(c) || // Method calls
|
|
523
|
+
/\bnew\s+/.test(c) || // Object instantiation like new Date()
|
|
524
|
+
/\b(typeof|instanceof|void|delete)\b/.test(c);
|
|
525
|
+
let g;
|
|
526
|
+
if (m || d)
|
|
527
|
+
try {
|
|
528
|
+
const p = z(c), h = typeof t == "object" && t !== null ? k(k({}, t), e || {}) : e || {};
|
|
529
|
+
g = p(h);
|
|
530
|
+
} catch (p) {
|
|
531
|
+
Q(
|
|
532
|
+
c,
|
|
533
|
+
p,
|
|
534
|
+
N(e, {
|
|
535
|
+
lineHint: "$for loop template binding"
|
|
536
|
+
})
|
|
537
|
+
), g = void 0;
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
const p = c.split(".").map((h) => h.trim());
|
|
541
|
+
g = I(t, p);
|
|
542
|
+
}
|
|
543
|
+
g !== void 0 && (r = r.replace(`{${c}}`, String(g != null ? g : "")));
|
|
544
|
+
}), o.textContent = r;
|
|
545
|
+
}
|
|
546
|
+
[n, ...n.querySelectorAll("*")].forEach((i) => {
|
|
547
|
+
Array.from(i.attributes).forEach((r) => {
|
|
548
|
+
if (r.value.includes("{")) {
|
|
549
|
+
const u = r.value;
|
|
550
|
+
r.__originalValue = u;
|
|
551
|
+
let f = u;
|
|
552
|
+
[...u.matchAll(/\{([^}]+)\}/g)].forEach((d) => {
|
|
553
|
+
const a = d[1].trim(), m = a.includes("(") && a.includes(")"), p = /[+*/%<>=!&|]/.test(a) || /\s-\s/.test(a) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || // Method calls
|
|
554
|
+
/\bnew\s+/.test(a) || // Object instantiation like new Date()
|
|
555
|
+
/\b(typeof|instanceof|void|delete)\b/.test(a);
|
|
556
|
+
let h;
|
|
557
|
+
if (p || m)
|
|
558
|
+
try {
|
|
559
|
+
const A = z(a), w = typeof t == "object" && t !== null ? k(k({}, t), e || {}) : e || {};
|
|
560
|
+
h = A(w);
|
|
561
|
+
} catch (A) {
|
|
562
|
+
Q(
|
|
563
|
+
a,
|
|
564
|
+
A,
|
|
565
|
+
N(e, {
|
|
566
|
+
attributeName: r.name,
|
|
567
|
+
lineHint: "$for loop attribute binding"
|
|
568
|
+
})
|
|
569
|
+
), h = void 0;
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
const A = a.split(".").map((w) => w.trim());
|
|
573
|
+
h = I(t, A);
|
|
574
|
+
}
|
|
575
|
+
h !== void 0 && (f = f.replace(`{${a}}`, String(h != null ? h : "")));
|
|
576
|
+
}), i.setAttribute(r.name, f);
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
}, lt = (n) => n instanceof ShadowRoot ? n.host : n, Wt = (n, t) => {
|
|
581
|
+
const e = /* @__PURE__ */ new Set();
|
|
582
|
+
t.forEach(({ path: o }) => {
|
|
583
|
+
const l = o[0];
|
|
584
|
+
e.add(l);
|
|
585
|
+
});
|
|
586
|
+
const s = [];
|
|
587
|
+
return e.forEach((o) => {
|
|
588
|
+
s.push(`
|
|
589
|
+
if (!Object.getOwnPropertyDescriptor(component, '${o}')) {
|
|
590
|
+
Object.defineProperty(component, '${o}', {
|
|
591
|
+
get() { return this.state.${o}; },
|
|
592
|
+
set(val) { this.state.${o} = val; },
|
|
593
|
+
enumerable: true,
|
|
594
|
+
configurable: true
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
`);
|
|
598
|
+
}), {
|
|
599
|
+
injectedCode: "",
|
|
600
|
+
// No longer needed in script scope
|
|
601
|
+
componentInjections: s.join(`
|
|
602
|
+
`),
|
|
603
|
+
bindVarNames: e
|
|
604
|
+
};
|
|
605
|
+
}, Mt = (n, t, e = /* @__PURE__ */ new Set()) => {
|
|
606
|
+
const s = [], o = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set();
|
|
607
|
+
t.forEach((u) => {
|
|
608
|
+
u.bindings.forEach((f) => {
|
|
609
|
+
const c = f.path[0];
|
|
610
|
+
l.add(c), f.isFunction && f.functionArgs && f.functionArgs.forEach((d) => {
|
|
611
|
+
l.add(d);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
}), e.forEach((u) => {
|
|
615
|
+
l.add(u);
|
|
616
|
+
});
|
|
617
|
+
const i = /(?:const|let|var)\s+(\w+)\s*=\s*([^;]+);?/g;
|
|
618
|
+
let r;
|
|
619
|
+
for (; (r = i.exec(n)) !== null; ) {
|
|
620
|
+
const u = r[1], f = r[2].trim();
|
|
621
|
+
l.has(u) && (s.push(`component.state.${u} = ${u};`), o.set(u, f));
|
|
622
|
+
}
|
|
623
|
+
return { stateBindings: s, boundVarNames: l, defaultValues: o };
|
|
624
|
+
}, Ht = (n, t) => {
|
|
625
|
+
if (t.size === 0) return n;
|
|
626
|
+
let e = n;
|
|
627
|
+
return t.forEach((s) => {
|
|
628
|
+
const o = new RegExp(
|
|
629
|
+
`\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
630
|
+
"g"
|
|
631
|
+
);
|
|
632
|
+
e = e.replace(
|
|
633
|
+
o,
|
|
634
|
+
`component.state.${s}$1 $2`
|
|
635
|
+
);
|
|
636
|
+
const l = new RegExp(
|
|
637
|
+
`(?<!component\\.state\\.)\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
638
|
+
"g"
|
|
639
|
+
);
|
|
640
|
+
e = e.replace(
|
|
641
|
+
l,
|
|
642
|
+
`component.state.${s}$1`
|
|
643
|
+
);
|
|
644
|
+
const i = new RegExp(
|
|
645
|
+
`\\b${s}\\.(\\w+(?:\\.\\w+)*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
646
|
+
"g"
|
|
647
|
+
);
|
|
648
|
+
e = e.replace(
|
|
649
|
+
i,
|
|
650
|
+
`component.state.${s}.$1 $2`
|
|
651
|
+
);
|
|
652
|
+
const r = new RegExp(
|
|
653
|
+
`(?<!component\\.state\\.)(?<!const\\s${s}\\s*=\\s*{[^}]*)\\b${s}\\.(\\w+(?:\\.\\w+)*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
654
|
+
"g"
|
|
655
|
+
);
|
|
656
|
+
e = e.replace(
|
|
657
|
+
r,
|
|
658
|
+
`component.state.${s}.$1`
|
|
659
|
+
);
|
|
660
|
+
const u = new RegExp(
|
|
661
|
+
`(?<!\\.)\\b(\\+\\+|\\-\\-)${s}\\b|\\b${s}(\\+\\+|\\-\\-)`,
|
|
662
|
+
"g"
|
|
663
|
+
);
|
|
664
|
+
e = e.replace(u, (d) => {
|
|
665
|
+
if (d.startsWith("++") || d.startsWith("--"))
|
|
666
|
+
return `${d.substring(0, 2)}component.state.${s}`;
|
|
667
|
+
{
|
|
668
|
+
const a = d.substring(d.length - 2);
|
|
669
|
+
return `component.state.${s}${a}`;
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
const f = new RegExp(
|
|
673
|
+
`(?<!\\.)\\b${s}\\s*(\\+=|\\-=|\\*=|\\/=|%=|\\*\\*=|<<=|>>=|>>>=|&=|\\|=|\\^=)`,
|
|
674
|
+
"g"
|
|
675
|
+
);
|
|
676
|
+
e = e.replace(
|
|
677
|
+
f,
|
|
678
|
+
`component.state.${s}$1`
|
|
679
|
+
);
|
|
680
|
+
const c = new RegExp(
|
|
681
|
+
`(?<!const\\s)(?<!let\\s)(?<!var\\s)(?<!\\.)\\b${s}\\s*=\\s*([^=])`,
|
|
682
|
+
"g"
|
|
683
|
+
);
|
|
684
|
+
e = e.replace(
|
|
685
|
+
c,
|
|
686
|
+
`component.state.${s} = $1`
|
|
687
|
+
);
|
|
688
|
+
}), e;
|
|
689
|
+
}, ut = (n, t, e, s, o, l = /* @__PURE__ */ new Set()) => {
|
|
690
|
+
try {
|
|
691
|
+
const { injectedCode: i, componentInjections: r, bindVarNames: u } = Wt(n, e), f = /function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[\w\s]*)\s*=>/g, c = [];
|
|
692
|
+
let d;
|
|
693
|
+
for (; (d = f.exec(n)) !== null; ) {
|
|
694
|
+
const B = d[1] || d[2];
|
|
695
|
+
B && c.push(B);
|
|
696
|
+
}
|
|
697
|
+
const a = c.map(
|
|
698
|
+
(B) => `component.${B} = typeof ${B} !== 'undefined' ? ${B}.bind(component) : undefined;`
|
|
699
|
+
).join(`
|
|
700
|
+
`), { stateBindings: m, boundVarNames: g, defaultValues: p } = Mt(n, t, l), h = /* @__PURE__ */ new Set([...g, ...u]), A = m.join(`
|
|
701
|
+
`), w = Ht(
|
|
702
|
+
n,
|
|
703
|
+
h
|
|
704
|
+
), L = `
|
|
705
|
+
(function() {
|
|
706
|
+
// Create component scope with direct access to state
|
|
707
|
+
const component = this;
|
|
708
|
+
const $state = component.state;
|
|
709
|
+
|
|
710
|
+
// Define $bind variables on component object for event handler access
|
|
711
|
+
${r}
|
|
712
|
+
|
|
713
|
+
// Provide framework utilities with $ prefix to avoid naming conflicts
|
|
714
|
+
const $setState = (updates) => component.setState(updates);
|
|
715
|
+
|
|
716
|
+
// Event bus methods for component communication
|
|
717
|
+
const $emit = (eventName, data) => arguments[2].emit(eventName, data);
|
|
718
|
+
const $listen = (eventName, callback) => {
|
|
719
|
+
const unsubscribe = arguments[2].listen(eventName, callback);
|
|
720
|
+
// Store unsubscribe function for cleanup on disconnect
|
|
721
|
+
if (!component.__eventUnsubscribers) {
|
|
722
|
+
component.__eventUnsubscribers = [];
|
|
723
|
+
}
|
|
724
|
+
component.__eventUnsubscribers.push(unsubscribe);
|
|
725
|
+
return unsubscribe;
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
// Also attach to component for event handler access
|
|
729
|
+
component.$emit = $emit;
|
|
730
|
+
component.$listen = $listen;
|
|
731
|
+
|
|
732
|
+
// Override querySelector/querySelectorAll to query within the component's host
|
|
733
|
+
const host = arguments[1];
|
|
734
|
+
const $querySelector = (selector) => host.querySelector(selector);
|
|
735
|
+
const $querySelectorAll = (selector) => host.querySelectorAll(selector);
|
|
736
|
+
|
|
737
|
+
// Execute script content within component scope so $bind variables are accessible
|
|
738
|
+
with(component) {
|
|
739
|
+
${w}
|
|
740
|
+
|
|
741
|
+
// Auto-bind variables to component state (e.g., const name = "value" → this.state.name = "value")
|
|
742
|
+
${A}
|
|
743
|
+
|
|
744
|
+
// Auto-attach all detected functions to component for onclick access
|
|
745
|
+
${a}
|
|
746
|
+
}
|
|
747
|
+
}).call(arguments[0], arguments[0], arguments[1], arguments[2])
|
|
748
|
+
`;
|
|
749
|
+
return new Function(L)(o, s, At), p;
|
|
750
|
+
} catch (i) {
|
|
751
|
+
return xt(i, N(o)), /* @__PURE__ */ new Map();
|
|
752
|
+
}
|
|
753
|
+
}, dt = (n, t) => {
|
|
754
|
+
[
|
|
755
|
+
"click",
|
|
756
|
+
"dblclick",
|
|
757
|
+
"mousedown",
|
|
758
|
+
"mouseup",
|
|
759
|
+
"mouseover",
|
|
760
|
+
"mouseout",
|
|
761
|
+
"mousemove",
|
|
762
|
+
"mouseenter",
|
|
763
|
+
"mouseleave",
|
|
764
|
+
"keydown",
|
|
765
|
+
"keyup",
|
|
766
|
+
"keypress",
|
|
767
|
+
"focus",
|
|
768
|
+
"blur",
|
|
769
|
+
"change",
|
|
770
|
+
"input",
|
|
771
|
+
"submit",
|
|
772
|
+
"reset",
|
|
773
|
+
"scroll",
|
|
774
|
+
"resize",
|
|
775
|
+
"load",
|
|
776
|
+
"unload",
|
|
777
|
+
"touchstart",
|
|
778
|
+
"touchend",
|
|
779
|
+
"touchmove",
|
|
780
|
+
"touchcancel",
|
|
781
|
+
"dragstart",
|
|
782
|
+
"drag",
|
|
783
|
+
"dragend",
|
|
784
|
+
"dragenter",
|
|
785
|
+
"dragover",
|
|
786
|
+
"dragleave",
|
|
787
|
+
"drop"
|
|
788
|
+
].forEach((s) => {
|
|
789
|
+
const o = `on${s}`;
|
|
790
|
+
(n instanceof ShadowRoot ? n.querySelectorAll(`[${o}]`) : t.querySelectorAll(`[${o}]`)).forEach((i) => {
|
|
791
|
+
const r = `${o}`;
|
|
792
|
+
if (i[`__processed_${r}`]) return;
|
|
793
|
+
const u = i.getAttribute(o);
|
|
794
|
+
u && (i.removeAttribute(o), i.addEventListener(
|
|
795
|
+
s,
|
|
796
|
+
function(f) {
|
|
797
|
+
new Function(
|
|
798
|
+
"event",
|
|
799
|
+
"component",
|
|
800
|
+
`
|
|
801
|
+
with(component) {
|
|
802
|
+
${u}
|
|
803
|
+
}
|
|
804
|
+
`
|
|
805
|
+
).call(this, f, t);
|
|
806
|
+
}
|
|
807
|
+
), i[`__processed_${r}`] = !0);
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
}, jt = (l, i, r, ...u) => D(null, [l, i, r, ...u], function* (n, t, e, s = [], o = /* @__PURE__ */ new Set()) {
|
|
811
|
+
const f = /* @__PURE__ */ new Map();
|
|
812
|
+
if (!(t != null && t.length)) return f;
|
|
813
|
+
const c = lt(n);
|
|
814
|
+
for (const d of t)
|
|
815
|
+
d.content && ut(
|
|
816
|
+
d.content,
|
|
817
|
+
e,
|
|
818
|
+
s,
|
|
819
|
+
n,
|
|
820
|
+
c,
|
|
821
|
+
o
|
|
822
|
+
).forEach((m, g) => {
|
|
823
|
+
f.has(g) || f.set(g, m);
|
|
824
|
+
});
|
|
825
|
+
return dt(n, c), f;
|
|
826
|
+
}), It = (n, t) => new Promise((e, s) => {
|
|
827
|
+
const o = document.querySelector(
|
|
828
|
+
`script[src="${n}"]`
|
|
829
|
+
);
|
|
830
|
+
if (o) {
|
|
831
|
+
if (o.dataset.loaded === "true") {
|
|
832
|
+
e();
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
o.addEventListener("load", () => e(), { once: !0 }), o.addEventListener(
|
|
836
|
+
"error",
|
|
837
|
+
() => s(new Error(`Failed to load external script: ${n}`)),
|
|
838
|
+
{ once: !0 }
|
|
839
|
+
);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const l = document.createElement("script");
|
|
843
|
+
l.src = n, t && (l.type = t), l.onload = () => {
|
|
844
|
+
l.dataset.loaded = "true", e();
|
|
845
|
+
}, l.onerror = () => s(new Error(`Failed to load external script: ${n}`)), document.head.appendChild(l);
|
|
846
|
+
}), qt = (i, r, u, ...f) => D(null, [i, r, u, ...f], function* (n, t, e, s = [], o = /* @__PURE__ */ new Set(), l) {
|
|
847
|
+
var d;
|
|
848
|
+
const c = lt(n);
|
|
849
|
+
for (const a of t) {
|
|
850
|
+
let m;
|
|
851
|
+
l ? l.startsWith("http://") || l.startsWith("https://") ? m = l : m = new URL(
|
|
852
|
+
l,
|
|
853
|
+
window.location.href
|
|
854
|
+
).href : m = window.location.href;
|
|
855
|
+
const g = new URL(a.src, m).href;
|
|
856
|
+
if (a.external)
|
|
857
|
+
yield It(g, a.type);
|
|
858
|
+
else if (a.type === "module") {
|
|
859
|
+
const p = c.tagName.toLowerCase();
|
|
860
|
+
window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(p, {
|
|
861
|
+
host: n,
|
|
862
|
+
shadowRoot: n instanceof ShadowRoot ? n : null,
|
|
863
|
+
element: c,
|
|
864
|
+
state: c.state,
|
|
865
|
+
setState: (d = c.setState) == null ? void 0 : d.bind(c)
|
|
866
|
+
});
|
|
867
|
+
const h = document.createElement("script");
|
|
868
|
+
h.type = "module", h.src = g, h.setAttribute("data-component", p), document.head.appendChild(h);
|
|
869
|
+
} else
|
|
870
|
+
yield fetch(g).then((p) => {
|
|
871
|
+
if (!p.ok)
|
|
872
|
+
throw new Error(`HTTP ${p.status}: ${p.statusText}`);
|
|
873
|
+
const h = p.headers.get("content-type");
|
|
874
|
+
if (h && !h.includes("javascript") && !h.includes("text/plain"))
|
|
875
|
+
throw new Error(`Expected JavaScript but got ${h}`);
|
|
876
|
+
return p.text();
|
|
877
|
+
}).then((p) => {
|
|
878
|
+
ut(
|
|
879
|
+
p,
|
|
880
|
+
e,
|
|
881
|
+
s,
|
|
882
|
+
n,
|
|
883
|
+
c,
|
|
884
|
+
o
|
|
885
|
+
);
|
|
886
|
+
}).catch((p) => {
|
|
887
|
+
console.error(`Failed to load external script: ${a.src}`, p);
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
dt(n, c);
|
|
891
|
+
}), Zt = (n, t) => {
|
|
892
|
+
var f, c, d, a, m, g, p, h, q, w, ft, ht;
|
|
893
|
+
const { tagName: e, template: s, scripts: o, externalScripts: l, styles: i, sourcePath: r } = n, B = class B extends HTMLElement {
|
|
894
|
+
constructor() {
|
|
895
|
+
super();
|
|
896
|
+
R(this, h);
|
|
897
|
+
R(this, f, []);
|
|
898
|
+
R(this, c, []);
|
|
899
|
+
R(this, d, []);
|
|
900
|
+
R(this, a, []);
|
|
901
|
+
R(this, m, []);
|
|
902
|
+
R(this, g, r);
|
|
903
|
+
R(this, p, /* @__PURE__ */ new WeakMap());
|
|
904
|
+
t && this.attachShadow({ mode: "open" });
|
|
905
|
+
const b = {};
|
|
906
|
+
let E = !1;
|
|
907
|
+
const S = () => {
|
|
908
|
+
E || (E = !0, requestAnimationFrame(() => {
|
|
909
|
+
E = !1, ot(_(this, f), this.state, this), it(_(this, d), this.state, this), rt(_(this, a), this.state, this), M(this, h, ht).call(this);
|
|
910
|
+
}));
|
|
911
|
+
}, v = () => {
|
|
912
|
+
S();
|
|
913
|
+
};
|
|
914
|
+
this.state = new Proxy(b, {
|
|
915
|
+
get: ($, y) => $[y],
|
|
916
|
+
set: ($, y, C) => {
|
|
917
|
+
const W = $[y];
|
|
918
|
+
return y in $ && Object.is(W, C) || (C !== null && typeof C == "object" ? $[y] = M(this, h, q).call(this, C, v) : $[y] = C, Object.getOwnPropertyDescriptor(this, y) || Object.defineProperty(this, y, {
|
|
919
|
+
get() {
|
|
920
|
+
return this.state[y];
|
|
921
|
+
},
|
|
922
|
+
set(V) {
|
|
923
|
+
this.state[y] = V;
|
|
924
|
+
},
|
|
925
|
+
enumerable: !0,
|
|
926
|
+
configurable: !0
|
|
927
|
+
}), v()), !0;
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Updates component state with one or more key-value pairs
|
|
933
|
+
* @param updates - Object containing state updates
|
|
934
|
+
* @example
|
|
935
|
+
* component.setState({ count: 5, name: 'John' })
|
|
936
|
+
*/
|
|
937
|
+
setState(b) {
|
|
938
|
+
Object.assign(this.state, b);
|
|
939
|
+
}
|
|
940
|
+
// Invoked when element is added to the DOM
|
|
941
|
+
connectedCallback() {
|
|
942
|
+
return D(this, null, function* () {
|
|
943
|
+
const b = t ? this.shadowRoot : this, { bindings: E, twoWayBindings: S, conditionals: v, loops: $ } = Ct(
|
|
944
|
+
b,
|
|
945
|
+
s
|
|
946
|
+
);
|
|
947
|
+
j(this, f, E), j(this, c, S), j(this, d, v), j(this, a, $);
|
|
948
|
+
const y = kt(v), C = Rt($);
|
|
949
|
+
St(b, i, t), yield qt(
|
|
950
|
+
b,
|
|
951
|
+
l,
|
|
952
|
+
_(this, f),
|
|
953
|
+
_(this, c),
|
|
954
|
+
/* @__PURE__ */ new Set([...y, ...C]),
|
|
955
|
+
_(this, g)
|
|
956
|
+
), (yield jt(
|
|
957
|
+
b,
|
|
958
|
+
o,
|
|
959
|
+
_(this, f),
|
|
960
|
+
_(this, c),
|
|
961
|
+
/* @__PURE__ */ new Set([...y, ...C])
|
|
962
|
+
)).forEach((x, V) => {
|
|
963
|
+
if (this.state[V] === void 0)
|
|
964
|
+
try {
|
|
965
|
+
const T = new Function(`return ${x}`);
|
|
966
|
+
this.state[V] = T();
|
|
967
|
+
} catch (T) {
|
|
968
|
+
this.state[V] = x;
|
|
969
|
+
}
|
|
970
|
+
}), this._initializeStateFromAttributes(), this._setupTwoWayBindings(), ot(_(this, f), this.state, this), it(_(this, d), this.state, this), rt(_(this, a), this.state, this), this._setupAttributeObserver();
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
// Invoked when element is removed from the DOM
|
|
974
|
+
disconnectedCallback() {
|
|
975
|
+
this.__attributeObserver && (this.__attributeObserver.disconnect(), this.__attributeObserver = null), _(this, m).forEach((E) => {
|
|
976
|
+
try {
|
|
977
|
+
E();
|
|
978
|
+
} catch (S) {
|
|
979
|
+
_t(
|
|
980
|
+
"cleanup",
|
|
981
|
+
S,
|
|
982
|
+
N(this, {
|
|
983
|
+
lineHint: "disconnectedCallback cleanup"
|
|
984
|
+
})
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
}), j(this, m, []);
|
|
988
|
+
const b = this.__eventUnsubscribers;
|
|
989
|
+
b && Array.isArray(b) && (b.forEach((E) => {
|
|
990
|
+
try {
|
|
991
|
+
E();
|
|
992
|
+
} catch (S) {
|
|
993
|
+
G.error(
|
|
994
|
+
"⚠️ Event Bus Error: Failed to unsubscribe from event",
|
|
995
|
+
N(this)
|
|
996
|
+
), G.error(` Error details: ${S.message}`);
|
|
997
|
+
}
|
|
998
|
+
}), this.__eventUnsubscribers = []);
|
|
999
|
+
}
|
|
1000
|
+
// Set up observer to watch for attribute changes
|
|
1001
|
+
_setupAttributeObserver() {
|
|
1002
|
+
const b = new MutationObserver((E) => {
|
|
1003
|
+
E.forEach((S) => {
|
|
1004
|
+
if (S.type === "attributes" && S.attributeName) {
|
|
1005
|
+
const v = this.getAttribute(S.attributeName);
|
|
1006
|
+
this._handleAttributeChange(S.attributeName, v);
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
b.observe(this, {
|
|
1011
|
+
attributes: !0,
|
|
1012
|
+
attributeOldValue: !0
|
|
1013
|
+
}), this.__attributeObserver = b;
|
|
1014
|
+
}
|
|
1015
|
+
// initializes the state from the attributes
|
|
1016
|
+
_initializeStateFromAttributes() {
|
|
1017
|
+
this.getAttributeNames().forEach((b) => {
|
|
1018
|
+
const E = this.getAttribute(b);
|
|
1019
|
+
this._handleAttributeChange(b, E);
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
// Invoked when attributes are changed.
|
|
1023
|
+
_handleAttributeChange(b, E) {
|
|
1024
|
+
var v;
|
|
1025
|
+
if (b) {
|
|
1026
|
+
const $ = "this.state.";
|
|
1027
|
+
b.startsWith($) && (b = b.slice($.length));
|
|
1028
|
+
}
|
|
1029
|
+
const S = M(v = B, w, ft).call(v, E);
|
|
1030
|
+
this.state[b] = S;
|
|
1031
|
+
}
|
|
1032
|
+
// Setup two-way data bindings for input elements with $bind
|
|
1033
|
+
_setupTwoWayBindings() {
|
|
1034
|
+
_(this, c).forEach(
|
|
1035
|
+
({ element: b, path: E, raw: S, isContentEditable: v, initialValue: $ }) => {
|
|
1036
|
+
var C, W;
|
|
1037
|
+
if (this._getNestedValue(E) === void 0) {
|
|
1038
|
+
const x = $ || "";
|
|
1039
|
+
K(this.state, E, x);
|
|
1040
|
+
}
|
|
1041
|
+
if (v) {
|
|
1042
|
+
const x = b;
|
|
1043
|
+
x.textContent = (C = this._getNestedValue(E)) != null ? C : "";
|
|
1044
|
+
const V = (X) => {
|
|
1045
|
+
const F = X.target.textContent || "";
|
|
1046
|
+
K(this.state, E, F);
|
|
1047
|
+
};
|
|
1048
|
+
x.addEventListener("input", V);
|
|
1049
|
+
const T = () => {
|
|
1050
|
+
x.removeEventListener("input", V);
|
|
1051
|
+
};
|
|
1052
|
+
_(this, m).push(T);
|
|
1053
|
+
} else {
|
|
1054
|
+
const x = b, V = x instanceof HTMLInputElement && x.type === "checkbox";
|
|
1055
|
+
x instanceof HTMLInputElement && x.type, V ? x.checked = !!this._getNestedValue(E) : x.value = (W = this._getNestedValue(E)) != null ? W : "";
|
|
1056
|
+
const T = (P) => {
|
|
1057
|
+
const F = P.target;
|
|
1058
|
+
let U;
|
|
1059
|
+
F instanceof HTMLInputElement && F.type === "checkbox" ? U = F.checked : (F instanceof HTMLInputElement && F.type, U = F.value), K(this.state, E, U);
|
|
1060
|
+
};
|
|
1061
|
+
x.addEventListener("input", T);
|
|
1062
|
+
const X = () => {
|
|
1063
|
+
x.removeEventListener("input", T);
|
|
1064
|
+
};
|
|
1065
|
+
if (_(this, m).push(X), x instanceof HTMLSelectElement || x instanceof HTMLInputElement && ["checkbox", "radio", "file"].includes(x.type)) {
|
|
1066
|
+
x.addEventListener("change", T);
|
|
1067
|
+
const P = () => {
|
|
1068
|
+
x.removeEventListener("change", T);
|
|
1069
|
+
};
|
|
1070
|
+
_(this, m).push(P);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
}
|
|
1076
|
+
// Helper to get nested value from state
|
|
1077
|
+
_getNestedValue(b) {
|
|
1078
|
+
return b.reduce((E, S) => E == null ? void 0 : E[S], this.state);
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
f = new WeakMap(), c = new WeakMap(), d = new WeakMap(), a = new WeakMap(), m = new WeakMap(), g = new WeakMap(), p = new WeakMap(), h = new WeakSet(), /**
|
|
1082
|
+
* Creates a deep reactive proxy that tracks nested object/array mutations
|
|
1083
|
+
* @param target - The object or array to make reactive
|
|
1084
|
+
* @param callback - Function to call when any nested property changes
|
|
1085
|
+
*/
|
|
1086
|
+
q = function(b, E) {
|
|
1087
|
+
if (b === null || typeof b != "object" || b instanceof HTMLElement || b instanceof Node)
|
|
1088
|
+
return b;
|
|
1089
|
+
if (_(this, p).has(b))
|
|
1090
|
+
return _(this, p).get(b);
|
|
1091
|
+
const S = new Proxy(b, {
|
|
1092
|
+
get: (v, $) => {
|
|
1093
|
+
const y = v[$];
|
|
1094
|
+
if (Array.isArray(v) && typeof y == "function" && [
|
|
1095
|
+
"push",
|
|
1096
|
+
"pop",
|
|
1097
|
+
"shift",
|
|
1098
|
+
"unshift",
|
|
1099
|
+
"splice",
|
|
1100
|
+
"sort",
|
|
1101
|
+
"reverse"
|
|
1102
|
+
].includes($))
|
|
1103
|
+
return (...W) => {
|
|
1104
|
+
const x = W.map(
|
|
1105
|
+
(T) => T !== null && typeof T == "object" ? M(this, h, q).call(this, T, E) : T
|
|
1106
|
+
), V = y.apply(v, x);
|
|
1107
|
+
return E(), V;
|
|
1108
|
+
};
|
|
1109
|
+
if (y !== null && typeof y == "object") {
|
|
1110
|
+
if (_(this, p).has(y))
|
|
1111
|
+
return _(this, p).get(y);
|
|
1112
|
+
const C = M(this, h, q).call(this, y, E);
|
|
1113
|
+
return v[$] = C, C;
|
|
1114
|
+
}
|
|
1115
|
+
return y;
|
|
1116
|
+
},
|
|
1117
|
+
set: (v, $, y) => {
|
|
1118
|
+
const C = v[$];
|
|
1119
|
+
return Object.is(C, y) || (y !== null && typeof y == "object" ? v[$] = M(this, h, q).call(this, y, E) : v[$] = y, E()), !0;
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
return _(this, p).set(b, S), S;
|
|
1123
|
+
}, w = new WeakSet(), ft = function(b) {
|
|
1124
|
+
if (b === null || b === "") return null;
|
|
1125
|
+
if (b !== "undefined")
|
|
1126
|
+
try {
|
|
1127
|
+
return JSON.parse(b);
|
|
1128
|
+
} catch (E) {
|
|
1129
|
+
return b;
|
|
1130
|
+
}
|
|
1131
|
+
}, // Update two-way bound elements when state changes
|
|
1132
|
+
ht = function() {
|
|
1133
|
+
_(this, c).forEach(({ element: b, path: E, isContentEditable: S }) => {
|
|
1134
|
+
const v = this._getNestedValue(E);
|
|
1135
|
+
if (S) {
|
|
1136
|
+
const $ = b;
|
|
1137
|
+
$.textContent !== v && ($.textContent = v != null ? v : "");
|
|
1138
|
+
} else {
|
|
1139
|
+
const $ = b;
|
|
1140
|
+
if ($ instanceof HTMLInputElement && $.type === "checkbox") {
|
|
1141
|
+
const y = !!v;
|
|
1142
|
+
$.checked !== y && ($.checked = y);
|
|
1143
|
+
} else
|
|
1144
|
+
$.value !== v && ($.value = v != null ? v : "");
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
}, R(B, w);
|
|
1148
|
+
let u = B;
|
|
1149
|
+
customElements.get(e) || (customElements.define(e, u), G.log(`Web component defined: <${e}></${e}>`));
|
|
1150
|
+
};
|
|
1151
|
+
export {
|
|
1152
|
+
Zt as defineWebComponent
|
|
1153
|
+
};
|
|
1154
|
+
//# sourceMappingURL=webcomponent-SSpadLeF.mjs.map
|