@vielzeug/wayfinder 1.0.5 → 2.1.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 +8 -2
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js.map +1 -1
- package/dist/_navigation.cjs +2 -0
- package/dist/_navigation.cjs.map +1 -0
- package/dist/_navigation.d.ts +10 -0
- package/dist/_navigation.d.ts.map +1 -0
- package/dist/_navigation.js +21 -0
- package/dist/_navigation.js.map +1 -0
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/context.cjs +1 -1
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.ts +5 -5
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +7 -6
- package/dist/context.js.map +1 -1
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.d.ts.map +1 -1
- package/dist/devtools.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -4
- package/dist/errors.js.map +1 -1
- package/dist/guards.cjs.map +1 -1
- package/dist/guards.d.ts +1 -1
- package/dist/guards.js.map +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.cjs.map +1 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +3 -1
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/path.cjs +1 -1
- package/dist/path.cjs.map +1 -1
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +6 -2
- package/dist/path.js.map +1 -1
- package/dist/router.cjs +1 -1
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.ts +10 -13
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +167 -145
- package/dist/router.js.map +1 -1
- package/dist/types.d.ts +13 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/wayfinder.cjs +1 -1
- package/dist/wayfinder.cjs.map +1 -1
- package/dist/wayfinder.iife.js +1 -1
- package/dist/wayfinder.iife.js.map +1 -1
- package/dist/wayfinder.js +1 -1
- package/dist/wayfinder.js.map +1 -1
- package/package.json +33 -28
package/dist/router.js
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { createNavigationCoordinator as e } from "./_navigation.js";
|
|
2
|
+
import { WayfinderDisposedError as t, WayfinderRedirectLoopError as n, WayfinderRouteError as r } from "./errors.js";
|
|
3
|
+
import { buildPreloadKey as i, buildUrl as a, joinPaths as o, matchRouteFor as s, matchesPrefix as c, normalizePath as l, parseQuery as u, readLocation as d, stripBase as f } from "./path.js";
|
|
4
|
+
import { compileRoutes as p } from "./compile.js";
|
|
5
|
+
import { buildMatchBranch as m, createRouteContext as h, createRouteState as g, executeMiddlewarePipeline as _, reportError as v } from "./context.js";
|
|
6
|
+
import { runLeaveBlockers as y } from "./guards.js";
|
|
7
|
+
import { createBrowserHistory as b } from "./history.js";
|
|
8
|
+
import { createHydrationManager as x } from "./hydration.js";
|
|
9
|
+
import { createPreloadManager as S } from "./preload.js";
|
|
9
10
|
//#region src/router.ts
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
if (
|
|
11
|
+
function C(e, t) {
|
|
12
|
+
let n = t.get(e);
|
|
13
|
+
if (n) return n;
|
|
13
14
|
let i = [...t.keys()].join(", ");
|
|
14
|
-
throw new
|
|
15
|
+
throw new r(i ? `Unknown route name: ${e}. Available routes: ${i}` : `Unknown route name: ${e}`);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function w(e, t, n = "/") {
|
|
17
18
|
if ("path" in e) return e.path;
|
|
18
|
-
let r =
|
|
19
|
-
return e.hash ? `${
|
|
19
|
+
let r = C(e.name, t), i = a(n, r.path, e.params, e.query);
|
|
20
|
+
return e.hash ? `${i}#${e.hash}` : i;
|
|
20
21
|
}
|
|
21
|
-
var
|
|
22
|
-
function
|
|
23
|
-
typeof e == "object" && e && (e[
|
|
24
|
-
}
|
|
25
|
-
function E(e) {
|
|
26
|
-
if (typeof e == "object" && e) return e[w];
|
|
22
|
+
var T = Symbol("wayfinder.errorContext");
|
|
23
|
+
function E(e, t) {
|
|
24
|
+
typeof e == "object" && e && (e[T] = t);
|
|
27
25
|
}
|
|
28
26
|
function D(e) {
|
|
27
|
+
if (typeof e == "object" && e) return e[T];
|
|
28
|
+
}
|
|
29
|
+
function O(e) {
|
|
29
30
|
return typeof e == "object" && !!e && typeof e[Symbol.asyncIterator] == "function" && typeof e.next == "function" && typeof e.return == "function";
|
|
30
31
|
}
|
|
31
|
-
var
|
|
32
|
+
var k = class {
|
|
32
33
|
#e;
|
|
33
34
|
#t;
|
|
34
35
|
#n;
|
|
@@ -38,8 +39,8 @@ var O = class {
|
|
|
38
39
|
#o;
|
|
39
40
|
#s;
|
|
40
41
|
#c;
|
|
41
|
-
#l =
|
|
42
|
-
#u =
|
|
42
|
+
#l = /* @__PURE__ */ new Set();
|
|
43
|
+
#u = e();
|
|
43
44
|
#d;
|
|
44
45
|
#f = !1;
|
|
45
46
|
#p = new AbortController();
|
|
@@ -49,9 +50,10 @@ var O = class {
|
|
|
49
50
|
#_;
|
|
50
51
|
#v;
|
|
51
52
|
#y;
|
|
53
|
+
ready;
|
|
52
54
|
constructor(e) {
|
|
53
|
-
let t =
|
|
54
|
-
if (this.#e =
|
|
55
|
+
let t = p(e);
|
|
56
|
+
if (this.#e = l(e.base ?? "/"), this.#t = e.middleware ?? [], this.#n = e.coerceSearch, this.#r = e.history ?? b(), this.#s = e.viewTransition ?? !1, this.#o = e.scroll, this.#c = e.onError, this.#i = t.records, this.#a = t.routesByName, this.#_ = x(), this.#v = S(), this.#d = g({
|
|
55
57
|
location: {
|
|
56
58
|
hash: "",
|
|
57
59
|
historyState: null,
|
|
@@ -81,7 +83,13 @@ var O = class {
|
|
|
81
83
|
} else this.#g = null;
|
|
82
84
|
this.#y = this.#x();
|
|
83
85
|
let { hash: n, pathname: r, search: i } = this.#r.location;
|
|
84
|
-
this.#m = `${r}${i}${n}
|
|
86
|
+
this.#m = `${r}${i}${n}`;
|
|
87
|
+
let a = this.#u.begin();
|
|
88
|
+
this.ready = this.#F(a, d(this.#e, this.#r), (e, t) => {
|
|
89
|
+
if (!a.isCurrent()) return;
|
|
90
|
+
let n = this.#z(e);
|
|
91
|
+
t && this.#r.replace(n, e.historyState), this.#m = n;
|
|
92
|
+
}, void 0, 0, !1).then(() => void 0), this.#w(this.ready, { source: "initial-navigation" }), this.beforeLeave = this.beforeLeave.bind(this), this.dispose = this.dispose.bind(this), this.getSnapshot = this.getSnapshot.bind(this), this.isActive = this.isActive.bind(this), this.load = this.load.bind(this), this.match = this.match.bind(this), this.navigate = this.navigate.bind(this), this.preload = this.preload.bind(this), this.subscribe = this.subscribe.bind(this), this.url = this.url.bind(this), this.waitFor = this.waitFor.bind(this);
|
|
85
93
|
}
|
|
86
94
|
getSnapshot() {
|
|
87
95
|
return this.#d;
|
|
@@ -92,39 +100,39 @@ var O = class {
|
|
|
92
100
|
};
|
|
93
101
|
}
|
|
94
102
|
navigate(e, t) {
|
|
95
|
-
let n =
|
|
96
|
-
return this.#
|
|
103
|
+
let n = w(typeof e == "string" ? { path: e } : e, this.#a);
|
|
104
|
+
return this.#V(n, t);
|
|
97
105
|
}
|
|
98
106
|
url(e, t, n) {
|
|
99
|
-
let r =
|
|
100
|
-
return
|
|
107
|
+
let r = C(e, this.#a);
|
|
108
|
+
return a(this.#e, r.path, t, n);
|
|
101
109
|
}
|
|
102
110
|
isActive(e, t = {}) {
|
|
103
|
-
let n =
|
|
104
|
-
return t.exact ?? !1 ?
|
|
111
|
+
let n = C(e, this.#a), r = this.#d.location.pathname;
|
|
112
|
+
return t.exact ?? !1 ? s(r, [n]).record != null : c(r, n);
|
|
105
113
|
}
|
|
106
|
-
|
|
107
|
-
let t =
|
|
114
|
+
match(e) {
|
|
115
|
+
let t = f(l(e), this.#e), { params: n, record: r } = s(t, this.#i);
|
|
108
116
|
if (!r || r.redirect) return null;
|
|
109
|
-
let i = this.#_.effectiveDefs(r), a =
|
|
117
|
+
let i = this.#_.effectiveDefs(r), a = m(i, n, t, i.map(() => void 0));
|
|
110
118
|
return a.length ? a : null;
|
|
111
119
|
}
|
|
112
|
-
async
|
|
120
|
+
async load(e, t) {
|
|
113
121
|
let n = await this.#k(e);
|
|
114
122
|
if (n.type !== "matched") return null;
|
|
115
123
|
let { location: r, params: i, record: a, resolvedQuery: o } = n, s = this.#_.effectiveDefs(a), c = s.some((e) => e.dataFn != null), l = s.map(() => void 0), u, d = "idle";
|
|
116
124
|
if (c) {
|
|
117
|
-
let e = t?.signal ?? new AbortController().signal, n =
|
|
125
|
+
let e = t?.signal ?? new AbortController().signal, n = m(s, i, r.pathname, l), a = h(r, o, i, n, () => Promise.resolve());
|
|
118
126
|
try {
|
|
119
127
|
l = await this.#D(s, a, e);
|
|
120
128
|
} catch (e) {
|
|
121
129
|
u = e, d = "error";
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
|
-
return
|
|
132
|
+
return g({
|
|
125
133
|
error: u,
|
|
126
134
|
location: r,
|
|
127
|
-
matches:
|
|
135
|
+
matches: m(s, i, r.pathname, l),
|
|
128
136
|
status: d
|
|
129
137
|
});
|
|
130
138
|
}
|
|
@@ -149,7 +157,7 @@ var O = class {
|
|
|
149
157
|
}
|
|
150
158
|
async preload(e, t, n) {
|
|
151
159
|
this.#b();
|
|
152
|
-
let
|
|
160
|
+
let r = C(e, this.#a), a = i(this.#e, r.path, t, n), o = this.#v.getInflight(a);
|
|
153
161
|
if (o) return o;
|
|
154
162
|
let s = this.#A(a, this.#p.signal, n).finally(() => {
|
|
155
163
|
this.#v.untrack(a);
|
|
@@ -167,8 +175,8 @@ var O = class {
|
|
|
167
175
|
handler: e,
|
|
168
176
|
routes: t?.routes
|
|
169
177
|
};
|
|
170
|
-
return this.#
|
|
171
|
-
this.#
|
|
178
|
+
return this.#l.add(n), () => {
|
|
179
|
+
this.#l.delete(n);
|
|
172
180
|
};
|
|
173
181
|
}
|
|
174
182
|
get disposalSignal() {
|
|
@@ -178,13 +186,13 @@ var O = class {
|
|
|
178
186
|
return this.#f;
|
|
179
187
|
}
|
|
180
188
|
dispose() {
|
|
181
|
-
this.#f || (this.#f = !0, this.#
|
|
189
|
+
this.#f || (this.#f = !0, this.#l.clear(), this.#h.clear(), this.#u.invalidate(new t()), this.#y(), this.#p.abort(new t()));
|
|
182
190
|
}
|
|
183
191
|
[Symbol.dispose]() {
|
|
184
192
|
this.dispose();
|
|
185
193
|
}
|
|
186
194
|
#b() {
|
|
187
|
-
if (this.#f) throw new
|
|
195
|
+
if (this.#f) throw new t();
|
|
188
196
|
}
|
|
189
197
|
#x() {
|
|
190
198
|
return this.#r.onPopstate(() => {
|
|
@@ -193,28 +201,31 @@ var O = class {
|
|
|
193
201
|
});
|
|
194
202
|
}
|
|
195
203
|
async #S(e, t) {
|
|
196
|
-
let n = this.#d.matches.map((e) => e.name),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
pathname: i,
|
|
200
|
-
query: l(r.search)
|
|
201
|
-
};
|
|
202
|
-
if (!await v(this.#u, n, c)) {
|
|
204
|
+
let n = this.#u.begin(), r = this.#d.matches.map((e) => e.name), i = this.#B(e), a = await y(this.#l, r, i);
|
|
205
|
+
if (!n.isCurrent()) return;
|
|
206
|
+
if (!a) {
|
|
203
207
|
this.#r.replace(t, this.#d.location.historyState);
|
|
204
208
|
return;
|
|
205
209
|
}
|
|
206
|
-
|
|
210
|
+
let o = await this.#F(n, d(this.#e, this.#r), (e, t) => {
|
|
211
|
+
if (!n.isCurrent()) return;
|
|
212
|
+
let r = this.#z(e);
|
|
213
|
+
t && this.#r.replace(r, e.historyState), this.#m = r;
|
|
214
|
+
}, void 0, 0, !1);
|
|
215
|
+
n.isCurrent() && !o && this.#r.replace(t, this.#d.location.historyState);
|
|
207
216
|
}
|
|
208
217
|
#C(e, t) {
|
|
209
|
-
|
|
218
|
+
v(e, t, this.#c);
|
|
210
219
|
}
|
|
211
220
|
#w(e, t) {
|
|
212
221
|
e.catch((e) => {
|
|
213
|
-
this.#C(e,
|
|
222
|
+
this.#C(e, D(e) ?? t);
|
|
214
223
|
});
|
|
215
224
|
}
|
|
216
225
|
#T() {
|
|
217
|
-
this.#h.forEach((e) =>
|
|
226
|
+
this.#h.forEach((e) => {
|
|
227
|
+
e(this.#d);
|
|
228
|
+
});
|
|
218
229
|
}
|
|
219
230
|
async #E(e, t) {
|
|
220
231
|
let n;
|
|
@@ -233,7 +244,7 @@ var O = class {
|
|
|
233
244
|
signal: n
|
|
234
245
|
});
|
|
235
246
|
try {
|
|
236
|
-
return
|
|
247
|
+
return O(i) ? await this.#E(i, n) : await i;
|
|
237
248
|
} catch (r) {
|
|
238
249
|
if (e.onError) return e.onError(r, {
|
|
239
250
|
...t,
|
|
@@ -252,7 +263,7 @@ var O = class {
|
|
|
252
263
|
signal: n
|
|
253
264
|
});
|
|
254
265
|
}), s = [], c = await Promise.all(o.map(async (r, i) => {
|
|
255
|
-
if (
|
|
266
|
+
if (O(r)) {
|
|
256
267
|
s.push(i);
|
|
257
268
|
return;
|
|
258
269
|
}
|
|
@@ -272,9 +283,9 @@ var O = class {
|
|
|
272
283
|
if (!r()) return;
|
|
273
284
|
l[n] = t;
|
|
274
285
|
let o = e.map((e, t) => s.includes(t) ? "streaming" : "idle");
|
|
275
|
-
this.#d =
|
|
286
|
+
this.#d = g({
|
|
276
287
|
location: i,
|
|
277
|
-
matches:
|
|
288
|
+
matches: m(e, a, i.pathname, l, o),
|
|
278
289
|
status: "streaming"
|
|
279
290
|
}), this.#T();
|
|
280
291
|
};
|
|
@@ -293,29 +304,29 @@ var O = class {
|
|
|
293
304
|
})), l;
|
|
294
305
|
}
|
|
295
306
|
async #k(e) {
|
|
296
|
-
let
|
|
307
|
+
let t = e;
|
|
297
308
|
for (let e = 0; e < 5; e += 1) {
|
|
298
|
-
let e = new URL(
|
|
309
|
+
let e = new URL(t, "http://localhost"), n = {
|
|
299
310
|
hash: e.hash.replace(/^#/, ""),
|
|
300
311
|
historyState: null,
|
|
301
|
-
pathname:
|
|
302
|
-
query:
|
|
303
|
-
}, r = await this.#j(
|
|
312
|
+
pathname: f(e.pathname, this.#e),
|
|
313
|
+
query: u(e.search)
|
|
314
|
+
}, r = await this.#j(n);
|
|
304
315
|
if (r.type !== "redirect") return r;
|
|
305
|
-
|
|
316
|
+
t = this.#L(r.redirectTo);
|
|
306
317
|
}
|
|
307
|
-
throw new
|
|
318
|
+
throw new n();
|
|
308
319
|
}
|
|
309
320
|
async #A(e, t, n) {
|
|
310
|
-
let
|
|
311
|
-
if (
|
|
312
|
-
let { location: a, params: o, record: s, resolvedQuery: c } =
|
|
321
|
+
let r = await this.#k(e);
|
|
322
|
+
if (r.type !== "matched") return;
|
|
323
|
+
let { location: a, params: o, record: s, resolvedQuery: c } = r, l = this.#_.effectiveDefs(s);
|
|
313
324
|
if (!l.some((e) => e.dataFn != null)) return;
|
|
314
|
-
let u =
|
|
315
|
-
this.#v.set(
|
|
325
|
+
let u = m(l, o, a.pathname, l.map(() => void 0)), d = h(a, c, o, u, () => Promise.resolve()), f = await this.#D(l, d, t);
|
|
326
|
+
this.#v.set(i(this.#e, s.path, o, n ?? a.query), f);
|
|
316
327
|
}
|
|
317
328
|
async #j(e) {
|
|
318
|
-
let { params: t, record: n } =
|
|
329
|
+
let { params: t, record: n } = s(e.pathname, this.#i);
|
|
319
330
|
if (!n) return {
|
|
320
331
|
location: e,
|
|
321
332
|
params: t,
|
|
@@ -324,7 +335,7 @@ var O = class {
|
|
|
324
335
|
if (n.redirect) return {
|
|
325
336
|
location: e,
|
|
326
337
|
params: t,
|
|
327
|
-
redirectTo:
|
|
338
|
+
redirectTo: w(n.redirect, this.#a, this.#e),
|
|
328
339
|
type: "redirect"
|
|
329
340
|
};
|
|
330
341
|
let r = e.query, i = n.coerceSearch ?? this.#n;
|
|
@@ -336,7 +347,7 @@ var O = class {
|
|
|
336
347
|
await this.#_.hydrate(n);
|
|
337
348
|
let a = this.#_.effectiveDefs(n);
|
|
338
349
|
return {
|
|
339
|
-
branch:
|
|
350
|
+
branch: m(a, t, e.pathname, a.map(() => void 0)),
|
|
340
351
|
location: e,
|
|
341
352
|
params: t,
|
|
342
353
|
record: n,
|
|
@@ -357,37 +368,38 @@ var O = class {
|
|
|
357
368
|
throw await e.return(void 0).catch(() => void 0), t;
|
|
358
369
|
}
|
|
359
370
|
}
|
|
360
|
-
async #N(e, t, n,
|
|
361
|
-
if (!
|
|
362
|
-
let
|
|
363
|
-
if (
|
|
364
|
-
let
|
|
365
|
-
if (
|
|
371
|
+
async #N(e, t, n, r, a, o) {
|
|
372
|
+
if (!o()) return;
|
|
373
|
+
let s = this.#_.effectiveDefs(e), c = s.some((e) => e.dataFn != null), l = s.map(() => void 0);
|
|
374
|
+
if (c) {
|
|
375
|
+
let c = i(this.#e, e.path, r, n.query), u = this.#v.consume(c);
|
|
376
|
+
if (u) l = u;
|
|
366
377
|
else {
|
|
367
|
-
let
|
|
368
|
-
this.#d =
|
|
378
|
+
let i = s.map((e) => e.dataFn ? "loading" : "idle");
|
|
379
|
+
this.#d = g({
|
|
369
380
|
location: n,
|
|
370
|
-
matches:
|
|
381
|
+
matches: m(s, r, n.pathname, l, i),
|
|
371
382
|
status: "loading"
|
|
372
383
|
}), this.#T();
|
|
373
384
|
try {
|
|
374
|
-
|
|
385
|
+
l = await this.#O(s, t, a, o, n, r);
|
|
375
386
|
} catch (t) {
|
|
376
|
-
|
|
387
|
+
if (!o()) return;
|
|
388
|
+
throw this.#d = g({
|
|
377
389
|
error: t,
|
|
378
390
|
location: n,
|
|
379
|
-
matches:
|
|
391
|
+
matches: m(s, r, n.pathname, l),
|
|
380
392
|
status: "error"
|
|
381
|
-
}),
|
|
393
|
+
}), E(t, {
|
|
382
394
|
routeName: e.leaf.name,
|
|
383
395
|
source: "data-loader"
|
|
384
396
|
}), t;
|
|
385
397
|
}
|
|
386
398
|
}
|
|
387
399
|
}
|
|
388
|
-
|
|
400
|
+
o() && (this.#d = g({
|
|
389
401
|
location: n,
|
|
390
|
-
matches:
|
|
402
|
+
matches: m(s, r, n.pathname, l),
|
|
391
403
|
status: "idle"
|
|
392
404
|
}));
|
|
393
405
|
}
|
|
@@ -401,57 +413,54 @@ var O = class {
|
|
|
401
413
|
}
|
|
402
414
|
await e();
|
|
403
415
|
}
|
|
404
|
-
async #F(e, t = 0) {
|
|
405
|
-
this.#l
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (o.type === "redirect") {
|
|
411
|
-
await this.#R(o.redirectTo, !0, t);
|
|
412
|
-
return;
|
|
416
|
+
async #F(e, t, r, i, a = 0, o = !1) {
|
|
417
|
+
let s = this.#d, c = () => e.isCurrent() && !this.#f, l = await this.#j(t);
|
|
418
|
+
if (!c()) return !1;
|
|
419
|
+
if (l.type === "redirect") {
|
|
420
|
+
if (a >= 5) throw new n();
|
|
421
|
+
return this.#F(e, this.#R(l.redirectTo, t.historyState), r, i, a + 1, !0);
|
|
413
422
|
}
|
|
414
|
-
if (
|
|
423
|
+
if (l.type === "unmatched") {
|
|
415
424
|
if (this.#g) {
|
|
416
|
-
let
|
|
425
|
+
let n = [this.#g.leaf], a = m(n, {}, t.pathname, [void 0]), l = !1, u = !1, d = t.query;
|
|
417
426
|
if (this.#n) try {
|
|
418
|
-
|
|
427
|
+
d = this.#n(t.query);
|
|
419
428
|
} catch (e) {
|
|
420
429
|
this.#C(e, { source: "coerce-search" });
|
|
421
430
|
}
|
|
422
|
-
let
|
|
423
|
-
if (!
|
|
424
|
-
let
|
|
425
|
-
await
|
|
426
|
-
|
|
431
|
+
let f = async () => {
|
|
432
|
+
if (!c()) return;
|
|
433
|
+
let n = h(t, d, {}, a, (e, t) => this.navigate(e, t));
|
|
434
|
+
u = await _(n, [...this.#t, ...this.#g.ownMiddleware], async () => {
|
|
435
|
+
c() && (l = !0, r(t, o), c() && await this.#N(this.#g, n, t, {}, e.signal, c));
|
|
427
436
|
});
|
|
428
437
|
};
|
|
429
438
|
try {
|
|
430
|
-
await this.#P(
|
|
439
|
+
await this.#P(f, i);
|
|
431
440
|
} finally {
|
|
432
|
-
|
|
441
|
+
c() && l && (this.#T(), this.#I(this.#d, s));
|
|
433
442
|
}
|
|
434
|
-
return;
|
|
443
|
+
return u && l;
|
|
435
444
|
}
|
|
436
|
-
this.#d =
|
|
437
|
-
location:
|
|
445
|
+
return !c() || (r(l.location, o), !c()) ? !1 : (this.#d = g({
|
|
446
|
+
location: l.location,
|
|
438
447
|
matches: [],
|
|
439
448
|
status: "idle"
|
|
440
|
-
}), this.#T(), this.#I(this.#d,
|
|
441
|
-
return;
|
|
449
|
+
}), this.#T(), this.#I(this.#d, s), !0);
|
|
442
450
|
}
|
|
443
|
-
let { branch:
|
|
444
|
-
if (!
|
|
445
|
-
let
|
|
446
|
-
await
|
|
447
|
-
|
|
451
|
+
let { branch: u, location: d, params: f, record: p, resolvedQuery: v } = l, y = !1, b = !1, x = async () => {
|
|
452
|
+
if (!c()) return;
|
|
453
|
+
let t = h(d, v, f, u, (e, t) => this.navigate(e, t));
|
|
454
|
+
b = await _(t, [...this.#t, ...p.ownMiddleware], async () => {
|
|
455
|
+
c() && (y = !0, r(d, o), c() && await this.#N(p, t, d, f, e.signal, c));
|
|
448
456
|
});
|
|
449
457
|
};
|
|
450
458
|
try {
|
|
451
|
-
await this.#P(
|
|
459
|
+
await this.#P(x, i);
|
|
452
460
|
} finally {
|
|
453
|
-
|
|
461
|
+
c() && y && (this.#T(), this.#I(this.#d, s));
|
|
454
462
|
}
|
|
463
|
+
return b && y;
|
|
455
464
|
}
|
|
456
465
|
#I(e, t) {
|
|
457
466
|
if (!this.#o || typeof window > "u") return;
|
|
@@ -465,38 +474,51 @@ var O = class {
|
|
|
465
474
|
}
|
|
466
475
|
}
|
|
467
476
|
#L(e) {
|
|
468
|
-
let t = new URL(e, "http://localhost"), n =
|
|
469
|
-
return `${
|
|
477
|
+
let t = new URL(e, "http://localhost"), n = f(t.pathname, this.#e);
|
|
478
|
+
return `${o(this.#e, n)}${t.search}${t.hash}`;
|
|
470
479
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
480
|
+
#R(e, t) {
|
|
481
|
+
let n = new URL(this.#L(e), "http://localhost");
|
|
482
|
+
return {
|
|
483
|
+
hash: n.hash.replace(/^#/, ""),
|
|
484
|
+
historyState: t,
|
|
485
|
+
pathname: f(n.pathname, this.#e),
|
|
486
|
+
query: u(n.search)
|
|
487
|
+
};
|
|
475
488
|
}
|
|
476
|
-
|
|
489
|
+
#z(e) {
|
|
490
|
+
let t = new URLSearchParams();
|
|
491
|
+
for (let [n, r] of Object.entries(e.query)) Array.isArray(r) ? r.forEach((e) => {
|
|
492
|
+
t.append(n, e);
|
|
493
|
+
}) : t.set(n, r);
|
|
494
|
+
let n = t.toString(), r = e.hash ? `#${e.hash}` : "";
|
|
495
|
+
return `${o(this.#e, e.pathname)}${n ? `?${n}` : ""}${r}`;
|
|
496
|
+
}
|
|
497
|
+
#B(e) {
|
|
498
|
+
let t = new URL(e, "http://localhost"), n = f(t.pathname, this.#e), { params: r, record: i } = s(n, this.#i);
|
|
499
|
+
return {
|
|
500
|
+
name: i?.leaf.name,
|
|
501
|
+
params: r,
|
|
502
|
+
pathname: n,
|
|
503
|
+
query: u(t.search)
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
async #V(e, t = {}) {
|
|
477
507
|
this.#b();
|
|
478
508
|
let n = this.#L(e);
|
|
479
509
|
if (!t.force && n === this.#m) return;
|
|
480
|
-
let r = this.#
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
};
|
|
486
|
-
if (await v(this.#u, i, f)) {
|
|
487
|
-
this.#m = n, t.replace ? this.#r.replace(n, t.state) : this.#r.push(n, t.state);
|
|
488
|
-
try {
|
|
489
|
-
await this.#F(t.viewTransition);
|
|
490
|
-
} catch (e) {
|
|
491
|
-
throw this.#m = r, e;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
510
|
+
let r = this.#u.begin(), i = this.#d.matches.map((e) => e.name), a = await y(this.#l, i, this.#B(n));
|
|
511
|
+
!r.isCurrent() || !a || await this.#F(r, this.#R(n, t.state), (e, t) => {
|
|
512
|
+
if (!r.isCurrent()) return;
|
|
513
|
+
let n = this.#z(e);
|
|
514
|
+
t ? this.#r.replace(n, e.historyState) : this.#r.push(n, e.historyState), this.#m = n;
|
|
515
|
+
}, t.viewTransition, 0, t.replace ?? !1);
|
|
494
516
|
}
|
|
495
517
|
};
|
|
496
|
-
function
|
|
497
|
-
return new
|
|
518
|
+
function A(e) {
|
|
519
|
+
return new k(e);
|
|
498
520
|
}
|
|
499
521
|
//#endregion
|
|
500
|
-
export {
|
|
522
|
+
export { A as createRouter };
|
|
501
523
|
|
|
502
524
|
//# sourceMappingURL=router.js.map
|