Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
/**
|
|
* Cookie reading and subscription for the instant navigation devtools panel.
|
|
*
|
|
* The cookie value is a JSON array:
|
|
* [0] — pending (waiting to capture)
|
|
* [1, null] — captured MPA page load
|
|
* [1, { from, to }] — captured SPA navigation (from/to route trees)
|
|
*
|
|
* The "to" tree may be null initially and updated after the prefetch resolves.
|
|
*/
|
|
import type { FlightRouterState } from '../../../../shared/lib/app-router-types';
|
|
export type InstantNavCookieData = {
|
|
state: 'pending';
|
|
} | {
|
|
state: 'mpa';
|
|
} | {
|
|
state: 'spa';
|
|
fromTree: FlightRouterState;
|
|
toTree: FlightRouterState | null;
|
|
};
|
|
export declare function readInstantNavCookieState(): InstantNavCookieData['state'] | null;
|
|
/**
|
|
* Formats a FlightRouterState tree into a route pattern string for display.
|
|
* Dynamic segments are shown with bracket syntax (e.g. [slug], [...params],
|
|
* [[...optional]]) rather than their filled-in values. Search params are
|
|
* omitted because they don't affect navigation.
|
|
*/
|
|
export declare function formatRoutePattern(tree: FlightRouterState): string;
|
|
/**
|
|
* Subscribes to the instant navigation cookie value. The cookie is the
|
|
* sole source of truth — this hook reads it via useSyncExternalStore.
|
|
*
|
|
* The raw cookie string is the snapshot (stable by value comparison).
|
|
* Parsing into structured data happens during render via useMemo.
|
|
*
|
|
* Returns null when the cookie is absent.
|
|
*/
|
|
export declare function useInstantNavCookieState(): InstantNavCookieData | null;
|