UNPKG

@shopify/app-bridge-host

Version:

App Bridge Host contains middleware and components that are meant to be consumed by the app's host. The middleware and `Frame` component are responsible for facilitating messages posted between the client and host, and used to act on actions sent from the

71 lines (70 loc) 2.19 kB
import React from 'react'; import { ReducerMap, Store } from './store/async'; import { TrackingEventPayload, Application, ApiClientConfig } from './types'; import { Props as HostProps } from './Host'; /** * 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; push(path: string): void; }; /** * The current pathname and query params * @internal * */ location: { pathname: string; search?: string; }; } /** * The interface for the HostProvider * @public * */ export interface Props extends HostProps { /** Configuration of the app */ 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<Store> & Pick<Store, 'features'>; router?: RouterContext; } /** * 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<State>(reducerMap: ReducerMap<State>): void; } /** * The context provider for the app, config and addReducer method * @public * */ export declare const HostContext: React.Context<HostContext | null>; /** * The context provider for the router. * Keeps track of the current location and * handles history push/replace * @public * */ export declare const RouterContext: React.Context<RouterContext | null>; /** * A component that creates a dynamic Redux store * and renders the Host * @public * */ export default function HostProvider(props: Props): JSX.Element;