@vielzeug/wayfinder 2.0.0 → 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.
Files changed (51) hide show
  1. package/README.md +2 -2
  2. package/dist/_dev.cjs.map +1 -1
  3. package/dist/_dev.js.map +1 -1
  4. package/dist/compile.cjs.map +1 -1
  5. package/dist/compile.d.ts.map +1 -1
  6. package/dist/compile.js.map +1 -1
  7. package/dist/context.cjs +1 -1
  8. package/dist/context.cjs.map +1 -1
  9. package/dist/context.d.ts +4 -4
  10. package/dist/context.d.ts.map +1 -1
  11. package/dist/context.js +1 -1
  12. package/dist/context.js.map +1 -1
  13. package/dist/devtools.cjs.map +1 -1
  14. package/dist/devtools.d.ts.map +1 -1
  15. package/dist/devtools.js.map +1 -1
  16. package/dist/errors.cjs +1 -1
  17. package/dist/errors.cjs.map +1 -1
  18. package/dist/errors.d.ts +0 -1
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/errors.js +1 -4
  21. package/dist/errors.js.map +1 -1
  22. package/dist/guards.cjs.map +1 -1
  23. package/dist/guards.d.ts +1 -1
  24. package/dist/guards.js.map +1 -1
  25. package/dist/history.cjs +1 -1
  26. package/dist/history.cjs.map +1 -1
  27. package/dist/history.d.ts.map +1 -1
  28. package/dist/history.js +3 -1
  29. package/dist/history.js.map +1 -1
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/path.cjs +1 -1
  33. package/dist/path.cjs.map +1 -1
  34. package/dist/path.d.ts.map +1 -1
  35. package/dist/path.js +6 -2
  36. package/dist/path.js.map +1 -1
  37. package/dist/router.cjs +1 -1
  38. package/dist/router.cjs.map +1 -1
  39. package/dist/router.d.ts +3 -4
  40. package/dist/router.d.ts.map +1 -1
  41. package/dist/router.js +37 -33
  42. package/dist/router.js.map +1 -1
  43. package/dist/types.d.ts +13 -14
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/wayfinder.cjs +1 -1
  46. package/dist/wayfinder.cjs.map +1 -1
  47. package/dist/wayfinder.iife.js +1 -1
  48. package/dist/wayfinder.iife.js.map +1 -1
  49. package/dist/wayfinder.js +1 -1
  50. package/dist/wayfinder.js.map +1 -1
  51. package/package.json +33 -28
package/dist/router.js CHANGED
@@ -85,11 +85,11 @@ var k = class {
85
85
  let { hash: n, pathname: r, search: i } = this.#r.location;
86
86
  this.#m = `${r}${i}${n}`;
87
87
  let a = this.#u.begin();
88
- this.ready = this.#F(a, d(this.#e, this.#r), void 0, 0, !1, (e, t) => {
88
+ this.ready = this.#F(a, d(this.#e, this.#r), (e, t) => {
89
89
  if (!a.isCurrent()) return;
90
90
  let n = this.#z(e);
91
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);
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);
93
93
  }
94
94
  getSnapshot() {
95
95
  return this.#d;
@@ -111,13 +111,13 @@ var k = class {
111
111
  let n = C(e, this.#a), r = this.#d.location.pathname;
112
112
  return t.exact ?? !1 ? s(r, [n]).record != null : c(r, n);
113
113
  }
114
- matchPath(e) {
114
+ match(e) {
115
115
  let t = f(l(e), this.#e), { params: n, record: r } = s(t, this.#i);
116
116
  if (!r || r.redirect) return null;
117
117
  let i = this.#_.effectiveDefs(r), a = m(i, n, t, i.map(() => void 0));
118
118
  return a.length ? a : null;
119
119
  }
120
- async loadPath(e, t) {
120
+ async load(e, t) {
121
121
  let n = await this.#k(e);
122
122
  if (n.type !== "matched") return null;
123
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";
@@ -207,11 +207,11 @@ var k = class {
207
207
  this.#r.replace(t, this.#d.location.historyState);
208
208
  return;
209
209
  }
210
- let o = await this.#F(n, d(this.#e, this.#r), void 0, 0, !1, (e, t) => {
210
+ let o = await this.#F(n, d(this.#e, this.#r), (e, t) => {
211
211
  if (!n.isCurrent()) return;
212
212
  let r = this.#z(e);
213
213
  t && this.#r.replace(r, e.historyState), this.#m = r;
214
- });
214
+ }, void 0, 0, !1);
215
215
  n.isCurrent() && !o && this.#r.replace(t, this.#d.location.historyState);
216
216
  }
217
217
  #C(e, t) {
@@ -223,7 +223,9 @@ var k = class {
223
223
  });
224
224
  }
225
225
  #T() {
226
- this.#h.forEach((e) => e(this.#d));
226
+ this.#h.forEach((e) => {
227
+ e(this.#d);
228
+ });
227
229
  }
228
230
  async #E(e, t) {
229
231
  let n;
@@ -366,27 +368,27 @@ var k = class {
366
368
  throw await e.return(void 0).catch(() => void 0), t;
367
369
  }
368
370
  }
369
- async #N(e, t, n, r, a, o, s) {
370
- if (!s()) return;
371
- let c = this.#_.effectiveDefs(e), l = c.some((e) => e.dataFn != null), u = c.map(() => void 0);
372
- if (l) {
373
- let a = i(this.#e, e.path, r, n.query), l = this.#v.consume(a);
374
- if (l) u = l;
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;
375
377
  else {
376
- let i = c.map((e) => e.dataFn ? "loading" : "idle");
378
+ let i = s.map((e) => e.dataFn ? "loading" : "idle");
377
379
  this.#d = g({
378
380
  location: n,
379
- matches: m(c, r, n.pathname, u, i),
381
+ matches: m(s, r, n.pathname, l, i),
380
382
  status: "loading"
381
383
  }), this.#T();
382
384
  try {
383
- u = await this.#O(c, t, o, s, n, r);
385
+ l = await this.#O(s, t, a, o, n, r);
384
386
  } catch (t) {
385
- if (!s()) return;
387
+ if (!o()) return;
386
388
  throw this.#d = g({
387
389
  error: t,
388
390
  location: n,
389
- matches: m(c, r, n.pathname, u),
391
+ matches: m(s, r, n.pathname, l),
390
392
  status: "error"
391
393
  }), E(t, {
392
394
  routeName: e.leaf.name,
@@ -395,9 +397,9 @@ var k = class {
395
397
  }
396
398
  }
397
399
  }
398
- s() && (this.#d = g({
400
+ o() && (this.#d = g({
399
401
  location: n,
400
- matches: m(c, r, n.pathname, u),
402
+ matches: m(s, r, n.pathname, l),
401
403
  status: "idle"
402
404
  }));
403
405
  }
@@ -411,16 +413,16 @@ var k = class {
411
413
  }
412
414
  await e();
413
415
  }
414
- async #F(e, t, r, i = 0, a = !1, o = () => void 0) {
416
+ async #F(e, t, r, i, a = 0, o = !1) {
415
417
  let s = this.#d, c = () => e.isCurrent() && !this.#f, l = await this.#j(t);
416
418
  if (!c()) return !1;
417
419
  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);
420
+ if (a >= 5) throw new n();
421
+ return this.#F(e, this.#R(l.redirectTo, t.historyState), r, i, a + 1, !0);
420
422
  }
421
423
  if (l.type === "unmatched") {
422
424
  if (this.#g) {
423
- let n = [this.#g.leaf], i = m(n, {}, t.pathname, [void 0]), l = !1, u = !1, d = t.query;
425
+ let n = [this.#g.leaf], a = m(n, {}, t.pathname, [void 0]), l = !1, u = !1, d = t.query;
424
426
  if (this.#n) try {
425
427
  d = this.#n(t.query);
426
428
  } catch (e) {
@@ -428,19 +430,19 @@ var k = class {
428
430
  }
429
431
  let f = async () => {
430
432
  if (!c()) return;
431
- let n = h(t, d, {}, i, (e, t) => this.navigate(e, t));
433
+ let n = h(t, d, {}, a, (e, t) => this.navigate(e, t));
432
434
  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));
435
+ c() && (l = !0, r(t, o), c() && await this.#N(this.#g, n, t, {}, e.signal, c));
434
436
  });
435
437
  };
436
438
  try {
437
- await this.#P(f, r);
439
+ await this.#P(f, i);
438
440
  } finally {
439
441
  c() && l && (this.#T(), this.#I(this.#d, s));
440
442
  }
441
443
  return u && l;
442
444
  }
443
- return !c() || (o(l.location, a), !c()) ? !1 : (this.#d = g({
445
+ return !c() || (r(l.location, o), !c()) ? !1 : (this.#d = g({
444
446
  location: l.location,
445
447
  matches: [],
446
448
  status: "idle"
@@ -450,11 +452,11 @@ var k = class {
450
452
  if (!c()) return;
451
453
  let t = h(d, v, f, u, (e, t) => this.navigate(e, t));
452
454
  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));
455
+ c() && (y = !0, r(d, o), c() && await this.#N(p, t, d, f, e.signal, c));
454
456
  });
455
457
  };
456
458
  try {
457
- await this.#P(x, r);
459
+ await this.#P(x, i);
458
460
  } finally {
459
461
  c() && y && (this.#T(), this.#I(this.#d, s));
460
462
  }
@@ -486,7 +488,9 @@ var k = class {
486
488
  }
487
489
  #z(e) {
488
490
  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);
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);
490
494
  let n = t.toString(), r = e.hash ? `#${e.hash}` : "";
491
495
  return `${o(this.#e, e.pathname)}${n ? `?${n}` : ""}${r}`;
492
496
  }
@@ -504,11 +508,11 @@ var k = class {
504
508
  let n = this.#L(e);
505
509
  if (!t.force && n === this.#m) return;
506
510
  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) => {
511
+ !r.isCurrent() || !a || await this.#F(r, this.#R(n, t.state), (e, t) => {
508
512
  if (!r.isCurrent()) return;
509
513
  let n = this.#z(e);
510
514
  t ? this.#r.replace(n, e.historyState) : this.#r.push(n, e.historyState), this.#m = n;
511
- });
515
+ }, t.viewTransition, 0, t.replace ?? !1);
512
516
  }
513
517
  };
