@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/dist/router.js CHANGED
@@ -1,34 +1,35 @@
1
- import { WayfinderDisposedError as e, WayfinderRedirectLoopError as t, WayfinderRouteError as n } from "./errors.js";
2
- import { buildPreloadKey as r, buildUrl as i, joinPaths as a, matchRouteFor as o, matchesPrefix as s, normalizePath as c, parseQuery as l, readLocation as u, stripBase as d } from "./path.js";
3
- import { compileRoutes as f } from "./compile.js";
4
- import { buildMatchBranch as p, createRouteContext as m, createRouteState as h, executeMiddlewarePipeline as g, reportError as _ } from "./context.js";
5
- import { runLeaveBlockers as v } from "./guards.js";
6
- import { createBrowserHistory as y } from "./history.js";
7
- import { createHydrationManager as b } from "./hydration.js";
8
- import { createPreloadManager as x } from "./preload.js";
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 S(e, t) {
11
- let r = t.get(e);
12
- if (r) return r;
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 n(i ? `Unknown route name: ${e}. Available routes: ${i}` : `Unknown route name: ${e}`);
15
+ throw new r(i ? `Unknown route name: ${e}. Available routes: ${i}` : `Unknown route name: ${e}`);
15
16
  }
16
- function C(e, t, n = "/") {
17
+ function w(e, t, n = "/") {
17
18
  if ("path" in e) return e.path;
18
- let r = i(n, S(e.name, t).path, e.params, e.query);
19
- return e.hash ? `${r}#${e.hash}` : r;
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 w = Symbol("wayfinder.errorContext");
22
- function T(e, t) {
23
- typeof e == "object" && e && (e[w] = t);
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 O = class {
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 = null;
42
- #u = /* @__PURE__ */ new Set();
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 = f(e);
54
- if (this.#e = c(e.base ?? "/"), this.#t = e.middleware ?? [], this.#n = e.coerceSearch, this.#r = e.history ?? y(), this.#s = e.viewTransition ?? !1, this.#o = e.scroll, this.#c = e.onError, this.#i = t.records, this.#a = t.routesByName, this.#_ = b(), this.#v = x(), this.#d = h({
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}`, this.#w(this.#F(), { source: "initial-navigation" });
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 = C(typeof e == "string" ? { path: e } : e, this.#a);
96
- return this.#z(n, t);
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 = S(e, this.#a);
100
- return i(this.#e, r.path, t, n);
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 = S(e, this.#a), r = this.#d.location.pathname;
104
- return t.exact ?? !1 ? o(r, [n]).record != null : s(r, n);
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
- resolve(e) {
107
- let t = d(c(e), this.#e), { params: n, record: r } = o(t, this.#i);
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 = p(i, n, t, i.map(() => void 0));
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 match(e, t) {
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(r, o, i, p(s, i, r.pathname, l), () => Promise.resolve());
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, n, e);
127
+ l = await this.#D(s, a, e);
120
128
  } catch (e) {
121
129
  u = e, d = "error";
122
130
  }
123
131
  }
124
- return h({
132
+ return g({
125
133
  error: u,
126
134
  location: r,
127
- matches: p(s, i, r.pathname, l),
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 i = S(e, this.#a), a = r(this.#e, i.path, t, n), o = this.#v.getInflight(a);
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.#u.add(n), () => {
171
- this.#u.delete(n);
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.#u.clear(), this.#h.clear(), this.#l?.abort(), this.#l = null, this.#y(), this.#p.abort(new e()));
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 e();
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), r = new URL(e, "http://localhost"), i = d(r.pathname, this.#e), { params: a, record: s } = o(i, this.#i), c = {
197
- name: s?.leaf.name,
198
- params: a,
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
- this.#m = e, await this.#F();
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
- _(e, t, this.#c);
218
+ v(e, t, this.#c);
210
219
  }
211
220
  #w(e, t) {
212
221
  e.catch((e) => {
213
- this.#C(e, E(e) ?? t);
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 D(i) ? await this.#E(i, n) : await i;
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 (D(r)) {
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 = h({
284
+ this.#d = g({
276
285
  location: i,
277
- matches: p(e, a, i.pathname, l, o),
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 n = e;
305
+ let t = e;
297
306
  for (let e = 0; e < 5; e += 1) {
298
- let e = new URL(n, "http://localhost"), t = {
307
+ let e = new URL(t, "http://localhost"), n = {
299
308
  hash: e.hash.replace(/^#/, ""),
300
309
  historyState: null,
301
- pathname: d(e.pathname, this.#e),
302
- query: l(e.search)
303
- }, r = await this.#j(t);
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
- n = this.#L(r.redirectTo);
314
+ t = this.#L(r.redirectTo);
306
315
  }
307
- throw new t();
316
+ throw new n();
308
317
  }
309
318
  async #A(e, t, n) {
310
- let i = await this.#k(e);
311
- if (i.type !== "matched") return;
312
- let { location: a, params: o, record: s, resolvedQuery: c } = i, l = this.#_.effectiveDefs(s);
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(a, c, o, p(l, o, a.pathname, l.map(() => void 0)), () => Promise.resolve()), d = await this.#D(l, u, t);
315
- this.#v.set(r(this.#e, s.path, o, n ?? a.query), d);
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 } = o(e.pathname, this.#i);
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: C(n.redirect, this.#a, this.#e),
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: p(a, t, e.pathname, a.map(() => void 0)),
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, i, a, o, s) {
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 = r(this.#e, e.path, i, n.query), l = this.#v.consume(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 r = c.map((e) => e.dataFn ? "loading" : "idle");
368
- this.#d = h({
376
+ let i = c.map((e) => e.dataFn ? "loading" : "idle");
377
+ this.#d = g({
369
378
  location: n,
370
- matches: p(c, i, n.pathname, u, r),
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, i);
383
+ u = await this.#O(c, t, o, s, n, r);
375
384
  } catch (t) {
376
- throw this.#d = h({
385
+ if (!s()) return;
386
+ throw this.#d = g({
377
387
  error: t,
378
388
  location: n,
379
- matches: p(c, i, n.pathname, u),
389
+ matches: m(c, r, n.pathname, u),
380
390
  status: "error"
381
- }), T(t, {
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 = h({
398
+ s() && (this.#d = g({
389
399
  location: n,
390
- matches: p(c, i, n.pathname, u),
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?.abort();
406
- let n = new AbortController();
407
- this.#l = n;
408
- let r = this.#d, i = () => !n.signal.aborted && !this.#f, a = u(this.#e, this.#r), o = await this.#j(a);
409
- if (!i()) return;
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 (o.type === "unmatched") {
421
+ if (l.type === "unmatched") {
415
422
  if (this.#g) {
416
- let t = p([this.#g.leaf], {}, a.pathname, [void 0]), o = !1, s = a.query;
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
- s = this.#n(a.query);
425
+ d = this.#n(t.query);
419
426
  } catch (e) {
420
427
  this.#C(e, { source: "coerce-search" });
421
428
  }
422
- let c = async () => {
423
- if (!i()) return;
424
- let e = m(a, s, {}, t, (e, t) => this.navigate(e, t));
425
- await g(e, [...this.#t, ...this.#g.ownMiddleware], async () => {
426
- o = !0, await this.#N(this.#g, e, a, {}, t, n.signal, i);
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(c, e);
437
+ await this.#P(f, r);
431
438
  } finally {
432
- i() && o && (this.#T(), this.#I(this.#d, r));
439
+ c() && l && (this.#T(), this.#I(this.#d, s));
433
440
  }
434
- return;
441
+ return u && l;
435
442
  }
436
- this.#d = h({
437
- location: o.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, r);
441
- return;
447
+ }), this.#T(), this.#I(this.#d, s), !0);
442
448
  }
443
- let { branch: s, location: c, params: l, record: d, resolvedQuery: f } = o, _ = !1, v = async () => {
444
- if (!i()) return;
445
- let e = m(c, f, l, s, (e, t) => this.navigate(e, t));
446
- await g(e, [...this.#t, ...d.ownMiddleware], async () => {
447
- _ = !0, await this.#N(d, e, c, l, s, n.signal, i);
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(v, e);
457
+ await this.#P(x, r);
452
458
  } finally {
453
- i() && _ && (this.#T(), this.#I(this.#d, r));
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 = d(t.pathname, this.#e);
469
- return `${a(this.#e, n)}${t.search}${t.hash}`;
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
- async #R(e, n = !0, r = 0) {
472
- if (r >= 5) throw new t();
473
- let i = this.#L(e);
474
- this.#m = i, n ? this.#r.replace(i) : this.#r.push(i), await this.#F(void 0, r + 1);
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
- async #z(e, t = {}) {
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.#m, i = this.#d.matches.map((e) => e.name), a = new URL(n, "http://localhost"), s = d(a.pathname, this.#e), { params: c, record: u } = o(s, this.#i), f = {
481
- name: u?.leaf.name,
482
- params: c,
483
- pathname: s,
484
- query: l(a.search)
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 k(e) {
497
- return new O(e);
514
+ function A(e) {
515
+ return new k(e);
498
516
  }
499
517
  //#endregion
500
- export { k as createRouter };
518
+ export { A as createRouter };
501
519
 
502
520
  //# sourceMappingURL=router.js.map