@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
90 lines (89 loc) • 3.37 kB
TypeScript
import { compose, Middleware as ReduxMiddleware, ReducersMapObject, Reducer, Store as ReduxStore } from 'redux';
import { buildMiddleware } from '../Middleware';
import { AppInfoStore } from './reducers/embeddedApp/appInfo';
import { FeaturesState } from './reducers/embeddedApp/features';
import { ToastStore } from './reducers/embeddedApp/toast';
import { LoadingStore } from './reducers/embeddedApp/loading';
import { ModalStore } from './reducers/embeddedApp/modal';
import { TitleBarStore } from './reducers/embeddedApp/titleBar';
import { ResourcePickerStore } from './reducers/embeddedApp/resourcePicker';
import { NavigationStore } from './reducers/embeddedApp/navigation';
import { POSStore } from './reducers/embeddedApp/pos';
import { StaffMemberStore } from './reducers/embeddedApp/staffMember';
import { ContextualSaveBarStore } from './reducers/embeddedApp/contextualSaveBar';
interface DevToolsOptions {
name?: string;
}
declare global {
interface Window {
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__: (options: DevToolsOptions) => typeof compose;
}
}
/**
* The interface for the app state
* @public
*/
export interface Store {
appInfo?: AppInfoStore;
features: FeaturesState;
pos?: POSStore;
staffMember?: StaffMemberStore;
isLegacy?: boolean;
contextualSaveBar?: ContextualSaveBarStore;
fullscreen?: boolean;
loading?: LoadingStore;
modal?: ModalStore;
navigation?: NavigationStore;
resourcePicker?: ResourcePickerStore | null;
titleBar?: TitleBarStore | null;
toast?: ToastStore;
}
/**
* The app state keyed with `appBridge`
* @internal
*/
export interface AppBridgeStore {
appBridge: Store;
}
/**
* The interface for an injected reducer's options
* @public
* */
export interface ReducerMap<State> {
/** A key matching a property in the app state */
key: keyof Store;
/** Reducer to add to a store */
reducer: Reducer<State>;
/** Optional default state for the injected reducer*/
initialState?: Partial<State>;
}
/**
* The constant key `appBridge`
* @public
*/
export declare const APP_BRIDGE_KEY = "appBridge";
/**
* Returns a combined reducer for the `appBridge` key
* Includes the private reducers 'appInfo', 'features', 'pos', 'staffMember' and 'isLegacy'
* @public
* @param stateReducers - a reducer map for the dynamic app state
* @param initialState - an optional default value for the store
*/
export declare function createReducers(stateReducers?: ReducersMapObject, initialState?: Partial<Store>): Reducer<AppBridgeStore, import("redux").AnyAction>;
/**
* Creates a store containing only the default reducers
* 'appInfo', 'features', 'pos', 'staffMember' and 'isLegacy'
* @public
*/
export declare function createStore(middlewares?: Array<ReturnType<typeof buildMiddleware> | ReduxMiddleware>, initialState?: Partial<Store>): ReduxStore<AppBridgeStore, import("redux").AnyAction> & {
dispatch: {};
};
/**
* Creates a method that when called, dynamically adds a reducer to
* the provided store
* @internal
* @param store - a Redux store
* @param globalInitialState - custom overrides for resolving the app state when adding a new reducer
* */
export declare function createAddReducer(store: ReduxStore, globalInitialState?: Partial<Store>): <State>({ key, reducer, initialState }: ReducerMap<State>) => void;
export {};