@vielzeug/wayfinder 1.0.4 → 2.0.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 +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +3 -8
- 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 +1 -1
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +33 -33
- 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 +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +18 -18
- package/dist/context.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/router.cjs +1 -1
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.ts +11 -13
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +159 -141
- package/dist/router.js.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 +10 -5
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), void 0, 0, !1, (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
|
+
}).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.loadPath = this.loadPath.bind(this), this.matchPath = this.matchPath.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
|
+
matchPath(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 loadPath(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 = m(
|
|
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
|
-
l = await this.#D(s,
|
|
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,24 +201,25 @@ 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), void 0, 0, !1, (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
|
+
});
|
|
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() {
|
|
@@ -233,7 +242,7 @@ var O = class {
|
|
|
233
242
|
signal: n
|
|
234
243
|
});
|
|
235
244
|
try {
|
|
236
|
-
return
|
|
245
|
+
return O(i) ? await this.#E(i, n) : await i;
|
|
237
246
|
} catch (r) {
|
|
238
247
|
if (e.onError) return e.onError(r, {
|
|
239
248
|
...t,
|
|
@@ -252,7 +261,7 @@ var O = class {
|
|
|
252
261
|
signal: n
|
|
253
262
|
});
|
|
254
263
|
}), s = [], c = await Promise.all(o.map(async (r, i) => {
|
|
255
|
-
if (
|
|
264
|
+
if (O(r)) {
|
|
256
265
|
s.push(i);
|
|
257
266
|
return;
|
|
258
267
|
}
|
|
@@ -272,9 +281,9 @@ var O = class {
|
|
|
272
281
|
if (!r()) return;
|
|
273
282
|
l[n] = t;
|
|
274
283
|
let o = e.map((e, t) => s.includes(t) ? "streaming" : "idle");
|
|
275
|
-
this.#d =
|
|
284
|
+
this.#d = g({
|
|
276
285
|
location: i,
|
|
277
|
-
matches:
|
|
286
|
+
matches: m(e, a, i.pathname, l, o),
|
|
278
287
|
status: "streaming"
|
|
279
288
|
}), this.#T();
|
|
280
289
|
};
|
|
@@ -293,29 +302,29 @@ var O = class {
|
|
|
293
302
|
})), l;
|
|
294
303
|
}
|
|
295
304
|
async #k(e) {
|
|
296
|
-
let
|
|
305
|
+
let t = e;
|
|
297
306
|
for (let e = 0; e < 5; e += 1) {
|
|
298
|
-
let e = new URL(
|
|
307
|
+
let e = new URL(t, "http://localhost"), n = {
|
|
299
308
|
hash: e.hash.replace(/^#/, ""),
|
|
300
309
|
historyState: null,
|
|
301
|
-
pathname:
|
|
302
|
-
query:
|
|
303
|
-
}, r = await this.#j(
|
|
310
|
+
pathname: f(e.pathname, this.#e),
|
|
311
|
+
query: u(e.search)
|
|
312
|
+
}, r = await this.#j(n);
|
|
304
313
|
if (r.type !== "redirect") return r;
|
|
305
|
-
|
|
314
|
+
t = this.#L(r.redirectTo);
|
|
306
315
|
}
|
|
307
|
-
throw new
|
|
316
|
+
throw new n();
|
|
308
317
|
}
|
|
309
318
|
async #A(e, t, n) {
|
|
310
|
-
let
|
|
311
|
-
if (
|
|
312
|
-
let { location: a, params: o, record: s, resolvedQuery: c } =
|
|
319
|
+
let r = await this.#k(e);
|
|
320
|
+
if (r.type !== "matched") return;
|
|
321
|
+
let { location: a, params: o, record: s, resolvedQuery: c } = r, l = this.#_.effectiveDefs(s);
|
|
313
322
|
if (!l.some((e) => e.dataFn != null)) return;
|
|
314
|
-
let u = m(
|
|
315
|
-
this.#v.set(
|
|
323
|
+
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);
|
|
324
|
+
this.#v.set(i(this.#e, s.path, o, n ?? a.query), f);
|
|
316
325
|
}
|
|
317
326
|
async #j(e) {
|
|
318
|
-
let { params: t, record: n } =
|
|
327
|
+
let { params: t, record: n } = s(e.pathname, this.#i);
|
|
319
328
|
if (!n) return {
|
|
320
329
|
location: e,
|
|
321
330
|
params: t,
|
|
@@ -324,7 +333,7 @@ var O = class {
|
|
|
324
333
|
if (n.redirect) return {
|
|
325
334
|
location: e,
|
|
326
335
|
params: t,
|
|
327
|
-
redirectTo:
|
|
336
|
+
redirectTo: w(n.redirect, this.#a, this.#e),
|
|
328
337
|
type: "redirect"
|
|
329
338
|
};
|
|
330
339
|
let r = e.query, i = n.coerceSearch ?? this.#n;
|
|
@@ -336,7 +345,7 @@ var O = class {
|
|
|
336
345
|
await this.#_.hydrate(n);
|
|
337
346
|
let a = this.#_.effectiveDefs(n);
|
|
338
347
|
return {
|
|
339
|
-
branch:
|
|
348
|
+
branch: m(a, t, e.pathname, a.map(() => void 0)),
|
|
340
349
|
location: e,
|
|
341
350
|
params: t,
|
|
342
351
|
record: n,
|
|
@@ -357,37 +366,38 @@ var O = class {
|
|
|
357
366
|
throw await e.return(void 0).catch(() => void 0), t;
|
|
358
367
|
}
|
|
359
368
|
}
|
|
360
|
-
async #N(e, t, n,
|
|
369
|
+
async #N(e, t, n, r, a, o, s) {
|
|
361
370
|
if (!s()) return;
|
|
362
371
|
let c = this.#_.effectiveDefs(e), l = c.some((e) => e.dataFn != null), u = c.map(() => void 0);
|
|
363
372
|
if (l) {
|
|
364
|
-
let a =
|
|
373
|
+
let a = i(this.#e, e.path, r, n.query), l = this.#v.consume(a);
|
|
365
374
|
if (l) u = l;
|
|
366
375
|
else {
|
|
367
|
-
let
|
|
368
|
-
this.#d =
|
|
376
|
+
let i = c.map((e) => e.dataFn ? "loading" : "idle");
|
|
377
|
+
this.#d = g({
|
|
369
378
|
location: n,
|
|
370
|
-
matches:
|
|
379
|
+
matches: m(c, r, n.pathname, u, i),
|
|
371
380
|
status: "loading"
|
|
372
381
|
}), this.#T();
|
|
373
382
|
try {
|
|
374
|
-
u = await this.#O(c, t, o, s, n,
|
|
383
|
+
u = await this.#O(c, t, o, s, n, r);
|
|
375
384
|
} catch (t) {
|
|
376
|
-
|
|
385
|
+
if (!s()) return;
|
|
386
|
+
throw this.#d = g({
|
|
377
387
|
error: t,
|
|
378
388
|
location: n,
|
|
379
|
-
matches:
|
|
389
|
+
matches: m(c, r, n.pathname, u),
|
|
380
390
|
status: "error"
|
|
381
|
-
}),
|
|
391
|
+
}), E(t, {
|
|
382
392
|
routeName: e.leaf.name,
|
|
383
393
|
source: "data-loader"
|
|
384
394
|
}), t;
|
|
385
395
|
}
|
|
386
396
|
}
|
|
387
397
|
}
|
|
388
|
-
s() && (this.#d =
|
|
398
|
+
s() && (this.#d = g({
|
|
389
399
|
location: n,
|
|
390
|
-
matches:
|
|
400
|
+
matches: m(c, r, n.pathname, u),
|
|
391
401
|
status: "idle"
|
|
392
402
|
}));
|
|
393
403
|
}
|
|
@@ -401,57 +411,54 @@ var O = class {
|
|
|
401
411
|
}
|
|
402
412
|
await e();
|
|
403
413
|
}
|
|
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;
|
|
414
|
+
async #F(e, t, r, i = 0, a = !1, o = () => void 0) {
|
|
415
|
+
let s = this.#d, c = () => e.isCurrent() && !this.#f, l = await this.#j(t);
|
|
416
|
+
if (!c()) return !1;
|
|
417
|
+
if (l.type === "redirect") {
|
|
418
|
+
if (i >= 5) throw new n();
|
|
419
|
+
return this.#F(e, this.#R(l.redirectTo, t.historyState), r, i + 1, !0, o);
|
|
413
420
|
}
|
|
414
|
-
if (
|
|
421
|
+
if (l.type === "unmatched") {
|
|
415
422
|
if (this.#g) {
|
|
416
|
-
let
|
|
423
|
+
let n = [this.#g.leaf], i = m(n, {}, t.pathname, [void 0]), l = !1, u = !1, d = t.query;
|
|
417
424
|
if (this.#n) try {
|
|
418
|
-
|
|
425
|
+
d = this.#n(t.query);
|
|
419
426
|
} catch (e) {
|
|
420
427
|
this.#C(e, { source: "coerce-search" });
|
|
421
428
|
}
|
|
422
|
-
let
|
|
423
|
-
if (!
|
|
424
|
-
let
|
|
425
|
-
await
|
|
426
|
-
|
|
429
|
+
let f = async () => {
|
|
430
|
+
if (!c()) return;
|
|
431
|
+
let n = h(t, d, {}, i, (e, t) => this.navigate(e, t));
|
|
432
|
+
u = await _(n, [...this.#t, ...this.#g.ownMiddleware], async () => {
|
|
433
|
+
c() && (l = !0, o(t, a), c() && await this.#N(this.#g, n, t, {}, i, e.signal, c));
|
|
427
434
|
});
|
|
428
435
|
};
|
|
429
436
|
try {
|
|
430
|
-
await this.#P(
|
|
437
|
+
await this.#P(f, r);
|
|
431
438
|
} finally {
|
|
432
|
-
|
|
439
|
+
c() && l && (this.#T(), this.#I(this.#d, s));
|
|
433
440
|
}
|
|
434
|
-
return;
|
|
441
|
+
return u && l;
|
|
435
442
|
}
|
|
436
|
-
this.#d =
|
|
437
|
-
location:
|
|
443
|
+
return !c() || (o(l.location, a), !c()) ? !1 : (this.#d = g({
|
|
444
|
+
location: l.location,
|
|
438
445
|
matches: [],
|
|
439
446
|
status: "idle"
|
|
440
|
-
}), this.#T(), this.#I(this.#d,
|
|
441
|
-
return;
|
|
447
|
+
}), this.#T(), this.#I(this.#d, s), !0);
|
|
442
448
|
}
|
|
443
|
-
let { branch:
|
|
444
|
-
if (!
|
|
445
|
-
let
|
|
446
|
-
await
|
|
447
|
-
|
|
449
|
+
let { branch: u, location: d, params: f, record: p, resolvedQuery: v } = l, y = !1, b = !1, x = async () => {
|
|
450
|
+
if (!c()) return;
|
|
451
|
+
let t = h(d, v, f, u, (e, t) => this.navigate(e, t));
|
|
452
|
+
b = await _(t, [...this.#t, ...p.ownMiddleware], async () => {
|
|
453
|
+
c() && (y = !0, o(d, a), c() && await this.#N(p, t, d, f, u, e.signal, c));
|
|
448
454
|
});
|
|
449
455
|
};
|
|
450
456
|
try {
|
|
451
|
-
await this.#P(
|
|
457
|
+
await this.#P(x, r);
|
|
452
458
|
} finally {
|
|
453
|
-
|
|
459
|
+
c() && y && (this.#T(), this.#I(this.#d, s));
|
|
454
460
|
}
|
|
461
|
+
return b && y;
|
|
455
462
|
}
|
|
456
463
|
#I(e, t) {
|
|
457
464
|
if (!this.#o || typeof window > "u") return;
|
|
@@ -465,38 +472,49 @@ var O = class {
|
|
|
465
472
|
}
|
|
466
473
|
}
|
|
467
474
|
#L(e) {
|
|
468
|
-
let t = new URL(e, "http://localhost"), n =
|
|
469
|
-
return `${
|
|
475
|
+
let t = new URL(e, "http://localhost"), n = f(t.pathname, this.#e);
|
|
476
|
+
return `${o(this.#e, n)}${t.search}${t.hash}`;
|
|
477
|
+
}
|
|
478
|
+
#R(e, t) {
|
|
479
|
+
let n = new URL(this.#L(e), "http://localhost");
|
|
480
|
+
return {
|
|
481
|
+
hash: n.hash.replace(/^#/, ""),
|
|
482
|
+
historyState: t,
|
|
483
|
+
pathname: f(n.pathname, this.#e),
|
|
484
|
+
query: u(n.search)
|
|
485
|
+
};
|
|
470
486
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
let
|
|
474
|
-
|
|
487
|
+
#z(e) {
|
|
488
|
+
let t = new URLSearchParams();
|
|
489
|
+
for (let [n, r] of Object.entries(e.query)) Array.isArray(r) ? r.forEach((e) => t.append(n, e)) : t.set(n, r);
|
|
490
|
+
let n = t.toString(), r = e.hash ? `#${e.hash}` : "";
|
|
491
|
+
return `${o(this.#e, e.pathname)}${n ? `?${n}` : ""}${r}`;
|
|
475
492
|
}
|
|
476
|
-
|
|
493
|
+
#B(e) {
|
|
494
|
+
let t = new URL(e, "http://localhost"), n = f(t.pathname, this.#e), { params: r, record: i } = s(n, this.#i);
|
|
495
|
+
return {
|
|
496
|
+
name: i?.leaf.name,
|
|
497
|
+
params: r,
|
|
498
|
+
pathname: n,
|
|
499
|
+
query: u(t.search)
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
async #V(e, t = {}) {
|
|
477
503
|
this.#b();
|
|
478
504
|
let n = this.#L(e);
|
|
479
505
|
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
|
-
}
|
|
506
|
+
let r = this.#u.begin(), i = this.#d.matches.map((e) => e.name), a = await y(this.#l, i, this.#B(n));
|
|
507
|
+
!r.isCurrent() || !a || await this.#F(r, this.#R(n, t.state), t.viewTransition, 0, t.replace ?? !1, (e, t) => {
|
|
508
|
+
if (!r.isCurrent()) return;
|
|
509
|
+
let n = this.#z(e);
|
|
510
|
+
t ? this.#r.replace(n, e.historyState) : this.#r.push(n, e.historyState), this.#m = n;
|
|
511
|
+
});
|
|
494
512
|
}
|
|
495
513
|
};
|
|
496
|
-
function
|
|
497
|
-
return new
|
|
514
|
+
function A(e) {
|
|
515
|
+
return new k(e);
|
|
498
516
|
}
|
|
499
517
|
//#endregion
|
|
500
|
-
export {
|
|
518
|
+
export { A as createRouter };
|
|
501
519
|
|
|
502
520
|
//# sourceMappingURL=router.js.map
|