UNPKG

@tanstack/solid-router

Version:

Modern and scalable routing for Solid applications

69 lines (68 loc) • 3.77 kB
import type { NavigationRef } from 'solid-js'; import type { AnyRouter, ParsedLocation } from '@tanstack/router-core'; /** * What the router says about its navigations to Solid's observe tier * (`OBSERVE.attribution.withOrigin`; `OBSERVE` is defined on the dev and * observe builds, undefined in production). A navigation is named by the * route pattern its pathname matches, so occurrences fold together; `to` and * `from` are the location's `href` — path, search and hash, as * `@solidjs/router` gives them, in the router's own path space (`name`'s, * before a basepath or rewrite is applied). */ /** When a navigation was requested, and the interaction it was requested in. */ export interface NavigationRequest { at: number; /** Required: `undefined` declares that the request was for no interaction. */ interaction: NavigationRef['interaction']; } /** * Records the navigation being requested now — a `commitLocation`, or a * blocker's `proceed` — for the history change it causes to answer. The * history may notify after awaiting its blockers, the interaction gone from * the stack by then; a later request replaces this one. */ export declare function noteRequest(router: AnyRouter): void; /** A blocker is deciding on the noted request: keep it past the commit. */ export declare function holdRequest(router: AnyRouter): void; /** * The commit that noted the request has returned. Without a blocker * holding it, the history has notified by then — or never will: the same * location reloads without a history change. */ export declare function releaseRequest(router: AnyRouter): void; /** Forgets the noted request: a blocker stopped the navigation it made. */ export declare function dropRequest(router: AnyRouter): void; /** The request noted for the history change being notified, if any. */ export declare function takeRequest(router: AnyRouter): NavigationRequest | undefined; /** A destination a pending navigation was sent on from, and when. */ export interface NavigationHop { location: ParsedLocation; at: number; } /** * The navigation a match publish lands: the latest location, from `from` * (the location shown, or the arrival while the first page is still * loading). Nothing when the publish reloads the location it came from. * `request` dates it from the request and joins it to the interaction that * asked, both gone by the time the loaders resolve and the publish runs; the * key's presence declares the interaction, `undefined` included. * * One ref per destination, to be opened nested, as `@solidjs/router` * declares a navigation sent elsewhere while pending (a redirect, or * another navigation): the first names the destination requested, and each * `hops` entry is abandoned by a `redirect: n` ref the engine folds onto it, * keeping the request's time and interaction and listing the abandoned * destinations in `redirects`. */ export declare function describeNavigation(router: AnyRouter, request: NavigationRequest, from: ParsedLocation | undefined, hops: ReadonlyArray<NavigationHop>): Array<NavigationRef> | undefined; /** * The route the document arrived on, declared around the work that * establishes the router's initial match, since a fresh document has no * publish to wrap. On the client the engine opens it at the time origin and * settles it as that work returns (the first `"navigation"` record, * `initial: true`); on the server the same call names the request's * `"render"` record (`RenderEvent.route`). The fields are getters of * `location`, read at settle: the canonical location the client committed, * or the one a server load resolved. */ export declare function describeInitial(router: AnyRouter, location: () => ParsedLocation): NavigationRef;