@jasonshimmy/custom-elements-runtime 2.3.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,267 +1,453 @@
|
|
|
1
|
-
import { component as
|
|
2
|
-
import { r as
|
|
3
|
-
import { createStore as
|
|
4
|
-
import { d as
|
|
5
|
-
import { match as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { component as tt, html as z, useOnConnected as et, useOnDisconnected as nt, useProps as st, useStyle as it } from "./custom-elements-runtime.es.js";
|
|
2
|
+
import { r as V, c as T } from "./namespace-helpers-Dw1mgQab.js";
|
|
3
|
+
import { createStore as rt } from "./custom-elements-runtime.store.es.js";
|
|
4
|
+
import { d as F, a as P } from "./logger-BuUYv7C_.js";
|
|
5
|
+
import { match as ct } from "./custom-elements-runtime.directives.es.js";
|
|
6
|
+
const Q = (o) => o ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(o)) : {}, lt = (o) => {
|
|
7
|
+
if (!o || Object.keys(o).length === 0) return "";
|
|
8
|
+
try {
|
|
9
|
+
return "?" + new URLSearchParams(o).toString();
|
|
10
|
+
} catch {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
}, at = (o) => o ? /^\s*javascript\s*:/i.test(o) : !1, ot = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
function ut(o) {
|
|
15
|
+
return o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9
16
|
}
|
|
10
|
-
function
|
|
11
|
-
if (!
|
|
12
|
-
let
|
|
13
|
-
return
|
|
17
|
+
function k(o) {
|
|
18
|
+
if (!o) return "/";
|
|
19
|
+
let i = o.replace(/\/+/g, "/");
|
|
20
|
+
return i.startsWith("/") || (i = "/" + i), i.length > 1 && i.endsWith("/") && (i = i.slice(0, -1)), i;
|
|
14
21
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
for (let c = 0; c <
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (c !==
|
|
21
|
-
return
|
|
22
|
-
`Route '${
|
|
22
|
+
function ft(o) {
|
|
23
|
+
const i = o.path || "/", s = k(i), d = s === "/" ? [] : s.split("/").filter(Boolean), h = [], l = [];
|
|
24
|
+
for (let c = 0; c < d.length; c++) {
|
|
25
|
+
const p = d[c];
|
|
26
|
+
if (p === "*") {
|
|
27
|
+
if (c !== d.length - 1)
|
|
28
|
+
return P(
|
|
29
|
+
`Route '${o.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`
|
|
23
30
|
), { invalid: !0 };
|
|
24
|
-
const
|
|
25
|
-
|
|
31
|
+
const g = `splat${h.length}`;
|
|
32
|
+
h.push(g), l.push("__SPLAT__");
|
|
26
33
|
continue;
|
|
27
34
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
`Route '${
|
|
35
|
+
const b = p.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
|
|
36
|
+
if (b) {
|
|
37
|
+
const g = b[1], q = !!b[2];
|
|
38
|
+
if (q && c !== d.length - 1)
|
|
39
|
+
return P(
|
|
40
|
+
`Route '${o.path}' contains a splat param ':${g}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`
|
|
34
41
|
), { invalid: !0 };
|
|
35
|
-
|
|
42
|
+
h.push(g), l.push(q ? "__SPLAT__" : "([^/]+)");
|
|
36
43
|
continue;
|
|
37
44
|
}
|
|
38
|
-
|
|
45
|
+
l.push(ut(p));
|
|
39
46
|
}
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
else if (
|
|
44
|
-
const
|
|
45
|
-
|
|
47
|
+
let m;
|
|
48
|
+
if (l.length === 0)
|
|
49
|
+
m = "^/$";
|
|
50
|
+
else if (l[l.length - 1] === "__SPLAT__") {
|
|
51
|
+
const p = l.slice(0, -1).join("/");
|
|
52
|
+
p ? m = `^/${p}(?:/(.*))?(?:/)?$` : m = "^(?:/(.*))?(?:/)?$";
|
|
46
53
|
} else
|
|
47
|
-
|
|
54
|
+
m = `^/${l.join("/")}(?:/)?$`;
|
|
48
55
|
try {
|
|
49
|
-
return { regex: new RegExp(
|
|
56
|
+
return { regex: new RegExp(m), paramNames: h };
|
|
50
57
|
} catch (c) {
|
|
51
|
-
return
|
|
58
|
+
return P(`Failed to compile route regex for '${o.path}': ${String(c)}`), { invalid: !0 };
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
59
|
-
const { regex:
|
|
61
|
+
const M = (o, i) => {
|
|
62
|
+
const s = k(i);
|
|
63
|
+
for (const d of o) {
|
|
64
|
+
let h = ot.get(d);
|
|
65
|
+
if (h || (h = ft(d), ot.set(d, h)), h.invalid) continue;
|
|
66
|
+
const { regex: l, paramNames: m } = h, c = l.exec(s);
|
|
60
67
|
if (c) {
|
|
61
|
-
const
|
|
68
|
+
const p = {}, b = (g) => {
|
|
62
69
|
try {
|
|
63
|
-
return decodeURIComponent(
|
|
70
|
+
return decodeURIComponent(g);
|
|
64
71
|
} catch {
|
|
65
|
-
return
|
|
72
|
+
return g;
|
|
66
73
|
}
|
|
67
74
|
};
|
|
68
|
-
for (let
|
|
69
|
-
const
|
|
70
|
-
|
|
75
|
+
for (let g = 0; g < m.length; g++) {
|
|
76
|
+
const q = c[g + 1] || "";
|
|
77
|
+
p[m[g]] = q ? b(q) : "";
|
|
71
78
|
}
|
|
72
|
-
return { route:
|
|
79
|
+
return { route: d, params: p };
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
return { route: null, params: {} };
|
|
76
83
|
};
|
|
77
|
-
function
|
|
78
|
-
for (const
|
|
79
|
-
if (
|
|
84
|
+
function K(o, i) {
|
|
85
|
+
for (const s of o)
|
|
86
|
+
if (M([s], i).route !== null) return s;
|
|
80
87
|
return null;
|
|
81
88
|
}
|
|
82
|
-
const
|
|
83
|
-
async function
|
|
84
|
-
if (
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
89
|
+
const H = {};
|
|
90
|
+
async function ht(o) {
|
|
91
|
+
if (o.component) return o.component;
|
|
92
|
+
if (o.load) {
|
|
93
|
+
if (H[o.path]) return H[o.path];
|
|
87
94
|
try {
|
|
88
|
-
const
|
|
89
|
-
return
|
|
95
|
+
const i = await o.load();
|
|
96
|
+
return H[o.path] = i.default, i.default;
|
|
90
97
|
} catch {
|
|
91
|
-
throw new Error(`Failed to load component for route: ${
|
|
98
|
+
throw new Error(`Failed to load component for route: ${o.path}`);
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
|
-
throw new Error(`No component or loader defined for route: ${
|
|
101
|
+
throw new Error(`No component or loader defined for route: ${o.path}`);
|
|
95
102
|
}
|
|
96
|
-
function
|
|
97
|
-
const { routes:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
function pt(o) {
|
|
104
|
+
const { routes: i, base: s = "", initialUrl: d, scrollToFragment: h = !0 } = o, l = (() => {
|
|
105
|
+
if (!s) return "";
|
|
106
|
+
const r = k(s);
|
|
107
|
+
return r === "/" ? "" : r;
|
|
108
|
+
})(), m = typeof h == "boolean" ? { enabled: !!h, offset: 0, timeoutMs: 2e3 } : {
|
|
109
|
+
enabled: h.enabled ?? !0,
|
|
110
|
+
offset: h.offset ?? 0,
|
|
111
|
+
timeoutMs: h.timeoutMs ?? 2e3
|
|
112
|
+
};
|
|
113
|
+
let c, p, b, g, q, B, D;
|
|
114
|
+
const Y = async (r, e) => {
|
|
115
|
+
const t = K(i, r.path);
|
|
116
|
+
if (!t || !t.beforeEnter) return !0;
|
|
102
117
|
try {
|
|
103
|
-
const
|
|
104
|
-
return typeof
|
|
105
|
-
} catch (
|
|
106
|
-
return
|
|
118
|
+
const n = await t.beforeEnter(r, e);
|
|
119
|
+
return typeof n == "string" ? (await y(n, !0), !1) : n !== !1;
|
|
120
|
+
} catch (n) {
|
|
121
|
+
return F("beforeEnter error", n), !1;
|
|
107
122
|
}
|
|
108
|
-
},
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
123
|
+
}, X = async (r, e) => {
|
|
124
|
+
const t = K(i, r.path);
|
|
125
|
+
if (!t || !t.onEnter) return !0;
|
|
111
126
|
try {
|
|
112
|
-
const
|
|
113
|
-
return typeof
|
|
114
|
-
} catch (
|
|
115
|
-
return
|
|
127
|
+
const n = await t.onEnter(r, e);
|
|
128
|
+
return typeof n == "string" ? (await y(n, !0), !1) : n !== !1;
|
|
129
|
+
} catch (n) {
|
|
130
|
+
return F("onEnter error", n), !1;
|
|
116
131
|
}
|
|
117
|
-
},
|
|
118
|
-
const
|
|
119
|
-
if (!(!
|
|
132
|
+
}, Z = (r, e) => {
|
|
133
|
+
const t = K(i, r.path);
|
|
134
|
+
if (!(!t || !t.afterEnter))
|
|
120
135
|
try {
|
|
121
|
-
|
|
122
|
-
} catch (
|
|
123
|
-
|
|
136
|
+
t.afterEnter(r, e);
|
|
137
|
+
} catch (n) {
|
|
138
|
+
F("afterEnter error", n);
|
|
124
139
|
}
|
|
125
|
-
}
|
|
140
|
+
};
|
|
141
|
+
let w = 0, C = null, O = null, L = null;
|
|
142
|
+
async function a(r, e = 0) {
|
|
126
143
|
try {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
const t = document.getElementById(r);
|
|
145
|
+
if (!t) return !1;
|
|
146
|
+
if (e && e > 0)
|
|
147
|
+
try {
|
|
148
|
+
const n = t.getBoundingClientRect(), E = Math.max(0, window.scrollY + n.top - e);
|
|
149
|
+
typeof window.scrollTo == "function" && window.scrollTo({ top: E, behavior: "auto" });
|
|
150
|
+
} catch {
|
|
151
|
+
try {
|
|
152
|
+
t.scrollIntoView();
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (typeof t.scrollIntoView == "function")
|
|
157
|
+
try {
|
|
158
|
+
t.scrollIntoView({
|
|
159
|
+
behavior: "auto",
|
|
160
|
+
block: "start",
|
|
161
|
+
inline: "nearest"
|
|
162
|
+
});
|
|
163
|
+
} catch {
|
|
164
|
+
try {
|
|
165
|
+
t.scrollIntoView();
|
|
166
|
+
} catch {
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return !0;
|
|
170
|
+
} catch {
|
|
171
|
+
return !1;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function u() {
|
|
175
|
+
if (C) {
|
|
176
|
+
try {
|
|
177
|
+
C.disconnect();
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
C = null;
|
|
181
|
+
}
|
|
182
|
+
if (O) {
|
|
183
|
+
try {
|
|
184
|
+
clearTimeout(O);
|
|
185
|
+
} catch {
|
|
186
|
+
}
|
|
187
|
+
O = null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function v(r, e, t) {
|
|
191
|
+
w += 1;
|
|
192
|
+
const n = w;
|
|
193
|
+
if (L) {
|
|
194
|
+
try {
|
|
195
|
+
L(!1);
|
|
196
|
+
} catch {
|
|
197
|
+
}
|
|
198
|
+
L = null;
|
|
199
|
+
}
|
|
200
|
+
return u(), new Promise((E) => {
|
|
201
|
+
L = E;
|
|
202
|
+
const f = (A) => {
|
|
203
|
+
if (n === w) {
|
|
204
|
+
u();
|
|
205
|
+
try {
|
|
206
|
+
E(A);
|
|
207
|
+
} finally {
|
|
208
|
+
L = null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
136
211
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
212
|
+
queueMicrotask(async () => {
|
|
213
|
+
if (n !== w) return f(!1);
|
|
214
|
+
if (await a(r, e)) return f(!0);
|
|
215
|
+
if (typeof window.requestAnimationFrame == "function")
|
|
216
|
+
window.requestAnimationFrame(async () => {
|
|
217
|
+
if (n !== w) return f(!1);
|
|
218
|
+
if (await a(r, e)) return f(!0);
|
|
219
|
+
if (n !== w) return f(!1);
|
|
220
|
+
const A = document.querySelector("router-view") || document.body;
|
|
221
|
+
try {
|
|
222
|
+
const x = new MutationObserver(async () => {
|
|
223
|
+
n === w && await a(r, e) && f(!0);
|
|
224
|
+
});
|
|
225
|
+
C = x, x.observe(A, {
|
|
226
|
+
childList: !0,
|
|
227
|
+
subtree: !0,
|
|
228
|
+
attributes: !1
|
|
229
|
+
}), O = window.setTimeout(() => {
|
|
230
|
+
if (n === w) {
|
|
231
|
+
try {
|
|
232
|
+
x.disconnect();
|
|
233
|
+
} catch {
|
|
234
|
+
}
|
|
235
|
+
C = null, O = null, f(!1);
|
|
236
|
+
}
|
|
237
|
+
}, t ?? 2e3);
|
|
238
|
+
} catch {
|
|
239
|
+
let R = 0;
|
|
240
|
+
const S = async () => {
|
|
241
|
+
if (n !== w) return f(!1);
|
|
242
|
+
if (await a(r, e)) return f(!0);
|
|
243
|
+
R += 1, R < 40 ? window.setTimeout(S, 50) : f(!1);
|
|
244
|
+
};
|
|
245
|
+
S();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
else {
|
|
249
|
+
const A = document.querySelector("router-view") || document.body;
|
|
250
|
+
try {
|
|
251
|
+
const x = new MutationObserver(async () => {
|
|
252
|
+
n === w && await a(r, e) && f(!0);
|
|
253
|
+
});
|
|
254
|
+
C = x, x.observe(A, {
|
|
255
|
+
childList: !0,
|
|
256
|
+
subtree: !0,
|
|
257
|
+
attributes: !1
|
|
258
|
+
}), O = window.setTimeout(() => {
|
|
259
|
+
if (n === w) {
|
|
260
|
+
try {
|
|
261
|
+
x.disconnect();
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
C = null, O = null, f(!1);
|
|
265
|
+
}
|
|
266
|
+
}, t ?? 2e3);
|
|
267
|
+
} catch {
|
|
268
|
+
let R = 0;
|
|
269
|
+
const S = async () => {
|
|
270
|
+
if (n !== w) return f(!1);
|
|
271
|
+
if (await a(r, e)) return f(!0);
|
|
272
|
+
R += 1, R < 40 ? window.setTimeout(S, 50) : f(!1);
|
|
273
|
+
};
|
|
274
|
+
S();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
const y = async (r, e = !1) => {
|
|
281
|
+
try {
|
|
282
|
+
const t = r.indexOf("#"), n = t >= 0 ? r.slice(t + 1) : "", E = t >= 0 ? r.slice(0, t) : r, f = E.indexOf("?"), $ = f >= 0 ? E.slice(0, f) : E, A = f >= 0 ? Q(E.slice(f)) : {}, x = $.startsWith(l) ? $.slice(l.length) : $, R = {
|
|
283
|
+
path: k(x || "/"),
|
|
284
|
+
query: A,
|
|
285
|
+
fragment: n
|
|
286
|
+
}, S = M(i, R.path);
|
|
287
|
+
if (!S.route) throw new Error(`No route found for ${R.path}`);
|
|
288
|
+
const N = b.getState(), W = {
|
|
289
|
+
path: R.path,
|
|
290
|
+
params: S.params,
|
|
291
|
+
query: R.query,
|
|
292
|
+
fragment: R.fragment
|
|
293
|
+
};
|
|
294
|
+
if (!await Y(W, N) || !await X(W, N)) return;
|
|
295
|
+
if (typeof window < "u" && typeof document < "u") {
|
|
296
|
+
const _ = lt(R.query), J = l + R.path + (_ || "") + (R.fragment ? "#" + R.fragment : "");
|
|
297
|
+
e ? window.history.replaceState({}, "", J) : window.history.pushState({}, "", J);
|
|
298
|
+
}
|
|
299
|
+
b.setState(W), Z(W, N);
|
|
300
|
+
try {
|
|
301
|
+
const _ = W.fragment;
|
|
302
|
+
m.enabled && _ && typeof window < "u" && typeof document < "u" && v(
|
|
303
|
+
String(_),
|
|
304
|
+
m.offset,
|
|
305
|
+
m.timeoutMs
|
|
306
|
+
).catch(() => {
|
|
307
|
+
});
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
} catch (t) {
|
|
311
|
+
F("Navigation error:", t);
|
|
141
312
|
}
|
|
142
313
|
};
|
|
143
|
-
if (typeof window < "u" && typeof document < "u" && typeof
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
return { path:
|
|
147
|
-
},
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
path:
|
|
151
|
-
params:
|
|
152
|
-
query:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
314
|
+
if (typeof window < "u" && typeof document < "u" && typeof d > "u") {
|
|
315
|
+
c = () => {
|
|
316
|
+
const e = new URL(window.location.href), t = e.pathname, n = t.startsWith(l) ? t.slice(l.length) : t, E = k(n || "/"), f = Q(e.search), $ = e.hash && e.hash.length ? e.hash.slice(1) : "";
|
|
317
|
+
return { path: E, query: f, fragment: $ };
|
|
318
|
+
}, p = c();
|
|
319
|
+
const r = M(i, p.path);
|
|
320
|
+
b = rt({
|
|
321
|
+
path: p.path,
|
|
322
|
+
params: r.params,
|
|
323
|
+
query: p.query,
|
|
324
|
+
fragment: p.fragment
|
|
325
|
+
}), g = async (e = !1) => {
|
|
326
|
+
const t = c();
|
|
327
|
+
await y(t.path, e);
|
|
328
|
+
}, window.addEventListener("popstate", () => g(!0)), q = (e) => y(e, !1), B = (e) => y(e, !0), D = () => window.history.back();
|
|
157
329
|
} else {
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
return { path:
|
|
161
|
-
},
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
path:
|
|
165
|
-
params:
|
|
166
|
-
query:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
330
|
+
c = () => {
|
|
331
|
+
const t = new URL(d || "/", "http://localhost"), n = t.pathname, E = n.startsWith(l) ? n.slice(l.length) : n, f = k(E || "/"), $ = Q(t.search), A = t.hash && t.hash.length ? t.hash.slice(1) : "";
|
|
332
|
+
return { path: f, query: $, fragment: A };
|
|
333
|
+
}, p = c();
|
|
334
|
+
const r = M(i, p.path);
|
|
335
|
+
b = rt({
|
|
336
|
+
path: p.path,
|
|
337
|
+
params: r.params,
|
|
338
|
+
query: p.query,
|
|
339
|
+
fragment: p.fragment
|
|
340
|
+
}), g = async () => {
|
|
341
|
+
const t = c();
|
|
342
|
+
await e(t.path);
|
|
170
343
|
};
|
|
171
|
-
const
|
|
344
|
+
const e = async (t) => {
|
|
172
345
|
try {
|
|
173
|
-
const
|
|
174
|
-
path:
|
|
175
|
-
query:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
346
|
+
const n = t.indexOf("#"), E = n >= 0 ? t.slice(n + 1) : "", f = n >= 0 ? t.slice(0, n) : t, $ = f.indexOf("?"), A = $ >= 0 ? f.slice(0, $) : f, x = $ >= 0 ? Q(f.slice($)) : {}, U = A.startsWith(l) ? A.slice(l.length) : A, S = {
|
|
347
|
+
path: k(U || "/"),
|
|
348
|
+
query: x,
|
|
349
|
+
fragment: E
|
|
350
|
+
}, N = M(i, S.path);
|
|
351
|
+
if (!N.route) throw new Error(`No route found for ${S.path}`);
|
|
352
|
+
const W = b.getState(), j = {
|
|
353
|
+
path: S.path,
|
|
354
|
+
params: N.params,
|
|
355
|
+
query: S.query,
|
|
356
|
+
fragment: S.fragment
|
|
357
|
+
}, I = K(i, j.path);
|
|
358
|
+
if (I?.beforeEnter) {
|
|
359
|
+
const _ = await I.beforeEnter(j, W);
|
|
360
|
+
if (typeof _ == "string") {
|
|
361
|
+
await e(_);
|
|
187
362
|
return;
|
|
188
363
|
}
|
|
189
|
-
if (
|
|
364
|
+
if (_ === !1) return;
|
|
190
365
|
}
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
if (typeof
|
|
194
|
-
await
|
|
366
|
+
if (I?.onEnter) {
|
|
367
|
+
const _ = await I.onEnter(j, W);
|
|
368
|
+
if (typeof _ == "string") {
|
|
369
|
+
await e(_);
|
|
195
370
|
return;
|
|
196
371
|
}
|
|
197
|
-
if (
|
|
372
|
+
if (_ === !1) return;
|
|
198
373
|
}
|
|
199
|
-
|
|
200
|
-
} catch (
|
|
201
|
-
throw
|
|
374
|
+
b.setState(j), I?.afterEnter && I.afterEnter(j, W);
|
|
375
|
+
} catch (n) {
|
|
376
|
+
throw F("SSR navigation error:", n), n;
|
|
202
377
|
}
|
|
203
378
|
};
|
|
204
|
-
|
|
379
|
+
q = async (t) => e(t), B = async (t) => e(t), D = () => {
|
|
205
380
|
};
|
|
206
381
|
}
|
|
207
382
|
return {
|
|
208
|
-
store:
|
|
209
|
-
push:
|
|
210
|
-
replace:
|
|
211
|
-
back:
|
|
212
|
-
subscribe:
|
|
213
|
-
matchRoute: (
|
|
214
|
-
getCurrent: () =>
|
|
215
|
-
resolveRouteComponent:
|
|
383
|
+
store: b,
|
|
384
|
+
push: q,
|
|
385
|
+
replace: B,
|
|
386
|
+
back: D,
|
|
387
|
+
subscribe: b.subscribe,
|
|
388
|
+
matchRoute: (r) => M(i, r),
|
|
389
|
+
getCurrent: () => b.getState(),
|
|
390
|
+
resolveRouteComponent: ht,
|
|
391
|
+
base: l,
|
|
392
|
+
// Public API: allow components or tests to explicitly request scrolling to
|
|
393
|
+
// a fragment when they know their DOM is ready. Returns true if scrolled.
|
|
394
|
+
scrollToFragment: (r) => {
|
|
395
|
+
const e = r || b.getState().fragment;
|
|
396
|
+
return !e || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : v(
|
|
397
|
+
String(e),
|
|
398
|
+
m.offset,
|
|
399
|
+
m.timeoutMs
|
|
400
|
+
);
|
|
401
|
+
}
|
|
216
402
|
};
|
|
217
403
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
404
|
+
function vt(o, i) {
|
|
405
|
+
return M(o, i);
|
|
220
406
|
}
|
|
221
|
-
let
|
|
222
|
-
function
|
|
223
|
-
const
|
|
224
|
-
return
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
227
|
-
const
|
|
228
|
-
let
|
|
229
|
-
|
|
407
|
+
let G = null;
|
|
408
|
+
function bt(o) {
|
|
409
|
+
const i = pt(o);
|
|
410
|
+
return G = i, tt("router-view", async () => {
|
|
411
|
+
const s = G || i;
|
|
412
|
+
if (!s) return z`<div>Router not initialized.</div>`;
|
|
413
|
+
const d = V(s.getCurrent());
|
|
414
|
+
let h;
|
|
415
|
+
et(() => {
|
|
230
416
|
try {
|
|
231
|
-
|
|
417
|
+
s && typeof s.subscribe == "function" && (h = s.subscribe((m) => {
|
|
232
418
|
try {
|
|
233
|
-
|
|
419
|
+
d.value = m;
|
|
234
420
|
} catch (c) {
|
|
235
|
-
|
|
421
|
+
P("router-view subscription update failed", c);
|
|
236
422
|
}
|
|
237
423
|
}));
|
|
238
|
-
} catch (
|
|
239
|
-
|
|
424
|
+
} catch (m) {
|
|
425
|
+
P("router-view subscribe failed", m);
|
|
240
426
|
}
|
|
241
|
-
}),
|
|
242
|
-
if (typeof
|
|
427
|
+
}), nt(() => {
|
|
428
|
+
if (typeof h == "function")
|
|
243
429
|
try {
|
|
244
|
-
|
|
245
|
-
} catch (
|
|
246
|
-
|
|
430
|
+
h();
|
|
431
|
+
} catch (m) {
|
|
432
|
+
P("router-view unsubscribe failed", m);
|
|
247
433
|
}
|
|
248
434
|
});
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
435
|
+
const l = s.matchRoute(d.value.path);
|
|
436
|
+
if (!l || !l.route) return z`<div>Not found</div>`;
|
|
251
437
|
try {
|
|
252
|
-
const c = await
|
|
438
|
+
const c = await s.resolveRouteComponent(l.route);
|
|
253
439
|
if (typeof c == "string")
|
|
254
440
|
return { tag: c, props: {}, children: [] };
|
|
255
441
|
if (typeof c == "function") {
|
|
256
|
-
const
|
|
257
|
-
return (
|
|
442
|
+
const p = c();
|
|
443
|
+
return (p instanceof Promise ? p : Promise.resolve(p)).then((g) => typeof g == "string" ? { tag: g, props: {}, children: [] } : g);
|
|
258
444
|
}
|
|
259
|
-
return
|
|
445
|
+
return z`<div>Invalid route component</div>`;
|
|
260
446
|
} catch {
|
|
261
|
-
return
|
|
447
|
+
return z`<div>Invalid route component</div>`;
|
|
262
448
|
}
|
|
263
|
-
}),
|
|
264
|
-
const
|
|
449
|
+
}), tt("router-link", () => {
|
|
450
|
+
const s = st({
|
|
265
451
|
to: "",
|
|
266
452
|
tag: "a",
|
|
267
453
|
replace: !1,
|
|
@@ -274,107 +460,154 @@ function Y(n) {
|
|
|
274
460
|
// allow host `class` and `style` attributes to be read via useProps
|
|
275
461
|
class: "",
|
|
276
462
|
style: ""
|
|
277
|
-
}),
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
463
|
+
}), d = G || i, h = V(d.getCurrent());
|
|
464
|
+
let l;
|
|
465
|
+
it(() => "a,button{display:inline-block;}");
|
|
466
|
+
const m = V(s.class || ""), c = V(s.style || "");
|
|
467
|
+
et((a) => {
|
|
282
468
|
try {
|
|
283
|
-
|
|
469
|
+
d && typeof d.subscribe == "function" && (l = d.subscribe((u) => {
|
|
284
470
|
try {
|
|
285
|
-
|
|
471
|
+
h.value = u;
|
|
286
472
|
} catch (v) {
|
|
287
|
-
|
|
473
|
+
P("router-link subscription update failed", v);
|
|
288
474
|
}
|
|
289
475
|
}));
|
|
290
|
-
} catch (
|
|
291
|
-
|
|
476
|
+
} catch (u) {
|
|
477
|
+
P("router-link subscribe failed", u);
|
|
292
478
|
}
|
|
293
479
|
try {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const v =
|
|
297
|
-
v && (
|
|
480
|
+
const u = a?._host;
|
|
481
|
+
if (u instanceof HTMLElement) {
|
|
482
|
+
const v = u.getAttribute("class"), y = u.getAttribute("style");
|
|
483
|
+
v && (m.value = v), y && (c.value = y), v !== null && u.removeAttribute("class"), y !== null && u.removeAttribute("style");
|
|
298
484
|
}
|
|
299
|
-
} catch (
|
|
300
|
-
|
|
485
|
+
} catch (u) {
|
|
486
|
+
P("router-link host migration failed", u);
|
|
301
487
|
}
|
|
302
|
-
}),
|
|
303
|
-
if (typeof
|
|
488
|
+
}), nt(() => {
|
|
489
|
+
if (typeof l == "function")
|
|
304
490
|
try {
|
|
305
|
-
|
|
306
|
-
} catch (
|
|
307
|
-
|
|
491
|
+
l();
|
|
492
|
+
} catch (a) {
|
|
493
|
+
P("router-link unsubscribe failed", a);
|
|
308
494
|
}
|
|
309
495
|
});
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
496
|
+
const p = T(() => {
|
|
497
|
+
const a = d?.base ?? "", u = s.to || "";
|
|
498
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(u) || u.startsWith("//"))
|
|
499
|
+
return !1;
|
|
500
|
+
const v = (u.split("#")[0] || "/").split("?")[0];
|
|
501
|
+
try {
|
|
502
|
+
let y = v;
|
|
503
|
+
a && y.startsWith(a) && (y = y.slice(a.length) || "/");
|
|
504
|
+
const r = k(h.value.path), e = k(y);
|
|
505
|
+
return r === e;
|
|
506
|
+
} catch {
|
|
507
|
+
return h.value.path === v;
|
|
508
|
+
}
|
|
509
|
+
}), b = T(() => {
|
|
510
|
+
const a = d?.base ?? "", u = s.to || "";
|
|
511
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(u) || u.startsWith("//"))
|
|
512
|
+
return !1;
|
|
513
|
+
const v = (u.split("#")[0] || "/").split("?")[0];
|
|
514
|
+
if (s.exact) return p.value;
|
|
515
|
+
try {
|
|
516
|
+
let y = v;
|
|
517
|
+
a && y.startsWith(a) && (y = y.slice(a.length) || "/");
|
|
518
|
+
const r = k(h.value.path), e = k(y);
|
|
519
|
+
return e === "/" ? r === "/" : r === e ? !0 : r.startsWith(e.endsWith("/") ? e : e + "/");
|
|
520
|
+
} catch {
|
|
521
|
+
return h.value && typeof h.value.path == "string" && h.value.path.startsWith(v);
|
|
522
|
+
}
|
|
523
|
+
}), g = T(() => {
|
|
524
|
+
const a = String(s.to || "");
|
|
525
|
+
if (at(a)) return null;
|
|
526
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(a) || a.startsWith("//"))
|
|
527
|
+
return a;
|
|
528
|
+
const [u, v] = a.split("#"), [y, r] = (u || "").split("?"), e = d?.base ?? "";
|
|
529
|
+
let t = y || "/";
|
|
530
|
+
e && t.startsWith(e) && (t = t.slice(e.length) || "/");
|
|
531
|
+
const n = k(t || "/");
|
|
532
|
+
return e + n + (r ? "?" + r : "") + (v ? "#" + v : "");
|
|
533
|
+
}), q = T(() => {
|
|
534
|
+
const u = (m && m.value || s.class || "").split(/\s+/).filter(Boolean), v = {};
|
|
535
|
+
for (const y of u) v[y] = !0;
|
|
317
536
|
return v;
|
|
318
|
-
}),
|
|
319
|
-
...
|
|
320
|
-
[
|
|
321
|
-
[
|
|
322
|
-
})),
|
|
323
|
-
() => Object.keys(
|
|
324
|
-
),
|
|
325
|
-
() =>
|
|
326
|
-
),
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
537
|
+
}), B = T(() => ({
|
|
538
|
+
...q.value,
|
|
539
|
+
[s.activeClass || "active"]: b.value,
|
|
540
|
+
[s.exactActiveClass || "exact-active"]: p.value
|
|
541
|
+
})), D = T(
|
|
542
|
+
() => Object.keys(B.value).filter((a) => B.value[a]).join(" ")
|
|
543
|
+
), Y = T(() => s.tag || "a"), X = T(() => Y.value === "button"), Z = T(
|
|
544
|
+
() => p.value ? s.ariaCurrentValue : null
|
|
545
|
+
), w = T(() => !!s.disabled), C = T(() => {
|
|
546
|
+
const a = String(s.to || "");
|
|
547
|
+
return (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(a) || a.startsWith("//") || !!s.external) && Y.value === "a";
|
|
548
|
+
}), O = T(
|
|
549
|
+
() => c && c.value || s.style || ""
|
|
550
|
+
), L = (a) => {
|
|
551
|
+
if (a.defaultPrevented || a.button !== 0 || a.metaKey || a.altKey || a.ctrlKey || a.shiftKey)
|
|
552
|
+
return;
|
|
553
|
+
if (w.value) {
|
|
554
|
+
a.preventDefault();
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const u = String(s.to || "");
|
|
558
|
+
if (at(u)) {
|
|
559
|
+
try {
|
|
560
|
+
a.preventDefault();
|
|
561
|
+
} catch {
|
|
562
|
+
}
|
|
563
|
+
P("Blocked unsafe javascript: URI in router-link.to");
|
|
333
564
|
return;
|
|
334
565
|
}
|
|
335
|
-
|
|
566
|
+
C.value || (a.preventDefault(), s.replace ? d.replace(s.to) : d.push(s.to));
|
|
336
567
|
};
|
|
337
|
-
return
|
|
338
|
-
${
|
|
339
|
-
|
|
340
|
-
|
|
568
|
+
return z`
|
|
569
|
+
${ct().when(
|
|
570
|
+
X.value,
|
|
571
|
+
z`
|
|
341
572
|
<button
|
|
342
573
|
part="button"
|
|
343
|
-
class="${
|
|
344
|
-
style="${
|
|
345
|
-
aria-current="${
|
|
346
|
-
disabled="${
|
|
347
|
-
aria-disabled="${
|
|
348
|
-
tabindex="${
|
|
349
|
-
@click="${
|
|
574
|
+
class="${D.value}"
|
|
575
|
+
style="${O.value || null}"
|
|
576
|
+
aria-current="${Z.value}"
|
|
577
|
+
disabled="${w.value ? "" : null}"
|
|
578
|
+
aria-disabled="${w.value ? "true" : null}"
|
|
579
|
+
tabindex="${w.value ? "-1" : null}"
|
|
580
|
+
@click="${L}"
|
|
350
581
|
>
|
|
351
582
|
<slot></slot>
|
|
352
583
|
</button>
|
|
353
584
|
`
|
|
354
|
-
).otherwise(
|
|
585
|
+
).otherwise(z`
|
|
355
586
|
<a
|
|
356
587
|
part="link"
|
|
357
|
-
href="${
|
|
358
|
-
class="${
|
|
359
|
-
style="${
|
|
360
|
-
aria-current="${
|
|
361
|
-
aria-disabled="${
|
|
362
|
-
tabindex="${
|
|
363
|
-
target="${
|
|
364
|
-
rel="${
|
|
365
|
-
@click="${
|
|
588
|
+
href="${w.value ? null : g.value}"
|
|
589
|
+
class="${D.value}"
|
|
590
|
+
style="${O.value || null}"
|
|
591
|
+
aria-current="${Z.value}"
|
|
592
|
+
aria-disabled="${w.value ? "true" : null}"
|
|
593
|
+
tabindex="${w.value ? "-1" : null}"
|
|
594
|
+
target="${C.value ? "_blank" : null}"
|
|
595
|
+
rel="${C.value ? "noopener noreferrer" : null}"
|
|
596
|
+
@click="${L}"
|
|
366
597
|
><slot></slot
|
|
367
598
|
></a>
|
|
368
599
|
`).done()}
|
|
369
600
|
`;
|
|
370
|
-
}),
|
|
601
|
+
}), i;
|
|
371
602
|
}
|
|
372
603
|
export {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
604
|
+
bt as initRouter,
|
|
605
|
+
M as matchRoute,
|
|
606
|
+
vt as matchRouteSSR,
|
|
607
|
+
k as normalizePathForRoute,
|
|
608
|
+
Q as parseQuery,
|
|
609
|
+
ht as resolveRouteComponent,
|
|
610
|
+
lt as serializeQuery,
|
|
611
|
+
pt as useRouter
|
|
379
612
|
};
|
|
380
613
|
//# sourceMappingURL=custom-elements-runtime.router.es.js.map
|