@elurjs/core 3.5.0 → 3.6.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.
- package/README.md +5 -5
- package/dist/lib/component.cjs +1 -1
- package/dist/lib/component.js +1 -1
- package/dist/lib/devtools.cjs +1 -1
- package/dist/lib/devtools.js +1 -1
- package/dist/lib/elur/component.cjs +1 -1
- package/dist/lib/elur/component.cjs.map +1 -1
- package/dist/lib/elur/component.d.cts +1 -1
- package/dist/lib/elur/component.d.ts +1 -1
- package/dist/lib/elur/component.js +1 -1
- package/dist/lib/elur/component.js.map +1 -1
- package/dist/lib/elur/devtools.cjs +1 -1
- package/dist/lib/elur/devtools.cjs.map +1 -1
- package/dist/lib/elur/devtools.js +1 -1
- package/dist/lib/elur/devtools.js.map +1 -1
- package/dist/lib/elur/lifecycle.cjs +1 -1
- package/dist/lib/elur/lifecycle.cjs.map +1 -1
- package/dist/lib/elur/lifecycle.d.cts +6 -0
- package/dist/lib/elur/lifecycle.d.ts +6 -0
- package/dist/lib/elur/lifecycle.js +40 -7
- package/dist/lib/elur/lifecycle.js.map +1 -1
- package/dist/lib/elur/reactivity.cjs +1 -1
- package/dist/lib/elur/reactivity.cjs.map +1 -1
- package/dist/lib/elur/reactivity.d.cts +7 -0
- package/dist/lib/elur/reactivity.d.ts +7 -0
- package/dist/lib/elur/reactivity.js +53 -23
- package/dist/lib/elur/reactivity.js.map +1 -1
- package/dist/lib/elur/router-registry.cjs +2 -0
- package/dist/lib/elur/router-registry.cjs.map +1 -0
- package/dist/lib/elur/router-registry.d.cts +14 -0
- package/dist/lib/elur/router-registry.d.ts +14 -0
- package/dist/lib/elur/router-registry.js +15 -0
- package/dist/lib/elur/router-registry.js.map +1 -0
- package/dist/lib/elur/router.cjs +3 -3
- package/dist/lib/elur/router.cjs.map +1 -1
- package/dist/lib/elur/router.d.cts +2 -5
- package/dist/lib/elur/router.d.ts +2 -5
- package/dist/lib/elur/router.js +159 -166
- package/dist/lib/elur/router.js.map +1 -1
- package/dist/lib/elur/template/html.cjs +1 -1
- package/dist/lib/elur/template/html.cjs.map +1 -1
- package/dist/lib/elur/template/html.js +1 -1
- package/dist/lib/elur/template/html.js.map +1 -1
- package/dist/lib/elur/template/types.cjs +1 -1
- package/dist/lib/elur/template/types.cjs.map +1 -1
- package/dist/lib/elur/template/types.js +1 -1
- package/dist/lib/elur/template/types.js.map +1 -1
- package/dist/lib/elur.cjs +1 -1
- package/dist/lib/elur.js +6 -5
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.js +6 -5
- package/dist/lib/lifecycle.cjs +1 -1
- package/dist/lib/lifecycle.js +40 -7
- package/dist/lib/router.cjs +3 -3
- package/dist/lib/router.js +159 -166
- package/dist/lib/signals.cjs +1 -1
- package/dist/lib/signals.js +53 -23
- package/package.json +1 -1
package/dist/lib/elur/router.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { signal as e } from "./signals.js";
|
|
2
2
|
import { ElurComponent as t } from "./lifecycle.js";
|
|
3
|
-
import {
|
|
4
|
-
import { html as
|
|
3
|
+
import { inject as n } from "./context.js";
|
|
4
|
+
import { html as r } from "./elur/template/html.js";
|
|
5
|
+
import { RouterKey as i, _debugRegisterRouter as a, _debugUnregisterRouter as o, _mountedRouters as s } from "./elur/router-registry.js";
|
|
5
6
|
//#region src/elur/router.ts
|
|
6
|
-
var
|
|
7
|
-
function d() {
|
|
8
|
-
if (!o) throw Error("[elur] No active router. Call createRouter() first, or instantiate an outlet that auto-bootstraps one (e.g. IonRouterOutlet).");
|
|
9
|
-
return o;
|
|
10
|
-
}
|
|
7
|
+
var c = null, l = null, u = "__elur_scroll", d = "__elur_pos";
|
|
11
8
|
function f() {
|
|
12
|
-
|
|
9
|
+
if (!c) throw Error("[elur] No active router. Call createRouter() first, or instantiate an outlet that auto-bootstraps one (e.g. IonRouterOutlet).");
|
|
10
|
+
return c;
|
|
13
11
|
}
|
|
14
12
|
function p() {
|
|
13
|
+
return c !== null;
|
|
14
|
+
}
|
|
15
|
+
function m() {
|
|
15
16
|
return {
|
|
16
17
|
left: window.scrollX ?? window.pageXOffset ?? 0,
|
|
17
18
|
top: window.scrollY ?? window.pageYOffset ?? 0
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function h(e) {
|
|
21
22
|
if (!e || typeof e != "object") return null;
|
|
22
|
-
let t = e[
|
|
23
|
+
let t = e[u];
|
|
23
24
|
if (!t || typeof t != "object") return null;
|
|
24
25
|
let n = t.left, r = t.top;
|
|
25
26
|
return typeof n != "number" || typeof r != "number" ? null : {
|
|
@@ -27,31 +28,31 @@ function ee(e) {
|
|
|
27
28
|
top: r
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function g(e) {
|
|
31
32
|
if (!e || typeof e != "object") return null;
|
|
32
|
-
let t = e[
|
|
33
|
+
let t = e[d];
|
|
33
34
|
return typeof t == "number" ? t : null;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function _(e, t, n) {
|
|
36
37
|
let r = e && typeof e == "object" ? { ...e } : {};
|
|
37
|
-
return r[
|
|
38
|
+
return r[u] = {
|
|
38
39
|
left: t.left,
|
|
39
40
|
top: t.top
|
|
40
|
-
}, r[
|
|
41
|
+
}, r[d] = n, r;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function v(e) {
|
|
43
44
|
let t = {};
|
|
44
45
|
return new URLSearchParams(e).forEach((e, n) => {
|
|
45
46
|
t[n] = e;
|
|
46
47
|
}), t;
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function y(e) {
|
|
49
50
|
let t = new URLSearchParams();
|
|
50
51
|
for (let [n, r] of Object.entries(e)) r != null && r !== !1 && t.set(n, String(r));
|
|
51
52
|
let n = t.toString();
|
|
52
53
|
return n ? "?" + n : "";
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function b(e) {
|
|
55
56
|
return e === "*" ? [{ kind: "wildcard" }] : e.split("/").filter(Boolean).map((e) => e === "*" ? { kind: "wildcard" } : e.startsWith(":") ? {
|
|
56
57
|
kind: "param",
|
|
57
58
|
name: e.slice(1)
|
|
@@ -60,13 +61,13 @@ function v(e) {
|
|
|
60
61
|
value: e
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
+
function x(e, t) {
|
|
64
65
|
return t === "*" ? e === "" ? "*" : e + "/*" : (e + (t.startsWith("/") ? t : "/" + t)).replace(/\/+/g, "/") || "/";
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function S(e, t = "", n = []) {
|
|
67
68
|
let r = [];
|
|
68
69
|
for (let i of e) {
|
|
69
|
-
let e =
|
|
70
|
+
let e = x(t, i.path), a = [...n, i.component], o = b(e);
|
|
70
71
|
r.push({
|
|
71
72
|
fullPath: e,
|
|
72
73
|
segments: o,
|
|
@@ -75,11 +76,11 @@ function b(e, t = "", n = []) {
|
|
|
75
76
|
meta: i.meta,
|
|
76
77
|
beforeEnter: i.beforeEnter,
|
|
77
78
|
record: i
|
|
78
|
-
}), i.children?.length && r.push(...
|
|
79
|
+
}), i.children?.length && r.push(...S(i.children, e, a));
|
|
79
80
|
}
|
|
80
81
|
return r;
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function C(e, t) {
|
|
83
84
|
let n = e.split("/").filter(Boolean), r = t.segments;
|
|
84
85
|
if (r.length === 1 && r[0].kind === "wildcard") return {};
|
|
85
86
|
let i = r.length > 0 && r[r.length - 1].kind === "wildcard", a = i ? r.slice(0, -1) : r;
|
|
@@ -99,15 +100,15 @@ function x(e, t) {
|
|
|
99
100
|
}
|
|
100
101
|
return o;
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function w(e) {
|
|
103
104
|
return e.segments.reduce((e, t) => t.kind === "literal" ? e + 2 : t.kind === "param" ? e + 1 : e, 0);
|
|
104
105
|
}
|
|
105
|
-
function
|
|
106
|
+
function T(e, t) {
|
|
106
107
|
let n, r = {}, i = -1;
|
|
107
108
|
for (let a of t) {
|
|
108
|
-
let t =
|
|
109
|
+
let t = C(e, a);
|
|
109
110
|
if (t === null) continue;
|
|
110
|
-
let o =
|
|
111
|
+
let o = w(a);
|
|
111
112
|
o > i && (n = a, r = t, i = o);
|
|
112
113
|
}
|
|
113
114
|
return n ? {
|
|
@@ -115,22 +116,22 @@ function C(e, t) {
|
|
|
115
116
|
params: r
|
|
116
117
|
} : void 0;
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
+
function E(e) {
|
|
119
120
|
let t = e.trim();
|
|
120
121
|
return !t || t === "/" ? "" : (t.startsWith("/") || (t = "/" + t), t.endsWith("/") && (t = t.slice(0, -1)), t);
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
+
function ee() {
|
|
123
124
|
if (typeof document > "u") return "";
|
|
124
125
|
let e = document.querySelector("base");
|
|
125
126
|
if (!e) return "";
|
|
126
127
|
let t = e.getAttribute("href") || "";
|
|
127
128
|
try {
|
|
128
|
-
return
|
|
129
|
+
return E(new URL(t, window.location.origin).pathname);
|
|
129
130
|
} catch {
|
|
130
|
-
return
|
|
131
|
+
return E(t);
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
+
function D(e) {
|
|
134
135
|
return e === !1 ? { allow: !1 } : e === !0 || e == null ? { allow: !0 } : typeof e == "string" ? {
|
|
135
136
|
allow: !1,
|
|
136
137
|
redirect: e
|
|
@@ -139,8 +140,8 @@ function te(e) {
|
|
|
139
140
|
redirect: e.redirect
|
|
140
141
|
} : { allow: !0 };
|
|
141
142
|
}
|
|
142
|
-
function
|
|
143
|
-
let r = n?.base == null ?
|
|
143
|
+
function O(t, n) {
|
|
144
|
+
let r = n?.base == null ? ee() : E(n.base), i = n?.mode ?? "history", a = i === "hash", o = n?.scrollBehavior, s = /* @__PURE__ */ new Map(), u = !1;
|
|
144
145
|
function d(e) {
|
|
145
146
|
return e ? e.startsWith("/") ? e : "/" + e : "/";
|
|
146
147
|
}
|
|
@@ -152,11 +153,11 @@ function E(t, n) {
|
|
|
152
153
|
}
|
|
153
154
|
return t;
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
+
function p(e) {
|
|
156
157
|
let t = d(e);
|
|
157
158
|
return r ? (r + t).replace(/\/+/g, "/") || "/" : t;
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
+
function b() {
|
|
160
161
|
let e = window.location.hash || "";
|
|
161
162
|
if (e.startsWith("#") && (e = e.slice(1)), !e) return {
|
|
162
163
|
pathname: "/",
|
|
@@ -170,64 +171,64 @@ function E(t, n) {
|
|
|
170
171
|
};
|
|
171
172
|
}
|
|
172
173
|
function x() {
|
|
173
|
-
return a ?
|
|
174
|
+
return a ? b() : {
|
|
174
175
|
pathname: f(window.location.pathname || "/"),
|
|
175
176
|
search: window.location.search || ""
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
-
let n =
|
|
179
|
+
function C(e, t) {
|
|
180
|
+
let n = p(e) + y(t);
|
|
180
181
|
return a ? "#" + n : n;
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
-
return d(e) +
|
|
183
|
+
function w(e, t) {
|
|
184
|
+
return d(e) + y(t);
|
|
184
185
|
}
|
|
185
|
-
let
|
|
186
|
-
for (let e of
|
|
187
|
-
let
|
|
186
|
+
let O = x(), k = O.pathname, A = v(O.search), j = S(t), M = /* @__PURE__ */ new Map();
|
|
187
|
+
for (let e of j) e.name && (M.has(e.name) && console.warn(`[Elur Router] Duplicate route name: "${e.name}"`), M.set(e.name, e));
|
|
188
|
+
let N = T(k, j), P = e(k), F = e(N?.params ?? {}), I = e(A), L = g(history.state) ?? 0, R = e({
|
|
188
189
|
action: "initial",
|
|
189
190
|
direction: "none"
|
|
190
|
-
}),
|
|
191
|
-
a ?
|
|
192
|
-
function
|
|
191
|
+
}), z = e(L > 0);
|
|
192
|
+
a ? s.set(w(k, A), m()) : history.replaceState(_(history.state, m(), L), "");
|
|
193
|
+
function B(e) {
|
|
193
194
|
window.scrollTo(e.left, e.top);
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
-
if (
|
|
197
|
-
let r =
|
|
196
|
+
function V(e, t, n) {
|
|
197
|
+
if (o) {
|
|
198
|
+
let r = o(e, t, n);
|
|
198
199
|
if (!r) return;
|
|
199
|
-
|
|
200
|
+
B(r);
|
|
200
201
|
return;
|
|
201
202
|
}
|
|
202
|
-
|
|
203
|
+
B(n ?? {
|
|
203
204
|
left: 0,
|
|
204
205
|
top: 0
|
|
205
206
|
});
|
|
206
207
|
}
|
|
207
|
-
function
|
|
208
|
-
let n =
|
|
208
|
+
function te(e, t) {
|
|
209
|
+
let n = m();
|
|
209
210
|
if (a) {
|
|
210
|
-
|
|
211
|
+
s.set(w(e, t), n);
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
213
|
-
history.replaceState(
|
|
214
|
+
history.replaceState(_(history.state, n, L), "");
|
|
214
215
|
}
|
|
215
|
-
let
|
|
216
|
-
function
|
|
217
|
-
let a = [...
|
|
216
|
+
let H = [], U = [], W = 0;
|
|
217
|
+
function G(e, t, n, r, i) {
|
|
218
|
+
let a = [...H];
|
|
218
219
|
n && a.push(n);
|
|
219
|
-
let o = ++
|
|
220
|
+
let o = ++W;
|
|
220
221
|
if (a.length === 0) {
|
|
221
222
|
r();
|
|
222
223
|
return;
|
|
223
224
|
}
|
|
224
225
|
let s = 0;
|
|
225
226
|
function c(n) {
|
|
226
|
-
if (o !==
|
|
227
|
-
let l =
|
|
227
|
+
if (o !== W) return;
|
|
228
|
+
let l = D(n);
|
|
228
229
|
if (!l.allow) {
|
|
229
230
|
if (l.redirect && l.redirect !== e) {
|
|
230
|
-
|
|
231
|
+
Q(l.redirect);
|
|
231
232
|
return;
|
|
232
233
|
}
|
|
233
234
|
if (l.redirect === e) {
|
|
@@ -250,9 +251,9 @@ function E(t, n) {
|
|
|
250
251
|
}
|
|
251
252
|
c(void 0);
|
|
252
253
|
}
|
|
253
|
-
let
|
|
254
|
-
function
|
|
255
|
-
let n = e.indexOf("?"), r = d((n === -1 ? e : e.slice(0, n)) || "/"), i = n === -1 ? {} :
|
|
254
|
+
let K = !1;
|
|
255
|
+
function q(e, t) {
|
|
256
|
+
let n = e.indexOf("?"), r = d((n === -1 ? e : e.slice(0, n)) || "/"), i = n === -1 ? {} : v(e.slice(n)), a = t ? {
|
|
256
257
|
...i,
|
|
257
258
|
...t
|
|
258
259
|
} : i, o = {};
|
|
@@ -262,8 +263,8 @@ function E(t, n) {
|
|
|
262
263
|
stringQuery: o
|
|
263
264
|
};
|
|
264
265
|
}
|
|
265
|
-
function
|
|
266
|
-
let t =
|
|
266
|
+
function ne(e) {
|
|
267
|
+
let t = M.get(e.name);
|
|
267
268
|
if (!t) throw Error(`[Elur Router] No route with name "${e.name}"`);
|
|
268
269
|
return "/" + t.segments.map((t) => {
|
|
269
270
|
if (t.kind === "literal") return t.value;
|
|
@@ -273,24 +274,24 @@ function E(t, n) {
|
|
|
273
274
|
return encodeURIComponent(String(n));
|
|
274
275
|
}).filter(Boolean).join("/");
|
|
275
276
|
}
|
|
276
|
-
function
|
|
277
|
-
return typeof e == "string" ?
|
|
277
|
+
function J(e, t) {
|
|
278
|
+
return typeof e == "string" ? q(e, t?.query) : q(ne(e), {
|
|
278
279
|
...e.query ?? {},
|
|
279
280
|
...t?.query ?? {}
|
|
280
281
|
});
|
|
281
282
|
}
|
|
282
|
-
|
|
283
|
-
let
|
|
284
|
-
let a =
|
|
285
|
-
r != null && (r <
|
|
286
|
-
r != null && (
|
|
287
|
-
let i =
|
|
288
|
-
|
|
283
|
+
l &&= (l(), null);
|
|
284
|
+
let Y = (e, t, n, r, i) => {
|
|
285
|
+
let a = P.value, o = { ...I.value }, s = T(e, j), c = "none";
|
|
286
|
+
r != null && (r < L ? c = "back" : r > L && (c = "forward")), G(e, a, s?.route.beforeEnter, () => {
|
|
287
|
+
r != null && (L = r);
|
|
288
|
+
let i = Z;
|
|
289
|
+
Z = void 0, R.value = {
|
|
289
290
|
action: "pop",
|
|
290
291
|
direction: c,
|
|
291
292
|
animation: i
|
|
292
|
-
},
|
|
293
|
-
for (let t of
|
|
293
|
+
}, F.value = s?.params ?? {}, I.value = t, P.value = e, z.value = L > 0, V(e, a, n);
|
|
294
|
+
for (let t of U) try {
|
|
294
295
|
t(e, a);
|
|
295
296
|
} catch {}
|
|
296
297
|
}, () => i(a, o));
|
|
@@ -301,78 +302,78 @@ function E(t, n) {
|
|
|
301
302
|
u = !1;
|
|
302
303
|
return;
|
|
303
304
|
}
|
|
304
|
-
let e = x(), t =
|
|
305
|
-
|
|
306
|
-
u = !0, window.location.hash =
|
|
305
|
+
let e = x(), t = v(e.search), n = s.get(w(e.pathname, t)) ?? null;
|
|
306
|
+
Y(e.pathname, t, n, null, (e, t) => {
|
|
307
|
+
u = !0, window.location.hash = C(e, t).slice(1), queueMicrotask(() => {
|
|
307
308
|
u = !1;
|
|
308
309
|
});
|
|
309
310
|
});
|
|
310
311
|
};
|
|
311
|
-
window.addEventListener("hashchange", e),
|
|
312
|
+
window.addEventListener("hashchange", e), l = () => window.removeEventListener("hashchange", e);
|
|
312
313
|
} else {
|
|
313
314
|
let e = (e) => {
|
|
314
|
-
let t = x(), n =
|
|
315
|
-
|
|
316
|
-
history.pushState(
|
|
315
|
+
let t = x(), n = v(t.search), r = h(e.state ?? history.state), i = g(e.state ?? history.state);
|
|
316
|
+
Y(t.pathname, n, r, i, (e, t) => {
|
|
317
|
+
history.pushState(_({}, m(), L), "", C(e, t));
|
|
317
318
|
});
|
|
318
319
|
};
|
|
319
|
-
window.addEventListener("popstate", e),
|
|
320
|
+
window.addEventListener("popstate", e), l = () => window.removeEventListener("popstate", e);
|
|
320
321
|
}
|
|
321
|
-
function
|
|
322
|
-
|
|
323
|
-
let
|
|
324
|
-
if (a)
|
|
322
|
+
function X(e, t, n, r, i, o, c) {
|
|
323
|
+
c || (te(n, r), L += 1), R.value = o, F.value = i?.params ?? {}, I.value = t, P.value = e, z.value = L > 0;
|
|
324
|
+
let l = C(e, t);
|
|
325
|
+
if (a) s.set(w(e, t), {
|
|
325
326
|
left: 0,
|
|
326
327
|
top: 0
|
|
327
|
-
}),
|
|
328
|
+
}), c ? history.replaceState(history.state, "", l) : (u = !0, window.location.hash = l.slice(1), queueMicrotask(() => {
|
|
328
329
|
u = !1;
|
|
329
330
|
}));
|
|
330
331
|
else {
|
|
331
|
-
let e =
|
|
332
|
+
let e = _({}, {
|
|
332
333
|
left: 0,
|
|
333
334
|
top: 0
|
|
334
|
-
},
|
|
335
|
-
|
|
335
|
+
}, L);
|
|
336
|
+
c ? history.replaceState(e, "", l) : history.pushState(e, "", l);
|
|
336
337
|
}
|
|
337
|
-
|
|
338
|
-
for (let t of
|
|
338
|
+
V(e, n, null);
|
|
339
|
+
for (let t of U) try {
|
|
339
340
|
t(e, n);
|
|
340
341
|
} catch {}
|
|
341
342
|
}
|
|
342
|
-
let
|
|
343
|
-
function
|
|
344
|
-
|
|
345
|
-
let { pathname: n, stringQuery: r } =
|
|
343
|
+
let Z;
|
|
344
|
+
function Q(e, t) {
|
|
345
|
+
K = !0;
|
|
346
|
+
let { pathname: n, stringQuery: r } = J(e, t), i = P.value, a = { ...I.value }, o = T(n, j), s = {
|
|
346
347
|
action: "push",
|
|
347
348
|
direction: t?.direction ?? "forward",
|
|
348
349
|
animation: t?.animation
|
|
349
350
|
};
|
|
350
|
-
|
|
351
|
+
G(n, i, o?.route.beforeEnter, () => X(n, r, i, a, o, s, !1));
|
|
351
352
|
}
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
let { pathname: n, stringQuery: r } =
|
|
353
|
+
function re(e, t) {
|
|
354
|
+
K = !0;
|
|
355
|
+
let { pathname: n, stringQuery: r } = J(e, t), i = P.value, a = { ...I.value }, o = T(n, j), s = {
|
|
355
356
|
action: "replace",
|
|
356
357
|
direction: t?.direction ?? "root",
|
|
357
358
|
animation: t?.animation
|
|
358
359
|
};
|
|
359
|
-
|
|
360
|
+
G(n, i, o?.route.beforeEnter, () => X(n, r, i, a, o, s, !0));
|
|
361
|
+
}
|
|
362
|
+
function ie(e) {
|
|
363
|
+
e !== void 0 && (Z = e), history.back();
|
|
360
364
|
}
|
|
361
365
|
function ae(e) {
|
|
362
|
-
e !== void 0 && (
|
|
366
|
+
e !== void 0 && (Z = e), history.forward();
|
|
363
367
|
}
|
|
364
368
|
function oe(e) {
|
|
365
|
-
e !== void 0 && (X = e), history.forward();
|
|
366
|
-
}
|
|
367
|
-
function se(e) {
|
|
368
369
|
history.go(e);
|
|
369
370
|
}
|
|
370
|
-
function
|
|
371
|
-
let n =
|
|
371
|
+
function se(e, t = !0) {
|
|
372
|
+
let n = P.value;
|
|
372
373
|
return t ? n === e : n === e || n.startsWith(e.endsWith("/") ? e : e + "/");
|
|
373
374
|
}
|
|
374
375
|
function ce(e) {
|
|
375
|
-
let t =
|
|
376
|
+
let t = T(e, j);
|
|
376
377
|
return t ? {
|
|
377
378
|
matched: !0,
|
|
378
379
|
params: t.params,
|
|
@@ -384,64 +385,64 @@ function E(t, n) {
|
|
|
384
385
|
};
|
|
385
386
|
}
|
|
386
387
|
function le(e) {
|
|
387
|
-
return V.push(e), () => {
|
|
388
|
-
let t = V.indexOf(e);
|
|
389
|
-
t !== -1 && V.splice(t, 1);
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
function ue(e) {
|
|
393
388
|
return H.push(e), () => {
|
|
394
389
|
let t = H.indexOf(e);
|
|
395
390
|
t !== -1 && H.splice(t, 1);
|
|
396
391
|
};
|
|
397
392
|
}
|
|
393
|
+
function ue(e) {
|
|
394
|
+
return U.push(e), () => {
|
|
395
|
+
let t = U.indexOf(e);
|
|
396
|
+
t !== -1 && U.splice(t, 1);
|
|
397
|
+
};
|
|
398
|
+
}
|
|
398
399
|
let $ = {
|
|
399
|
-
current:
|
|
400
|
-
params:
|
|
401
|
-
query:
|
|
402
|
-
intent:
|
|
403
|
-
canGoBack:
|
|
400
|
+
current: P,
|
|
401
|
+
params: F,
|
|
402
|
+
query: I,
|
|
403
|
+
intent: R,
|
|
404
|
+
canGoBack: z,
|
|
404
405
|
base: r || "/",
|
|
405
|
-
navigate:
|
|
406
|
-
replace:
|
|
407
|
-
back:
|
|
408
|
-
forward:
|
|
409
|
-
go:
|
|
410
|
-
isActive:
|
|
406
|
+
navigate: Q,
|
|
407
|
+
replace: re,
|
|
408
|
+
back: ie,
|
|
409
|
+
forward: ae,
|
|
410
|
+
go: oe,
|
|
411
|
+
isActive: se,
|
|
411
412
|
resolve: ce,
|
|
412
413
|
beforeEach: le,
|
|
413
414
|
afterEach: ue,
|
|
414
415
|
routes: t,
|
|
415
|
-
_flat:
|
|
416
|
-
_guards:
|
|
416
|
+
_flat: j,
|
|
417
|
+
_guards: H,
|
|
417
418
|
_base: r,
|
|
418
419
|
_mode: i
|
|
419
420
|
};
|
|
420
|
-
return
|
|
421
|
-
|
|
422
|
-
let e =
|
|
423
|
-
a ? (
|
|
421
|
+
return c && console.warn("[elur] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."), c = $, queueMicrotask(() => {
|
|
422
|
+
K || G(k, "", T(k, j)?.route.beforeEnter, () => {}, () => {
|
|
423
|
+
let e = C("/", {});
|
|
424
|
+
a ? (s.set(w("/", {}), {
|
|
424
425
|
left: 0,
|
|
425
426
|
top: 0
|
|
426
|
-
}), history.replaceState(history.state, "", e)) : history.replaceState(
|
|
427
|
+
}), history.replaceState(history.state, "", e)) : history.replaceState(_({}, {
|
|
427
428
|
left: 0,
|
|
428
429
|
top: 0
|
|
429
|
-
},
|
|
430
|
-
let t =
|
|
431
|
-
|
|
430
|
+
}, L), "", e);
|
|
431
|
+
let t = T("/", j);
|
|
432
|
+
R.value = {
|
|
432
433
|
action: "replace",
|
|
433
434
|
direction: "root"
|
|
434
|
-
},
|
|
435
|
+
}, P.value = "/", F.value = t?.params ?? {}, I.value = {}, z.value = L > 0, V("/", k, null);
|
|
435
436
|
});
|
|
436
437
|
}), $;
|
|
437
438
|
}
|
|
438
|
-
function
|
|
439
|
-
return
|
|
439
|
+
function k() {
|
|
440
|
+
return n(i) || f();
|
|
440
441
|
}
|
|
441
|
-
function
|
|
442
|
-
|
|
442
|
+
function A() {
|
|
443
|
+
l &&= (l(), null), c = null, s.length = 0;
|
|
443
444
|
}
|
|
444
|
-
var
|
|
445
|
+
var j = class extends t {
|
|
445
446
|
_depth;
|
|
446
447
|
_router;
|
|
447
448
|
constructor(e = 0, t) {
|
|
@@ -449,23 +450,23 @@ var k = class extends t {
|
|
|
449
450
|
}
|
|
450
451
|
render() {
|
|
451
452
|
let e = this._depth, t = this._router;
|
|
452
|
-
return
|
|
453
|
-
let n = t ??
|
|
454
|
-
if (!
|
|
453
|
+
return r`<div class="router-view">${() => {
|
|
454
|
+
let n = t ?? k(), i = T(n.current.value, n._flat);
|
|
455
|
+
if (!i) return r`
|
|
455
456
|
<div style="color:#f87171;padding:16px 0">
|
|
456
457
|
404 — Route not found: <strong>${n.current.value}</strong>
|
|
457
458
|
</div>
|
|
458
459
|
`;
|
|
459
|
-
if (e >=
|
|
460
|
+
if (e >= i.route.chain.length) return r`
|
|
460
461
|
<span></span>
|
|
461
462
|
`;
|
|
462
|
-
let a =
|
|
463
|
-
return a ? a() :
|
|
463
|
+
let a = i.route.chain[e];
|
|
464
|
+
return a ? a() : r`
|
|
464
465
|
<span></span>
|
|
465
466
|
`;
|
|
466
467
|
}}</div>`;
|
|
467
468
|
}
|
|
468
|
-
},
|
|
469
|
+
}, M = class extends t {
|
|
469
470
|
_to;
|
|
470
471
|
_label;
|
|
471
472
|
_router;
|
|
@@ -473,26 +474,18 @@ var k = class extends t {
|
|
|
473
474
|
super(), this._to = e, this._label = t, this._router = n;
|
|
474
475
|
}
|
|
475
476
|
render() {
|
|
476
|
-
let e = this._to, t = this._label, n = this._router ??
|
|
477
|
-
return
|
|
477
|
+
let e = this._to, t = this._label, n = this._router ?? k(), i = e.startsWith("/") ? e : "/" + e, a = (n._base ? n._base + i : i).replace(/\/+/g, "/");
|
|
478
|
+
return r`
|
|
478
479
|
<a href=${n._mode === "hash" ? "#" + a : a} style=${() => n.current.value === e ? "color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a" : "color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"} @click=${(t) => {
|
|
479
480
|
t.preventDefault(), n.navigate(e);
|
|
480
481
|
}}>${t}</a>
|
|
481
482
|
`;
|
|
482
483
|
}
|
|
483
484
|
};
|
|
484
|
-
function j(e) {
|
|
485
|
-
let t = c.indexOf(e);
|
|
486
|
-
t >= 0 && c.splice(t, 1), c.push(e);
|
|
487
|
-
}
|
|
488
|
-
function M(e) {
|
|
489
|
-
let t = c.indexOf(e);
|
|
490
|
-
t >= 0 && c.splice(t, 1);
|
|
491
|
-
}
|
|
492
485
|
function N() {
|
|
493
|
-
let e =
|
|
486
|
+
let e = s.length ? s[s.length - 1] : c;
|
|
494
487
|
if (!e) return null;
|
|
495
|
-
let t = e, n = t.current.value, r =
|
|
488
|
+
let t = e, n = t.current.value, r = T(n, t._flat), i = r?.route.beforeEnter, a = t._guards.map((e, t) => e.name || `beforeEach#${t + 1}`);
|
|
496
489
|
return i && a.push(i.name || "beforeEnter"), {
|
|
497
490
|
mode: t._mode,
|
|
498
491
|
base: t._base || "/",
|
|
@@ -508,6 +501,6 @@ function N() {
|
|
|
508
501
|
};
|
|
509
502
|
}
|
|
510
503
|
//#endregion
|
|
511
|
-
export {
|
|
504
|
+
export { M as Link, i as RouterKey, j as RouterView, N as _debugGetRouterInternal, a as _debugRegisterRouter, o as _debugUnregisterRouter, p as _hasActiveRouter, A as _resetRouter, O as createRouter, k as elurRouter };
|
|
512
505
|
|
|
513
506
|
//# sourceMappingURL=router.js.map
|