import React from 'react'; import { Middleware as ReduxMiddleware, Store as ReduxStore } from 'redux'; import { buildMiddleware } from './Middleware'; import { ReducerMap, Store } from './store/async'; import { TrackingEventPayload, Application, ApiClientConfig } from './types'; import { Props as HostProps } from './Host'; /** * The current pathname, search params and hash * @internal * */ export interface Location { pathname: string; search?: string; hash?: string; } /** * The method to call when attempting to update the router history * When the return value is a string or `true`, the router update will be blocked * @internal * */ export interface Prompt { (nextLocation?: Location): string | false | void; } /** * The interface for the Navigation Context * @public * */ export interface RouterContext { /** The `handle` or `apiKey` for the current app */ appRoot: string; hostname: string; /** The router to be to handle router actions */ history: { replace(path: string): void; replace(nextLocation: Location): void; push(path: string): void; push(nextLocation: Location): void; block?(prompt?: boolean | string | Prompt): () => void; }; location: Location; } /** * The interface for the HostProvider * @public * */ export interface Props extends HostProps { /** Configuration of the app to load*/ config?: ApiClientConfig; /** Optional handler for when App Bridge actions are dispatched */ dispatchClientEventHandler?: (trackingEventPayload: TrackingEventPayload) => void; /** Required to set the initial app state * @remarks feature permissions must be specified using the key `features` which will take effect immediately * other state properties (ex. `loading`, `toast`, etc..) will only be set after the relevant reducer has loaded */ initialState: Partial & Pick; /** The middleware to use when creating the Redux store */ middleware?: Array | ReduxMiddleware>; router?: RouterContext; /** Enables the Redux dev tools if set to `true` */ debug?: boolean; } /** * The interface for the Host Context that can be * consumed by the Host Provider's child components * @public * */ export interface HostContext { app: Application; config: ApiClientConfig; addReducer(reducerMap: ReducerMap): void; store: ReduxStore; } /** * The context provider for the app, config and addReducer method * @public * */ export declare const HostContext: React.Context; /** * The context provider for the router. * Keeps track of the current location and * handles history push/replace * @public * */ export declare const RouterContext: React.Context; /** * A component that creates a dynamic Redux store * and renders the Host * @public * */ export default function HostProvider(props: Props): JSX.Element;