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