| | 'use client' |
| |
|
| | import type { |
| | FocusAndScrollRef, |
| | PrefetchKind, |
| | } from '../../client/components/router-reducer/router-reducer-types' |
| | import type { Params } from '../../server/request/params' |
| | import type { |
| | FlightRouterState, |
| | FlightSegmentPath, |
| | CacheNode, |
| | } from './app-router-types' |
| | import React from 'react' |
| |
|
| | export interface NavigateOptions { |
| | scroll?: boolean |
| | } |
| |
|
| | export interface PrefetchOptions { |
| | kind: PrefetchKind |
| | onInvalidate?: () => void |
| | } |
| |
|
| | export interface AppRouterInstance { |
| | |
| | |
| | |
| | back(): void |
| | |
| | |
| | |
| | forward(): void |
| | |
| | |
| | |
| | refresh(): void |
| | |
| | |
| | |
| | |
| | hmrRefresh(): void |
| | |
| | |
| | |
| | |
| | push(href: string, options?: NavigateOptions): void |
| | |
| | |
| | |
| | |
| | replace(href: string, options?: NavigateOptions): void |
| | |
| | |
| | |
| | prefetch(href: string, options?: PrefetchOptions): void |
| | } |
| |
|
| | export const AppRouterContext = React.createContext<AppRouterInstance | null>( |
| | null |
| | ) |
| | export const LayoutRouterContext = React.createContext<{ |
| | parentTree: FlightRouterState |
| | parentCacheNode: CacheNode |
| | parentSegmentPath: FlightSegmentPath | null |
| | parentParams: Params |
| | debugNameContext: string |
| | url: string |
| | isActive: boolean |
| | } | null>(null) |
| |
|
| | export const GlobalLayoutRouterContext = React.createContext<{ |
| | tree: FlightRouterState |
| | focusAndScrollRef: FocusAndScrollRef |
| | nextUrl: string | null |
| | previousNextUrl: string | null |
| | }>(null as any) |
| |
|
| | export const TemplateContext = React.createContext<React.ReactNode>(null as any) |
| |
|
| | if (process.env.NODE_ENV !== 'production') { |
| | AppRouterContext.displayName = 'AppRouterContext' |
| | LayoutRouterContext.displayName = 'LayoutRouterContext' |
| | GlobalLayoutRouterContext.displayName = 'GlobalLayoutRouterContext' |
| | TemplateContext.displayName = 'TemplateContext' |
| | } |
| |
|
| | export const MissingSlotContext = React.createContext<Set<string>>(new Set()) |
| |
|