import * as H from 'history'; import React from 'react'; import { type Observable } from 'rxjs'; import { type UrlQueryMap } from '@grafana/data'; import { type LocationUpdate } from './LocationSrv'; /** * @public * A wrapper to help work with browser location and history */ export interface LocationService { partial: (query: Record, replace?: boolean) => void; push: (location: H.Path | H.LocationDescriptor) => void; replace: (location: H.Path | H.LocationDescriptor) => void; reload: () => void; getLocation: () => H.Location; getHistory: () => H.History; getSearch: () => URLSearchParams; getSearchObject: () => UrlQueryMap; getLocationObservable: () => Observable; /** * This is from the old LocationSrv interface * @deprecated use partial, push or replace instead */ update: (update: LocationUpdate) => void; } /** * Wraps `H.History` so every navigation — programmatic push/replace, * `` clicks, and `` rendering via createHref — flows through * `appendOrgId` at one chokepoint. `getHistory()` returns `this`, so * react-router uses the wrapper too. * @internal */ export declare class HistoryWrapper implements LocationService, H.History { private readonly base; private locationObservable; private orgIdGetter?; private singleHistoryEntryMode; constructor(history?: H.History); get length(): number; get action(): H.Action; get location(): H.Location; push: H.History['push']; replace: H.History['replace']; createHref: H.History['createHref']; go: H.History['go']; goBack: H.History['goBack']; goForward: H.History['goForward']; block: H.History['block']; listen: H.History['listen']; setOrgIdGetter: (fn: () => number) => void; setSingleHistoryEntryMode: (enabled: boolean) => void; appendOrgId(location: H.LocationDescriptorObject): H.LocationDescriptorObject; appendOrgId(location: H.Path | H.LocationDescriptor): H.Path | H.LocationDescriptor; getLocationObservable: () => Observable>; getHistory: () => this; getSearch: () => URLSearchParams; getLocation: () => H.Location; getSearchObject: () => UrlQueryMap; partial: (query: Record, replace?: boolean) => void; reload: () => void; /** @deprecated use partial, push or replace instead */ update: (options: LocationUpdate) => void; } /** * @public * Parses a location search string to an object * */ export declare function locationSearchToObject(search: string | number): UrlQueryMap; /** * @public */ export declare let locationService: LocationService; /** * Used for tests only * @internal */ export declare const setLocationService: (location: LocationService) => void; /** @internal */ export declare const navigationLogger: (message?: any, ...optionalParams: any[]) => void; export declare function useLocationService(): LocationService; export declare const LocationServiceProvider: React.FC<{ service: LocationService; children: React.ReactNode; }>;