514
518
  function A(e) {
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","names":["#base","#globalMiddleware","#globalCoerceSearch","#history","#records","#routesByName","#scroll","#useViewTransition","#onError","#beforeLeaveBlockers","#navigation","#disposeController","#listeners","#notFoundRecord","#hydration","#preload","#unlistenHistory","#currentState","#registerHistoryListener","#lastHref","#handleRoute","#hrefForLocation","#runInBackground","#assertNotDisposed","#navigateToPath","#resolveUrl","#loadDataDrain","#doPreload","#reportError","#disposed","#handleHistoryNavigation","#navigationDestination","#drainGenerator","#loadDataStream","#notifyListeners","#runStreamingLoader","#prepareRoute","#resolveDestination","#runTerminal","#runWithTransition","#locationFromPath","#applyScroll"],"sources":["../src/router.ts"],"sourcesContent":["import type {\n BeforeLeaveBlocker,\n BeforeLeaveOptions,\n CoerceSearchFn,\n DataContext,\n DataFn,\n HistoryDriver,\n IsActiveOptions,\n MatchStatus,\n Middleware,\n NamedNavigationTarget,\n NavigateOptions,\n NavigationDestination,\n PathParams,\n QueryParams,\n RawNavigationTarget,\n ResolvedQueryParams,\n RouteBranchDef,\n RouteContext,\n RouteLocation,\n RouteMatchBranch,\n RouteName,\n RouteParams,\n RoutePathByName,\n RouteRecord,\n RouterErrorContext,\n RouterOptions,\n RouteState,\n RouteTable,\n Unsubscribe,\n} from './types';\n\nimport { createNavigationCoordinator, type NavigationAttempt } from './_navigation';\nimport { compileRoutes } from './compile';\nimport {\n buildMatchBranch,\n createRouteContext,\n createRouteState,\n executeMiddlewarePipeline,\n reportError,\n} from './context';\nimport { WayfinderDisposedError, WayfinderRedirectLoopError, WayfinderRouteError } from './errors';\nimport { type RegisteredBlocker, runLeaveBlockers } from './guards';\nimport { createBrowserHistory } from './history';\nimport { createHydrationManager } from './hydration';\nimport {\n buildPreloadKey,\n buildUrl,\n joinPaths,\n matchesPrefix,\n matchRouteFor,\n normalizePath,\n parseQuery,\n readLocation,\n stripBase,\n} from './path';\nimport { createPreloadManager } from './preload';\n\n// ─── Module-level helpers (formerly in resolve.ts) ────────────────────────────\n\nfunction getRouteByName<TMeta, TComponent>(\n name: string,\n routesByName: ReadonlyMap<string, RouteRecord<TMeta, TComponent>>,\n): RouteRecord<TMeta, TComponent> {\n const route = routesByName.get(name);\n\n if (route) return route;\n\n const available = [...routesByName.keys()].join(', ');\n\n throw new WayfinderRouteError(\n available ? `Unknown route name: ${name}. Available routes: ${available}` : `Unknown route name: ${name}`,\n );\n}\n\nfunction resolveTarget<TMeta, TComponent>(\n target: { path: string } | { hash?: string; name: string; params?: RouteParams; query?: ResolvedQueryParams },\n routesByName: ReadonlyMap<string, RouteRecord<TMeta, TComponent>>,\n base = '/',\n): string {\n if ('path' in target) return target.path;\n\n const route = getRouteByName(target.name, routesByName);\n const path = buildUrl(base, route.path, target.params, target.query);\n\n return target.hash ? `${path}#${target.hash}` : path;\n}\n\n// ─── Internal helper ─────────────────────────────────────────────────────────\n\nconst ERROR_CONTEXT = Symbol('wayfinder.errorContext');\n\nfunction attachErrorContext(error: unknown, context: RouterErrorContext): void {\n if (error !== null && typeof error === 'object') {\n (error as Record<symbol, RouterErrorContext>)[ERROR_CONTEXT] = context;\n }\n}\n\nfunction getErrorContext(error: unknown): RouterErrorContext | undefined {\n if (error !== null && typeof error === 'object') {\n return (error as Record<symbol, RouterErrorContext | undefined>)[ERROR_CONTEXT];\n }\n\n return undefined;\n}\n\n// ─── Internal types ───────────────────────────────────────────────────────────\n\ntype NavigationDecision<TMeta, TComponent> =\n | {\n branch: RouteMatchBranch<TMeta, TComponent>;\n location: RouteLocation;\n params: RouteParams;\n record: RouteRecord<TMeta, TComponent>;\n resolvedQuery: ResolvedQueryParams;\n type: 'matched';\n }\n | { location: RouteLocation; params: RouteParams; type: 'unmatched' }\n | { location: RouteLocation; params: RouteParams; redirectTo: string; type: 'redirect' };\n\n// ─── Streaming helper ─────────────────────────────────────────────────────────\n\nfunction isAsyncGenerator(value: unknown): value is AsyncGenerator<unknown, unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as AsyncGenerator)[Symbol.asyncIterator] === 'function' &&\n typeof (value as AsyncGenerator).next === 'function' &&\n typeof (value as AsyncGenerator).return === 'function'\n );\n}\n\n// ─── Router class ─────────────────────────────────────────────────────────────\n\nclass Router<TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown> {\n readonly #base: string;\n readonly #globalMiddleware: readonly Middleware[];\n readonly #globalCoerceSearch?: CoerceSearchFn;\n readonly #history: HistoryDriver;\n readonly #records: readonly RouteRecord<TMeta, TComponent>[];\n readonly #routesByName: ReadonlyMap<string, RouteRecord<TMeta, TComponent>>;\n readonly #scroll?: RouterOptions<TRoutes, TMeta, TComponent>['scroll'];\n readonly #useViewTransition: boolean;\n readonly #onError?: RouterOptions<TRoutes, TMeta, TComponent>['onError'];\n\n // Mutable navigation state\n readonly #beforeLeaveBlockers = new Set<RegisteredBlocker>();\n readonly #navigation = createNavigationCoordinator();\n #currentState: RouteState<TMeta, TComponent>;\n #disposed = false;\n readonly #disposeController = new AbortController();\n #lastHref = '/';\n readonly #listeners = new Set<(state: RouteState<TMeta, TComponent>) => void>();\n // F5: compiled notFound fallback record\n readonly #notFoundRecord: RouteRecord<TMeta, TComponent> | null;\n\n // Sub-managers\n readonly #hydration: ReturnType<typeof createHydrationManager<TMeta, TComponent>>;\n readonly #preload: ReturnType<typeof createPreloadManager>;\n\n readonly #unlistenHistory: () => void;\n\n /** Resolves when the constructor-triggered navigation has settled; rejects if it fails. */\n readonly ready: Promise<void>;\n\n constructor(options: RouterOptions<TRoutes, TMeta, TComponent>) {\n const compiled = compileRoutes(options);\n\n this.#base = normalizePath(options.base ?? '/');\n this.#globalMiddleware = (options.middleware ?? []) as unknown as Middleware[];\n this.#globalCoerceSearch = options.coerceSearch;\n this.#history = options.history ?? createBrowserHistory();\n this.#useViewTransition = options.viewTransition ?? false;\n this.#scroll = options.scroll;\n this.#onError = options.onError;\n this.#records = compiled.records as unknown as readonly RouteRecord<TMeta, TComponent>[];\n this.#routesByName = compiled.routesByName as unknown as ReadonlyMap<string, RouteRecord<TMeta, TComponent>>;\n this.#hydration = createHydrationManager<TMeta, TComponent>();\n this.#preload = createPreloadManager();\n this.#currentState = createRouteState<TMeta, TComponent>({\n location: { hash: '', historyState: null, pathname: '/', query: {} },\n matches: [] as RouteMatchBranch<TMeta, TComponent>,\n status: 'idle',\n });\n\n // F5: Build a synthetic RouteRecord for the notFound fallback.\n if (options.notFound) {\n const nf = options.notFound;\n const leafDef: RouteBranchDef<TMeta, TComponent> = {\n component: nf.component as TComponent | undefined,\n dataFn: nf.data,\n meta: nf.meta as TMeta | undefined,\n name: '__notFound__',\n };\n\n this.#notFoundRecord = {\n branchDefs: [leafDef],\n leaf: leafDef,\n matcher: { paramNames: [], pattern: /(?:)/, prefixPattern: /(?:)/ },\n ownMiddleware: (nf.middleware ?? []) as unknown as Middleware[],\n path: '/*',\n };\n } else {\n this.#notFoundRecord = null;\n }\n\n this.#unlistenHistory = this.#registerHistoryListener();\n\n const { hash, pathname, search } = this.#history.location;\n\n this.#lastHref = `${pathname}${search}${hash}`;\n\n const attempt = this.#navigation.begin();\n\n this.ready = this.#handleRoute(\n attempt,\n readLocation(this.#base, this.#history),\n undefined,\n 0,\n false,\n (location, replace) => {\n if (!attempt.isCurrent()) return;\n\n const href = this.#hrefForLocation(location);\n\n if (replace) this.#history.replace(href, location.historyState);\n\n this.#lastHref = href;\n },\n ).then(() => undefined);\n this.#runInBackground(this.ready, { source: 'initial-navigation' });\n\n // Router actions are intentionally bound once so they remain safe when destructured.\n this.beforeLeave = this.beforeLeave.bind(this);\n this.dispose = this.dispose.bind(this);\n this.getSnapshot = this.getSnapshot.bind(this);\n this.isActive = this.isActive.bind(this);\n this.loadPath = this.loadPath.bind(this);\n this.matchPath = this.matchPath.bind(this);\n this.navigate = this.navigate.bind(this);\n this.preload = this.preload.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.url = this.url.bind(this);\n this.waitFor = this.waitFor.bind(this);\n }\n\n // ─── Public state ─────────────────────────────────────────────────────────\n\n /**\n * Returns the current immutable router state snapshot.\n *\n * Compatible with React's `useSyncExternalStore`:\n * ```ts\n * const state = useSyncExternalStore(\n * (cb) => router.subscribe(cb),\n * () => router.getSnapshot()\n * );\n * ```\n */\n getSnapshot(): RouteState<TMeta, TComponent> {\n return this.#currentState;\n }\n\n // ─── Subscription ─────────────────────────────────────────────────────────\n\n /**\n * Subscribe to state changes. The listener is called on each subsequent state change;\n * use `getSnapshot()` to read the current value immediately.\n */\n subscribe(listener: (state: RouteState<TMeta, TComponent>) => void): Unsubscribe {\n this.#assertNotDisposed();\n this.#listeners.add(listener);\n\n return () => {\n this.#listeners.delete(listener);\n };\n }\n\n // ─── Navigation ───────────────────────────────────────────────────────────\n\n /**\n * Navigate using a named route target or a raw path target.\n *\n * If a data loader throws after terminal execution begins, history has already committed\n * the destination and the returned Promise rejects with the loader error.\n */\n navigate(\n target: NamedNavigationTarget<TRoutes> | RawNavigationTarget | string,\n options?: NavigateOptions,\n ): Promise<void> {\n const normalized = typeof target === 'string' ? { path: target } : target;\n const destination = resolveTarget(normalized, this.#routesByName);\n\n return this.#navigateToPath(destination, options);\n }\n\n // ─── URL helpers ──────────────────────────────────────────────────────────\n\n /** Build a URL for a named route, including optional params and query string. */\n url<Name extends RouteName<TRoutes>>(\n name: Name,\n params?: PathParams<RoutePathByName<TRoutes, Name>>,\n query?: ResolvedQueryParams,\n ): string {\n const route = getRouteByName(name, this.#routesByName);\n\n return buildUrl(this.#base, route.path, params, query);\n }\n\n /** Returns true when the current location matches the named route by prefix (default) or exactly. */\n isActive<Name extends RouteName<TRoutes>>(name: Name, options: IsActiveOptions = {}): boolean {\n const route = getRouteByName(name, this.#routesByName);\n const pathname = this.#currentState.location.pathname;\n const exact = options.exact ?? false;\n\n return exact ? matchRouteFor(pathname, [route]).record != null : matchesPrefix(pathname, route);\n }\n\n /** Match a pathname to a route branch without running middleware or data loaders. Returns null for redirects or no match. */\n matchPath(pathname: string): RouteMatchBranch<TMeta, TComponent> | null {\n const normalizedPathname = stripBase(normalizePath(pathname), this.#base);\n const { params, record } = matchRouteFor(normalizedPathname, this.#records);\n\n if (!record || record.redirect) return null;\n\n const defs = this.#hydration.effectiveDefs(record);\n const branch = buildMatchBranch(\n defs,\n params,\n normalizedPathname,\n defs.map(() => undefined),\n );\n\n return branch.length ? branch : null;\n }\n\n /**\n * Load a URL into a route state including data loader results, without modifying\n * router state or history. Follows declarative redirects and may resolve lazy modules.\n *\n * R5: Accepts an options object instead of a bare AbortSignal.\n */\n async loadPath(url: string, options?: { signal?: AbortSignal }): Promise<RouteState<TMeta, TComponent> | null> {\n const prepared = await this.#resolveUrl(url);\n\n if (prepared.type !== 'matched') return null;\n\n const { location, params, record, resolvedQuery } = prepared;\n const defs = this.#hydration.effectiveDefs(record);\n const hasData = defs.some((d) => d.dataFn != null);\n let dataResults: unknown[] = defs.map(() => undefined);\n let error: unknown;\n let status: 'error' | 'idle' = 'idle';\n\n if (hasData) {\n const effectiveSignal = options?.signal ?? new AbortController().signal;\n const branch = buildMatchBranch(defs, params, location.pathname, dataResults);\n const context = createRouteContext<TRoutes>(location, resolvedQuery, params, branch, () => Promise.resolve());\n\n try {\n dataResults = await this.#loadDataDrain(defs, context, effectiveSignal);\n } catch (e) {\n error = e;\n status = 'error';\n }\n }\n\n return createRouteState<TMeta, TComponent>({\n error,\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults),\n status,\n });\n }\n\n /**\n * Returns a Promise that resolves the next time the router reaches `status: 'idle'`\n * and the active matches include a route named `name`.\n *\n * - Resolves immediately if the router is already `idle` at `name`.\n * - Rejects immediately if the router is already in `status: 'error'`.\n * - If the router is currently `idle` at a **different** route and no navigation is in\n * flight, this promise will not resolve until a future navigation lands on `name`.\n * Typical use-case is awaiting a navigation you just triggered:\n * `router.navigate(target); await router.waitFor('routeName')`.\n * @throws {WayfinderDisposedError} if the router is disposed while the promise is pending,\n * or if called after the router has already been disposed.\n */\n waitFor(name: RouteName<TRoutes>): Promise<RouteState<TMeta, TComponent>> {\n this.#assertNotDisposed();\n\n return new Promise((resolve, reject) => {\n const matchesName = (state: RouteState<TMeta, TComponent>): boolean =>\n state.status === 'idle' && state.matches.some((m) => m.name === name);\n\n if (this.#currentState.status === 'error') {\n reject(this.#currentState.error);\n\n return;\n }\n\n if (matchesName(this.#currentState)) {\n resolve(this.#currentState);\n\n return;\n }\n\n const unsub = this.subscribe((state) => {\n if (matchesName(state)) {\n unsub();\n resolve(state);\n } else if (state.status === 'error') {\n unsub();\n reject(state.error);\n }\n });\n\n this.#disposeController.signal.addEventListener(\n 'abort',\n () => {\n unsub();\n reject(this.#disposeController.signal.reason);\n },\n { once: true },\n );\n });\n }\n\n // ─── Preload ──────────────────────────────────────────────────────────────\n\n /**\n * Eagerly execute the data loaders for a named route without navigating.\n * Results are cached and reused during the next navigation to the same route.\n * Concurrent calls for the same route are deduplicated.\n *\n * Pass the same `query` you intend to navigate with to ensure the cached result\n * matches the navigation's cache key. Without `query`, the preload key is the\n * bare path — any navigation with a query string will produce a cache miss.\n *\n * @throws {WayfinderDisposedError} if the router has already been disposed.\n */\n async preload<Name extends RouteName<TRoutes>>(\n name: Name,\n params?: PathParams<RoutePathByName<TRoutes, Name>>,\n query?: QueryParams,\n ): Promise<void> {\n this.#assertNotDisposed();\n\n const route = getRouteByName(name, this.#routesByName);\n const cacheKey = buildPreloadKey(this.#base, route.path, params as RouteParams, query);\n\n const inflight = this.#preload.getInflight(cacheKey);\n\n if (inflight) return inflight;\n\n const work = this.#doPreload(cacheKey, this.#disposeController.signal, query).finally(() => {\n this.#preload.untrack(cacheKey);\n });\n\n this.#preload.track(cacheKey, work);\n\n try {\n return await work;\n } catch (error) {\n if (this.#onError) this.#reportError(error, { source: 'preload' });\n\n throw error;\n }\n }\n\n // ─── Navigation guards ────────────────────────────────────────────────────\n\n /**\n * Register a leave guard. Called before user-triggered navigation attempts.\n * Return `false` to cancel; `true` to allow.\n * Returns a function that removes the guard.\n *\n * Use `options.routes` to scope the guard to specific routes (fires only when navigating\n * away from a route whose name appears in the array, checked against any node in the active branch).\n */\n beforeLeave(blocker: BeforeLeaveBlocker, options?: BeforeLeaveOptions<TRoutes>): Unsubscribe {\n this.#assertNotDisposed();\n\n const entry: RegisteredBlocker = {\n handler: blocker,\n routes: options?.routes as string[] | undefined,\n };\n\n this.#beforeLeaveBlockers.add(entry);\n\n return () => {\n this.#beforeLeaveBlockers.delete(entry);\n };\n }\n\n // ─── Lifecycle ────────────────────────────────────────────────────────────\n\n get disposalSignal(): AbortSignal {\n return this.#disposeController.signal;\n }\n\n get disposed(): boolean {\n return this.#disposed;\n }\n\n /** Dispose event listeners and prevent further router interaction. Idempotent. */\n dispose(): void {\n if (this.#disposed) return;\n\n this.#disposed = true;\n this.#beforeLeaveBlockers.clear();\n this.#listeners.clear();\n this.#navigation.invalidate(new WayfinderDisposedError());\n this.#unlistenHistory();\n // Abort the disposal signal last — waitFor() listeners clean themselves up via this signal.\n this.#disposeController.abort(new WayfinderDisposedError());\n }\n\n [Symbol.dispose](): void {\n this.dispose();\n }\n\n // ─── Private: assertions ──────────────────────────────────────────────────\n\n #assertNotDisposed(): void {\n if (this.#disposed) throw new WayfinderDisposedError();\n }\n\n // ─── Private: history listener ────────────────────────────────────────────\n\n #registerHistoryListener(): () => void {\n return this.#history.onPopstate(() => {\n const { hash, pathname, search } = this.#history.location;\n const newHref = `${pathname}${search}${hash}`;\n const previousHref = this.#lastHref;\n\n if (newHref === previousHref) return;\n\n this.#runInBackground(this.#handleHistoryNavigation(newHref, previousHref), { source: 'history-listener' });\n });\n }\n\n async #handleHistoryNavigation(newHref: string, previousHref: string): Promise<void> {\n const attempt = this.#navigation.begin();\n const activeMatchNames = this.#currentState.matches.map((m) => m.name);\n const destination = this.#navigationDestination(newHref);\n const allowed = await runLeaveBlockers(this.#beforeLeaveBlockers, activeMatchNames, destination);\n\n if (!attempt.isCurrent()) return;\n\n if (!allowed) {\n this.#history.replace(previousHref, this.#currentState.location.historyState);\n\n return;\n }\n\n const terminalRan = await this.#handleRoute(\n attempt,\n readLocation(this.#base, this.#history),\n undefined,\n 0,\n false,\n (location, replace) => {\n if (!attempt.isCurrent()) return;\n\n const href = this.#hrefForLocation(location);\n\n if (replace) this.#history.replace(href, location.historyState);\n\n this.#lastHref = href;\n },\n );\n\n if (attempt.isCurrent() && !terminalRan) {\n this.#history.replace(previousHref, this.#currentState.location.historyState);\n }\n }\n\n // ─── Private: error handling ──────────────────────────────────────────────\n\n #reportError(error: unknown, context: RouterErrorContext): void {\n reportError(error, context, this.#onError);\n }\n\n #runInBackground(promise: Promise<void>, context: RouterErrorContext): void {\n void promise.catch((error) => {\n this.#reportError(error, getErrorContext(error) ?? context);\n });\n }\n\n // ─── Private: listener notification ──────────────────────────────────────\n\n #notifyListeners(): void {\n this.#listeners.forEach((listener) => listener(this.#currentState));\n }\n\n // ─── Private: data loaders ────────────────────────────────────────────────\n\n /**\n * R10: Drain an async generator to completion. Private class method replaces\n * the module-level `drainGenerator` helper.\n */\n async #drainGenerator(gen: AsyncGenerator<unknown, unknown>, signal: AbortSignal): Promise<unknown> {\n let lastYield: unknown;\n\n while (true) {\n if (signal.aborted) {\n await gen.return(undefined as unknown).catch(() => undefined);\n\n return lastYield;\n }\n\n const { done, value } = await gen.next();\n\n if (done) return value ?? lastYield;\n\n lastYield = value;\n }\n }\n\n /**\n * Drain all data loaders to completion. Async generators are consumed entirely.\n * Used in `loadPath()` and `preload()`. Per-def `onError` boundaries are applied.\n */\n async #loadDataDrain(\n defs: readonly RouteBranchDef<TMeta, TComponent>[],\n context: RouteContext<RouteParams, TRoutes>,\n signal: AbortSignal,\n ): Promise<unknown[]> {\n return Promise.all(\n defs.map(async (def) => {\n if (!def.dataFn) return undefined;\n\n const dataFn = def.dataFn as unknown as DataFn<RouteParams, TRoutes>;\n const raw = dataFn({ ...context, signal } as DataContext<RouteParams, TRoutes>);\n\n try {\n return isAsyncGenerator(raw) ? await this.#drainGenerator(raw, signal) : await (raw as Promise<unknown>);\n } catch (err) {\n if (def.onError) return def.onError(err, { ...context, signal } as unknown as DataContext);\n\n throw err;\n }\n }),\n );\n }\n\n /**\n * Run all data loaders in streaming mode. Generators yield partial states via `onPartial`.\n * Non-generator loaders are awaited normally. Per-def `onError` boundaries are applied.\n * Used during live navigation in `#runTerminal`.\n */\n async #loadDataStream(\n defs: readonly RouteBranchDef<TMeta, TComponent>[],\n context: RouteContext<RouteParams, TRoutes>,\n signal: AbortSignal,\n isCurrent: () => boolean,\n location: RouteLocation,\n params: RouteParams,\n ): Promise<unknown[]> {\n const rawResults: Array<AsyncGenerator<unknown, unknown> | unknown> = defs.map((def) => {\n if (!def.dataFn) return undefined;\n\n const dataFn = def.dataFn as unknown as DataFn<RouteParams, TRoutes>;\n\n return dataFn({ ...context, signal } as DataContext<RouteParams, TRoutes>);\n });\n\n const streamingIndices: number[] = [];\n\n const settled: unknown[] = await Promise.all(\n rawResults.map(async (raw, i) => {\n if (isAsyncGenerator(raw)) {\n streamingIndices.push(i);\n\n return undefined;\n }\n\n if (raw === undefined) return undefined;\n\n try {\n return await (raw as Promise<unknown>);\n } catch (err) {\n const def = defs[i]!;\n\n if (def.onError) return def.onError(err, { ...context, signal } as unknown as DataContext);\n\n throw err;\n }\n }),\n );\n\n if (streamingIndices.length === 0) return settled;\n\n const streamingData: unknown[] = [...settled];\n\n const onPartial = (value: unknown, idx: number): void => {\n if (!isCurrent()) return;\n\n streamingData[idx] = value;\n\n const nodeStatuses: MatchStatus[] = defs.map((_, i) => (streamingIndices.includes(i) ? 'streaming' : 'idle'));\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location,\n matches: buildMatchBranch(defs, params, location.pathname, streamingData, nodeStatuses),\n status: 'streaming',\n });\n this.#notifyListeners();\n };\n\n await Promise.all(\n streamingIndices.map(async (idx) => {\n const gen = rawResults[idx] as AsyncGenerator<unknown, unknown>;\n\n try {\n streamingData[idx] = await this.#runStreamingLoader(gen, idx, signal, isCurrent, onPartial);\n } catch (err) {\n const def = defs[idx]!;\n\n if (def.onError) {\n streamingData[idx] = await def.onError(err, { ...context, signal } as unknown as DataContext);\n } else {\n throw err;\n }\n }\n }),\n );\n\n return streamingData;\n }\n\n // ─── Private: URL resolution ──────────────────────────────────────────────\n\n /** Parse a URL, call #prepareRoute, and follow declarative redirects up to 5 hops. */\n async #resolveUrl(url: string): Promise<NavigationDecision<TMeta, TComponent>> {\n let destination = url;\n\n for (let i = 0; i < 5; i += 1) {\n const parsed = new URL(destination, 'http://localhost');\n const location: RouteLocation = {\n hash: parsed.hash.replace(/^#/, ''),\n historyState: null,\n pathname: stripBase(parsed.pathname, this.#base),\n query: parseQuery(parsed.search),\n };\n\n const prepared = await this.#prepareRoute(location);\n\n if (prepared.type !== 'redirect') return prepared;\n\n destination = this.#resolveDestination(prepared.redirectTo);\n }\n\n throw new WayfinderRedirectLoopError();\n }\n\n // ─── Private: preload ─────────────────────────────────────────────────────\n\n async #doPreload(startUrl: string, signal: AbortSignal, query?: QueryParams): Promise<void> {\n const prepared = await this.#resolveUrl(startUrl);\n\n if (prepared.type !== 'matched') return;\n\n const { location, params, record, resolvedQuery } = prepared;\n const defs = this.#hydration.effectiveDefs(record);\n const hasData = defs.some((d) => d.dataFn != null);\n\n if (!hasData) return;\n\n const branch = buildMatchBranch(\n defs,\n params,\n location.pathname,\n defs.map(() => undefined),\n );\n const context = createRouteContext<TRoutes>(location, resolvedQuery, params, branch, () => Promise.resolve());\n const results = await this.#loadDataDrain(defs, context, signal);\n\n this.#preload.set(buildPreloadKey(this.#base, record.path, params, query ?? location.query), results);\n }\n\n // ─── Private: route preparation ───────────────────────────────────────────\n\n async #prepareRoute(location: RouteLocation): Promise<NavigationDecision<TMeta, TComponent>> {\n const { params, record } = matchRouteFor(location.pathname, this.#records);\n\n if (!record) {\n return { location, params, type: 'unmatched' };\n }\n\n if (record.redirect) {\n return {\n location,\n params,\n redirectTo: resolveTarget(record.redirect, this.#routesByName, this.#base),\n type: 'redirect',\n };\n }\n\n let resolvedQuery: ResolvedQueryParams = location.query;\n\n const coerce: CoerceSearchFn | undefined = record.coerceSearch ?? this.#globalCoerceSearch;\n\n if (coerce) {\n try {\n resolvedQuery = coerce(location.query);\n } catch (err) {\n this.#reportError(err, { source: 'coerce-search' });\n resolvedQuery = location.query;\n }\n }\n\n await this.#hydration.hydrate(record);\n\n const defs = this.#hydration.effectiveDefs(record);\n\n return {\n branch: buildMatchBranch(\n defs,\n params,\n location.pathname,\n defs.map(() => undefined),\n ),\n location,\n params,\n record,\n resolvedQuery,\n type: 'matched',\n };\n }\n\n // ─── Private: streaming data loader ──────────────────────────────────────\n\n /**\n * Drain an AsyncGenerator data loader, emitting `status: 'streaming'` for every yielded\n * partial value and returning the generator's return value as the final settled data.\n * Aborts cleanly when the signal fires or the navigation is superseded.\n */\n async #runStreamingLoader(\n generator: AsyncGenerator<unknown, unknown>,\n defIndex: number,\n signal: AbortSignal,\n isCurrent: () => boolean,\n onPartial: (data: unknown, defIndex: number) => void,\n ): Promise<unknown> {\n let lastValue: unknown;\n\n try {\n while (true) {\n if (signal.aborted || !isCurrent()) {\n await generator.return(undefined as unknown);\n\n return lastValue;\n }\n\n const { done, value } = await generator.next();\n\n if (done) return value ?? lastValue;\n\n lastValue = value;\n onPartial(value, defIndex);\n }\n } catch (err) {\n await generator.return(undefined as unknown).catch(() => undefined);\n throw err;\n }\n }\n\n // ─── Private: terminal (data only — F4: handler removed) ─────────────────\n\n async #runTerminal(\n record: RouteRecord<TMeta, TComponent>,\n context: RouteContext<RouteParams, TRoutes>,\n location: RouteLocation,\n params: RouteParams,\n _initialBranch: RouteMatchBranch<TMeta, TComponent>,\n signal: AbortSignal,\n isCurrent: () => boolean,\n ): Promise<void> {\n if (!isCurrent()) return;\n\n const defs = this.#hydration.effectiveDefs(record);\n const hasData = defs.some((d) => d.dataFn != null);\n let dataResults: unknown[] = defs.map(() => undefined);\n\n if (hasData) {\n const preloadKey = buildPreloadKey(this.#base, record.path, params, location.query);\n const cached = this.#preload.consume(preloadKey);\n\n if (cached) {\n dataResults = cached;\n } else {\n // Emit per-node loading state (F1) while data is in-flight.\n const loadingStatuses: MatchStatus[] = defs.map((d) => (d.dataFn ? 'loading' : 'idle'));\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults, loadingStatuses),\n status: 'loading',\n });\n this.#notifyListeners();\n\n try {\n dataResults = await this.#loadDataStream(defs, context, signal, isCurrent, location, params);\n } catch (error) {\n if (!isCurrent()) return;\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n error,\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults),\n status: 'error',\n });\n // R3: attach enriched context so the eventual reporter uses it.\n attachErrorContext(error, { routeName: record.leaf.name, source: 'data-loader' });\n // Do not call #notifyListeners here — the finally block in #handleRoute does it once.\n throw error;\n }\n }\n }\n\n if (!isCurrent()) return;\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults),\n status: 'idle',\n });\n }\n\n // ─── Private: view transitions ────────────────────────────────────────────\n\n async #runWithTransition(run: () => Promise<void>, useTransition?: boolean): Promise<void> {\n const shouldUseTransition = useTransition ?? this.#useViewTransition;\n\n if (shouldUseTransition && typeof document !== 'undefined') {\n type ViewTransitionDocument = Document & {\n startViewTransition?: (callback: () => void | Promise<void>) => { finished: Promise<void> };\n };\n\n const doc = document as ViewTransitionDocument;\n\n if (doc.startViewTransition) {\n await doc.startViewTransition(run).finished;\n\n return;\n }\n }\n\n await run();\n }\n\n // ─── Private: main navigation orchestrator ────────────────────────────────\n\n /**\n * Declarative redirects reuse the active attempt and replace the final history entry.\n * Middleware redirects call `ctx.navigate()`, which starts a new attempt.\n */\n async #handleRoute(\n attempt: NavigationAttempt,\n currentLocation: RouteLocation,\n useTransition?: boolean,\n depth = 0,\n replace = false,\n commit: (location: RouteLocation, replace: boolean) => void = () => undefined,\n ): Promise<boolean> {\n const prevState = this.#currentState;\n const isCurrent = (): boolean => attempt.isCurrent() && !this.#disposed;\n const prepared = await this.#prepareRoute(currentLocation);\n\n if (!isCurrent()) return false;\n\n if (prepared.type === 'redirect') {\n if (depth >= 5) throw new WayfinderRedirectLoopError();\n\n return this.#handleRoute(\n attempt,\n this.#locationFromPath(prepared.redirectTo, currentLocation.historyState),\n useTransition,\n depth + 1,\n true,\n commit,\n );\n }\n\n if (prepared.type === 'unmatched') {\n // F5: fall back to notFound record when defined.\n if (this.#notFoundRecord) {\n const nfDefs = [this.#notFoundRecord.leaf];\n const nfBranch = buildMatchBranch(nfDefs, {}, currentLocation.pathname, [undefined]);\n let committed = false;\n let terminalRan = false;\n\n // Apply global coerceSearch to the unmatched location so notFound handlers\n // receive typed query params, consistent with matched-route behaviour.\n let nfResolvedQuery: ResolvedQueryParams = currentLocation.query;\n\n if (this.#globalCoerceSearch) {\n try {\n nfResolvedQuery = this.#globalCoerceSearch(currentLocation.query);\n } catch (err) {\n this.#reportError(err, { source: 'coerce-search' });\n }\n }\n\n const run = async (): Promise<void> => {\n if (!isCurrent()) return;\n\n const context = createRouteContext<TRoutes>(\n currentLocation,\n nfResolvedQuery,\n {},\n nfBranch,\n (target, options) => this.navigate(target, options),\n );\n\n terminalRan = await executeMiddlewarePipeline(\n context,\n [...this.#globalMiddleware, ...this.#notFoundRecord!.ownMiddleware] as unknown as Middleware<TRoutes>[],\n async () => {\n if (!isCurrent()) return;\n\n committed = true;\n commit(currentLocation, replace);\n\n if (!isCurrent()) return;\n\n await this.#runTerminal(\n this.#notFoundRecord!,\n context,\n currentLocation,\n {},\n nfBranch,\n attempt.signal,\n isCurrent,\n );\n },\n );\n };\n\n try {\n await this.#runWithTransition(run, useTransition);\n } finally {\n if (isCurrent() && committed) {\n this.#notifyListeners();\n this.#applyScroll(this.#currentState, prevState);\n }\n }\n\n return terminalRan && committed;\n }\n\n if (!isCurrent()) return false;\n\n commit(prepared.location, replace);\n\n if (!isCurrent()) return false;\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location: prepared.location,\n matches: [] as RouteMatchBranch<TMeta, TComponent>,\n status: 'idle',\n });\n this.#notifyListeners();\n this.#applyScroll(this.#currentState, prevState);\n\n return true;\n }\n\n const { branch, location, params, record, resolvedQuery } = prepared;\n let committed = false;\n let terminalRan = false;\n\n const run = async (): Promise<void> => {\n if (!isCurrent()) return;\n\n const context = createRouteContext<TRoutes>(location, resolvedQuery, params, branch, (target, options) =>\n this.navigate(target, options),\n );\n\n terminalRan = await executeMiddlewarePipeline(\n context,\n [...this.#globalMiddleware, ...record.ownMiddleware] as unknown as Middleware<TRoutes>[],\n async () => {\n if (!isCurrent()) return;\n\n committed = true;\n commit(location, replace);\n\n if (!isCurrent()) return;\n\n await this.#runTerminal(record, context, location, params, branch, attempt.signal, isCurrent);\n },\n );\n };\n\n try {\n await this.#runWithTransition(run, useTransition);\n } finally {\n if (isCurrent() && committed) {\n this.#notifyListeners();\n this.#applyScroll(this.#currentState, prevState);\n }\n }\n\n return terminalRan && committed;\n }\n\n // ─── Private: scroll ─────────────────────────────────────────────────────\n\n #applyScroll(to: RouteState<TMeta, TComponent>, from: RouteState<TMeta, TComponent>): void {\n if (!this.#scroll || typeof window === 'undefined') return;\n\n const decision = this.#scroll(to, from);\n\n if (decision === 'preserve') return;\n\n if (decision === 'top') {\n window.scrollTo(0, 0);\n\n return;\n }\n\n window.scrollTo(decision.x, decision.y);\n }\n\n // ─── Private: destination resolution ─────────────────────────────────────\n\n #resolveDestination(path: string): string {\n const parsed = new URL(path, 'http://localhost');\n const normalizedPath = stripBase(parsed.pathname, this.#base);\n\n return `${joinPaths(this.#base, normalizedPath)}${parsed.search}${parsed.hash}`;\n }\n\n #locationFromPath(path: string, historyState: unknown): RouteLocation {\n const parsed = new URL(this.#resolveDestination(path), 'http://localhost');\n\n return {\n hash: parsed.hash.replace(/^#/, ''),\n historyState,\n pathname: stripBase(parsed.pathname, this.#base),\n query: parseQuery(parsed.search),\n };\n }\n\n #hrefForLocation(location: RouteLocation): string {\n const search = new URLSearchParams();\n\n for (const [key, value] of Object.entries(location.query)) {\n if (Array.isArray(value)) value.forEach((item) => search.append(key, item));\n else search.set(key, value);\n }\n\n const query = search.toString();\n const hash = location.hash ? `#${location.hash}` : '';\n\n return `${joinPaths(this.#base, location.pathname)}${query ? `?${query}` : ''}${hash}`;\n }\n\n #navigationDestination(href: string): NavigationDestination {\n const parsed = new URL(href, 'http://localhost');\n const pathname = stripBase(parsed.pathname, this.#base);\n const { params, record } = matchRouteFor(pathname, this.#records);\n\n return {\n name: record?.leaf.name,\n params,\n pathname,\n query: parseQuery(parsed.search),\n };\n }\n\n /** User-initiated navigation. History changes only after middleware reaches the terminal stage. */\n async #navigateToPath(path: string, options: NavigateOptions = {}): Promise<void> {\n this.#assertNotDisposed();\n\n const destination = this.#resolveDestination(path);\n\n if (!options.force && destination === this.#lastHref) return;\n\n const attempt = this.#navigation.begin();\n const activeMatchNames = this.#currentState.matches.map((match) => match.name);\n const allowed = await runLeaveBlockers(\n this.#beforeLeaveBlockers,\n activeMatchNames,\n this.#navigationDestination(destination),\n );\n\n if (!attempt.isCurrent() || !allowed) return;\n\n await this.#handleRoute(\n attempt,\n this.#locationFromPath(destination, options.state),\n options.viewTransition,\n 0,\n options.replace ?? false,\n (location, replace) => {\n if (!attempt.isCurrent()) return;\n\n const href = this.#hrefForLocation(location);\n\n if (replace) this.#history.replace(href, location.historyState);\n else this.#history.push(href, location.historyState);\n\n this.#lastHref = href;\n },\n );\n }\n}\n\n// ─── Public factory ───────────────────────────────────────────────────────────\n\n/**\n * Create a new router instance from a route table.\n *\n * @example\n * const router = createRouter({\n * routes: {\n * home: { path: '/' },\n * userDetail: { path: '/users/:id', data: fetchUser },\n * },\n * });\n */\nexport function createRouter<const TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown>(\n options: RouterOptions<TRoutes, TMeta, TComponent>,\n): Router<TRoutes, TMeta, TComponent> {\n return new Router(options);\n}\n\n// Export the Router type (not the constructor value) for type annotations.\nexport type { Router };\n"],"mappings":";;;;;;;;;;AA4DA,SAAS,EACP,GACA,GACgC;CAChC,IAAM,IAAQ,EAAa,IAAI,CAAI;CAEnC,IAAI,GAAO,OAAO;CAElB,IAAM,IAAY,CAAC,GAAG,EAAa,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;CAEpD,MAAM,IAAI,EACR,IAAY,uBAAuB,EAAK,sBAAsB,MAAc,uBAAuB,GACrG;AACF;AAEA,SAAS,EACP,GACA,GACA,IAAO,KACC;CACR,IAAI,UAAU,GAAQ,OAAO,EAAO;CAEpC,IAAM,IAAQ,EAAe,EAAO,MAAM,CAAY,GAChD,IAAO,EAAS,GAAM,EAAM,MAAM,EAAO,QAAQ,EAAO,KAAK;CAEnE,OAAO,EAAO,OAAO,GAAG,EAAK,GAAG,EAAO,SAAS;AAClD;AAIA,IAAM,IAAgB,OAAO,wBAAwB;AAErD,SAAS,EAAmB,GAAgB,GAAmC;CAC7E,AAAsB,OAAO,KAAU,YAAnC,MACF,EAA8C,KAAiB;AAEnE;AAEA,SAAS,EAAgB,GAAgD;CACvE,IAAsB,OAAO,KAAU,YAAnC,GACF,OAAQ,EAAyD;AAIrE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,IAAc,KAAKc,GAAoB,CAAI;EAEjD,IAAI,CAAC,EAAQ,SAAS,MAAgB,KAAKlB,IAAW;EAEtD,IAAM,IAAU,KAAKT,GAAY,MAAM,GACjC,IAAmB,KAAKO,GAAc,QAAQ,KAAK,MAAU,EAAM,IAAI,GACvE,IAAU,MAAM,EACpB,KAAKR,IACL,GACA,KAAKsB,GAAuB,CAAW,CACzC;EAEI,CAAC,EAAQ,UAAU,KAAK,CAAC,KAE7B,MAAM,KAAKX,GACT,GACA,KAAKoB,GAAkB,GAAa,EAAQ,KAAK,GACjD,EAAQ,gBACR,GACA,EAAQ,WAAW,KAClB,GAAU,MAAY;GACrB,IAAI,CAAC,EAAQ,UAAU,GAAG;GAE1B,IAAM,IAAO,KAAKnB,GAAiB,CAAQ;GAK3C,AAHI,IAAS,KAAKlB,GAAS,QAAQ,GAAM,EAAS,YAAY,IACzD,KAAKA,GAAS,KAAK,GAAM,EAAS,YAAY,GAEnD,KAAKgB,KAAY;EACnB,CACF;CACF;AACF;AAeA,SAAgB,EACd,GACoC;CACpC,OAAO,IAAI,EAAO,CAAO;AAC3B"}
1
+ {"version":3,"file":"router.js","names":["#base","#globalMiddleware","#globalCoerceSearch","#history","#records","#routesByName","#scroll","#useViewTransition","#onError","#beforeLeaveBlockers","#navigation","#disposeController","#listeners","#notFoundRecord","#hydration","#preload","#unlistenHistory","#currentState","#registerHistoryListener","#lastHref","#handleRoute","#hrefForLocation","#runInBackground","#assertNotDisposed","#navigateToPath","#resolveUrl","#loadDataDrain","#doPreload","#reportError","#disposed","#handleHistoryNavigation","#navigationDestination","#drainGenerator","#loadDataStream","#notifyListeners","#runStreamingLoader","#prepareRoute","#resolveDestination","#runTerminal","#runWithTransition","#locationFromPath","#applyScroll"],"sources":["../src/router.ts"],"sourcesContent":["import { createNavigationCoordinator, type NavigationAttempt } from './_navigation';\nimport { compileRoutes } from './compile';\nimport {\n buildMatchBranch,\n createRouteContext,\n createRouteState,\n executeMiddlewarePipeline,\n reportError,\n} from './context';\nimport { WayfinderDisposedError, WayfinderRedirectLoopError, WayfinderRouteError } from './errors';\nimport { type RegisteredBlocker, runLeaveBlockers } from './guards';\nimport { createBrowserHistory } from './history';\nimport { createHydrationManager } from './hydration';\nimport {\n buildPreloadKey,\n buildUrl,\n joinPaths,\n matchesPrefix,\n matchRouteFor,\n normalizePath,\n parseQuery,\n readLocation,\n stripBase,\n} from './path';\nimport { createPreloadManager } from './preload';\nimport type {\n BeforeLeaveBlocker,\n BeforeLeaveOptions,\n CoerceSearchFn,\n DataContext,\n DataFn,\n HistoryDriver,\n IsActiveOptions,\n Middleware,\n NamedNavigationTarget,\n NavigateOptions,\n NavigationDestination,\n NavigationStatus,\n PathParams,\n QueryParams,\n RawNavigationTarget,\n ResolvedQueryParams,\n RouteBranchDef,\n RouteContext,\n RouteLocation,\n RouteMatchBranch,\n RouteName,\n RouteParams,\n RoutePathByName,\n RouteRecord,\n RouterErrorContext,\n RouterOptions,\n RouteState,\n RouteTable,\n Unsubscribe,\n} from './types';\n\n// ─── Module-level helpers (formerly in resolve.ts) ────────────────────────────\n\nfunction getRouteByName<TMeta, TComponent>(\n name: string,\n routesByName: ReadonlyMap<string, RouteRecord<TMeta, TComponent>>,\n): RouteRecord<TMeta, TComponent> {\n const route = routesByName.get(name);\n\n if (route) return route;\n\n const available = [...routesByName.keys()].join(', ');\n\n throw new WayfinderRouteError(\n available ? `Unknown route name: ${name}. Available routes: ${available}` : `Unknown route name: ${name}`,\n );\n}\n\nfunction resolveTarget<TMeta, TComponent>(\n target: { path: string } | { hash?: string; name: string; params?: RouteParams; query?: ResolvedQueryParams },\n routesByName: ReadonlyMap<string, RouteRecord<TMeta, TComponent>>,\n base = '/',\n): string {\n if ('path' in target) return target.path;\n\n const route = getRouteByName(target.name, routesByName);\n const path = buildUrl(base, route.path, target.params, target.query);\n\n return target.hash ? `${path}#${target.hash}` : path;\n}\n\n// ─── Internal helper ─────────────────────────────────────────────────────────\n\nconst ERROR_CONTEXT = Symbol('wayfinder.errorContext');\n\nfunction attachErrorContext(error: unknown, context: RouterErrorContext): void {\n if (error !== null && typeof error === 'object') {\n (error as Record<symbol, RouterErrorContext>)[ERROR_CONTEXT] = context;\n }\n}\n\nfunction getErrorContext(error: unknown): RouterErrorContext | undefined {\n if (error !== null && typeof error === 'object') {\n return (error as Record<symbol, RouterErrorContext | undefined>)[ERROR_CONTEXT];\n }\n\n return undefined;\n}\n\n// ─── Internal types ───────────────────────────────────────────────────────────\n\ntype NavigationDecision<TMeta, TComponent> =\n | {\n branch: RouteMatchBranch<TMeta, TComponent>;\n location: RouteLocation;\n params: RouteParams;\n record: RouteRecord<TMeta, TComponent>;\n resolvedQuery: ResolvedQueryParams;\n type: 'matched';\n }\n | { location: RouteLocation; params: RouteParams; type: 'unmatched' }\n | { location: RouteLocation; params: RouteParams; redirectTo: string; type: 'redirect' };\n\n// ─── Streaming helper ─────────────────────────────────────────────────────────\n\nfunction isAsyncGenerator(value: unknown): value is AsyncGenerator<unknown, unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as AsyncGenerator)[Symbol.asyncIterator] === 'function' &&\n typeof (value as AsyncGenerator).next === 'function' &&\n typeof (value as AsyncGenerator).return === 'function'\n );\n}\n\n// ─── Router class ─────────────────────────────────────────────────────────────\n\nclass Router<TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown> {\n readonly #base: string;\n readonly #globalMiddleware: readonly Middleware[];\n readonly #globalCoerceSearch?: CoerceSearchFn;\n readonly #history: HistoryDriver;\n readonly #records: readonly RouteRecord<TMeta, TComponent>[];\n readonly #routesByName: ReadonlyMap<string, RouteRecord<TMeta, TComponent>>;\n readonly #scroll?: RouterOptions<TRoutes, TMeta, TComponent>['scroll'];\n readonly #useViewTransition: boolean;\n readonly #onError?: RouterOptions<TRoutes, TMeta, TComponent>['onError'];\n\n // Mutable navigation state\n readonly #beforeLeaveBlockers = new Set<RegisteredBlocker>();\n readonly #navigation = createNavigationCoordinator();\n #currentState: RouteState<TMeta, TComponent>;\n #disposed = false;\n readonly #disposeController = new AbortController();\n #lastHref = '/';\n readonly #listeners = new Set<(state: RouteState<TMeta, TComponent>) => void>();\n // Compiled notFound fallback record\n readonly #notFoundRecord: RouteRecord<TMeta, TComponent> | null;\n\n // Sub-managers\n readonly #hydration: ReturnType<typeof createHydrationManager<TMeta, TComponent>>;\n readonly #preload: ReturnType<typeof createPreloadManager>;\n\n readonly #unlistenHistory: () => void;\n\n /** Resolves when the constructor-triggered navigation has settled; rejects if it fails. */\n readonly ready: Promise<void>;\n\n constructor(options: RouterOptions<TRoutes, TMeta, TComponent>) {\n const compiled = compileRoutes(options);\n\n this.#base = normalizePath(options.base ?? '/');\n this.#globalMiddleware = (options.middleware ?? []) as unknown as Middleware[];\n this.#globalCoerceSearch = options.coerceSearch;\n this.#history = options.history ?? createBrowserHistory();\n this.#useViewTransition = options.viewTransition ?? false;\n this.#scroll = options.scroll;\n this.#onError = options.onError;\n this.#records = compiled.records as unknown as readonly RouteRecord<TMeta, TComponent>[];\n this.#routesByName = compiled.routesByName as unknown as ReadonlyMap<string, RouteRecord<TMeta, TComponent>>;\n this.#hydration = createHydrationManager<TMeta, TComponent>();\n this.#preload = createPreloadManager();\n this.#currentState = createRouteState<TMeta, TComponent>({\n location: { hash: '', historyState: null, pathname: '/', query: {} },\n matches: [] as RouteMatchBranch<TMeta, TComponent>,\n status: 'idle',\n });\n\n // Build a synthetic RouteRecord for the notFound fallback.\n if (options.notFound) {\n const nf = options.notFound;\n const leafDef: RouteBranchDef<TMeta, TComponent> = {\n component: nf.component as TComponent | undefined,\n dataFn: nf.data,\n meta: nf.meta as TMeta | undefined,\n name: '__notFound__',\n };\n\n this.#notFoundRecord = {\n branchDefs: [leafDef],\n leaf: leafDef,\n matcher: { paramNames: [], pattern: /(?:)/, prefixPattern: /(?:)/ },\n ownMiddleware: (nf.middleware ?? []) as unknown as Middleware[],\n path: '/*',\n };\n } else {\n this.#notFoundRecord = null;\n }\n\n this.#unlistenHistory = this.#registerHistoryListener();\n\n const { hash, pathname, search } = this.#history.location;\n\n this.#lastHref = `${pathname}${search}${hash}`;\n\n const attempt = this.#navigation.begin();\n\n this.ready = this.#handleRoute(\n attempt,\n readLocation(this.#base, this.#history),\n (location, replace) => {\n if (!attempt.isCurrent()) return;\n\n const href = this.#hrefForLocation(location);\n\n if (replace) this.#history.replace(href, location.historyState);\n\n this.#lastHref = href;\n },\n undefined,\n 0,\n false,\n ).then(() => undefined);\n this.#runInBackground(this.ready, { source: 'initial-navigation' });\n\n // Router actions are intentionally bound once so they remain safe when destructured.\n this.beforeLeave = this.beforeLeave.bind(this);\n this.dispose = this.dispose.bind(this);\n this.getSnapshot = this.getSnapshot.bind(this);\n this.isActive = this.isActive.bind(this);\n this.load = this.load.bind(this);\n this.match = this.match.bind(this);\n this.navigate = this.navigate.bind(this);\n this.preload = this.preload.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.url = this.url.bind(this);\n this.waitFor = this.waitFor.bind(this);\n }\n\n // ─── Public state ─────────────────────────────────────────────────────────\n\n /**\n * Returns the current immutable router state snapshot.\n *\n * Compatible with React's `useSyncExternalStore`:\n * ```ts\n * const state = useSyncExternalStore(\n * (cb) => router.subscribe(cb),\n * () => router.getSnapshot()\n * );\n * ```\n */\n getSnapshot(): RouteState<TMeta, TComponent> {\n return this.#currentState;\n }\n\n // ─── Subscription ─────────────────────────────────────────────────────────\n\n /**\n * Subscribe to state changes. The listener is called on each subsequent state change;\n * use `getSnapshot()` to read the current value immediately.\n */\n subscribe(listener: (state: RouteState<TMeta, TComponent>) => void): Unsubscribe {\n this.#assertNotDisposed();\n this.#listeners.add(listener);\n\n return () => {\n this.#listeners.delete(listener);\n };\n }\n\n // ─── Navigation ───────────────────────────────────────────────────────────\n\n /**\n * Navigate using a named route target or a raw path target.\n *\n * If a data loader throws after terminal execution begins, history has already committed\n * the destination and the returned Promise rejects with the loader error.\n */\n navigate(\n target: NamedNavigationTarget<TRoutes> | RawNavigationTarget | string,\n options?: NavigateOptions,\n ): Promise<void> {\n const normalized = typeof target === 'string' ? { path: target } : target;\n const destination = resolveTarget(normalized, this.#routesByName);\n\n return this.#navigateToPath(destination, options);\n }\n\n // ─── URL helpers ──────────────────────────────────────────────────────────\n\n /** Build a URL for a named route, including optional params and query string. */\n url<Name extends RouteName<TRoutes>>(\n name: Name,\n params?: PathParams<RoutePathByName<TRoutes, Name>>,\n query?: ResolvedQueryParams,\n ): string {\n const route = getRouteByName(name, this.#routesByName);\n\n return buildUrl(this.#base, route.path, params, query);\n }\n\n /** Returns true when the current location matches the named route by prefix (default) or exactly. */\n isActive<Name extends RouteName<TRoutes>>(name: Name, options: IsActiveOptions = {}): boolean {\n const route = getRouteByName(name, this.#routesByName);\n const pathname = this.#currentState.location.pathname;\n const exact = options.exact ?? false;\n\n return exact ? matchRouteFor(pathname, [route]).record != null : matchesPrefix(pathname, route);\n }\n\n /** Match a pathname to a route branch without running middleware or data loaders. Returns null for redirects or no match. */\n match(pathname: string): RouteMatchBranch<TMeta, TComponent> | null {\n const normalizedPathname = stripBase(normalizePath(pathname), this.#base);\n const { params, record } = matchRouteFor(normalizedPathname, this.#records);\n\n if (!record || record.redirect) return null;\n\n const defs = this.#hydration.effectiveDefs(record);\n const branch = buildMatchBranch(\n defs,\n params,\n normalizedPathname,\n defs.map(() => undefined),\n );\n\n return branch.length ? branch : null;\n }\n\n /**\n * Load a URL into a route state including data loader results, without modifying\n * router state or history. Follows declarative redirects and may resolve lazy modules.\n * Middleware is not executed — use `navigate()` when middleware side effects are needed.\n */\n async load(url: string, options?: { signal?: AbortSignal }): Promise<RouteState<TMeta, TComponent> | null> {\n const prepared = await this.#resolveUrl(url);\n\n if (prepared.type !== 'matched') return null;\n\n const { location, params, record, resolvedQuery } = prepared;\n const defs = this.#hydration.effectiveDefs(record);\n const hasData = defs.some((d) => d.dataFn != null);\n let dataResults: unknown[] = defs.map(() => undefined);\n let error: unknown;\n let status: 'error' | 'idle' = 'idle';\n\n if (hasData) {\n const effectiveSignal = options?.signal ?? new AbortController().signal;\n const branch = buildMatchBranch(defs, params, location.pathname, dataResults);\n const context = createRouteContext<TRoutes>(location, resolvedQuery, params, branch, () => Promise.resolve());\n\n try {\n dataResults = await this.#loadDataDrain(defs, context, effectiveSignal);\n } catch (e) {\n error = e;\n status = 'error';\n }\n }\n\n return createRouteState<TMeta, TComponent>({\n error,\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults),\n status,\n });\n }\n\n /**\n * Returns a Promise that resolves the next time the router reaches `status: 'idle'`\n * and the active matches include a route named `name`.\n *\n * - Resolves immediately if the router is already `idle` at `name`.\n * - Rejects immediately if the router is already in `status: 'error'`.\n * - If the router is currently `idle` at a **different** route and no navigation is in\n * flight, this promise will not resolve until a future navigation lands on `name`.\n * Typical use-case is awaiting a navigation you just triggered:\n * `router.navigate(target); await router.waitFor('routeName')`.\n * @throws {WayfinderDisposedError} if the router is disposed while the promise is pending,\n * or if called after the router has already been disposed.\n */\n waitFor(name: RouteName<TRoutes>): Promise<RouteState<TMeta, TComponent>> {\n this.#assertNotDisposed();\n\n return new Promise((resolve, reject) => {\n const matchesName = (state: RouteState<TMeta, TComponent>): boolean =>\n state.status === 'idle' && state.matches.some((m) => m.name === name);\n\n if (this.#currentState.status === 'error') {\n reject(this.#currentState.error);\n\n return;\n }\n\n if (matchesName(this.#currentState)) {\n resolve(this.#currentState);\n\n return;\n }\n\n const unsub = this.subscribe((state) => {\n if (matchesName(state)) {\n unsub();\n resolve(state);\n } else if (state.status === 'error') {\n unsub();\n reject(state.error);\n }\n });\n\n this.#disposeController.signal.addEventListener(\n 'abort',\n () => {\n unsub();\n reject(this.#disposeController.signal.reason);\n },\n { once: true },\n );\n });\n }\n\n // ─── Preload ──────────────────────────────────────────────────────────────\n\n /**\n * Eagerly execute the data loaders for a named route without navigating.\n * Results are cached and reused during the next navigation to the same route.\n * Concurrent calls for the same route are deduplicated.\n *\n * Pass the same `query` you intend to navigate with to ensure the cached result\n * matches the navigation's cache key. Without `query`, the preload key is the\n * bare path — any navigation with a query string will produce a cache miss.\n *\n * @throws {WayfinderDisposedError} if the router has already been disposed.\n */\n async preload<Name extends RouteName<TRoutes>>(\n name: Name,\n params?: PathParams<RoutePathByName<TRoutes, Name>>,\n query?: QueryParams,\n ): Promise<void> {\n this.#assertNotDisposed();\n\n const route = getRouteByName(name, this.#routesByName);\n const cacheKey = buildPreloadKey(this.#base, route.path, params as RouteParams, query);\n\n const inflight = this.#preload.getInflight(cacheKey);\n\n if (inflight) return inflight;\n\n const work = this.#doPreload(cacheKey, this.#disposeController.signal, query).finally(() => {\n this.#preload.untrack(cacheKey);\n });\n\n this.#preload.track(cacheKey, work);\n\n try {\n return await work;\n } catch (error) {\n if (this.#onError) this.#reportError(error, { source: 'preload' });\n\n throw error;\n }\n }\n\n // ─── Navigation guards ────────────────────────────────────────────────────\n\n /**\n * Register a leave guard. Called before user-triggered navigation attempts.\n * Return `false` to cancel; `true` to allow.\n * Returns a function that removes the guard.\n *\n * Use `options.routes` to scope the guard to specific routes (fires only when navigating\n * away from a route whose name appears in the array, checked against any node in the active branch).\n */\n beforeLeave(blocker: BeforeLeaveBlocker, options?: BeforeLeaveOptions<TRoutes>): Unsubscribe {\n this.#assertNotDisposed();\n\n const entry: RegisteredBlocker = {\n handler: blocker,\n routes: options?.routes as string[] | undefined,\n };\n\n this.#beforeLeaveBlockers.add(entry);\n\n return () => {\n this.#beforeLeaveBlockers.delete(entry);\n };\n }\n\n // ─── Lifecycle ────────────────────────────────────────────────────────────\n\n get disposalSignal(): AbortSignal {\n return this.#disposeController.signal;\n }\n\n get disposed(): boolean {\n return this.#disposed;\n }\n\n /** Dispose event listeners and prevent further router interaction. Idempotent. */\n dispose(): void {\n if (this.#disposed) return;\n\n this.#disposed = true;\n this.#beforeLeaveBlockers.clear();\n this.#listeners.clear();\n this.#navigation.invalidate(new WayfinderDisposedError());\n this.#unlistenHistory();\n // Abort the disposal signal last — waitFor() listeners clean themselves up via this signal.\n this.#disposeController.abort(new WayfinderDisposedError());\n }\n\n [Symbol.dispose](): void {\n this.dispose();\n }\n\n // ─── Private: assertions ──────────────────────────────────────────────────\n\n #assertNotDisposed(): void {\n if (this.#disposed) throw new WayfinderDisposedError();\n }\n\n // ─── Private: history listener ────────────────────────────────────────────\n\n #registerHistoryListener(): () => void {\n return this.#history.onPopstate(() => {\n const { hash, pathname, search } = this.#history.location;\n const newHref = `${pathname}${search}${hash}`;\n const previousHref = this.#lastHref;\n\n if (newHref === previousHref) return;\n\n this.#runInBackground(this.#handleHistoryNavigation(newHref, previousHref), { source: 'history-listener' });\n });\n }\n\n async #handleHistoryNavigation(newHref: string, previousHref: string): Promise<void> {\n const attempt = this.#navigation.begin();\n const activeMatchNames = this.#currentState.matches.map((m) => m.name);\n const destination = this.#navigationDestination(newHref);\n const allowed = await runLeaveBlockers(this.#beforeLeaveBlockers, activeMatchNames, destination);\n\n if (!attempt.isCurrent()) return;\n\n if (!allowed) {\n this.#history.replace(previousHref, this.#currentState.location.historyState);\n\n return;\n }\n\n const terminalRan = await this.#handleRoute(\n attempt,\n readLocation(this.#base, this.#history),\n (location, replace) => {\n if (!attempt.isCurrent()) return;\n\n const href = this.#hrefForLocation(location);\n\n if (replace) this.#history.replace(href, location.historyState);\n\n this.#lastHref = href;\n },\n undefined,\n 0,\n false,\n );\n\n if (attempt.isCurrent() && !terminalRan) {\n this.#history.replace(previousHref, this.#currentState.location.historyState);\n }\n }\n\n // ─── Private: error handling ──────────────────────────────────────────────\n\n #reportError(error: unknown, context: RouterErrorContext): void {\n reportError(error, context, this.#onError);\n }\n\n #runInBackground(promise: Promise<void>, context: RouterErrorContext): void {\n void promise.catch((error) => {\n this.#reportError(error, getErrorContext(error) ?? context);\n });\n }\n\n // ─── Private: listener notification ──────────────────────────────────────\n\n #notifyListeners(): void {\n this.#listeners.forEach((listener) => {\n listener(this.#currentState);\n });\n }\n\n // ─── Private: data loaders ────────────────────────────────────────────────\n\n /**\n * R10: Drain an async generator to completion. Private class method replaces\n * the module-level `drainGenerator` helper.\n */\n async #drainGenerator(gen: AsyncGenerator<unknown, unknown>, signal: AbortSignal): Promise<unknown> {\n let lastYield: unknown;\n\n while (true) {\n if (signal.aborted) {\n await gen.return(undefined as unknown).catch(() => undefined);\n\n return lastYield;\n }\n\n const { done, value } = await gen.next();\n\n if (done) return value ?? lastYield;\n\n lastYield = value;\n }\n }\n\n /**\n * Drain all data loaders to completion. Async generators are consumed entirely.\n * Used in `load()` and `preload()`. Per-def `onError` boundaries are applied.\n */\n async #loadDataDrain(\n defs: readonly RouteBranchDef<TMeta, TComponent>[],\n context: RouteContext<RouteParams, TRoutes>,\n signal: AbortSignal,\n ): Promise<unknown[]> {\n return Promise.all(\n defs.map(async (def) => {\n if (!def.dataFn) return undefined;\n\n const dataFn = def.dataFn as unknown as DataFn<RouteParams, TRoutes>;\n const raw = dataFn({ ...context, signal } as DataContext<RouteParams, TRoutes>);\n\n try {\n return isAsyncGenerator(raw) ? await this.#drainGenerator(raw, signal) : await (raw as Promise<unknown>);\n } catch (err) {\n if (def.onError) return def.onError(err, { ...context, signal } as unknown as DataContext);\n\n throw err;\n }\n }),\n );\n }\n\n /**\n * Run all data loaders in streaming mode. Generators yield partial states via `onPartial`.\n * Non-generator loaders are awaited normally. Per-def `onError` boundaries are applied.\n * Used during live navigation in `#runTerminal`.\n */\n async #loadDataStream(\n defs: readonly RouteBranchDef<TMeta, TComponent>[],\n context: RouteContext<RouteParams, TRoutes>,\n signal: AbortSignal,\n isCurrent: () => boolean,\n location: RouteLocation,\n params: RouteParams,\n ): Promise<unknown[]> {\n const rawResults: Array<AsyncGenerator<unknown, unknown> | unknown> = defs.map((def) => {\n if (!def.dataFn) return undefined;\n\n const dataFn = def.dataFn as unknown as DataFn<RouteParams, TRoutes>;\n\n return dataFn({ ...context, signal } as DataContext<RouteParams, TRoutes>);\n });\n\n const streamingIndices: number[] = [];\n\n const settled: unknown[] = await Promise.all(\n rawResults.map(async (raw, i) => {\n if (isAsyncGenerator(raw)) {\n streamingIndices.push(i);\n\n return undefined;\n }\n\n if (raw === undefined) return undefined;\n\n try {\n return await (raw as Promise<unknown>);\n } catch (err) {\n const def = defs[i]!;\n\n if (def.onError) return def.onError(err, { ...context, signal } as unknown as DataContext);\n\n throw err;\n }\n }),\n );\n\n if (streamingIndices.length === 0) return settled;\n\n const streamingData: unknown[] = [...settled];\n\n const onPartial = (value: unknown, idx: number): void => {\n if (!isCurrent()) return;\n\n streamingData[idx] = value;\n\n const nodeStatuses: NavigationStatus[] = defs.map((_, i) =>\n streamingIndices.includes(i) ? 'streaming' : 'idle',\n );\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location,\n matches: buildMatchBranch(defs, params, location.pathname, streamingData, nodeStatuses),\n status: 'streaming',\n });\n this.#notifyListeners();\n };\n\n await Promise.all(\n streamingIndices.map(async (idx) => {\n const gen = rawResults[idx] as AsyncGenerator<unknown, unknown>;\n\n try {\n streamingData[idx] = await this.#runStreamingLoader(gen, idx, signal, isCurrent, onPartial);\n } catch (err) {\n const def = defs[idx]!;\n\n if (def.onError) {\n streamingData[idx] = await def.onError(err, { ...context, signal } as unknown as DataContext);\n } else {\n throw err;\n }\n }\n }),\n );\n\n return streamingData;\n }\n\n // ─── Private: URL resolution ──────────────────────────────────────────────\n\n /** Parse a URL, call #prepareRoute, and follow declarative redirects up to 5 hops. */\n async #resolveUrl(url: string): Promise<NavigationDecision<TMeta, TComponent>> {\n let destination = url;\n\n for (let i = 0; i < 5; i += 1) {\n const parsed = new URL(destination, 'http://localhost');\n const location: RouteLocation = {\n hash: parsed.hash.replace(/^#/, ''),\n historyState: null,\n pathname: stripBase(parsed.pathname, this.#base),\n query: parseQuery(parsed.search),\n };\n\n const prepared = await this.#prepareRoute(location);\n\n if (prepared.type !== 'redirect') return prepared;\n\n destination = this.#resolveDestination(prepared.redirectTo);\n }\n\n throw new WayfinderRedirectLoopError();\n }\n\n // ─── Private: preload ─────────────────────────────────────────────────────\n\n async #doPreload(startUrl: string, signal: AbortSignal, query?: QueryParams): Promise<void> {\n const prepared = await this.#resolveUrl(startUrl);\n\n if (prepared.type !== 'matched') return;\n\n const { location, params, record, resolvedQuery } = prepared;\n const defs = this.#hydration.effectiveDefs(record);\n const hasData = defs.some((d) => d.dataFn != null);\n\n if (!hasData) return;\n\n const branch = buildMatchBranch(\n defs,\n params,\n location.pathname,\n defs.map(() => undefined),\n );\n const context = createRouteContext<TRoutes>(location, resolvedQuery, params, branch, () => Promise.resolve());\n const results = await this.#loadDataDrain(defs, context, signal);\n\n this.#preload.set(buildPreloadKey(this.#base, record.path, params, query ?? location.query), results);\n }\n\n // ─── Private: route preparation ───────────────────────────────────────────\n\n async #prepareRoute(location: RouteLocation): Promise<NavigationDecision<TMeta, TComponent>> {\n const { params, record } = matchRouteFor(location.pathname, this.#records);\n\n if (!record) {\n return { location, params, type: 'unmatched' };\n }\n\n if (record.redirect) {\n return {\n location,\n params,\n redirectTo: resolveTarget(record.redirect, this.#routesByName, this.#base),\n type: 'redirect',\n };\n }\n\n let resolvedQuery: ResolvedQueryParams = location.query;\n\n const coerce: CoerceSearchFn | undefined = record.coerceSearch ?? this.#globalCoerceSearch;\n\n if (coerce) {\n try {\n resolvedQuery = coerce(location.query);\n } catch (err) {\n this.#reportError(err, { source: 'coerce-search' });\n resolvedQuery = location.query;\n }\n }\n\n await this.#hydration.hydrate(record);\n\n const defs = this.#hydration.effectiveDefs(record);\n\n return {\n branch: buildMatchBranch(\n defs,\n params,\n location.pathname,\n defs.map(() => undefined),\n ),\n location,\n params,\n record,\n resolvedQuery,\n type: 'matched',\n };\n }\n\n // ─── Private: streaming data loader ──────────────────────────────────────\n\n /**\n * Drain an AsyncGenerator data loader, emitting `status: 'streaming'` for every yielded\n * partial value and returning the generator's return value as the final settled data.\n * Aborts cleanly when the signal fires or the navigation is superseded.\n */\n async #runStreamingLoader(\n generator: AsyncGenerator<unknown, unknown>,\n defIndex: number,\n signal: AbortSignal,\n isCurrent: () => boolean,\n onPartial: (data: unknown, defIndex: number) => void,\n ): Promise<unknown> {\n let lastValue: unknown;\n\n try {\n while (true) {\n if (signal.aborted || !isCurrent()) {\n await generator.return(undefined as unknown);\n\n return lastValue;\n }\n\n const { done, value } = await generator.next();\n\n if (done) return value ?? lastValue;\n\n lastValue = value;\n onPartial(value, defIndex);\n }\n } catch (err) {\n await generator.return(undefined as unknown).catch(() => undefined);\n throw err;\n }\n }\n\n // ─── Private: terminal (data only) ────────────────────────────────────────\n\n async #runTerminal(\n record: RouteRecord<TMeta, TComponent>,\n context: RouteContext<RouteParams, TRoutes>,\n location: RouteLocation,\n params: RouteParams,\n signal: AbortSignal,\n isCurrent: () => boolean,\n ): Promise<void> {\n if (!isCurrent()) return;\n\n const defs = this.#hydration.effectiveDefs(record);\n const hasData = defs.some((d) => d.dataFn != null);\n let dataResults: unknown[] = defs.map(() => undefined);\n\n if (hasData) {\n const preloadKey = buildPreloadKey(this.#base, record.path, params, location.query);\n const cached = this.#preload.consume(preloadKey);\n\n if (cached) {\n dataResults = cached;\n } else {\n // Emit per-node loading state while data is in-flight.\n const loadingStatuses: NavigationStatus[] = defs.map((d) => (d.dataFn ? 'loading' : 'idle'));\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults, loadingStatuses),\n status: 'loading',\n });\n this.#notifyListeners();\n\n try {\n dataResults = await this.#loadDataStream(defs, context, signal, isCurrent, location, params);\n } catch (error) {\n if (!isCurrent()) return;\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n error,\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults),\n status: 'error',\n });\n // Attach enriched context so the eventual reporter uses it.\n attachErrorContext(error, { routeName: record.leaf.name, source: 'data-loader' });\n // Do not call #notifyListeners here — the finally block in #handleRoute does it once.\n throw error;\n }\n }\n }\n\n if (!isCurrent()) return;\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location,\n matches: buildMatchBranch(defs, params, location.pathname, dataResults),\n status: 'idle',\n });\n }\n\n // ─── Private: view transitions ────────────────────────────────────────────\n\n async #runWithTransition(run: () => Promise<void>, useTransition?: boolean): Promise<void> {\n const shouldUseTransition = useTransition ?? this.#useViewTransition;\n\n if (shouldUseTransition && typeof document !== 'undefined') {\n type ViewTransitionDocument = Document & {\n startViewTransition?: (callback: () => void | Promise<void>) => { finished: Promise<void> };\n };\n\n const doc = document as ViewTransitionDocument;\n\n if (doc.startViewTransition) {\n await doc.startViewTransition(run).finished;\n\n return;\n }\n }\n\n await run();\n }\n\n // ─── Private: main navigation orchestrator ────────────────────────────────\n\n /**\n * Declarative redirects reuse the active attempt and replace the final history entry.\n * Middleware redirects call `ctx.navigate()`, which starts a new attempt.\n */\n async #handleRoute(\n attempt: NavigationAttempt,\n currentLocation: RouteLocation,\n commit: (location: RouteLocation, replace: boolean) => void,\n useTransition?: boolean,\n depth = 0,\n replace = false,\n ): Promise<boolean> {\n const prevState = this.#currentState;\n const isCurrent = (): boolean => attempt.isCurrent() && !this.#disposed;\n const prepared = await this.#prepareRoute(currentLocation);\n\n if (!isCurrent()) return false;\n\n if (prepared.type === 'redirect') {\n if (depth >= 5) throw new WayfinderRedirectLoopError();\n\n return this.#handleRoute(\n attempt,\n this.#locationFromPath(prepared.redirectTo, currentLocation.historyState),\n commit,\n useTransition,\n depth + 1,\n true,\n );\n }\n\n if (prepared.type === 'unmatched') {\n // Fall back to notFound record when defined.\n if (this.#notFoundRecord) {\n const nfDefs = [this.#notFoundRecord.leaf];\n const nfBranch = buildMatchBranch(nfDefs, {}, currentLocation.pathname, [undefined]);\n let committed = false;\n let terminalRan = false;\n\n // Apply global coerceSearch to the unmatched location so notFound handlers\n // receive typed query params, consistent with matched-route behaviour.\n let nfResolvedQuery: ResolvedQueryParams = currentLocation.query;\n\n if (this.#globalCoerceSearch) {\n try {\n nfResolvedQuery = this.#globalCoerceSearch(currentLocation.query);\n } catch (err) {\n this.#reportError(err, { source: 'coerce-search' });\n }\n }\n\n const run = async (): Promise<void> => {\n if (!isCurrent()) return;\n\n const context = createRouteContext<TRoutes>(\n currentLocation,\n nfResolvedQuery,\n {},\n nfBranch,\n (target, options) => this.navigate(target, options),\n );\n\n terminalRan = await executeMiddlewarePipeline(\n context,\n [...this.#globalMiddleware, ...this.#notFoundRecord!.ownMiddleware] as unknown as Middleware<TRoutes>[],\n async () => {\n if (!isCurrent()) return;\n\n committed = true;\n commit(currentLocation, replace);\n\n if (!isCurrent()) return;\n\n await this.#runTerminal(this.#notFoundRecord!, context, currentLocation, {}, attempt.signal, isCurrent);\n },\n );\n };\n\n try {\n await this.#runWithTransition(run, useTransition);\n } finally {\n if (isCurrent() && committed) {\n this.#notifyListeners();\n this.#applyScroll(this.#currentState, prevState);\n }\n }\n\n return terminalRan && committed;\n }\n\n if (!isCurrent()) return false;\n\n commit(prepared.location, replace);\n\n if (!isCurrent()) return false;\n\n this.#currentState = createRouteState<TMeta, TComponent>({\n location: prepared.location,\n matches: [] as RouteMatchBranch<TMeta, TComponent>,\n status: 'idle',\n });\n this.#notifyListeners();\n this.#applyScroll(this.#currentState, prevState);\n\n return true;\n }\n\n const { branch, location, params, record, resolvedQuery } = prepared;\n let committed = false;\n let terminalRan = false;\n\n const run = async (): Promise<void> => {\n if (!isCurrent()) return;\n\n const context = createRouteContext<TRoutes>(location, resolvedQuery, params, branch, (target, options) =>\n this.navigate(target, options),\n );\n\n terminalRan = await executeMiddlewarePipeline(\n context,\n [...this.#globalMiddleware, ...record.ownMiddleware] as unknown as Middleware<TRoutes>[],\n async () => {\n if (!isCurrent()) return;\n\n committed = true;\n commit(location, replace);\n\n if (!isCurrent()) return;\n\n await this.#runTerminal(record, context, location, params, attempt.signal, isCurrent);\n },\n );\n };\n\n try {\n await this.#runWithTransition(run, useTransition);\n } finally {\n if (isCurrent() && committed) {\n this.#notifyListeners();\n this.#applyScroll(this.#currentState, prevState);\n }\n }\n\n return terminalRan && committed;\n }\n\n // ─── Private: scroll ─────────────────────────────────────────────────────\n\n #applyScroll(to: RouteState<TMeta, TComponent>, from: RouteState<TMeta, TComponent>): void {\n if (!this.#scroll || typeof window === 'undefined') return;\n\n const decision = this.#scroll(to, from);\n\n if (decision === 'preserve') return;\n\n if (decision === 'top') {\n window.scrollTo(0, 0);\n\n return;\n }\n\n window.scrollTo(decision.x, decision.y);\n }\n\n // ─── Private: destination resolution ─────────────────────────────────────\n\n #resolveDestination(path: string): string {\n const parsed = new URL(path, 'http://localhost');\n const normalizedPath = stripBase(parsed.pathname, this.#base);\n\n return `${joinPaths(this.#base, normalizedPath)}${parsed.search}${parsed.hash}`;\n }\n\n #locationFromPath(path: string, historyState: unknown): RouteLocation {\n const parsed = new URL(this.#resolveDestination(path), 'http://localhost');\n\n return {\n hash: parsed.hash.replace(/^#/, ''),\n historyState,\n pathname: stripBase(parsed.pathname, this.#base),\n query: parseQuery(parsed.search),\n };\n }\n\n #hrefForLocation(location: RouteLocation): string {\n const search = new URLSearchParams();\n\n for (const [key, value] of Object.entries(location.query)) {\n if (Array.isArray(value))\n value.forEach((item) => {\n search.append(key, item);\n });\n else search.set(key, value);\n }\n\n const query = search.toString();\n const hash = location.hash ? `#${location.hash}` : '';\n\n return `${joinPaths(this.#base, location.pathname)}${query ? `?${query}` : ''}${hash}`;\n }\n\n #navigationDestination(href: string): NavigationDestination {\n const parsed = new URL(href, 'http://localhost');\n const pathname = stripBase(parsed.pathname, this.#base);\n const { params, record } = matchRouteFor(pathname, this.#records);\n\n return {\n name: record?.leaf.name,\n params,\n pathname,\n query: parseQuery(parsed.search),\n };\n }\n\n /** User-initiated navigation. History changes only after middleware reaches the terminal stage. */\n async #navigateToPath(path: string, options: NavigateOptions = {}): Promise<void> {\n this.#assertNotDisposed();\n\n const destination = this.#resolveDestination(path);\n\n if (!options.force && destination === this.#lastHref) return;\n\n const attempt = this.#navigation.begin();\n const activeMatchNames = this.#currentState.matches.map((match) => match.name);\n const allowed = await runLeaveBlockers(\n this.#beforeLeaveBlockers,\n activeMatchNames,\n this.#navigationDestination(destination),\n );\n\n if (!attempt.isCurrent() || !allowed) return;\n\n await this.#handleRoute(\n attempt,\n this.#locationFromPath(destination, options.state),\n (location, replace) => {\n if (!attempt.isCurrent()) return;\n\n const href = this.#hrefForLocation(location);\n\n if (replace) this.#history.replace(href, location.historyState);\n else this.#history.push(href, location.historyState);\n\n this.#lastHref = href;\n },\n options.viewTransition,\n 0,\n options.replace ?? false,\n );\n }\n}\n\n// ─── Public factory ───────────────────────────────────────────────────────────\n\n/**\n * Create a new router instance from a route table.\n *\n * @example\n * const router = createRouter({\n * routes: {\n * home: { path: '/' },\n * userDetail: { path: '/users/:id', data: fetchUser },\n * },\n * });\n */\nexport function createRouter<const TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown>(\n options: RouterOptions<TRoutes, TMeta, TComponent>,\n): Router<TRoutes, TMeta, TComponent> {\n return new Router(options);\n}\n\n// Export the Router type (not the constructor value) for type annotations.\nexport type { Router };\n"],"mappings":";;;;;;;;;;AA2DA,SAAS,EACP,GACA,GACgC;CAChC,IAAM,IAAQ,EAAa,IAAI,CAAI;CAEnC,IAAI,GAAO,OAAO;CAElB,IAAM,IAAY,CAAC,GAAG,EAAa,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;CAEpD,MAAM,IAAI,EACR,IAAY,uBAAuB,EAAK,sBAAsB,MAAc,uBAAuB,GACrG;AACF;AAEA,SAAS,EACP,GACA,GACA,IAAO,KACC;CACR,IAAI,UAAU,GAAQ,OAAO,EAAO;CAEpC,IAAM,IAAQ,EAAe,EAAO,MAAM,CAAY,GAChD,IAAO,EAAS,GAAM,EAAM,MAAM,EAAO,QAAQ,EAAO,KAAK;CAEnE,OAAO,EAAO,OAAO,GAAG,EAAK,GAAG,EAAO,SAAS;AAClD;AAIA,IAAM,IAAgB,OAAO,wBAAwB;AAErD,SAAS,EAAmB,GAAgB,GAAmC;CAC7E,AAAsB,OAAO,KAAU,YAAnC,MACF,EAA8C,KAAiB;AAEnE;AAEA,SAAS,EAAgB,GAAgD;CACvE,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GAAc,IAA2B,CAAC,GAAkB;EAChF,KAAKD,GAAmB;EAExB,IAAM,IAAc,KAAKc,GAAoB,CAAI;EAEjD,IAAI,CAAC,EAAQ,SAAS,MAAgB,KAAKlB,IAAW;EAEtD,IAAM,IAAU,KAAKT,GAAY,MAAM,GACjC,IAAmB,KAAKO,GAAc,QAAQ,KAAK,MAAU,EAAM,IAAI,GACvE,IAAU,MAAM,EACpB,KAAKR,IACL,GACA,KAAKsB,GAAuB,CAAW,CACzC;EAEI,CAAC,EAAQ,UAAU,KAAK,CAAC,KAE7B,MAAM,KAAKX,GACT,GACA,KAAKoB,GAAkB,GAAa,EAAQ,KAAK,IAChD,GAAU,MAAY;GACrB,IAAI,CAAC,EAAQ,UAAU,GAAG;GAE1B,IAAM,IAAO,KAAKnB,GAAiB,CAAQ;GAK3C,AAHI,IAAS,KAAKlB,GAAS,QAAQ,GAAM,EAAS,YAAY,IACzD,KAAKA,GAAS,KAAK,GAAM,EAAS,YAAY,GAEnD,KAAKgB,KAAY;EACnB,GACA,EAAQ,gBACR,GACA,EAAQ,WAAW,EACrB;CACF;AACF;AAeA,SAAgB,EACd,GACoC;CACpC,OAAO,IAAI,EAAO,CAAO;AAC3B"}
package/dist/types.d.ts CHANGED
@@ -18,10 +18,8 @@ export type MaybePromise<T> = T | Promise<T>;
18
18
  * The `return` value becomes the final settled data (status: `'idle'`).
19
19
  */
20
20
  export type DataStream<T = unknown> = AsyncGenerator<T, T>;
21
- /** Navigation status for the whole router and per-route match status (F1). */
21
+ /** Navigation status for the whole router and per-route match status. */
22
22
  export type NavigationStatus = 'error' | 'idle' | 'loading' | 'streaming';
23
- /** Per-route match status (F1). Reflects whether this specific branch node is still loading. */
24
- export type MatchStatus = NavigationStatus;
25
23
  export type IsActiveOptions = {
26
24
  /** Require an exact pathname match. Defaults to prefix matching. */
27
25
  exact?: boolean;
@@ -32,7 +30,7 @@ export type ScrollPosition = {
32
30
  };
33
31
  export type ScrollDecision = ScrollPosition | 'preserve' | 'top';
34
32
  /**
35
- * Discriminated error context passed to `onError` (R3).
33
+ * Discriminated error context passed to `onError`.
36
34
  * Each variant carries enough information to distinguish where the error originated.
37
35
  */
38
36
  export type RouterErrorContext = {
@@ -54,7 +52,7 @@ export type RouterErrorSource = RouterErrorContext['source'];
54
52
  */
55
53
  export type CoerceSearchFn<Q extends ResolvedQueryParams = ResolvedQueryParams> = (raw: QueryParams) => Q;
56
54
  /**
57
- * Destination info passed to `beforeLeave` blockers (R4).
55
+ * Destination info passed to `beforeLeave` blockers.
58
56
  * Gives guards enough context to make an informed allow/block decision.
59
57
  */
60
58
  export type NavigationDestination = {
@@ -98,8 +96,9 @@ export type NavigationTarget = UntypedNamedNavigationTarget | RawNavigationTarge
98
96
  /**
99
97
  * Context available in middleware and data loaders.
100
98
  *
101
- * R7: `TLocals` has been removed. Use `locals: Record<string, unknown>` and cast
102
- * inside your middleware when you need typed access (e.g. `ctx.locals as AuthCtx`).
99
+ * `locals` is a mutable bag for passing values between middleware functions in a navigation.
100
+ * Reset to an empty object at the start of every navigation. Cast inside your middleware when
101
+ * you need typed access (e.g. `ctx.locals as AuthCtx`).
103
102
  */
104
103
  export type RouteContext<Params extends RouteParams = RouteParams, TRoutes extends RouteTable = RouteTable> = {
105
104
  readonly hash: string;
@@ -165,7 +164,7 @@ type ContentRouteDefinition<Path extends string = string> = RouteCommon & RouteP
165
164
  /**
166
165
  * Data loader. Runs after middleware; result is available as `match.data` in the matched branch.
167
166
  * Supports streaming via AsyncGenerator. May also perform side effects directly
168
- * (rendering, state hydration) — replaces the former `handler` concept (F4).
167
+ * (rendering, state hydration) — replaces the former `handler` concept.
169
168
  */
170
169
  data?: DataFn<PathParams<Path>>;
171
170
  /** Lazy-load the route module. The resolved export replaces data/component/meta. */
@@ -233,7 +232,7 @@ export type NamedNavigationTarget<TRoutes extends RouteTable> = {
233
232
  /**
234
233
  * A single node in the matched route branch (root → leaf).
235
234
  *
236
- * F1: Each match node carries its own `status` so nested layouts can reflect
235
+ * Each match node carries its own `status` so nested layouts can reflect
237
236
  * per-slot loading/streaming state without polling the router-level status.
238
237
  */
239
238
  export type RouteMatch<TMeta = unknown, TComponent = unknown> = {
@@ -245,8 +244,8 @@ export type RouteMatch<TMeta = unknown, TComponent = unknown> = {
245
244
  readonly name: string;
246
245
  readonly params: RouteParams;
247
246
  readonly pathname: string;
248
- /** F1: Per-node loading status. Reflects individual loader state in nested layouts. */
249
- readonly status: MatchStatus;
247
+ /** Per-node loading status. Reflects individual loader state in nested layouts. */
248
+ readonly status: NavigationStatus;
250
249
  };
251
250
  /** Ordered array of matched route nodes from the root layout down to the active leaf. */
252
251
  export type RouteMatchBranch<TMeta = unknown, TComponent = unknown> = readonly RouteMatch<TMeta, TComponent>[];
@@ -288,7 +287,7 @@ export type RouterOptions<TRoutes extends RouteTable = RouteTable, TMeta = unkno
288
287
  /** Global middleware applied to every route. */
289
288
  middleware?: Middleware<TRoutes>[];
290
289
  /**
291
- * F5: Fallback route rendered when no route matches.
290
+ * Fallback route rendered when no route matches.
292
291
  * Declared explicitly and matched last after all routes.
293
292
  * The `data` function receives the unmatched pathname via `ctx.pathname`.
294
293
  */
@@ -304,14 +303,14 @@ export type RouterOptions<TRoutes extends RouteTable = RouteTable, TMeta = unkno
304
303
  };
305
304
  /** Pluggable history driver. Use `createBrowserHistory()` for standard SPAs, `createMemoryHistory()` for SSR/tests. */
306
305
  export interface HistoryDriver {
306
+ /** Navigate one entry back in history, equivalent to the browser back button. */
307
+ back(): void;
307
308
  readonly location: {
308
309
  readonly hash: string;
309
310
  readonly pathname: string;
310
311
  readonly search: string;
311
312
  readonly state: unknown;
312
313
  };
313
- /** Navigate one entry back in history, equivalent to the browser back button. */
314
- back(): void;
315
314
  /**
316
315
  * Subscribe to backwards/forwards navigation (popstate-equivalent).
317
316
  * `push()` and `replace()` are silent — they do not notify subscribers.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,k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