driftjs-router 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-cjs.js +1 -1
- package/dist/index-es.js +320 -375
- package/dist/index.d.ts +242 -0
- package/package.json +11 -11
package/dist/index-es.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { createContext as e, onUnmount as t } from "driftjs-shared";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var n = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports);
|
|
4
|
+
//#endregion
|
|
2
5
|
//#region src/path.ts
|
|
3
|
-
function
|
|
6
|
+
function r(e) {
|
|
4
7
|
if (!e || e === "/") return "/";
|
|
5
8
|
let t = e.replace(/\/+/g, "/");
|
|
6
9
|
return t.startsWith("/") || (t = "/" + t), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t;
|
|
7
10
|
}
|
|
8
|
-
function
|
|
11
|
+
function i(e) {
|
|
9
12
|
if (!e) return "";
|
|
10
13
|
let t = e.trim();
|
|
11
14
|
return t.startsWith("/") || (t = "/" + t), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t === "/" ? "" : t;
|
|
12
15
|
}
|
|
13
|
-
function
|
|
16
|
+
function a(e, t) {
|
|
14
17
|
if (!t) return e;
|
|
15
18
|
if (e.startsWith(t)) {
|
|
16
19
|
let n = e.slice(t.length);
|
|
@@ -18,17 +21,17 @@ function i(e, t) {
|
|
|
18
21
|
}
|
|
19
22
|
return e;
|
|
20
23
|
}
|
|
21
|
-
function
|
|
24
|
+
function o(e, t) {
|
|
22
25
|
let n = t.startsWith("/") ? t : "/" + t;
|
|
23
26
|
return e ? e + n : n;
|
|
24
27
|
}
|
|
25
|
-
function
|
|
28
|
+
function s(e, t) {
|
|
26
29
|
let n = t.startsWith("/") ? t : "/" + t;
|
|
27
30
|
return (e || "") + "#" + n;
|
|
28
31
|
}
|
|
29
32
|
//#endregion
|
|
30
33
|
//#region src/history.ts
|
|
31
|
-
function
|
|
34
|
+
function c() {
|
|
32
35
|
let e = [];
|
|
33
36
|
return {
|
|
34
37
|
get list() {
|
|
@@ -48,50 +51,50 @@ function s() {
|
|
|
48
51
|
}
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
|
-
function
|
|
54
|
+
function l(e) {
|
|
52
55
|
if (typeof window > "u") return null;
|
|
53
56
|
let t = e ?? window.history.state;
|
|
54
57
|
if (!t || typeof t != "object") return t ?? null;
|
|
55
58
|
let { __drift_pos: n, __drift_has_data: r, ...i } = t;
|
|
56
59
|
return Object.keys(i).length > 0 || r ? i : null;
|
|
57
60
|
}
|
|
58
|
-
function
|
|
61
|
+
function u(e, t) {
|
|
59
62
|
return {
|
|
60
63
|
...e || {},
|
|
61
64
|
__drift_pos: t,
|
|
62
65
|
...e === void 0 ? {} : { __drift_has_data: !0 }
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
|
-
function
|
|
66
|
-
let t =
|
|
68
|
+
function d(e = "") {
|
|
69
|
+
let t = i(e), n = c(), r = () => typeof window > "u" ? "/" : window.location.pathname + window.location.search + window.location.hash, s = () => a(r(), t) || "/", d = s(), f = typeof window < "u" && window.history.state && typeof window.history.state.__drift_pos == "number" ? window.history.state.__drift_pos : 0;
|
|
67
70
|
if (typeof window < "u" && (window.history.state == null || typeof window.history.state.__drift_pos != "number")) {
|
|
68
71
|
let e = window.history.state || {};
|
|
69
72
|
window.history.replaceState({
|
|
70
73
|
...e,
|
|
71
74
|
__drift_pos: f
|
|
72
|
-
}, "",
|
|
75
|
+
}, "", o(t, d));
|
|
73
76
|
}
|
|
74
77
|
let p = (e) => {
|
|
75
|
-
let t = d, r =
|
|
78
|
+
let t = d, r = s();
|
|
76
79
|
d = r;
|
|
77
80
|
let i = typeof window < "u" && window.history.state || e.state || null, a = i && typeof i.__drift_pos == "number" ? i.__drift_pos : f, o = a - f;
|
|
78
81
|
f = a;
|
|
79
|
-
let
|
|
82
|
+
let c = {
|
|
80
83
|
direction: o > 0 ? "forward" : o < 0 ? "back" : "unknown",
|
|
81
84
|
delta: o,
|
|
82
85
|
type: "pop"
|
|
83
86
|
};
|
|
84
|
-
n.notify(r, t,
|
|
87
|
+
n.notify(r, t, c);
|
|
85
88
|
};
|
|
86
89
|
return typeof window < "u" && window.addEventListener("popstate", p), {
|
|
87
90
|
get base() {
|
|
88
91
|
return t;
|
|
89
92
|
},
|
|
90
93
|
get location() {
|
|
91
|
-
return
|
|
94
|
+
return s();
|
|
92
95
|
},
|
|
93
96
|
get state() {
|
|
94
|
-
return
|
|
97
|
+
return l(window.history.state);
|
|
95
98
|
},
|
|
96
99
|
listen(e) {
|
|
97
100
|
return n.listen(e);
|
|
@@ -99,12 +102,12 @@ function u(e = "") {
|
|
|
99
102
|
push(e, n) {
|
|
100
103
|
if (typeof window > "u") return;
|
|
101
104
|
f++;
|
|
102
|
-
let r =
|
|
105
|
+
let r = o(t, e), i = u(n, f);
|
|
103
106
|
window.history.pushState(i, "", r), d = e;
|
|
104
107
|
},
|
|
105
108
|
replace(e, n) {
|
|
106
109
|
if (typeof window > "u") return;
|
|
107
|
-
let r =
|
|
110
|
+
let r = o(t, e), i = u(n, f);
|
|
108
111
|
window.history.replaceState(i, "", r), d = e;
|
|
109
112
|
},
|
|
110
113
|
go(e) {
|
|
@@ -115,57 +118,57 @@ function u(e = "") {
|
|
|
115
118
|
}
|
|
116
119
|
};
|
|
117
120
|
}
|
|
118
|
-
function
|
|
119
|
-
let t =
|
|
121
|
+
function f(e = "") {
|
|
122
|
+
let t = i(e), n = c(), r = () => {
|
|
120
123
|
if (typeof window > "u") return "/";
|
|
121
124
|
let e = window.location.hash;
|
|
122
125
|
if (!e || e === "#") return "/";
|
|
123
126
|
let t = e.startsWith("#") ? e.slice(1) : e;
|
|
124
127
|
return t.startsWith("/") ? t : "/" + t;
|
|
125
|
-
}, a =
|
|
128
|
+
}, a = r(), o = typeof window < "u" && window.history.state && typeof window.history.state.__drift_pos == "number" ? window.history.state.__drift_pos : 0;
|
|
126
129
|
if (typeof window < "u" && (window.history.state == null || typeof window.history.state.__drift_pos != "number")) {
|
|
127
130
|
let e = window.history.state || {};
|
|
128
131
|
window.history.replaceState({
|
|
129
132
|
...e,
|
|
130
|
-
__drift_pos:
|
|
131
|
-
}, "",
|
|
133
|
+
__drift_pos: o
|
|
134
|
+
}, "", s(t, a));
|
|
132
135
|
}
|
|
133
136
|
let d = (e) => {
|
|
134
|
-
let t =
|
|
137
|
+
let t = r();
|
|
135
138
|
if (t === a) return;
|
|
136
|
-
let
|
|
139
|
+
let i = a;
|
|
137
140
|
a = t;
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
let
|
|
141
|
-
direction:
|
|
142
|
-
delta:
|
|
141
|
+
let s = typeof window < "u" && window.history.state || null, c = s && typeof s.__drift_pos == "number" ? s.__drift_pos : o, l = c - o;
|
|
142
|
+
o = c;
|
|
143
|
+
let u = {
|
|
144
|
+
direction: l > 0 ? "forward" : l < 0 ? "back" : "unknown",
|
|
145
|
+
delta: l,
|
|
143
146
|
type: "pop"
|
|
144
147
|
};
|
|
145
|
-
n.notify(t,
|
|
148
|
+
n.notify(t, i, u);
|
|
146
149
|
};
|
|
147
150
|
return typeof window < "u" && (window.addEventListener("popstate", d), window.addEventListener("hashchange", d)), {
|
|
148
151
|
get base() {
|
|
149
152
|
return t;
|
|
150
153
|
},
|
|
151
154
|
get location() {
|
|
152
|
-
return
|
|
155
|
+
return r();
|
|
153
156
|
},
|
|
154
157
|
get state() {
|
|
155
|
-
return
|
|
158
|
+
return l(window.history.state);
|
|
156
159
|
},
|
|
157
160
|
listen(e) {
|
|
158
161
|
return n.listen(e);
|
|
159
162
|
},
|
|
160
163
|
push(e, n) {
|
|
161
164
|
if (typeof window > "u") return;
|
|
162
|
-
|
|
163
|
-
let r =
|
|
165
|
+
o++;
|
|
166
|
+
let r = s(t, e), i = u(n, o);
|
|
164
167
|
window.history.pushState(i, "", r), a = e;
|
|
165
168
|
},
|
|
166
169
|
replace(e, n) {
|
|
167
170
|
if (typeof window > "u") return;
|
|
168
|
-
let r =
|
|
171
|
+
let r = s(t, e), i = u(n, o);
|
|
169
172
|
window.history.replaceState(i, "", r), a = e;
|
|
170
173
|
},
|
|
171
174
|
go(e) {
|
|
@@ -176,14 +179,14 @@ function d(e = "") {
|
|
|
176
179
|
}
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
|
-
function
|
|
180
|
-
let n =
|
|
182
|
+
function p(e = "/", t = "") {
|
|
183
|
+
let n = i(t), r = [a(e.startsWith("/") ? e : "/" + e, n) || "/"], o = [null], s = 0, c = [];
|
|
181
184
|
return {
|
|
182
185
|
get base() {
|
|
183
186
|
return n;
|
|
184
187
|
},
|
|
185
188
|
get location() {
|
|
186
|
-
return
|
|
189
|
+
return r[s] ?? "/";
|
|
187
190
|
},
|
|
188
191
|
get state() {
|
|
189
192
|
return o[s] ?? null;
|
|
@@ -196,286 +199,227 @@ function f(e = "/", t = "") {
|
|
|
196
199
|
},
|
|
197
200
|
push(e, t) {
|
|
198
201
|
let n = e.startsWith("/") ? e : "/" + e;
|
|
199
|
-
|
|
202
|
+
r.splice(s + 1), o.splice(s + 1), r.push(n), o.push(t || null), s++;
|
|
200
203
|
},
|
|
201
204
|
replace(e, t) {
|
|
202
205
|
let n = e.startsWith("/") ? e : "/" + e;
|
|
203
|
-
|
|
206
|
+
r[s] = n, o[s] = t || null;
|
|
204
207
|
},
|
|
205
208
|
go(e) {
|
|
206
|
-
let t =
|
|
207
|
-
if (n >= 0 && n <
|
|
209
|
+
let t = r[s] ?? "/", n = s + e;
|
|
210
|
+
if (n >= 0 && n < r.length) {
|
|
208
211
|
s = n;
|
|
209
|
-
let
|
|
212
|
+
let i = r[s] ?? "/", a = {
|
|
210
213
|
direction: e > 0 ? "forward" : e < 0 ? "back" : "unknown",
|
|
211
214
|
delta: e,
|
|
212
215
|
type: "pop"
|
|
213
216
|
};
|
|
214
|
-
for (let e of c) e(
|
|
217
|
+
for (let e of c) e(i, t, a);
|
|
215
218
|
}
|
|
216
219
|
},
|
|
217
220
|
destroy() {
|
|
218
|
-
c.length = 0,
|
|
221
|
+
c.length = 0, r.length = 0, o.length = 0, s = 0;
|
|
219
222
|
}
|
|
220
223
|
};
|
|
221
224
|
}
|
|
222
225
|
//#endregion
|
|
223
|
-
//#region
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (r === "\\") {
|
|
236
|
-
t.push({
|
|
237
|
-
type: "ESCAPED_CHAR",
|
|
238
|
-
index: n++,
|
|
239
|
-
value: e[n++]
|
|
240
|
-
});
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
if (r === "{") {
|
|
244
|
-
t.push({
|
|
245
|
-
type: "OPEN",
|
|
246
|
-
index: n,
|
|
247
|
-
value: e[n++]
|
|
248
|
-
});
|
|
249
|
-
continue;
|
|
226
|
+
//#region src/matcher.ts
|
|
227
|
+
var m = (/* @__PURE__ */ n(((e) => {
|
|
228
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.PathError = e.TokenData = void 0, e.compile = l, e.pathToRegexp = f;
|
|
229
|
+
var t = "/", n = (e) => e, r = /^[$_\p{ID_Start}]$/u, i = /^[$\u200c\u200d\p{ID_Continue}]$/u;
|
|
230
|
+
function a(e) {
|
|
231
|
+
return e.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
232
|
+
}
|
|
233
|
+
var o = class {
|
|
234
|
+
constructor(e, t) {
|
|
235
|
+
this.tokens = e, this.originalPath = t;
|
|
250
236
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
});
|
|
257
|
-
continue;
|
|
237
|
+
};
|
|
238
|
+
e.TokenData = o;
|
|
239
|
+
var s = class extends TypeError {
|
|
240
|
+
constructor(e, t) {
|
|
241
|
+
let n = e;
|
|
242
|
+
t && (n += `: ${t}`), n += "; visit https://git.new/pathToRegexpError for info", super(n), this.originalPath = t;
|
|
258
243
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
244
|
+
};
|
|
245
|
+
e.PathError = s;
|
|
246
|
+
function c(e, t = {}) {
|
|
247
|
+
let { encodePath: a = n } = t, c = [...e], l = 0;
|
|
248
|
+
function u(t) {
|
|
249
|
+
let n = [], o = "";
|
|
250
|
+
function d() {
|
|
251
|
+
o &&= (n.push({
|
|
252
|
+
type: "text",
|
|
253
|
+
value: a(o)
|
|
254
|
+
}), "");
|
|
267
255
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
if (r === "(") {
|
|
277
|
-
var s = 1, c = "", a = n + 1;
|
|
278
|
-
if (e[a] === "?") throw TypeError(`Pattern cannot start with "?" at ${a}`);
|
|
279
|
-
for (; a < e.length;) {
|
|
280
|
-
if (e[a] === "\\") {
|
|
281
|
-
c += e[a++] + e[a++];
|
|
256
|
+
for (; l < c.length;) {
|
|
257
|
+
let a = c[l++];
|
|
258
|
+
if (a === t) return d(), n;
|
|
259
|
+
if (a === "\\") {
|
|
260
|
+
if (l === c.length) throw new s(`Unexpected end after \\ at index ${l}`, e);
|
|
261
|
+
o += c[l++];
|
|
282
262
|
continue;
|
|
283
263
|
}
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
264
|
+
if (a === ":" || a === "*") {
|
|
265
|
+
let t = a === ":" ? "param" : "wildcard", o = "";
|
|
266
|
+
if (r.test(c[l])) do
|
|
267
|
+
o += c[l++];
|
|
268
|
+
while (i.test(c[l]));
|
|
269
|
+
else if (c[l] === "\"") {
|
|
270
|
+
let t = l;
|
|
271
|
+
for (; l < c.length;) {
|
|
272
|
+
if (c[++l] === "\"") {
|
|
273
|
+
l++, t = 0;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
c[l] === "\\" && l++, o += c[l];
|
|
277
|
+
}
|
|
278
|
+
if (t) throw new s(`Unterminated quote at index ${t}`, e);
|
|
288
279
|
}
|
|
289
|
-
|
|
290
|
-
|
|
280
|
+
if (!o) throw new s(`Missing parameter name at index ${l}`, e);
|
|
281
|
+
d(), n.push({
|
|
282
|
+
type: t,
|
|
283
|
+
name: o
|
|
284
|
+
});
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (a === "{") {
|
|
288
|
+
d(), n.push({
|
|
289
|
+
type: "group",
|
|
290
|
+
tokens: u("}")
|
|
291
|
+
});
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (a === "}" || a === "(" || a === ")" || a === "[" || a === "]" || a === "+" || a === "?" || a === "!") throw new s(`Unexpected ${a} at index ${l - 1}`, e);
|
|
295
|
+
o += a;
|
|
291
296
|
}
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
t.push({
|
|
295
|
-
type: "PATTERN",
|
|
296
|
-
index: n,
|
|
297
|
-
value: c
|
|
298
|
-
}), n = a;
|
|
299
|
-
continue;
|
|
297
|
+
if (t) throw new s(`Unexpected end at index ${l}, expected ${t}`, e);
|
|
298
|
+
return d(), n;
|
|
300
299
|
}
|
|
301
|
-
|
|
302
|
-
type: "CHAR",
|
|
303
|
-
index: n,
|
|
304
|
-
value: e[n++]
|
|
305
|
-
});
|
|
300
|
+
return new o(u(""), e);
|
|
306
301
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return e;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}, g = function(e) {
|
|
332
|
-
var t = s[s.length - 1], n = e || (t && typeof t == "string" ? t : "");
|
|
333
|
-
if (t && !n) throw TypeError(`Must have text between two parameters, missing text after "${t.name}"`);
|
|
334
|
-
return !n || h(n) ? `[^${_(o)}]+?` : `(?:(?!${_(n)})[^${_(o)}])+?`;
|
|
335
|
-
}; l < n.length;) {
|
|
336
|
-
var v = d("CHAR"), y = d("NAME"), b = d("PATTERN");
|
|
337
|
-
if (y || b) {
|
|
338
|
-
var x = v || "";
|
|
339
|
-
i.indexOf(x) === -1 && (u += x, x = ""), u &&= (s.push(u), ""), s.push({
|
|
340
|
-
name: y || c++,
|
|
341
|
-
prefix: x,
|
|
342
|
-
suffix: "",
|
|
343
|
-
pattern: b || g(x),
|
|
344
|
-
modifier: d("MODIFIER") || ""
|
|
345
|
-
});
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
var S = v || d("ESCAPED_CHAR");
|
|
349
|
-
if (S) {
|
|
350
|
-
u += S;
|
|
351
|
-
continue;
|
|
302
|
+
function l(e, n = {}) {
|
|
303
|
+
let { encode: r = encodeURIComponent, delimiter: i = t } = n, a = u((typeof e == "object" ? e : c(e, n)).tokens, i, r);
|
|
304
|
+
return function(e = {}) {
|
|
305
|
+
let t = [], n = a(e, t);
|
|
306
|
+
if (t.length) throw TypeError(`Missing parameters: ${t.join(", ")}`);
|
|
307
|
+
return n;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function u(e, t, n) {
|
|
311
|
+
let r = e.map((e) => d(e, t, n));
|
|
312
|
+
return (e, t) => {
|
|
313
|
+
let n = "";
|
|
314
|
+
for (let i of r) n += i(e, t);
|
|
315
|
+
return n;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function d(e, t, r) {
|
|
319
|
+
if (e.type === "text") return () => e.value;
|
|
320
|
+
if (e.type === "group") {
|
|
321
|
+
let n = u(e.tokens, t, r);
|
|
322
|
+
return (e, t) => {
|
|
323
|
+
let r = t.length, i = n(e, t);
|
|
324
|
+
return t.length === r ? i : (t.length = r, "");
|
|
325
|
+
};
|
|
352
326
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
327
|
+
let i = r || n;
|
|
328
|
+
return e.type === "wildcard" && r !== !1 ? (n, r) => {
|
|
329
|
+
let a = n[e.name];
|
|
330
|
+
if (a == null) return r.push(e.name), "";
|
|
331
|
+
if (!Array.isArray(a) || a.length === 0) throw TypeError(`Expected "${e.name}" to be a non-empty array`);
|
|
332
|
+
let o = "";
|
|
333
|
+
for (let n = 0; n < a.length; n++) {
|
|
334
|
+
if (typeof a[n] != "string") throw TypeError(`Expected "${e.name}/${n}" to be a string`);
|
|
335
|
+
n > 0 && (o += t), o += i(a[n]);
|
|
336
|
+
}
|
|
337
|
+
return o;
|
|
338
|
+
} : (t, n) => {
|
|
339
|
+
let r = t[e.name];
|
|
340
|
+
if (r == null) return n.push(e.name), "";
|
|
341
|
+
if (typeof r != "string") throw TypeError(`Expected "${e.name}" to be a string`);
|
|
342
|
+
return i(r);
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function f(e, n = {}) {
|
|
346
|
+
let { delimiter: r = t, end: i = !0, sensitive: o = !1, trailing: l = !0 } = n, u = [], d = "", f = 0;
|
|
347
|
+
function h(e) {
|
|
348
|
+
if (Array.isArray(e)) {
|
|
349
|
+
for (let t of e) h(t);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
let t = typeof e == "object" ? e : c(e, n);
|
|
353
|
+
p(t.tokens, 0, [], (e) => {
|
|
354
|
+
if (f >= 256) throw new s("Too many path combinations", t.originalPath);
|
|
355
|
+
f > 0 && (d += "|"), d += m(e, r, u, t.originalPath), f++;
|
|
361
356
|
});
|
|
362
|
-
continue;
|
|
363
357
|
}
|
|
364
|
-
|
|
358
|
+
h(e);
|
|
359
|
+
let g = `^(?:${d})`;
|
|
360
|
+
return l && (g += "(?:" + a(r) + "$)?"), g += i ? "$" : "(?=" + a(r) + "|$)", {
|
|
361
|
+
regexp: new RegExp(g, o ? "" : "i"),
|
|
362
|
+
keys: u
|
|
363
|
+
};
|
|
365
364
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
t === void 0 && (t = {});
|
|
373
|
-
var n = v(t), r = t.encode, i = r === void 0 ? function(e) {
|
|
374
|
-
return e;
|
|
375
|
-
} : r, a = t.validate, o = a === void 0 || a, s = e.map(function(e) {
|
|
376
|
-
if (typeof e == "object") return RegExp(`^(?:${e.pattern})\$`, n);
|
|
377
|
-
});
|
|
378
|
-
return function(t) {
|
|
379
|
-
for (var n = "", r = 0; r < e.length; r++) {
|
|
380
|
-
var a = e[r];
|
|
381
|
-
if (typeof a == "string") {
|
|
382
|
-
n += a;
|
|
365
|
+
function p(e, t, n, r) {
|
|
366
|
+
for (; t < e.length;) {
|
|
367
|
+
let i = e[t++];
|
|
368
|
+
if (i.type === "group") {
|
|
369
|
+
let a = n.length;
|
|
370
|
+
p(i.tokens, 0, n, (n) => p(e, t, n, r)), n.length = a;
|
|
383
371
|
continue;
|
|
384
372
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
if (typeof c == "string" || typeof c == "number") {
|
|
400
|
-
var f = i(String(c), a);
|
|
401
|
-
if (o && !s[r].test(f)) throw TypeError(`Expected "${a.name}" to match "${a.pattern}", but got "${f}"`);
|
|
402
|
-
n += a.prefix + f + a.suffix;
|
|
403
|
-
continue;
|
|
373
|
+
n.push(i);
|
|
374
|
+
}
|
|
375
|
+
r(n);
|
|
376
|
+
}
|
|
377
|
+
function m(e, t, n, r) {
|
|
378
|
+
let i = "", o = "", c = "", l = 0, u = 0, d = 0;
|
|
379
|
+
function f(n, r) {
|
|
380
|
+
for (; n < e.length;) {
|
|
381
|
+
let i = e[n++];
|
|
382
|
+
if (i.type === r) return !0;
|
|
383
|
+
if (i.type === "text" && i.value.includes(t)) break;
|
|
404
384
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
385
|
+
return !1;
|
|
386
|
+
}
|
|
387
|
+
function p(t) {
|
|
388
|
+
let n = "";
|
|
389
|
+
for (; t < e.length;) {
|
|
390
|
+
let r = e[t++];
|
|
391
|
+
if (r.type !== "text") break;
|
|
392
|
+
n += r.value;
|
|
408
393
|
}
|
|
394
|
+
return n;
|
|
409
395
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
if (!t) return e;
|
|
421
|
-
for (var n = /\((?:\?<(.*?)>)?(?!\?)/g, r = 0, i = n.exec(e.source); i;) t.push({
|
|
422
|
-
name: i[1] || r++,
|
|
423
|
-
prefix: "",
|
|
424
|
-
suffix: "",
|
|
425
|
-
modifier: "",
|
|
426
|
-
pattern: ""
|
|
427
|
-
}), i = n.exec(e.source);
|
|
428
|
-
return e;
|
|
429
|
-
}
|
|
430
|
-
function b(e, t, n) {
|
|
431
|
-
var r = e.map(function(e) {
|
|
432
|
-
return C(e, t, n).source;
|
|
433
|
-
});
|
|
434
|
-
return RegExp(`(?:${r.join("|")})`, v(n));
|
|
435
|
-
}
|
|
436
|
-
function x(e, t, n) {
|
|
437
|
-
return S(m(e, n), t, n);
|
|
438
|
-
}
|
|
439
|
-
function S(e, t, n) {
|
|
440
|
-
n === void 0 && (n = {});
|
|
441
|
-
for (var r = n.strict, i = r !== void 0 && r, a = n.start, o = a === void 0 || a, s = n.end, c = s === void 0 || s, l = n.encode, u = l === void 0 ? function(e) {
|
|
442
|
-
return e;
|
|
443
|
-
} : l, d = n.delimiter, f = d === void 0 ? "/#?" : d, p = n.endsWith, m = `[${_(p === void 0 ? "" : p)}]|\$`, h = `[${_(f)}]`, g = o ? "^" : "", y = 0, b = e; y < b.length; y++) {
|
|
444
|
-
var x = b[y];
|
|
445
|
-
if (typeof x == "string") g += _(u(x));
|
|
446
|
-
else {
|
|
447
|
-
var S = _(u(x.prefix)), C = _(u(x.suffix));
|
|
448
|
-
if (x.pattern) if (t && t.push(x), S || C) if (x.modifier === "+" || x.modifier === "*") {
|
|
449
|
-
var w = x.modifier === "*" ? "?" : "";
|
|
450
|
-
g += `(?:${S}((?:${x.pattern})(?:${C}${S}(?:${x.pattern}))*)${C})${w}`;
|
|
451
|
-
} else g += `(?:${S}(${x.pattern})${C})${x.modifier}`;
|
|
452
|
-
else {
|
|
453
|
-
if (x.modifier === "+" || x.modifier === "*") throw TypeError(`Can not repeat "${x.name}" without a prefix and suffix`);
|
|
454
|
-
g += `(${x.pattern})${x.modifier}`;
|
|
396
|
+
for (; d < e.length;) {
|
|
397
|
+
let m = e[d++];
|
|
398
|
+
if (m.type === "text") {
|
|
399
|
+
i += a(m.value), o += m.value, l === 2 && (c += m.value), m.value.includes(t) && (u = 0);
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (m.type === "param" || m.type === "wildcard") {
|
|
403
|
+
if (l && !o) throw new s(`Missing text before "${m.name}" ${m.type}`, r);
|
|
404
|
+
m.type === "param" ? (i += u & 2 ? `(${h(t, o)}+)` : f(d, "wildcard") ? `(${h(t, p(d))}+)` : u & 1 ? `(${h(t, o)}+|${a(o)})` : `(${h(t, "")}+)`, u |= l = 1) : (i += u & 2 ? `(${h(o, "")}+)` : c ? `(${h(c, "")}+|${h(t, "")}+)` : "([^]+)", c = "", u |= l = 2), n.push(m), o = "";
|
|
405
|
+
continue;
|
|
455
406
|
}
|
|
456
|
-
|
|
407
|
+
throw TypeError(`Unknown token type: ${m.type}`);
|
|
457
408
|
}
|
|
409
|
+
return i;
|
|
458
410
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
var T = e[e.length - 1], E = typeof T == "string" ? h.indexOf(T[T.length - 1]) > -1 : T === void 0;
|
|
462
|
-
i || (g += `(?:${h}(?=${m}))?`), E || (g += `(?=${h}|${m})`);
|
|
411
|
+
function h(e, t) {
|
|
412
|
+
return t.length > e.length ? h(t, e) : (e === t && (t = ""), t.length > 1 ? `(?:(?!${a(e)}|${a(t)})[^])` : e.length > 1 ? `(?:(?!${a(e)})[^${a(t)}])` : `[^${a(e + t)}]`);
|
|
463
413
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
function C(e, t, n) {
|
|
467
|
-
return e instanceof RegExp ? y(e, t) : Array.isArray(e) ? b(e, t, n) : x(e, t, n);
|
|
468
|
-
}
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/matcher.ts
|
|
471
|
-
function w(e) {
|
|
414
|
+
})))();
|
|
415
|
+
function h(e) {
|
|
472
416
|
try {
|
|
473
417
|
return decodeURIComponent(e);
|
|
474
418
|
} catch {
|
|
475
419
|
return e;
|
|
476
420
|
}
|
|
477
421
|
}
|
|
478
|
-
function
|
|
422
|
+
function g(e) {
|
|
479
423
|
let t = Object.create(null);
|
|
480
424
|
if (!e) return t;
|
|
481
425
|
let n = e.startsWith("?") ? e.slice(1) : e;
|
|
@@ -495,7 +439,7 @@ function T(e) {
|
|
|
495
439
|
}
|
|
496
440
|
return t;
|
|
497
441
|
}
|
|
498
|
-
function
|
|
442
|
+
function _(e) {
|
|
499
443
|
let t = Object.keys(e);
|
|
500
444
|
if (t.length === 0) return "";
|
|
501
445
|
let n = [];
|
|
@@ -510,74 +454,75 @@ function E(e) {
|
|
|
510
454
|
}
|
|
511
455
|
return n.length > 0 ? "?" + n.join("&") : "";
|
|
512
456
|
}
|
|
513
|
-
function
|
|
514
|
-
let t = e.replace(
|
|
515
|
-
|
|
457
|
+
function v(e) {
|
|
458
|
+
let t = e.replace(/:([a-zA-Z0-9_$]+)\(\.\*\)\*?/g, "*$1");
|
|
459
|
+
t = t.replace(/\/\*$/, "/*pathMatch"), t = t.replace(/\/(:[a-zA-Z0-9_$]+)\?/g, "{/$1}");
|
|
460
|
+
let n = [], r = "", i = 0;
|
|
461
|
+
for (; i < t.length;) if (t[i] === ":" && /[a-zA-Z0-9_$]/.test(t[i + 1] || "")) {
|
|
516
462
|
let e = "";
|
|
517
|
-
for (
|
|
518
|
-
if (t[
|
|
519
|
-
let
|
|
520
|
-
for (
|
|
521
|
-
if (t[
|
|
522
|
-
|
|
523
|
-
continue;
|
|
524
|
-
}
|
|
525
|
-
if (t[n] === "(") {
|
|
526
|
-
i++, a += "(?:", n++;
|
|
463
|
+
for (i++; i < t.length && /[a-zA-Z0-9_$]/.test(t[i]);) e += t[i], i++;
|
|
464
|
+
if (r += ":" + e, t[i] === "(") {
|
|
465
|
+
let e = 1, r = "";
|
|
466
|
+
for (i++; i < t.length && e > 0;) {
|
|
467
|
+
if (t[i] === "\\") {
|
|
468
|
+
r += t[i] + (t[i + 1] || ""), i += 2;
|
|
527
469
|
continue;
|
|
528
470
|
}
|
|
529
|
-
if (t[
|
|
530
|
-
|
|
471
|
+
if (t[i] === "(") e++;
|
|
472
|
+
else if (t[i] === ")" && (e--, e === 0)) {
|
|
473
|
+
i++;
|
|
531
474
|
break;
|
|
532
475
|
}
|
|
533
|
-
|
|
476
|
+
r += t[i], i++;
|
|
534
477
|
}
|
|
535
|
-
r
|
|
536
|
-
}
|
|
537
|
-
} else r += t[
|
|
538
|
-
return
|
|
478
|
+
r && n.push(r.replace(/(^|[^\\])\((?!\?)/g, "$1(?:"));
|
|
479
|
+
}
|
|
480
|
+
} else r += t[i], i++;
|
|
481
|
+
return {
|
|
482
|
+
normalized: r,
|
|
483
|
+
patterns: n
|
|
484
|
+
};
|
|
539
485
|
}
|
|
540
|
-
function
|
|
486
|
+
function y(e, t) {
|
|
541
487
|
let n = {};
|
|
542
|
-
for (let [e, r] of Object.entries(t)) r != null && (n[e] = r);
|
|
488
|
+
for (let [e, r] of Object.entries(t)) r != null && (n[e] = Array.isArray(r) ? r.join("/") : String(r));
|
|
489
|
+
let { normalized: r } = v(e);
|
|
543
490
|
try {
|
|
544
|
-
return
|
|
545
|
-
validate: !1,
|
|
546
|
-
encode: (e) => e
|
|
547
|
-
})(n);
|
|
491
|
+
return (0, m.compile)(r, { encode: !1 })(n);
|
|
548
492
|
} catch {
|
|
549
|
-
let
|
|
550
|
-
for (let [
|
|
551
|
-
return
|
|
493
|
+
let e = r;
|
|
494
|
+
for (let [t, r] of Object.entries(n)) e = e.replace(RegExp(`:${t}\\b`, "g"), String(r)), e = e.replace(RegExp(`\\*${t}\\b`, "g"), String(r));
|
|
495
|
+
return e = e.replace(/\{(\/[^}]+)\}/g, ""), e;
|
|
552
496
|
}
|
|
553
497
|
}
|
|
554
|
-
function
|
|
498
|
+
function b(e) {
|
|
555
499
|
if (e === "/" || e === "") return {
|
|
556
500
|
regex: /^\/?$/,
|
|
557
501
|
paramNames: [],
|
|
558
502
|
score: 1e3
|
|
559
503
|
};
|
|
560
|
-
let t =
|
|
504
|
+
let { normalized: t, patterns: n } = v(e), { regexp: r, keys: i } = (0, m.pathToRegexp)(t, {
|
|
561
505
|
sensitive: !1,
|
|
562
|
-
strict: !1,
|
|
563
506
|
end: !0
|
|
564
|
-
}),
|
|
565
|
-
for (let
|
|
507
|
+
}), a = r.source;
|
|
508
|
+
for (let e of n) a = a.replace("([^\\/]+)", `(${e})`);
|
|
509
|
+
let o = n.length > 0 ? new RegExp(a, r.flags) : r, s = i.map((e) => typeof e.name == "number" ? "pathMatch" : String(e.name)), c = 0;
|
|
510
|
+
for (let t of e.split("/").filter(Boolean)) t === "*" || t.includes("(.*)") || t.startsWith("*") ? c += 1 : t.includes(":") ? t.includes("(") ? c += 30 : t.includes("?") ? c += 15 : c += 20 : c += 100;
|
|
566
511
|
return {
|
|
567
|
-
regex:
|
|
568
|
-
paramNames:
|
|
569
|
-
score:
|
|
512
|
+
regex: o,
|
|
513
|
+
paramNames: s,
|
|
514
|
+
score: c
|
|
570
515
|
};
|
|
571
516
|
}
|
|
572
|
-
function
|
|
573
|
-
let
|
|
574
|
-
|
|
575
|
-
let { regex: i, paramNames: a, score: o } =
|
|
517
|
+
function x(e, t) {
|
|
518
|
+
let n = e.path;
|
|
519
|
+
n = t ? e.path.startsWith("/") ? r(e.path) : r(`${t.path === "/" ? "" : t.path}/${e.path}`) : r(e.path);
|
|
520
|
+
let { regex: i, paramNames: a, score: o } = b(n), s = {};
|
|
576
521
|
e.components ? Object.assign(s, e.components) : e.component && (s.default = e.component);
|
|
577
522
|
let c = e.beforeEnter ? Array.isArray(e.beforeEnter) ? e.beforeEnter : [e.beforeEnter] : void 0, l = {};
|
|
578
523
|
typeof e.props == "boolean" || typeof e.props == "function" ? l.default = e.props : e.props && typeof e.props == "object" && (l = e.props);
|
|
579
524
|
let u = {
|
|
580
|
-
path:
|
|
525
|
+
path: n,
|
|
581
526
|
name: e.name,
|
|
582
527
|
components: s,
|
|
583
528
|
children: [],
|
|
@@ -590,16 +535,16 @@ function A(e, t) {
|
|
|
590
535
|
score: o,
|
|
591
536
|
redirect: e.redirect
|
|
592
537
|
};
|
|
593
|
-
return e.children && e.children.length > 0 && (u.children = e.children.map((e) =>
|
|
538
|
+
return e.children && e.children.length > 0 && (u.children = e.children.map((e) => x(e, u))), u;
|
|
594
539
|
}
|
|
595
|
-
function
|
|
596
|
-
let t = [],
|
|
540
|
+
function S(e) {
|
|
541
|
+
let t = [], n = /* @__PURE__ */ new Map(), i = [];
|
|
597
542
|
function a(e, t) {
|
|
598
|
-
t.push(e), e.name &&
|
|
543
|
+
t.push(e), e.name && n.set(e.name, e);
|
|
599
544
|
for (let n of e.children) a(n, t);
|
|
600
545
|
}
|
|
601
546
|
function o() {
|
|
602
|
-
|
|
547
|
+
n.clear();
|
|
603
548
|
let e = [];
|
|
604
549
|
for (let t of i) a(t, e);
|
|
605
550
|
t = e.sort((e, t) => {
|
|
@@ -607,17 +552,17 @@ function j(e) {
|
|
|
607
552
|
return (t.score ?? 0) - n;
|
|
608
553
|
});
|
|
609
554
|
}
|
|
610
|
-
for (let t of e) i.push(
|
|
555
|
+
for (let t of e) i.push(x(t));
|
|
611
556
|
o();
|
|
612
557
|
function s(e) {
|
|
613
|
-
let
|
|
558
|
+
let n = r(e);
|
|
614
559
|
for (let e of t) {
|
|
615
|
-
let t =
|
|
560
|
+
let t = n.match(e.regex);
|
|
616
561
|
if (t) {
|
|
617
562
|
let n = {};
|
|
618
563
|
for (let r = 0; r < e.paramNames.length; r++) {
|
|
619
564
|
let i = e.paramNames[r], a = t[r + 1];
|
|
620
|
-
n[i] = a === void 0 ? "" :
|
|
565
|
+
n[i] = a === void 0 ? "" : h(a);
|
|
621
566
|
}
|
|
622
567
|
return {
|
|
623
568
|
record: e,
|
|
@@ -636,19 +581,19 @@ function j(e) {
|
|
|
636
581
|
let t = e.indexOf("#"), n = e;
|
|
637
582
|
t !== -1 && (o = e.slice(t), n = e.slice(0, t));
|
|
638
583
|
let r = n.indexOf("?");
|
|
639
|
-
r === -1 ? i = n : (a =
|
|
584
|
+
r === -1 ? i = n : (a = g(n.slice(r)), i = n.slice(0, r));
|
|
640
585
|
} else {
|
|
641
586
|
if (e.name) {
|
|
642
587
|
l = e.name;
|
|
643
|
-
let t =
|
|
644
|
-
t && (i = t.path, c = { ...e.params || {} }, i =
|
|
588
|
+
let t = n.get(l);
|
|
589
|
+
t && (i = t.path, c = { ...e.params || {} }, i = y(i, c));
|
|
645
590
|
} else e.path && (i = e.path);
|
|
646
591
|
e.query && (a = { ...e.query }), e.hash && (o = e.hash.startsWith("#") ? e.hash : "#" + e.hash), e.params && (c = {
|
|
647
592
|
...c,
|
|
648
593
|
...e.params
|
|
649
594
|
});
|
|
650
595
|
}
|
|
651
|
-
i =
|
|
596
|
+
i = r(i);
|
|
652
597
|
let { record: u, params: d } = s(i), f = {
|
|
653
598
|
...d,
|
|
654
599
|
...c
|
|
@@ -657,7 +602,7 @@ function j(e) {
|
|
|
657
602
|
let e = u;
|
|
658
603
|
for (; e;) p.unshift(e), e = e.parent;
|
|
659
604
|
}
|
|
660
|
-
let m =
|
|
605
|
+
let m = _(a), h = i + m + o;
|
|
661
606
|
return {
|
|
662
607
|
path: i,
|
|
663
608
|
fullPath: h,
|
|
@@ -674,16 +619,16 @@ function j(e) {
|
|
|
674
619
|
resolve: c,
|
|
675
620
|
addRoute(e, t) {
|
|
676
621
|
if (typeof e == "string" && t) {
|
|
677
|
-
let
|
|
678
|
-
if (
|
|
679
|
-
let e =
|
|
680
|
-
return
|
|
681
|
-
let t =
|
|
682
|
-
t !== -1 && (
|
|
622
|
+
let r = n.get(e);
|
|
623
|
+
if (r) {
|
|
624
|
+
let e = x(t, r);
|
|
625
|
+
return r.children.push(e), o(), () => {
|
|
626
|
+
let t = r.children.indexOf(e);
|
|
627
|
+
t !== -1 && (r.children.splice(t, 1), o());
|
|
683
628
|
};
|
|
684
629
|
}
|
|
685
630
|
} else if (typeof e == "object") {
|
|
686
|
-
let t =
|
|
631
|
+
let t = x(e);
|
|
687
632
|
return i.push(t), o(), () => {
|
|
688
633
|
let e = i.indexOf(t);
|
|
689
634
|
e !== -1 && (i.splice(e, 1), o());
|
|
@@ -692,7 +637,7 @@ function j(e) {
|
|
|
692
637
|
return () => {};
|
|
693
638
|
},
|
|
694
639
|
removeRoute(e) {
|
|
695
|
-
let t =
|
|
640
|
+
let t = n.get(e);
|
|
696
641
|
if (t) {
|
|
697
642
|
if (t.parent) {
|
|
698
643
|
let e = t.parent.children.indexOf(t);
|
|
@@ -705,7 +650,7 @@ function j(e) {
|
|
|
705
650
|
}
|
|
706
651
|
},
|
|
707
652
|
hasRoute(e) {
|
|
708
|
-
return
|
|
653
|
+
return n.has(e);
|
|
709
654
|
},
|
|
710
655
|
getRoutes() {
|
|
711
656
|
return [...t];
|
|
@@ -714,9 +659,9 @@ function j(e) {
|
|
|
714
659
|
}
|
|
715
660
|
//#endregion
|
|
716
661
|
//#region types/index.ts
|
|
717
|
-
var
|
|
662
|
+
var C = /* @__PURE__ */ function(e) {
|
|
718
663
|
return e[e.aborted = 4] = "aborted", e[e.cancelled = 8] = "cancelled", e[e.duplicated = 16] = "duplicated", e;
|
|
719
|
-
}({}),
|
|
664
|
+
}({}), w = e(void 0, "DriftRouter"), T = e(void 0, "DriftRoute"), E = e(0, "DriftRouterDepth"), D = Object.freeze({
|
|
720
665
|
path: "/",
|
|
721
666
|
fullPath: "/",
|
|
722
667
|
query: {},
|
|
@@ -727,16 +672,16 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
727
672
|
meta: {},
|
|
728
673
|
href: "/"
|
|
729
674
|
});
|
|
730
|
-
function
|
|
675
|
+
function O(e, t, n, r) {
|
|
731
676
|
let i = "Navigation failed";
|
|
732
|
-
e ===
|
|
677
|
+
e === C.aborted ? i = `Navigation aborted from "${t.fullPath}" to "${n.fullPath}" via a navigation guard.` : e === C.cancelled ? i = `Navigation cancelled from "${t.fullPath}" to "${n.fullPath}" with a newer navigation.` : e === C.duplicated && (i = `Avoided redundant navigation to current location: "${n.fullPath}".`);
|
|
733
678
|
let a = Error(r || i);
|
|
734
679
|
return a.name = "NavigationFailure", a.type = e, a.from = t, a.to = n, a;
|
|
735
680
|
}
|
|
736
|
-
function
|
|
681
|
+
function k(e, t) {
|
|
737
682
|
return !e || typeof e != "object" || e.name !== "NavigationFailure" || typeof e.type != "number" ? !1 : t === void 0 || e.type === t;
|
|
738
683
|
}
|
|
739
|
-
async function
|
|
684
|
+
async function A(e) {
|
|
740
685
|
for (let t of e) for (let e of Object.keys(t.components)) {
|
|
741
686
|
let n = t.components[e];
|
|
742
687
|
if (typeof n == "function" && !("__drift_fn__" in n) && !n.bytecode) try {
|
|
@@ -747,7 +692,7 @@ async function z(e) {
|
|
|
747
692
|
}
|
|
748
693
|
}
|
|
749
694
|
}
|
|
750
|
-
async function
|
|
695
|
+
async function j(e, t, n) {
|
|
751
696
|
for (let r of e) {
|
|
752
697
|
let e;
|
|
753
698
|
try {
|
|
@@ -760,8 +705,8 @@ async function B(e, t, n) {
|
|
|
760
705
|
}
|
|
761
706
|
return !0;
|
|
762
707
|
}
|
|
763
|
-
function
|
|
764
|
-
let { history: t, routes: n, scrollBehavior: r, linkActiveClass: i, linkExactActiveClass: a } = e, o =
|
|
708
|
+
function M(e) {
|
|
709
|
+
let { history: t, routes: n, scrollBehavior: r, linkActiveClass: i, linkExactActiveClass: a } = e, o = S(n), s = [], c = [], l = [], u = [], d = [], f = D, p = null, m = null, h = null;
|
|
765
710
|
p = new Promise((e, t) => {
|
|
766
711
|
m = e, h = t;
|
|
767
712
|
});
|
|
@@ -770,7 +715,7 @@ function V(e) {
|
|
|
770
715
|
if (u.length > 0) for (let t of u) t(e);
|
|
771
716
|
}
|
|
772
717
|
function v(e, t, n) {
|
|
773
|
-
if (
|
|
718
|
+
if (typeof window < "u" && r) try {
|
|
774
719
|
let i = r(e, t, n);
|
|
775
720
|
if (!i) return;
|
|
776
721
|
let a = (e) => {
|
|
@@ -791,32 +736,32 @@ function V(e) {
|
|
|
791
736
|
async function y(e, n = !1, r = !1, i = 0) {
|
|
792
737
|
if (i > 20) {
|
|
793
738
|
let t = o.resolve(e, f);
|
|
794
|
-
return
|
|
739
|
+
return O(C.aborted, f, t, "Infinite redirect loop detected");
|
|
795
740
|
}
|
|
796
741
|
let a = o.resolve(e, f), u = f;
|
|
797
742
|
if (a.matched.length > 0) {
|
|
798
743
|
let e = a.matched[a.matched.length - 1];
|
|
799
744
|
if (e.redirect) return y(typeof e.redirect == "function" ? e.redirect(a) : e.redirect, !0, r, i + 1);
|
|
800
745
|
}
|
|
801
|
-
if (u.fullPath === a.fullPath && u !==
|
|
746
|
+
if (u.fullPath === a.fullPath && u !== D) return O(C.duplicated, u, a);
|
|
802
747
|
let p = ++g, m = [...s];
|
|
803
748
|
for (let e of a.matched) e.beforeEnter && m.push(...e.beforeEnter);
|
|
804
|
-
let h = await
|
|
805
|
-
if (p !== g) return
|
|
806
|
-
if (h === !1) return
|
|
807
|
-
if (h instanceof Error) return _(h),
|
|
749
|
+
let h = await j(m, a, u);
|
|
750
|
+
if (p !== g) return O(C.cancelled, u, a);
|
|
751
|
+
if (h === !1) return O(C.aborted, u, a);
|
|
752
|
+
if (h instanceof Error) return _(h), O(C.aborted, u, a, h.message);
|
|
808
753
|
if (typeof h == "string" || typeof h == "object" && h) return y(h, n, r, i + 1);
|
|
809
754
|
try {
|
|
810
|
-
await
|
|
755
|
+
await A(a.matched);
|
|
811
756
|
} catch (e) {
|
|
812
|
-
return _(e),
|
|
757
|
+
return _(e), O(C.aborted, u, a, String(e));
|
|
813
758
|
}
|
|
814
|
-
if (p !== g) return
|
|
759
|
+
if (p !== g) return O(C.cancelled, u, a);
|
|
815
760
|
if (c.length > 0) {
|
|
816
|
-
let e = await
|
|
817
|
-
if (p !== g) return
|
|
818
|
-
if (e === !1) return
|
|
819
|
-
if (e instanceof Error) return _(e),
|
|
761
|
+
let e = await j(c, a, u);
|
|
762
|
+
if (p !== g) return O(C.cancelled, u, a);
|
|
763
|
+
if (e === !1) return O(C.aborted, u, a);
|
|
764
|
+
if (e instanceof Error) return _(e), O(C.aborted, u, a, e.message);
|
|
820
765
|
if (typeof e == "string" || typeof e == "object" && e) return y(e, n, r, i + 1);
|
|
821
766
|
}
|
|
822
767
|
r || (n ? t.replace(a.fullPath) : t.push(a.fullPath));
|
|
@@ -835,10 +780,10 @@ function V(e) {
|
|
|
835
780
|
}
|
|
836
781
|
let b = t.listen(async (e, n, r) => {
|
|
837
782
|
let i = await y(e, !1, r.type === "pop");
|
|
838
|
-
i &&
|
|
783
|
+
i && k(i, C.aborted) && r.delta && t.go(-r.delta);
|
|
839
784
|
});
|
|
840
785
|
return y(t.location || "/", !0, !0).then((e) => {
|
|
841
|
-
e && e.type ===
|
|
786
|
+
e && e.type === C.aborted ? (h && h(e), _(e)) : m && m();
|
|
842
787
|
}).catch((e) => {
|
|
843
788
|
h && h(e), _(e);
|
|
844
789
|
}), {
|
|
@@ -918,7 +863,7 @@ function V(e) {
|
|
|
918
863
|
}
|
|
919
864
|
//#endregion
|
|
920
865
|
//#region src/components/RouterView.drift
|
|
921
|
-
var
|
|
866
|
+
var N = {
|
|
922
867
|
bytecode: new Uint32Array([
|
|
923
868
|
6,
|
|
924
869
|
0,
|
|
@@ -943,8 +888,8 @@ var H = {
|
|
|
943
888
|
1
|
|
944
889
|
]),
|
|
945
890
|
constants: [
|
|
946
|
-
{ __drift_fn__: (e, t, n, r, i, a) => {
|
|
947
|
-
if ((e || {}).router = a(e, "RouterContext").inject(), (e || {}).depth = a(e, "RouterDepthContext").inject(0), (e || {}).CurrentComponent = null, a(e, "RouterDepthContext").provide(a(e, "depth") + 1), (e || {}).updateCurrentComponent = function() {
|
|
891
|
+
{ __drift_fn__: (e, t, n, r, i, a, o) => {
|
|
892
|
+
if (typeof o == "function" && e ? o(e, "router", a(e, "RouterContext").inject()) : (e || {}).router = a(e, "RouterContext").inject(), typeof o == "function" && e ? o(e, "depth", a(e, "RouterDepthContext").inject(0)) : (e || {}).depth = a(e, "RouterDepthContext").inject(0), typeof o == "function" && e ? o(e, "CurrentComponent", null) : (e || {}).CurrentComponent = null, a(e, "RouterDepthContext").provide(a(e, "depth") + 1), (e || {}).updateCurrentComponent = function() {
|
|
948
893
|
if (!a(e, "router") || !a(e, "router").currentRoute || !a(e, "router").currentRoute.matched || !a(e, "router").currentRoute.matched[a(e, "depth")]) {
|
|
949
894
|
a(e, "CurrentComponent") !== null && (typeof n == "function" ? n(e, "CurrentComponent", null) : (e || {}).CurrentComponent = null);
|
|
950
895
|
return;
|
|
@@ -994,11 +939,11 @@ var H = {
|
|
|
994
939
|
derived: [],
|
|
995
940
|
effects: [],
|
|
996
941
|
scope: {
|
|
997
|
-
RouterContext:
|
|
998
|
-
RouterDepthContext:
|
|
942
|
+
RouterContext: w,
|
|
943
|
+
RouterDepthContext: E,
|
|
999
944
|
onUnmount: t
|
|
1000
945
|
}
|
|
1001
|
-
},
|
|
946
|
+
}, P = {
|
|
1002
947
|
bytecode: new Uint32Array([
|
|
1003
948
|
6,
|
|
1004
949
|
0,
|
|
@@ -1049,8 +994,8 @@ var H = {
|
|
|
1049
994
|
1
|
|
1050
995
|
]),
|
|
1051
996
|
constants: [
|
|
1052
|
-
{ __drift_fn__: (e, t, n, r, i, a) => {
|
|
1053
|
-
if ((e || {}).router = a(e, "RouterContext").inject(), (e || {}).to = a(e, "props").to || "/", (e || {}).replace = a(e, "props").replace || !1, (e || {}).target = a(e, "props").target || "_self", (e || {}).rel = a(e, "props").rel || "", (e || {}).customClass = a(e, "props").class || "", (e || {}).label = a(e, "props").label || a(e, "props").title || "", (e || {}).currentPath = a(e, "router") && a(e, "router").currentRoute ? a(e, "router").currentRoute.path : "", (e || {}).getHref = function(e, t) {
|
|
997
|
+
{ __drift_fn__: (e, t, n, r, i, a, o) => {
|
|
998
|
+
if (typeof o == "function" && e ? o(e, "router", a(e, "RouterContext").inject()) : (e || {}).router = a(e, "RouterContext").inject(), typeof o == "function" && e ? o(e, "to", a(e, "props").to || "/") : (e || {}).to = a(e, "props").to || "/", typeof o == "function" && e ? o(e, "replace", a(e, "props").replace || !1) : (e || {}).replace = a(e, "props").replace || !1, typeof o == "function" && e ? o(e, "target", a(e, "props").target || "_self") : (e || {}).target = a(e, "props").target || "_self", typeof o == "function" && e ? o(e, "rel", a(e, "props").rel || "") : (e || {}).rel = a(e, "props").rel || "", typeof o == "function" && e ? o(e, "customClass", a(e, "props").class || "") : (e || {}).customClass = a(e, "props").class || "", typeof o == "function" && e ? o(e, "label", a(e, "props").label || a(e, "props").title || "") : (e || {}).label = a(e, "props").label || a(e, "props").title || "", typeof o == "function" && e ? o(e, "currentPath", a(e, "router") && a(e, "router").currentRoute ? a(e, "router").currentRoute.path : "") : (e || {}).currentPath = a(e, "router") && a(e, "router").currentRoute ? a(e, "router").currentRoute.path : "", (e || {}).getHref = function(e, t) {
|
|
1054
999
|
let n = e || "/";
|
|
1055
1000
|
return t ? t.resolve(n).href : typeof n == "string" ? n : n && n.path ? n.path : "#";
|
|
1056
1001
|
}, (e || {}).getActiveClass = function(e, t, n, r, i, a) {
|
|
@@ -1147,9 +1092,9 @@ var H = {
|
|
|
1147
1092
|
derived: [],
|
|
1148
1093
|
effects: [],
|
|
1149
1094
|
scope: {
|
|
1150
|
-
RouterContext:
|
|
1095
|
+
RouterContext: w,
|
|
1151
1096
|
onUnmount: t
|
|
1152
1097
|
}
|
|
1153
1098
|
};
|
|
1154
1099
|
//#endregion
|
|
1155
|
-
export {
|
|
1100
|
+
export { P as Link, T as RouteContext, w as RouterContext, E as RouterDepthContext, N as RouterView, D as START_LOCATION_NORMALIZED, u as buildHistoryState, b as compilePathToRegex, c as createHistoryListeners, o as createHref, S as createMatcher, p as createMemoryHistory, O as createNavigationFailure, M as createRouter, f as createWebHashHistory, d as createWebHistory, l as extractHistoryState, s as formatHashHref, k as isNavigationFailure, i as normalizeBase, r as normalizePath, x as normalizeRouteRecord, g as parseQuery, _ as stringifyQuery, a as stripBase };
|