@jasonshimmy/custom-elements-runtime 2.4.0 → 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,273 +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
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
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(
|
|
50
|
-
} catch (
|
|
51
|
-
return
|
|
56
|
+
return { regex: new RegExp(m), paramNames: h };
|
|
57
|
+
} catch (c) {
|
|
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:
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
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);
|
|
67
|
+
if (c) {
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
}
|
|
138
211
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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);
|
|
143
312
|
}
|
|
144
313
|
};
|
|
145
|
-
if (typeof window < "u" && typeof document < "u" && typeof
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
return { path:
|
|
149
|
-
},
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
path:
|
|
153
|
-
params:
|
|
154
|
-
query:
|
|
155
|
-
fragment:
|
|
156
|
-
}),
|
|
157
|
-
const
|
|
158
|
-
await
|
|
159
|
-
}, window.addEventListener("popstate", () =>
|
|
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();
|
|
160
329
|
} else {
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
return { path:
|
|
164
|
-
},
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
path:
|
|
168
|
-
params:
|
|
169
|
-
query:
|
|
170
|
-
fragment:
|
|
171
|
-
}),
|
|
172
|
-
const
|
|
173
|
-
await
|
|
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);
|
|
174
343
|
};
|
|
175
|
-
const
|
|
344
|
+
const e = async (t) => {
|
|
176
345
|
try {
|
|
177
|
-
const
|
|
178
|
-
path: (
|
|
179
|
-
query:
|
|
180
|
-
fragment:
|
|
181
|
-
},
|
|
182
|
-
if (!
|
|
183
|
-
const
|
|
184
|
-
path:
|
|
185
|
-
params:
|
|
186
|
-
query:
|
|
187
|
-
fragment:
|
|
188
|
-
},
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
191
|
-
if (typeof
|
|
192
|
-
await
|
|
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(_);
|
|
193
362
|
return;
|
|
194
363
|
}
|
|
195
|
-
if (
|
|
364
|
+
if (_ === !1) return;
|
|
196
365
|
}
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
if (typeof
|
|
200
|
-
await
|
|
366
|
+
if (I?.onEnter) {
|
|
367
|
+
const _ = await I.onEnter(j, W);
|
|
368
|
+
if (typeof _ == "string") {
|
|
369
|
+
await e(_);
|
|
201
370
|
return;
|
|
202
371
|
}
|
|
203
|
-
if (
|
|
372
|
+
if (_ === !1) return;
|
|
204
373
|
}
|
|
205
|
-
|
|
206
|
-
} catch (
|
|
207
|
-
throw
|
|
374
|
+
b.setState(j), I?.afterEnter && I.afterEnter(j, W);
|
|
375
|
+
} catch (n) {
|
|
376
|
+
throw F("SSR navigation error:", n), n;
|
|
208
377
|
}
|
|
209
378
|
};
|
|
210
|
-
|
|
379
|
+
q = async (t) => e(t), B = async (t) => e(t), D = () => {
|
|
211
380
|
};
|
|
212
381
|
}
|
|
213
382
|
return {
|
|
214
|
-
store:
|
|
215
|
-
push:
|
|
216
|
-
replace:
|
|
217
|
-
back:
|
|
218
|
-
subscribe:
|
|
219
|
-
matchRoute: (
|
|
220
|
-
getCurrent: () =>
|
|
221
|
-
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
|
+
}
|
|
222
402
|
};
|
|
223
403
|
}
|
|
224
|
-
function
|
|
225
|
-
return
|
|
404
|
+
function vt(o, i) {
|
|
405
|
+
return M(o, i);
|
|
226
406
|
}
|
|
227
|
-
let
|
|
228
|
-
function
|
|
229
|
-
const
|
|
230
|
-
return
|
|
231
|
-
const
|
|
232
|
-
if (!
|
|
233
|
-
const
|
|
234
|
-
let
|
|
235
|
-
|
|
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(() => {
|
|
236
416
|
try {
|
|
237
|
-
|
|
417
|
+
s && typeof s.subscribe == "function" && (h = s.subscribe((m) => {
|
|
238
418
|
try {
|
|
239
|
-
|
|
240
|
-
} catch (
|
|
241
|
-
|
|
419
|
+
d.value = m;
|
|
420
|
+
} catch (c) {
|
|
421
|
+
P("router-view subscription update failed", c);
|
|
242
422
|
}
|
|
243
423
|
}));
|
|
244
|
-
} catch (
|
|
245
|
-
|
|
424
|
+
} catch (m) {
|
|
425
|
+
P("router-view subscribe failed", m);
|
|
246
426
|
}
|
|
247
|
-
}),
|
|
248
|
-
if (typeof
|
|
427
|
+
}), nt(() => {
|
|
428
|
+
if (typeof h == "function")
|
|
249
429
|
try {
|
|
250
|
-
|
|
251
|
-
} catch (
|
|
252
|
-
|
|
430
|
+
h();
|
|
431
|
+
} catch (m) {
|
|
432
|
+
P("router-view unsubscribe failed", m);
|
|
253
433
|
}
|
|
254
434
|
});
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
435
|
+
const l = s.matchRoute(d.value.path);
|
|
436
|
+
if (!l || !l.route) return z`<div>Not found</div>`;
|
|
257
437
|
try {
|
|
258
|
-
const
|
|
259
|
-
if (typeof
|
|
260
|
-
return { tag:
|
|
261
|
-
if (typeof
|
|
262
|
-
const
|
|
263
|
-
return (
|
|
438
|
+
const c = await s.resolveRouteComponent(l.route);
|
|
439
|
+
if (typeof c == "string")
|
|
440
|
+
return { tag: c, props: {}, children: [] };
|
|
441
|
+
if (typeof c == "function") {
|
|
442
|
+
const p = c();
|
|
443
|
+
return (p instanceof Promise ? p : Promise.resolve(p)).then((g) => typeof g == "string" ? { tag: g, props: {}, children: [] } : g);
|
|
264
444
|
}
|
|
265
|
-
return
|
|
445
|
+
return z`<div>Invalid route component</div>`;
|
|
266
446
|
} catch {
|
|
267
|
-
return
|
|
447
|
+
return z`<div>Invalid route component</div>`;
|
|
268
448
|
}
|
|
269
|
-
}),
|
|
270
|
-
const
|
|
449
|
+
}), tt("router-link", () => {
|
|
450
|
+
const s = st({
|
|
271
451
|
to: "",
|
|
272
452
|
tag: "a",
|
|
273
453
|
replace: !1,
|
|
@@ -280,120 +460,154 @@ function rt(n) {
|
|
|
280
460
|
// allow host `class` and `style` attributes to be read via useProps
|
|
281
461
|
class: "",
|
|
282
462
|
style: ""
|
|
283
|
-
}),
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
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) => {
|
|
288
468
|
try {
|
|
289
|
-
|
|
469
|
+
d && typeof d.subscribe == "function" && (l = d.subscribe((u) => {
|
|
290
470
|
try {
|
|
291
|
-
|
|
292
|
-
} catch (
|
|
293
|
-
|
|
471
|
+
h.value = u;
|
|
472
|
+
} catch (v) {
|
|
473
|
+
P("router-link subscription update failed", v);
|
|
294
474
|
}
|
|
295
475
|
}));
|
|
296
|
-
} catch (
|
|
297
|
-
|
|
476
|
+
} catch (u) {
|
|
477
|
+
P("router-link subscribe failed", u);
|
|
298
478
|
}
|
|
299
479
|
try {
|
|
300
|
-
const
|
|
301
|
-
if (
|
|
302
|
-
const
|
|
303
|
-
|
|
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");
|
|
304
484
|
}
|
|
305
|
-
} catch (
|
|
306
|
-
|
|
485
|
+
} catch (u) {
|
|
486
|
+
P("router-link host migration failed", u);
|
|
307
487
|
}
|
|
308
|
-
}),
|
|
309
|
-
if (typeof
|
|
488
|
+
}), nt(() => {
|
|
489
|
+
if (typeof l == "function")
|
|
310
490
|
try {
|
|
311
|
-
|
|
312
|
-
} catch (
|
|
313
|
-
|
|
491
|
+
l();
|
|
492
|
+
} catch (a) {
|
|
493
|
+
P("router-link unsubscribe failed", a);
|
|
314
494
|
}
|
|
315
495
|
});
|
|
316
|
-
const
|
|
317
|
-
const
|
|
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];
|
|
318
501
|
try {
|
|
319
|
-
|
|
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;
|
|
320
506
|
} catch {
|
|
321
|
-
return
|
|
507
|
+
return h.value.path === v;
|
|
322
508
|
}
|
|
323
|
-
}),
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
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;
|
|
326
515
|
try {
|
|
327
|
-
|
|
328
|
-
|
|
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 + "/");
|
|
329
520
|
} catch {
|
|
330
|
-
return
|
|
521
|
+
return h.value && typeof h.value.path == "string" && h.value.path.startsWith(v);
|
|
331
522
|
}
|
|
332
|
-
}),
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
()
|
|
342
|
-
),
|
|
343
|
-
(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
),
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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;
|
|
536
|
+
return v;
|
|
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");
|
|
351
564
|
return;
|
|
352
565
|
}
|
|
353
|
-
|
|
566
|
+
C.value || (a.preventDefault(), s.replace ? d.replace(s.to) : d.push(s.to));
|
|
354
567
|
};
|
|
355
|
-
return
|
|
356
|
-
${
|
|
357
|
-
|
|
358
|
-
|
|
568
|
+
return z`
|
|
569
|
+
${ct().when(
|
|
570
|
+
X.value,
|
|
571
|
+
z`
|
|
359
572
|
<button
|
|
360
573
|
part="button"
|
|
361
|
-
class="${
|
|
362
|
-
style="${
|
|
363
|
-
aria-current="${
|
|
364
|
-
disabled="${
|
|
365
|
-
aria-disabled="${
|
|
366
|
-
tabindex="${
|
|
367
|
-
@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}"
|
|
368
581
|
>
|
|
369
582
|
<slot></slot>
|
|
370
583
|
</button>
|
|
371
584
|
`
|
|
372
|
-
).otherwise(
|
|
585
|
+
).otherwise(z`
|
|
373
586
|
<a
|
|
374
587
|
part="link"
|
|
375
|
-
href="${
|
|
376
|
-
class="${
|
|
377
|
-
style="${
|
|
378
|
-
aria-current="${
|
|
379
|
-
aria-disabled="${
|
|
380
|
-
tabindex="${
|
|
381
|
-
target="${
|
|
382
|
-
rel="${
|
|
383
|
-
@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}"
|
|
384
597
|
><slot></slot
|
|
385
598
|
></a>
|
|
386
599
|
`).done()}
|
|
387
600
|
`;
|
|
388
|
-
}),
|
|
601
|
+
}), i;
|
|
389
602
|
}
|
|
390
603
|
export {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
|
398
612
|
};
|
|
399
613
|
//# sourceMappingURL=custom-elements-runtime.router.es.js.map
|