@jasonshimmy/custom-elements-runtime 0.0.3 → 0.0.4
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/README.md +50 -44
- package/dist/custom-elements-runtime.cjs.js +5 -5
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +307 -235
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.umd.js +5 -5
- package/dist/custom-elements-runtime.umd.js.map +1 -1
- package/dist/router.d.ts +52 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/store.d.ts +4 -8
- package/package.json +1 -1
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
subscribe(t) {
|
|
10
|
-
this.listeners.push(t), t(this.state);
|
|
1
|
+
function $(e) {
|
|
2
|
+
let t = new Proxy(e, {
|
|
3
|
+
set: (i, a, c) => (i[a] = c, s(), !0)
|
|
4
|
+
});
|
|
5
|
+
const n = [];
|
|
6
|
+
function r(i) {
|
|
7
|
+
n.push(i), i(t);
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
return
|
|
9
|
+
function o() {
|
|
10
|
+
return t;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function s() {
|
|
13
|
+
n.forEach((i) => i(t));
|
|
17
14
|
}
|
|
15
|
+
return { subscribe: r, getState: o };
|
|
18
16
|
}
|
|
19
17
|
class y extends EventTarget {
|
|
20
18
|
handlers = {};
|
|
@@ -140,8 +138,8 @@ class y extends EventTarget {
|
|
|
140
138
|
this.eventCounters.clear();
|
|
141
139
|
}
|
|
142
140
|
}
|
|
143
|
-
const
|
|
144
|
-
function
|
|
141
|
+
const w = y.getInstance(), F = typeof window > "u" || typeof document > "u";
|
|
142
|
+
function K(e) {
|
|
145
143
|
return {
|
|
146
144
|
state: e,
|
|
147
145
|
emit: () => {
|
|
@@ -155,19 +153,19 @@ function W(e) {
|
|
|
155
153
|
}
|
|
156
154
|
};
|
|
157
155
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
156
|
+
function U(e, t = {}) {
|
|
157
|
+
F || console.warn("[SSR] renderToString should only be used on the server");
|
|
160
158
|
try {
|
|
161
|
-
const n = e.state, r =
|
|
159
|
+
const n = e.state, r = K(n), o = e.template(n, r);
|
|
162
160
|
let s = "";
|
|
163
161
|
t.includeStyles && e.style && (s = `<style>${typeof e.style == "function" ? e.style(n) : e.style}</style>`);
|
|
164
|
-
const i = t.sanitizeAttributes ? t.sanitizeAttributes(e.attrs || {}) : e.attrs || {}, a = Object.entries(i).map(([
|
|
165
|
-
return t.prettyPrint ?
|
|
162
|
+
const i = t.sanitizeAttributes ? t.sanitizeAttributes(e.attrs || {}) : e.attrs || {}, a = Object.entries(i).map(([u, d]) => `${j(u)}="${j(d)}"`).join(" "), l = `${a ? `<${e.tag} ${a}>` : `<${e.tag}>`}${s}${o}</${e.tag}>`;
|
|
163
|
+
return t.prettyPrint ? Z(l) : l;
|
|
166
164
|
} catch (n) {
|
|
167
|
-
return console.error(`[SSR] Error rendering ${e.tag}:`, n), `<${e.tag}><div style="color: red;">SSR Error: ${
|
|
165
|
+
return console.error(`[SSR] Error rendering ${e.tag}:`, n), `<${e.tag}><div style="color: red;">SSR Error: ${G(String(n))}</div></${e.tag}>`;
|
|
168
166
|
}
|
|
169
167
|
}
|
|
170
|
-
function
|
|
168
|
+
function st(e, t = {}) {
|
|
171
169
|
const n = {
|
|
172
170
|
components: /* @__PURE__ */ new Map(),
|
|
173
171
|
styles: /* @__PURE__ */ new Set()
|
|
@@ -177,7 +175,7 @@ function tt(e, t = {}) {
|
|
|
177
175
|
const c = typeof i.style == "function" ? i.style(i.state) : i.style;
|
|
178
176
|
n.styles.add(c);
|
|
179
177
|
}
|
|
180
|
-
const a =
|
|
178
|
+
const a = U(i, { ...t, includeStyles: !1 });
|
|
181
179
|
r.push(a);
|
|
182
180
|
});
|
|
183
181
|
const o = Array.from(n.styles).join(`
|
|
@@ -185,7 +183,7 @@ function tt(e, t = {}) {
|
|
|
185
183
|
return { html: r.join(`
|
|
186
184
|
`), styles: o, context: n };
|
|
187
185
|
}
|
|
188
|
-
function
|
|
186
|
+
function it(e) {
|
|
189
187
|
const t = Array.from(e.components.entries()).map(([n, r]) => ({
|
|
190
188
|
tag: n,
|
|
191
189
|
state: r.state
|
|
@@ -225,33 +223,33 @@ function et(e) {
|
|
|
225
223
|
}
|
|
226
224
|
<\/script>`.trim();
|
|
227
225
|
}
|
|
228
|
-
const
|
|
226
|
+
const G = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), j = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">"), Z = (e) => e.replace(/></g, `>
|
|
229
227
|
<`).split(`
|
|
230
228
|
`).map((t) => {
|
|
231
229
|
const n = (t.match(/^<[^\/]/g) || []).length - (t.match(/<\//g) || []).length;
|
|
232
230
|
return " ".repeat(Math.max(0, n)) + t.trim();
|
|
233
231
|
}).join(`
|
|
234
232
|
`);
|
|
235
|
-
function
|
|
233
|
+
function x(e) {
|
|
236
234
|
return String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
237
235
|
}
|
|
238
|
-
function
|
|
236
|
+
function O(e, t) {
|
|
239
237
|
if (typeof e != "string" || !t) return String(e);
|
|
240
238
|
for (const n in t) {
|
|
241
239
|
if (typeof t[n] == "string" && e === t[n])
|
|
242
|
-
return
|
|
240
|
+
return x(e);
|
|
243
241
|
if (Array.isArray(t[n])) {
|
|
244
242
|
for (const r of t[n])
|
|
245
243
|
if (r && typeof r == "object") {
|
|
246
244
|
for (const o in r)
|
|
247
245
|
if (typeof r[o] == "string" && e === r[o])
|
|
248
|
-
return
|
|
246
|
+
return x(e);
|
|
249
247
|
}
|
|
250
248
|
}
|
|
251
249
|
}
|
|
252
250
|
return String(e);
|
|
253
251
|
}
|
|
254
|
-
function
|
|
252
|
+
function ot(e, ...t) {
|
|
255
253
|
function n(r, o, s) {
|
|
256
254
|
if (Array.isArray(r)) {
|
|
257
255
|
const i = r.map((a) => n(a, o, s));
|
|
@@ -269,22 +267,22 @@ function nt(e, ...t) {
|
|
|
269
267
|
for (let c = 0; c < e.length; c++)
|
|
270
268
|
if (s += e[c], c < t.length) {
|
|
271
269
|
let l = t[c];
|
|
272
|
-
const
|
|
273
|
-
l = n(l, r, o), l instanceof Promise ? (i = !0, a.push(l)) : /=\s*"?$/.test(
|
|
270
|
+
const u = e[c], d = /data-on-[a-z]+="?$/.test(u);
|
|
271
|
+
l = n(l, r, o), l instanceof Promise ? (i = !0, a.push(l)) : /=\s*"?$/.test(u) && typeof l == "string" && !d ? (l = l.replace(/"/g, """).replace(/'/g, "'"), s += l) : !d && !/=\s*"?$/.test(u) ? s += O(l, r) : s += l;
|
|
274
272
|
}
|
|
275
273
|
return i ? Promise.all(a).then((c) => {
|
|
276
|
-
let l = "",
|
|
277
|
-
for (let
|
|
278
|
-
if (l += e[
|
|
279
|
-
let
|
|
280
|
-
const h = e[
|
|
281
|
-
|
|
274
|
+
let l = "", u = 0;
|
|
275
|
+
for (let d = 0; d < e.length; d++)
|
|
276
|
+
if (l += e[d], d < t.length) {
|
|
277
|
+
let f = t[d];
|
|
278
|
+
const h = e[d], m = /data-on-[a-z]+="?$/.test(h);
|
|
279
|
+
f = n(f, r, o), f instanceof Promise ? l += c[u++] : /=\s*"?$/.test(h) && typeof f == "string" && !m ? (f = f.replace(/"/g, """).replace(/'/g, "'"), l += f) : !m && !/=\s*"?$/.test(h) ? l += O(f, r) : l += f;
|
|
282
280
|
}
|
|
283
281
|
return l;
|
|
284
282
|
}) : s;
|
|
285
283
|
};
|
|
286
284
|
}
|
|
287
|
-
function
|
|
285
|
+
function at(e, ...t) {
|
|
288
286
|
const n = "compiled-" + Math.random().toString(36).slice(2);
|
|
289
287
|
function r(s, i, a) {
|
|
290
288
|
return Array.isArray(s) ? s.map((c) => r(c, i, a)).join("") : typeof s == "function" ? r(s(i, a), i, a) : s == null ? "" : String(s);
|
|
@@ -294,53 +292,53 @@ function rt(e, ...t) {
|
|
|
294
292
|
for (let c = 0; c < e.length; c++)
|
|
295
293
|
if (a += e[c], c < t.length) {
|
|
296
294
|
let l = t[c];
|
|
297
|
-
const
|
|
298
|
-
l = r(l, s, i), /=\s*"?$/.test(
|
|
295
|
+
const u = e[c], d = /data-on-[a-z]+="?$/.test(u);
|
|
296
|
+
l = r(l, s, i), /=\s*"?$/.test(u) && typeof l == "string" && !d ? (l = l.replace(/"/g, """).replace(/'/g, "'"), a += l) : !d && !/=\s*"?$/.test(u) ? a += O(l, s) : a += l ?? "";
|
|
299
297
|
}
|
|
300
298
|
return a;
|
|
301
299
|
};
|
|
302
300
|
return o.id = n, o;
|
|
303
301
|
}
|
|
304
|
-
function
|
|
302
|
+
function ct(e, ...t) {
|
|
305
303
|
let n = "";
|
|
306
304
|
for (let r = 0; r < e.length; r++)
|
|
307
305
|
n += e[r], r < t.length && (n += t[r] ?? "");
|
|
308
306
|
return n;
|
|
309
307
|
}
|
|
310
|
-
function
|
|
308
|
+
function lt(e) {
|
|
311
309
|
return Object.keys(e).filter((t) => e[t]).join(" ");
|
|
312
310
|
}
|
|
313
|
-
function
|
|
311
|
+
function ut(e) {
|
|
314
312
|
return Object.entries(e).map(([t, n]) => `${t}: ${n}`).join("; ");
|
|
315
313
|
}
|
|
316
|
-
function
|
|
314
|
+
function B(e, t, n) {
|
|
317
315
|
const [r, ...o] = n.split("|").map((a) => a.trim());
|
|
318
316
|
if (!r || r === "__proto__" || r === "constructor" || r === "prototype") return;
|
|
319
317
|
function s(a, c, l) {
|
|
320
|
-
const
|
|
321
|
-
let
|
|
322
|
-
for (let
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
const u = c.split(".");
|
|
319
|
+
let d = a;
|
|
320
|
+
for (let f = 0; f < u.length - 1; f++)
|
|
321
|
+
u[f] in d || (d[u[f]] = {}), d = d[u[f]];
|
|
322
|
+
d[u[u.length - 1]] = l;
|
|
325
323
|
}
|
|
326
324
|
const i = (a) => {
|
|
327
325
|
let c;
|
|
328
326
|
if (e instanceof HTMLInputElement && e.type === "checkbox") {
|
|
329
327
|
c = e.value;
|
|
330
|
-
const l = e.getAttribute("data-true-value"),
|
|
331
|
-
let
|
|
332
|
-
if (
|
|
328
|
+
const l = e.getAttribute("data-true-value"), u = e.getAttribute("data-false-value");
|
|
329
|
+
let d = Array.isArray(t[r]) ? t[r] : void 0;
|
|
330
|
+
if (d) {
|
|
333
331
|
if (e.checked)
|
|
334
|
-
|
|
332
|
+
d.includes(c) || d.push(c);
|
|
335
333
|
else {
|
|
336
|
-
const
|
|
337
|
-
|
|
334
|
+
const f = d.indexOf(c);
|
|
335
|
+
f !== -1 && d.splice(f, 1);
|
|
338
336
|
}
|
|
339
|
-
s(t, r, [...
|
|
337
|
+
s(t, r, [...d]);
|
|
340
338
|
} else
|
|
341
|
-
l !== null ||
|
|
342
|
-
} else e instanceof HTMLInputElement && e.type === "radio" ? (c = e.value, s(t, r, c), ((e.form || e.closest("form") || e.getRootNode()) instanceof Element ? (e.form || e.closest("form") || e.getRootNode()).querySelectorAll(`input[type="radio"][name="${e.name}"][data-model="${n}"]`) : []).forEach((
|
|
343
|
-
|
|
339
|
+
l !== null || u !== null ? e.checked ? s(t, r, l) : s(t, r, u !== null ? u : !1) : s(t, r, e.checked);
|
|
340
|
+
} else e instanceof HTMLInputElement && e.type === "radio" ? (c = e.value, s(t, r, c), ((e.form || e.closest("form") || e.getRootNode()) instanceof Element ? (e.form || e.closest("form") || e.getRootNode()).querySelectorAll(`input[type="radio"][name="${e.name}"][data-model="${n}"]`) : []).forEach((u) => {
|
|
341
|
+
u.checked = u.value === String(c);
|
|
344
342
|
})) : (c = e.value, e instanceof HTMLInputElement && e.type === "number" && (c = Number(c)), o.includes("trim") && typeof c == "string" && (c = c.trim()), o.includes("number") && (c = Number(c)), s(t, r, c));
|
|
345
343
|
if ("_vnode" in e && typeof e._vnode == "object" && e._vnode?.props && (e._vnode.props.value = c), a.type === "input" && (e._isDirty = !0), a.type === "keydown" && a.key === "Enter" && (e._isDirty = !1, e instanceof HTMLElement && e.isConnected)) {
|
|
346
344
|
let l = e.parentElement;
|
|
@@ -352,7 +350,7 @@ function U(e, t, n) {
|
|
|
352
350
|
};
|
|
353
351
|
e.addEventListener("input", i), e.addEventListener("change", i), e.addEventListener("keydown", i), e.addEventListener("blur", i);
|
|
354
352
|
}
|
|
355
|
-
const
|
|
353
|
+
const H = (() => {
|
|
356
354
|
try {
|
|
357
355
|
if (typeof process < "u" && process.env)
|
|
358
356
|
return process.env.NODE_ENV === "development";
|
|
@@ -360,33 +358,33 @@ const R = (() => {
|
|
|
360
358
|
}
|
|
361
359
|
return typeof window < "u" ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" : !1;
|
|
362
360
|
})();
|
|
363
|
-
function
|
|
364
|
-
const { development: n =
|
|
361
|
+
function dt(e, t = {}) {
|
|
362
|
+
const { development: n = H, cache: r = !0, optimize: o = !0 } = t, s = q(e);
|
|
365
363
|
if (r && T.has(s)) {
|
|
366
364
|
if (n) {
|
|
367
|
-
const i =
|
|
365
|
+
const i = v.get(s) || {
|
|
368
366
|
compilationTime: 0,
|
|
369
367
|
renderTime: 0,
|
|
370
368
|
updateTime: 0,
|
|
371
369
|
cacheHits: 0,
|
|
372
370
|
cacheMisses: 0
|
|
373
371
|
};
|
|
374
|
-
i.cacheHits++,
|
|
372
|
+
i.cacheHits++, v.set(s, i);
|
|
375
373
|
}
|
|
376
374
|
return T.get(s);
|
|
377
375
|
}
|
|
378
376
|
if (n) {
|
|
379
|
-
const i =
|
|
377
|
+
const i = v.get(s) || {
|
|
380
378
|
compilationTime: 0,
|
|
381
379
|
renderTime: 0,
|
|
382
380
|
updateTime: 0,
|
|
383
381
|
cacheHits: 0,
|
|
384
382
|
cacheMisses: 0
|
|
385
383
|
};
|
|
386
|
-
i.cacheMisses++,
|
|
384
|
+
i.cacheMisses++, v.set(s, i);
|
|
387
385
|
}
|
|
388
386
|
try {
|
|
389
|
-
const i =
|
|
387
|
+
const i = V(e, { development: n, optimize: o });
|
|
390
388
|
return r && T.set(s, i), i;
|
|
391
389
|
} catch (i) {
|
|
392
390
|
return n && (console.error("[Template Compiler] Error compiling template:", i), console.error("[Template Compiler] Template:", e)), {
|
|
@@ -399,7 +397,7 @@ function at(e, t = {}) {
|
|
|
399
397
|
};
|
|
400
398
|
}
|
|
401
399
|
}
|
|
402
|
-
function
|
|
400
|
+
function X(e, t) {
|
|
403
401
|
if (typeof document > "u")
|
|
404
402
|
return [0];
|
|
405
403
|
try {
|
|
@@ -409,10 +407,10 @@ function Z(e, t) {
|
|
|
409
407
|
return c;
|
|
410
408
|
} else if (a.nodeType === Node.ELEMENT_NODE) {
|
|
411
409
|
let l = 0;
|
|
412
|
-
for (let
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
return
|
|
410
|
+
for (let u = 0; u < a.childNodes.length; u++) {
|
|
411
|
+
const d = a.childNodes[u], f = n(d, [...c, l]);
|
|
412
|
+
if (f)
|
|
413
|
+
return f;
|
|
416
414
|
l++;
|
|
417
415
|
}
|
|
418
416
|
}
|
|
@@ -421,13 +419,13 @@ function Z(e, t) {
|
|
|
421
419
|
const s = new DOMParser().parseFromString(`<div>${e}</div>`, "text/html").body.firstElementChild;
|
|
422
420
|
return n(s) || [0];
|
|
423
421
|
} catch (n) {
|
|
424
|
-
return
|
|
422
|
+
return H && console.warn("[Template Compiler] Error finding DOM path for placeholder:", t, n), [0];
|
|
425
423
|
}
|
|
426
424
|
}
|
|
427
|
-
function
|
|
428
|
-
return new
|
|
425
|
+
function V(e, t) {
|
|
426
|
+
return new Y(e, t).compile();
|
|
429
427
|
}
|
|
430
|
-
class
|
|
428
|
+
class Y {
|
|
431
429
|
template;
|
|
432
430
|
options;
|
|
433
431
|
dynamics = [];
|
|
@@ -437,20 +435,20 @@ class X {
|
|
|
437
435
|
}
|
|
438
436
|
compile() {
|
|
439
437
|
this.parseTemplate();
|
|
440
|
-
const t = this.createStaticFragment(), n =
|
|
438
|
+
const t = this.createStaticFragment(), n = q(this.template), r = (o, s) => {
|
|
441
439
|
let i = "";
|
|
442
440
|
for (let a = 0; a < this.statics.length; a++)
|
|
443
441
|
if (i += this.statics[a], a < this.dynamics.length) {
|
|
444
442
|
let c = this.dynamics[a].getValue(o, s);
|
|
445
443
|
if (c instanceof Promise)
|
|
446
444
|
return Promise.all(this.dynamics.map((l) => {
|
|
447
|
-
const
|
|
448
|
-
return
|
|
445
|
+
const u = l.getValue(o, s);
|
|
446
|
+
return u instanceof Promise ? u : Promise.resolve(u);
|
|
449
447
|
})).then((l) => {
|
|
450
|
-
let
|
|
451
|
-
for (let
|
|
452
|
-
|
|
453
|
-
return
|
|
448
|
+
let u = "";
|
|
449
|
+
for (let d = 0; d < this.statics.length; d++)
|
|
450
|
+
u += this.statics[d], d < l.length && (u += l[d]);
|
|
451
|
+
return u;
|
|
454
452
|
});
|
|
455
453
|
i += c;
|
|
456
454
|
}
|
|
@@ -475,8 +473,8 @@ class X {
|
|
|
475
473
|
if (s.endsWith('style="color:'))
|
|
476
474
|
a = "style", c = "color";
|
|
477
475
|
else if (a === "style") {
|
|
478
|
-
const
|
|
479
|
-
|
|
476
|
+
const u = s.match(/style\s*=\s*"?([^:;]+):\s*$/);
|
|
477
|
+
u && (c = u[1].trim());
|
|
480
478
|
}
|
|
481
479
|
const l = r[1].trim();
|
|
482
480
|
this.analyzeDynamicExpression(l, this.dynamics.length, a, c), n = r.index + r[0].length;
|
|
@@ -488,7 +486,7 @@ class X {
|
|
|
488
486
|
let s = "text", i;
|
|
489
487
|
r ? r === "class" ? (s = "class", i = "class") : r === "style" ? (s = "style", i = o || "style") : r === "value" ? (s = "property", i = "value") : (s = "attribute", i = r) : t.includes("class.") ? (s = "class", i = t.split(".")[1]) : t.includes("style.") ? (s = "style", i = t.split(".")[1]) : t.includes("@") ? (s = "event", i = t.split("@")[1]) : t === "class" ? (s = "class", i = "class") : t === "style" ? (s = "style", i = "style") : t === "value" ? (s = "property", i = "value") : t === "title" && (s = "attribute", i = "title");
|
|
490
488
|
const a = `__DYNAMIC_${n}__`, c = this.statics.join(a);
|
|
491
|
-
let l =
|
|
489
|
+
let l = X(c, a);
|
|
492
490
|
this.statics.length === 2 && s !== "text" ? l = [0] : this.statics.length === 2 && l.length === 0 && (l = [0]), this.dynamics.push({
|
|
493
491
|
path: l,
|
|
494
492
|
type: s,
|
|
@@ -528,7 +526,7 @@ class X {
|
|
|
528
526
|
}
|
|
529
527
|
}
|
|
530
528
|
}
|
|
531
|
-
function
|
|
529
|
+
function k(e, t) {
|
|
532
530
|
try {
|
|
533
531
|
if (t.length === 1 && t[0] === 0 && e instanceof Element)
|
|
534
532
|
return e;
|
|
@@ -544,23 +542,23 @@ function O(e, t) {
|
|
|
544
542
|
return null;
|
|
545
543
|
}
|
|
546
544
|
}
|
|
547
|
-
function
|
|
545
|
+
function D(e, t, n) {
|
|
548
546
|
let r;
|
|
549
|
-
return e.fragment && !e.hasDynamics ? r = e.fragment.cloneNode(!0) : r =
|
|
547
|
+
return e.fragment && !e.hasDynamics ? r = e.fragment.cloneNode(!0) : r = Q(e, t, n), r;
|
|
550
548
|
}
|
|
551
|
-
function
|
|
549
|
+
function J(e, t, n, r, o) {
|
|
552
550
|
if (e.hasDynamics)
|
|
553
551
|
for (const s of e.dynamics)
|
|
554
552
|
try {
|
|
555
553
|
const i = s.getValue(n, r);
|
|
556
554
|
if (o !== void 0 && s.getValue(o, r) === i)
|
|
557
555
|
continue;
|
|
558
|
-
|
|
556
|
+
P(t, s, i);
|
|
559
557
|
} catch (i) {
|
|
560
558
|
console.warn("[Template Compiler] Error applying update:", i);
|
|
561
559
|
}
|
|
562
560
|
}
|
|
563
|
-
function
|
|
561
|
+
function Q(e, t, n) {
|
|
564
562
|
let r = "";
|
|
565
563
|
for (let a = 0; a < e.statics.length; a++)
|
|
566
564
|
if (r += e.statics[a], a < e.dynamics.length) {
|
|
@@ -576,12 +574,12 @@ function Y(e, t, n) {
|
|
|
576
574
|
for (; s.body.firstChild; )
|
|
577
575
|
i.appendChild(s.body.firstChild);
|
|
578
576
|
for (const a of e.dynamics) {
|
|
579
|
-
const c = a.getValue(t, n), l =
|
|
580
|
-
|
|
577
|
+
const c = a.getValue(t, n), l = k(i, a.path);
|
|
578
|
+
P(l, a, c);
|
|
581
579
|
}
|
|
582
580
|
return i;
|
|
583
581
|
}
|
|
584
|
-
function
|
|
582
|
+
function P(e, t, n) {
|
|
585
583
|
try {
|
|
586
584
|
if (t.type === "text") {
|
|
587
585
|
const o = document.createTreeWalker(
|
|
@@ -597,11 +595,11 @@ function I(e, t, n) {
|
|
|
597
595
|
}
|
|
598
596
|
}
|
|
599
597
|
if (s) return;
|
|
600
|
-
const a =
|
|
598
|
+
const a = k(e, t.path);
|
|
601
599
|
a && a.nodeType === Node.TEXT_NODE && (a.textContent = n == null ? "" : String(n));
|
|
602
600
|
return;
|
|
603
601
|
}
|
|
604
|
-
const r =
|
|
602
|
+
const r = k(e, t.path);
|
|
605
603
|
if (!r)
|
|
606
604
|
return;
|
|
607
605
|
switch (t.type) {
|
|
@@ -630,11 +628,11 @@ function I(e, t, n) {
|
|
|
630
628
|
throw new Error(`Unknown update type: ${t.type}`);
|
|
631
629
|
}
|
|
632
630
|
} catch (r) {
|
|
633
|
-
(typeof globalThis < "u" ? globalThis.isDevelopment :
|
|
631
|
+
(typeof globalThis < "u" ? globalThis.isDevelopment : H) && console.warn("[Template Compiler] Error applying update:", t, r);
|
|
634
632
|
}
|
|
635
633
|
}
|
|
636
|
-
const T = /* @__PURE__ */ new Map(),
|
|
637
|
-
function
|
|
634
|
+
const T = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
|
|
635
|
+
function q(e) {
|
|
638
636
|
let t = 0;
|
|
639
637
|
for (let n = 0; n < e.length; n++) {
|
|
640
638
|
const r = e.charCodeAt(n);
|
|
@@ -642,10 +640,10 @@ function N(e) {
|
|
|
642
640
|
}
|
|
643
641
|
return `tpl_${Math.abs(t).toString(36)}`;
|
|
644
642
|
}
|
|
645
|
-
function
|
|
643
|
+
function I(e, t, n, r, o) {
|
|
646
644
|
return r && o ? `${t}.${e}[${n}]:${r}:${o}` : r ? `${t}.${e}[${n}]:${r}` : `${t}.${e}[${n}]`;
|
|
647
645
|
}
|
|
648
|
-
function
|
|
646
|
+
function N(e, t, n) {
|
|
649
647
|
if (!(!e || !(e instanceof Element)) && e.contains(n) && n.parentNode === e)
|
|
650
648
|
try {
|
|
651
649
|
e.replaceChild(t, n);
|
|
@@ -677,23 +675,23 @@ function g(e) {
|
|
|
677
675
|
}
|
|
678
676
|
return t;
|
|
679
677
|
}
|
|
680
|
-
function
|
|
678
|
+
function tt(e) {
|
|
681
679
|
const t = document.createElement("template");
|
|
682
680
|
t.innerHTML = e.trim();
|
|
683
681
|
const n = Array.from(t.content.childNodes);
|
|
684
|
-
return n.length === 1 ?
|
|
682
|
+
return n.length === 1 ? L(n[0]) : {
|
|
685
683
|
type: "#fragment",
|
|
686
684
|
key: void 0,
|
|
687
685
|
props: {},
|
|
688
|
-
children: n.map((o, s) =>
|
|
686
|
+
children: n.map((o, s) => L(o, "#fragment", s)),
|
|
689
687
|
dom: void 0
|
|
690
688
|
};
|
|
691
689
|
}
|
|
692
|
-
function
|
|
690
|
+
function L(e, t = "", n = 0) {
|
|
693
691
|
if (!e)
|
|
694
692
|
return { type: "#unknown", key: void 0, props: {}, children: [], dom: void 0 };
|
|
695
693
|
if (e.nodeType === Node.TEXT_NODE)
|
|
696
|
-
return !e.nodeValue || /^\s*$/.test(e.nodeValue) ? { type: "#whitespace", key: void 0, props: {}, children: [], dom: void 0 } : { type: "#text", key:
|
|
694
|
+
return !e.nodeValue || /^\s*$/.test(e.nodeValue) ? { type: "#whitespace", key: void 0, props: {}, children: [], dom: void 0 } : { type: "#text", key: I("#text", t, n), props: { nodeValue: e.nodeValue }, children: [], dom: e };
|
|
697
695
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
698
696
|
const r = e, o = {};
|
|
699
697
|
Array.from(r.attributes).forEach((l) => {
|
|
@@ -702,12 +700,12 @@ function k(e, t = "", n = 0) {
|
|
|
702
700
|
const s = r.tagName.toLowerCase();
|
|
703
701
|
let i;
|
|
704
702
|
if ((s === "input" || s === "select" || s === "textarea") && r.hasAttribute("data-model")) {
|
|
705
|
-
const l = r.getAttribute("data-model"),
|
|
706
|
-
i = `${s}:${l}:${
|
|
707
|
-
let
|
|
708
|
-
|
|
709
|
-
} else s === "input" || s === "textarea" || s === "select" || r.hasAttribute("contenteditable") ? (i = `${s}:${t}:${n}`, o["data-uid"] = i, r.setAttribute("data-uid", i)) : (i =
|
|
710
|
-
const a = Array.from(r.childNodes).map((l,
|
|
703
|
+
const l = r.getAttribute("data-model"), u = r.getAttribute("type") ?? "";
|
|
704
|
+
i = `${s}:${l}:${u}`, o["data-uid"] = i, r.setAttribute("data-uid", i);
|
|
705
|
+
let d = r.getAttribute("value"), f = r.getAttribute("checked");
|
|
706
|
+
d && (o.value = d), f && (o.checked = f);
|
|
707
|
+
} else s === "input" || s === "textarea" || s === "select" || r.hasAttribute("contenteditable") ? (i = `${s}:${t}:${n}`, o["data-uid"] = i, r.setAttribute("data-uid", i)) : (i = I(s, t, n), s === "li" && (o["data-uid"] = i, r.setAttribute("data-uid", i)));
|
|
708
|
+
const a = Array.from(r.childNodes).map((l, u) => L(l, i, u));
|
|
711
709
|
return {
|
|
712
710
|
type: s,
|
|
713
711
|
key: i,
|
|
@@ -718,7 +716,7 @@ function k(e, t = "", n = 0) {
|
|
|
718
716
|
}
|
|
719
717
|
return { type: "#unknown", key: void 0, props: {}, children: [], dom: void 0 };
|
|
720
718
|
}
|
|
721
|
-
function
|
|
719
|
+
function R(e, t, n) {
|
|
722
720
|
if (!t || !n) return;
|
|
723
721
|
function r(c) {
|
|
724
722
|
return !!c && c.type !== "#whitespace" && !(c.type === "#text" && (!c.props?.nodeValue || /^\s*$/.test(c.props.nodeValue)));
|
|
@@ -727,7 +725,7 @@ function L(e, t, n) {
|
|
|
727
725
|
if (t.type !== n.type || t.key !== n.key) {
|
|
728
726
|
const c = g(n);
|
|
729
727
|
if (c instanceof Node && t.dom instanceof Node && e.contains(t.dom)) {
|
|
730
|
-
if (
|
|
728
|
+
if (N(e, c, t.dom), i && n.props && e.firstChild instanceof HTMLInputElement) {
|
|
731
729
|
const l = e.firstChild;
|
|
732
730
|
l.type === "radio" || l.type, l.value = n.props.value, l.setAttribute("value", n.props.value), "checked" in n.props && (l.checked = n.props.checked === !0 || n.props.checked === "true");
|
|
733
731
|
}
|
|
@@ -763,21 +761,21 @@ function L(e, t, n) {
|
|
|
763
761
|
const a = t.dom;
|
|
764
762
|
if (a && a instanceof Element && n.props) {
|
|
765
763
|
const c = a.tagName.toLowerCase() === "input" ? a.getAttribute("type") : void 0, l = a.tagName.includes("-");
|
|
766
|
-
for (const [
|
|
767
|
-
if (!(c === "radio" &&
|
|
768
|
-
if (c === "checkbox" &&
|
|
769
|
-
a.setAttribute("value",
|
|
764
|
+
for (const [u, d] of Object.entries(n.props))
|
|
765
|
+
if (!(c === "radio" && u === "value")) {
|
|
766
|
+
if (c === "checkbox" && u === "value") {
|
|
767
|
+
a.setAttribute("value", d);
|
|
770
768
|
continue;
|
|
771
769
|
}
|
|
772
|
-
a.setAttribute(
|
|
770
|
+
a.setAttribute(u, d);
|
|
773
771
|
}
|
|
774
772
|
if (l)
|
|
775
|
-
for (const [
|
|
776
|
-
a.setAttribute(
|
|
777
|
-
for (const
|
|
778
|
-
if (!(
|
|
779
|
-
if (c === "radio" &&
|
|
780
|
-
a.removeAttribute(
|
|
773
|
+
for (const [u, d] of Object.entries(n.props))
|
|
774
|
+
a.setAttribute(u, d);
|
|
775
|
+
for (const u of Array.from(a.attributes).map((d) => d.name))
|
|
776
|
+
if (!(u in n.props)) {
|
|
777
|
+
if (c === "radio" && u === "value" || c === "checkbox" && u === "value") continue;
|
|
778
|
+
a.removeAttribute(u);
|
|
781
779
|
}
|
|
782
780
|
}
|
|
783
781
|
if (n.type === "#text") {
|
|
@@ -785,24 +783,24 @@ function L(e, t, n) {
|
|
|
785
783
|
a.nodeValue !== n.props.nodeValue && (a.nodeValue = n.props.nodeValue), n.dom = a;
|
|
786
784
|
else {
|
|
787
785
|
const c = document.createTextNode(n.props.nodeValue ?? "");
|
|
788
|
-
a && e.contains(a) && a.parentNode === e ?
|
|
786
|
+
a && e.contains(a) && a.parentNode === e ? N(e, c, a) : e.appendChild(c), n.dom = c;
|
|
789
787
|
}
|
|
790
788
|
return;
|
|
791
789
|
}
|
|
792
790
|
if (a instanceof Element) {
|
|
793
791
|
const c = /* @__PURE__ */ new Map();
|
|
794
|
-
o.forEach((
|
|
795
|
-
const l = new Set(s.map((
|
|
796
|
-
let
|
|
797
|
-
for (let
|
|
798
|
-
const h = s[
|
|
792
|
+
o.forEach((f) => f.key && c.set(f.key, f));
|
|
793
|
+
const l = new Set(s.map((f) => f.key));
|
|
794
|
+
let u = [];
|
|
795
|
+
for (let f = 0; f < s.length; f++) {
|
|
796
|
+
const h = s[f], m = h.key ? c.get(h.key) : o[f];
|
|
799
797
|
let p;
|
|
800
|
-
const
|
|
801
|
-
if (m && m.dom && (!
|
|
802
|
-
|
|
798
|
+
const C = h.type === "input" || h.type === "select" || h.type === "textarea";
|
|
799
|
+
if (m && m.dom && (!C || m.type === h.type && m.key === h.key))
|
|
800
|
+
R(a, m, h), p = m.dom;
|
|
803
801
|
else {
|
|
804
|
-
const
|
|
805
|
-
if (p =
|
|
802
|
+
const E = g(h);
|
|
803
|
+
if (p = E instanceof Node ? E : void 0, p) {
|
|
806
804
|
if ((p instanceof Element || p instanceof Node) && p.contains(a))
|
|
807
805
|
throw console.error("[VDOM] Attempted to insert a parent into its own child:", {
|
|
808
806
|
parentTag: a.tagName,
|
|
@@ -812,88 +810,151 @@ function L(e, t, n) {
|
|
|
812
810
|
parent: a,
|
|
813
811
|
child: p
|
|
814
812
|
}), new Error("VDOM patch error: Attempted to insert a parent into its own child");
|
|
815
|
-
a.insertBefore(p, a.childNodes[
|
|
813
|
+
a.insertBefore(p, a.childNodes[f] || null);
|
|
816
814
|
}
|
|
817
815
|
}
|
|
818
|
-
h.dom = p, p &&
|
|
816
|
+
h.dom = p, p && u.push(p);
|
|
819
817
|
}
|
|
820
|
-
for (o.forEach((
|
|
821
|
-
!l.has(
|
|
818
|
+
for (o.forEach((f) => {
|
|
819
|
+
!l.has(f.key) && f.dom && a.contains(f.dom) && a.removeChild(f.dom);
|
|
822
820
|
}); a.childNodes.length > s.length; )
|
|
823
821
|
a.removeChild(a.lastChild);
|
|
824
|
-
for (let
|
|
825
|
-
if (a.childNodes[
|
|
826
|
-
if ((
|
|
822
|
+
for (let f = 0; f < u.length; f++)
|
|
823
|
+
if (a.childNodes[f] !== u[f]) {
|
|
824
|
+
if ((u[f] instanceof Element || u[f] instanceof Node) && u[f].contains(a))
|
|
827
825
|
throw new Error("VDOM patch error: Attempted to insert a parent into its own child");
|
|
828
|
-
a.insertBefore(
|
|
826
|
+
a.insertBefore(u[f], a.childNodes[f] || null);
|
|
829
827
|
}
|
|
830
828
|
n.dom = a;
|
|
831
|
-
const
|
|
832
|
-
Array.from(a.childNodes).forEach((
|
|
833
|
-
const m =
|
|
834
|
-
(m && !
|
|
829
|
+
const d = new Set(s.map((f) => f.key));
|
|
830
|
+
Array.from(a.childNodes).forEach((f, h) => {
|
|
831
|
+
const m = f.getAttribute?.("data-uid");
|
|
832
|
+
(m && !d.has(m) || h >= s.length) && a.removeChild(f);
|
|
835
833
|
});
|
|
836
834
|
}
|
|
837
835
|
}
|
|
836
|
+
const et = (e) => e ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(e)) : {}, b = (e, t) => {
|
|
837
|
+
for (const n of e) {
|
|
838
|
+
const r = [], o = n.path.replace(/:[^/]+/g, (a) => (r.push(a.slice(1)), "([^/]+)")), s = new RegExp(`^${o}$`), i = t.match(s);
|
|
839
|
+
if (i) {
|
|
840
|
+
const a = {};
|
|
841
|
+
return r.forEach((c, l) => {
|
|
842
|
+
a[c] = i[l + 1];
|
|
843
|
+
}), { route: n, params: a };
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return { route: null, params: {} };
|
|
847
|
+
};
|
|
848
|
+
function nt(e) {
|
|
849
|
+
const { routes: t, base: n = "" } = e;
|
|
850
|
+
let r, o, s, i, a, c, l;
|
|
851
|
+
if (typeof window < "u" && typeof document < "u") {
|
|
852
|
+
r = () => {
|
|
853
|
+
const d = new URL(window.location.href), f = d.pathname.replace(n, "") || "/", h = et(d.search);
|
|
854
|
+
return { path: f, query: h };
|
|
855
|
+
}, o = r();
|
|
856
|
+
const u = b(t, o.path);
|
|
857
|
+
s = $({
|
|
858
|
+
path: o.path,
|
|
859
|
+
params: u.params,
|
|
860
|
+
query: o.query
|
|
861
|
+
}), i = () => {
|
|
862
|
+
const d = r(), f = b(t, d.path), h = s.getState();
|
|
863
|
+
h.path = d.path, h.params = f.params, h.query = d.query;
|
|
864
|
+
}, window.addEventListener("popstate", i), a = (d) => {
|
|
865
|
+
window.history.pushState({}, "", n + d), i();
|
|
866
|
+
}, c = (d) => {
|
|
867
|
+
window.history.replaceState({}, "", n + d), i();
|
|
868
|
+
}, l = () => window.history.back();
|
|
869
|
+
} else {
|
|
870
|
+
r = () => ({ path: "/", query: {} }), o = r();
|
|
871
|
+
const u = b(t, o.path);
|
|
872
|
+
s = $({
|
|
873
|
+
path: o.path,
|
|
874
|
+
params: u.params,
|
|
875
|
+
query: o.query
|
|
876
|
+
}), i = () => {
|
|
877
|
+
}, a = () => {
|
|
878
|
+
}, c = () => {
|
|
879
|
+
}, l = () => {
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
return {
|
|
883
|
+
store: s,
|
|
884
|
+
push: a,
|
|
885
|
+
replace: c,
|
|
886
|
+
back: l,
|
|
887
|
+
subscribe: s.subscribe,
|
|
888
|
+
matchRoute: (u) => b(t, u),
|
|
889
|
+
getCurrent: () => s.getState()
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
function ft(e) {
|
|
893
|
+
const t = nt(e);
|
|
894
|
+
return typeof window < "u" && (window.__routerInstance = t), t;
|
|
895
|
+
}
|
|
896
|
+
function ht(e, t) {
|
|
897
|
+
return b(e, t);
|
|
898
|
+
}
|
|
838
899
|
function M(e, t) {
|
|
839
900
|
const n = [], r = t ? Object.keys(t) : [], o = { ...e };
|
|
840
901
|
let s = null;
|
|
841
|
-
function i(
|
|
842
|
-
return n.push(
|
|
843
|
-
const
|
|
844
|
-
|
|
902
|
+
function i(u) {
|
|
903
|
+
return n.push(u), () => {
|
|
904
|
+
const d = n.indexOf(u);
|
|
905
|
+
d !== -1 && n.splice(d, 1);
|
|
845
906
|
};
|
|
846
907
|
}
|
|
847
|
-
function a(
|
|
848
|
-
Object.assign(s,
|
|
908
|
+
function a(u) {
|
|
909
|
+
Object.assign(s, u), n.forEach((d) => d(s));
|
|
849
910
|
}
|
|
850
911
|
const c = /* @__PURE__ */ new WeakMap();
|
|
851
|
-
function l(
|
|
852
|
-
if (c.has(
|
|
853
|
-
const
|
|
854
|
-
get(
|
|
912
|
+
function l(u) {
|
|
913
|
+
if (c.has(u)) return c.get(u);
|
|
914
|
+
const d = new Proxy(u, {
|
|
915
|
+
get(f, h, m) {
|
|
855
916
|
if (h === "subscribe") return i;
|
|
856
917
|
if (h === "set") return a;
|
|
857
918
|
if (t && r.includes(h))
|
|
858
919
|
return t[h](s);
|
|
859
|
-
const p = Reflect.get(
|
|
920
|
+
const p = Reflect.get(f, h, m);
|
|
860
921
|
return typeof p == "object" && p !== null ? l(p) : p;
|
|
861
922
|
},
|
|
862
|
-
set(
|
|
923
|
+
set(f, h, m, p) {
|
|
863
924
|
if (t && r.includes(h))
|
|
864
925
|
return !1;
|
|
865
|
-
const
|
|
866
|
-
return
|
|
926
|
+
const C = f[h], E = Reflect.set(f, h, m, p);
|
|
927
|
+
return C !== m && n.forEach((W) => W(s)), E;
|
|
867
928
|
},
|
|
868
|
-
deleteProperty(
|
|
929
|
+
deleteProperty(f, h) {
|
|
869
930
|
if (t && r.includes(h))
|
|
870
931
|
return !1;
|
|
871
|
-
const m = Reflect.deleteProperty(
|
|
932
|
+
const m = Reflect.deleteProperty(f, h);
|
|
872
933
|
return n.forEach((p) => p(s)), m;
|
|
873
934
|
}
|
|
874
935
|
});
|
|
875
|
-
return c.set(
|
|
936
|
+
return c.set(u, d), d;
|
|
876
937
|
}
|
|
877
938
|
return s = l(o), s;
|
|
878
939
|
}
|
|
879
|
-
const
|
|
880
|
-
function
|
|
881
|
-
|
|
940
|
+
const _ = [];
|
|
941
|
+
function pt(e) {
|
|
942
|
+
_.push(e);
|
|
882
943
|
}
|
|
883
|
-
function
|
|
944
|
+
function A(e, t = /* @__PURE__ */ new WeakSet()) {
|
|
884
945
|
if (e === null || typeof e != "object" || t.has(e)) return e;
|
|
885
|
-
if (t.add(e), Array.isArray(e)) return e.map((o) =>
|
|
946
|
+
if (t.add(e), Array.isArray(e)) return e.map((o) => A(o, t));
|
|
886
947
|
Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null && Object.setPrototypeOf(e, null);
|
|
887
948
|
const n = ["__proto__", "constructor", "prototype"], r = /* @__PURE__ */ Object.create(null);
|
|
888
949
|
for (const o of Object.keys(e))
|
|
889
|
-
n.includes(o) || (r[o] =
|
|
950
|
+
n.includes(o) || (r[o] = A(e[o], t));
|
|
890
951
|
return r;
|
|
891
952
|
}
|
|
892
953
|
function S(e) {
|
|
893
954
|
return !!e && typeof e.then == "function";
|
|
894
955
|
}
|
|
895
|
-
let
|
|
896
|
-
typeof HTMLElement < "u" && (
|
|
956
|
+
let z;
|
|
957
|
+
typeof HTMLElement < "u" && (z = class extends HTMLElement {
|
|
897
958
|
/**
|
|
898
959
|
* Syncs whitelisted state properties to attributes after render.
|
|
899
960
|
* Only keys listed in config.reflect are reflected.
|
|
@@ -958,7 +1019,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
958
1019
|
o = isNaN(s) ? this.config?.state?.[e] : s;
|
|
959
1020
|
}
|
|
960
1021
|
else r === "boolean" && (o = o === "true");
|
|
961
|
-
o =
|
|
1022
|
+
o = A(o), this.stateObj[e] !== o && (this.config?.debug && console.log("[runtime] state update:", { name: e, value: o }), this.stateObj[e] = o, this.render());
|
|
962
1023
|
}
|
|
963
1024
|
}
|
|
964
1025
|
/**
|
|
@@ -1021,7 +1082,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1021
1082
|
if (n) {
|
|
1022
1083
|
const [, o, s, i] = n, a = parseInt(s, 10), c = this.stateObj[o];
|
|
1023
1084
|
e instanceof HTMLInputElement && e.type === "checkbox" && (e.checked = !!(Array.isArray(c) && c[a] && c[a][i]));
|
|
1024
|
-
const l = (
|
|
1085
|
+
const l = (u) => {
|
|
1025
1086
|
!Array.isArray(c) || !c[a] || (e instanceof HTMLInputElement && e.type === "checkbox" ? c[a][i] = e.checked : c[a][i] = e.value);
|
|
1026
1087
|
};
|
|
1027
1088
|
e.addEventListener("input", l), e.addEventListener("change", l), e._listItemModelListener = l;
|
|
@@ -1029,12 +1090,12 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1029
1090
|
}
|
|
1030
1091
|
const r = t.match(/^([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)((?:\|[a-zA-Z0-9_]+)*)$/);
|
|
1031
1092
|
if (r) {
|
|
1032
|
-
const [, o, s, i] = r, a = this.stateObj[o], c = i ? i.split("|").map((
|
|
1093
|
+
const [, o, s, i] = r, a = this.stateObj[o], c = i ? i.split("|").map((u) => u.trim()).filter(Boolean) : [];
|
|
1033
1094
|
e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked = !!(a && a[s]) : e instanceof HTMLInputElement && (e.value = a ? String(a[s] ?? "") : "");
|
|
1034
|
-
const l = (
|
|
1095
|
+
const l = (u) => {
|
|
1035
1096
|
if (!a) return;
|
|
1036
|
-
let
|
|
1037
|
-
e instanceof HTMLInputElement && e.type === "checkbox" ?
|
|
1097
|
+
let d;
|
|
1098
|
+
e instanceof HTMLInputElement && e.type === "checkbox" ? d = e.checked : (d = e.value, c.includes("number") && (d = Number(d)), c.includes("trim") && typeof d == "string" && (d = d.trim())), a[s] = d;
|
|
1038
1099
|
};
|
|
1039
1100
|
e.addEventListener("input", l), e.addEventListener("change", l), e._listItemModelListener = l;
|
|
1040
1101
|
}
|
|
@@ -1047,7 +1108,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1047
1108
|
const e = this.shadowRoot;
|
|
1048
1109
|
e && (e.querySelectorAll("[data-model]").forEach((t) => {
|
|
1049
1110
|
const n = t.getAttribute("data-model");
|
|
1050
|
-
n && (t._dataModelBound || (
|
|
1111
|
+
n && (t._dataModelBound || (B(t, this.stateObj, n), t._dataModelBound = !0));
|
|
1051
1112
|
}), e.querySelectorAll("[data-model]").forEach((t) => {
|
|
1052
1113
|
const [n] = t.getAttribute("data-model")?.split("|").map((r) => r.trim()) ?? [];
|
|
1053
1114
|
if (!(!n || !(n in this.stateObj)))
|
|
@@ -1089,11 +1150,11 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1089
1150
|
state: this.stateObj,
|
|
1090
1151
|
emit: (s, i) => this.dispatchEvent(new CustomEvent(s, { detail: i, bubbles: !0 })),
|
|
1091
1152
|
onGlobal: (s, i) => {
|
|
1092
|
-
const a =
|
|
1153
|
+
const a = w.on(s, i);
|
|
1093
1154
|
return this._globalUnsubscribes.push(a), a;
|
|
1094
1155
|
},
|
|
1095
|
-
offGlobal: (s, i) =>
|
|
1096
|
-
emitGlobal: (s, i) =>
|
|
1156
|
+
offGlobal: (s, i) => w.off(s, i),
|
|
1157
|
+
emitGlobal: (s, i) => w.emit(s, i)
|
|
1097
1158
|
}, Object.keys(this.config).forEach((s) => {
|
|
1098
1159
|
if (s.startsWith("on") && s.length > 2 && typeof this.config[s] == "function") {
|
|
1099
1160
|
const i = s.charAt(2).toLowerCase() + s.slice(3), a = (c) => {
|
|
@@ -1181,7 +1242,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1181
1242
|
render() {
|
|
1182
1243
|
this._hasError = !1, this.syncControlledInputsAndEvents(), setTimeout(() => this.attachControlledInputListeners(), 0);
|
|
1183
1244
|
try {
|
|
1184
|
-
|
|
1245
|
+
_.forEach((t) => {
|
|
1185
1246
|
try {
|
|
1186
1247
|
t.onRender?.(this.stateObj, this.api);
|
|
1187
1248
|
} catch (n) {
|
|
@@ -1247,14 +1308,14 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1247
1308
|
};
|
|
1248
1309
|
if (typeof e == "string") {
|
|
1249
1310
|
let n = function(c) {
|
|
1250
|
-
return c.replace(/<([a-zA-Z0-9]+)([^>]*)>/g, (l,
|
|
1251
|
-
const
|
|
1252
|
-
return `<${
|
|
1311
|
+
return c.replace(/<([a-zA-Z0-9]+)([^>]*)>/g, (l, u, d) => {
|
|
1312
|
+
const f = d.replace(/\s+on[a-zA-Z]+\s*=\s*(['"][^'"]*['"]|[^\s>]*)/gi, "");
|
|
1313
|
+
return `<${u}${f}>`;
|
|
1253
1314
|
});
|
|
1254
1315
|
}, r = function(c) {
|
|
1255
1316
|
c.children.forEach(r);
|
|
1256
1317
|
};
|
|
1257
|
-
const o = n(e), s =
|
|
1318
|
+
const o = n(e), s = tt(o);
|
|
1258
1319
|
r(s);
|
|
1259
1320
|
const i = this.shadowRoot;
|
|
1260
1321
|
if (!i)
|
|
@@ -1265,8 +1326,8 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1265
1326
|
(l) => l.nodeType === 1 && l !== a
|
|
1266
1327
|
);
|
|
1267
1328
|
if (c) {
|
|
1268
|
-
Array.from(c.childNodes).forEach((
|
|
1269
|
-
|
|
1329
|
+
Array.from(c.childNodes).forEach((d) => {
|
|
1330
|
+
d.nodeType === 1 && d.nodeName === "STYLE" || c.removeChild(d);
|
|
1270
1331
|
});
|
|
1271
1332
|
const l = {
|
|
1272
1333
|
type: "#fragment",
|
|
@@ -1274,12 +1335,12 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1274
1335
|
children: s.children,
|
|
1275
1336
|
props: {},
|
|
1276
1337
|
key: void 0
|
|
1277
|
-
},
|
|
1278
|
-
|
|
1338
|
+
}, u = this._prevVNode && this._prevVNode.type === "#fragment" ? { ...this._prevVNode, dom: c } : l;
|
|
1339
|
+
R(c, u, l);
|
|
1279
1340
|
} else
|
|
1280
1341
|
s.children.forEach((l) => {
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1342
|
+
const u = g(l);
|
|
1343
|
+
u && i.appendChild(u), l.dom = u ?? void 0;
|
|
1283
1344
|
});
|
|
1284
1345
|
} else {
|
|
1285
1346
|
let c = Array.from(this.shadowRoot.childNodes).find(
|
|
@@ -1290,7 +1351,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1290
1351
|
const l = g(s);
|
|
1291
1352
|
l && (this.shadowRoot.contains(c) && this.shadowRoot.replaceChild(l, c), c = l);
|
|
1292
1353
|
} else
|
|
1293
|
-
|
|
1354
|
+
R(c, this._prevVNode, s);
|
|
1294
1355
|
else
|
|
1295
1356
|
c = g(s), c && this.shadowRoot.appendChild(c);
|
|
1296
1357
|
s.dom = c;
|
|
@@ -1299,13 +1360,13 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1299
1360
|
} else {
|
|
1300
1361
|
const n = !this.shadowRoot.firstElementChild, r = this.lastCompiledTemplate?.id === e.id;
|
|
1301
1362
|
if (n) {
|
|
1302
|
-
const o =
|
|
1363
|
+
const o = D(e, this.stateObj, this.api);
|
|
1303
1364
|
this.shadowRoot.appendChild(o);
|
|
1304
1365
|
} else if (r && this.shadowRoot.firstElementChild) {
|
|
1305
1366
|
const o = this.lastState;
|
|
1306
|
-
|
|
1367
|
+
J(e, this.shadowRoot.firstElementChild, this.stateObj, this.api, o || void 0);
|
|
1307
1368
|
} else {
|
|
1308
|
-
const o =
|
|
1369
|
+
const o = D(e, this.stateObj, this.api);
|
|
1309
1370
|
let s = this.shadowRoot.querySelector("style");
|
|
1310
1371
|
s || (s = document.createElement("style"), this.shadowRoot.insertBefore(s, this.shadowRoot.firstChild)), this.config.style ? s.textContent = typeof this.config.style == "function" ? this.config.style(this.stateObj) : this.config.style : s.textContent = "";
|
|
1311
1372
|
let i = this.shadowRoot.querySelector("[data-root]");
|
|
@@ -1326,7 +1387,7 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1326
1387
|
* @param error - Error object
|
|
1327
1388
|
*/
|
|
1328
1389
|
_handleRenderError(e) {
|
|
1329
|
-
if (this._hasError = !0, this.config.debug && console.error(`[runtime] Render error in <${this.tagName.toLowerCase()}>:`, e),
|
|
1390
|
+
if (this._hasError = !0, this.config.debug && console.error(`[runtime] Render error in <${this.tagName.toLowerCase()}>:`, e), _.forEach((t) => t.onError?.(e instanceof Error ? e : new Error(String(e)), this.stateObj, this.api)), "onError" in this.config && typeof this.config.onError == "function")
|
|
1330
1391
|
try {
|
|
1331
1392
|
this.config.onError(e instanceof Error ? e : new Error(String(e)), this.api.state, this.api);
|
|
1332
1393
|
} catch (t) {
|
|
@@ -1414,8 +1475,8 @@ typeof HTMLElement < "u" && (P = class extends HTMLElement {
|
|
|
1414
1475
|
`;
|
|
1415
1476
|
}
|
|
1416
1477
|
});
|
|
1417
|
-
function
|
|
1418
|
-
if (t =
|
|
1478
|
+
function rt(e, t) {
|
|
1479
|
+
if (t = A(t), t.debug && console.log(`[runtime] Debugging component: ${e}`, t), !e || !t.template) {
|
|
1419
1480
|
t && typeof t.onError == "function" && t.onError(new Error("Component requires tag and template"), t.state ?? {}, {
|
|
1420
1481
|
state: t.state ?? {},
|
|
1421
1482
|
emit: () => {
|
|
@@ -1429,11 +1490,11 @@ function lt(e, t) {
|
|
|
1429
1490
|
}), t && t.debug && console.error("[runtime] Malformed config:", { tag: e, config: t });
|
|
1430
1491
|
return;
|
|
1431
1492
|
}
|
|
1432
|
-
if (
|
|
1493
|
+
if (_.forEach((u) => {
|
|
1433
1494
|
try {
|
|
1434
|
-
|
|
1435
|
-
} catch (
|
|
1436
|
-
t && typeof t.onError == "function" && t.onError(
|
|
1495
|
+
u.onInit?.(t);
|
|
1496
|
+
} catch (d) {
|
|
1497
|
+
t && typeof t.onError == "function" && t.onError(d instanceof Error ? d : new Error(String(d)), t.state, {
|
|
1437
1498
|
state: t.state,
|
|
1438
1499
|
emit: () => {
|
|
1439
1500
|
},
|
|
@@ -1443,11 +1504,11 @@ function lt(e, t) {
|
|
|
1443
1504
|
},
|
|
1444
1505
|
emitGlobal: () => {
|
|
1445
1506
|
}
|
|
1446
|
-
}), t && t.debug && console.error("[runtime] Plugin onInit error:",
|
|
1507
|
+
}), t && t.debug && console.error("[runtime] Plugin onInit error:", d);
|
|
1447
1508
|
}
|
|
1448
1509
|
}), (typeof window < "u" && window.VITE_DEV_HMR || typeof import.meta < "u" && void 0) && customElements.get(e))
|
|
1449
1510
|
try {
|
|
1450
|
-
document.querySelectorAll(e).forEach((
|
|
1511
|
+
document.querySelectorAll(e).forEach((u) => u.remove()), window.customElements._definitions && delete window.customElements._definitions[e];
|
|
1451
1512
|
} catch {
|
|
1452
1513
|
}
|
|
1453
1514
|
if (customElements.get(e)) {
|
|
@@ -1457,9 +1518,9 @@ function lt(e, t) {
|
|
|
1457
1518
|
const s = M(t.state ?? {}, t.computed);
|
|
1458
1519
|
t.state = s, t._subscribe = s.subscribe;
|
|
1459
1520
|
const i = t.state ?? {}, a = Object.keys(i).filter(
|
|
1460
|
-
(
|
|
1521
|
+
(u) => ["string", "number", "boolean"].includes(typeof i[u])
|
|
1461
1522
|
);
|
|
1462
|
-
class c extends
|
|
1523
|
+
class c extends z {
|
|
1463
1524
|
static get observedAttributes() {
|
|
1464
1525
|
return a;
|
|
1465
1526
|
}
|
|
@@ -1470,31 +1531,42 @@ function lt(e, t) {
|
|
|
1470
1531
|
const l = c;
|
|
1471
1532
|
typeof customElements < "u" && !customElements.get(e) && (window.__componentRegistry = window.__componentRegistry || {}, window.__componentRegistry[e] = t, customElements.define(e, l));
|
|
1472
1533
|
}
|
|
1534
|
+
rt("router-view", {
|
|
1535
|
+
template: (e, t) => {
|
|
1536
|
+
const n = window.__routerInstance;
|
|
1537
|
+
if (!n) return "<div>Router not initialized.</div>";
|
|
1538
|
+
const { path: r } = n.getCurrent(), o = n.matchRoute(r);
|
|
1539
|
+
return o.route ? `<${o.route.component}></${o.route.component}>` : "<div>Not found</div>";
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1473
1542
|
export {
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1543
|
+
$ as Store,
|
|
1544
|
+
lt as classes,
|
|
1545
|
+
at as compile,
|
|
1546
|
+
dt as compileTemplate,
|
|
1547
|
+
rt as component,
|
|
1548
|
+
L as createVNodeFromElement,
|
|
1549
|
+
ct as css,
|
|
1550
|
+
A as deepSanitizeObject,
|
|
1551
|
+
w as eventBus,
|
|
1552
|
+
it as generateHydrationScript,
|
|
1553
|
+
I as getVNodeKey,
|
|
1554
|
+
ot as html,
|
|
1555
|
+
ft as initRouter,
|
|
1486
1556
|
S as isPromise,
|
|
1557
|
+
ht as matchRouteSSR,
|
|
1487
1558
|
g as mountVNode,
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1559
|
+
tt as parseVNodeFromHTML,
|
|
1560
|
+
R as patchVNode,
|
|
1561
|
+
D as renderCompiledTemplate,
|
|
1562
|
+
st as renderComponentsToString,
|
|
1563
|
+
U as renderToString,
|
|
1564
|
+
_ as runtimePlugins,
|
|
1565
|
+
N as safeReplaceChild,
|
|
1566
|
+
ut as styles,
|
|
1567
|
+
J as updateCompiledTemplate,
|
|
1568
|
+
B as useDataModel,
|
|
1569
|
+
nt as useRouter,
|
|
1570
|
+
pt as useRuntimePlugin
|
|
1499
1571
|
};
|
|
1500
1572
|
//# sourceMappingURL=custom-elements-runtime.es.js.map
|