import { AnyAction, Dispatch, Unsubscribe } from '@shopify/app-bridge/actions/types'; import { Context, ContextualMessageTransport } from '@shopify/app-bridge/MessageTransport'; import { TransportSubscription, TransportDispatch } from '@shopify/app-bridge'; import { Store } from './store/async'; export declare const MessageTransportType = "application"; /** * Configuration provided by an app. */ export interface AppConfig { apiKey: string; } /** * Configuration for an app. */ export interface PrivilegedAppConfig extends AppConfig { apiClientId?: string; appId: string; name: string; shopId: string; url: string; handle: string; } export declare type ApiClientConfig = PrivilegedAppConfig; /** * Interface for interacting with a loaded application. An application may have * many transports for communication (e.g. multiple frames). */ export interface Application { /** * Attach a transport to an application. * @returns a method that can be called to detach the transport */ attach(to: ContextualMessageTransport): (unload?: boolean) => void; /** * Dispatch an action on all transports for an application. * * @todo Add option to dispatch directly to a given transport */ dispatch(action: AnyAction): void; /** * Get the current state of an application. * * @todo Filter once application state structure is finalised */ getState(): any; /** * Subscribe to all actions from an application on all transports. */ subscribe(listener: (message: TransportDispatch) => void): () => void; /** * Returns true if an action is subcribed for a specific transport context */ isTransportSubscribed(context: Context, type: string, id?: string): boolean; } export interface LoadData { type: typeof MessageTransportType; config: ApiClientConfig; } export interface MiddlewareAPI { dispatch: Dispatch; getState(): S; } /** * Build middleware, binding it to a given Redux Store. The returned middleware * will be responsible for loading application instances. */ export interface Middleware { load(data: LoadData): Application; (api: MiddlewareAPI): (next: Dispatch) => Dispatch; } export declare type Reducer = (state: S, action: AnyAction) => S; export interface Store { dispatch: Dispatch; getState(): S; subscribe(listener: () => void): Unsubscribe; replaceReducer(nextReducer: Reducer): void; } export interface Subscription { [key: string]: TransportSubscription[] | undefined; } export declare type Subscriptions = { [key in Context]: Subscription; }; export { AnyAction, Dispatch }; export interface TrackingEventPayload { action: AnyAction; appId: string; shopId: string; } /** * A union of all dynamic keys in the app store * @public */ export declare type HostFeatures = keyof Store; /** * The interface for the host's components * @public * */ export interface ComponentProps { globalStore: Store; }