@shopify/app-bridge-host
Version:
App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se
37 lines (36 loc) • 1.59 kB
TypeScript
import type { Store } from './store';
import { feature as navigationFeature } from './store/reducers/embeddedApp/navigation';
import { feature as contextualSaveBarFeature } from './store/reducers/embeddedApp/contextualSaveBar';
import { feature as pickerFeature } from './store/reducers/embeddedApp/picker';
import { feature as titleBarFeature } from './store/reducers/embeddedApp/titleBar';
import type { SessionTokenFeature } from './features/sessionToken';
import { feature as toastFeature } from './store/reducers/embeddedApp/toast';
export interface ClientApi {
navigation: ReturnType<typeof navigationFeature.getApi>;
contextualSaveBar: ReturnType<typeof contextualSaveBarFeature.getApi>;
unstablePicker: ReturnType<typeof pickerFeature.getApi>;
titleBar: ReturnType<typeof titleBarFeature.getApi>;
sessionToken: ReturnType<SessionTokenFeature['getApi']>;
toast: ReturnType<typeof toastFeature.getApi>;
}
type Intersection<A, B> = {
[P in keyof A & keyof B]: A[P] | B[P];
};
export type ClientApiKeys = keyof Intersection<Store, ClientApi>;
export interface ProxyResolver {
<Api>(api: Api): boolean;
}
export interface ApiProxy {
[key: string]: ProxyWithQueue;
}
export type ProxyWithQueue = {
[key in typeof RESOLVE_QUEUE_KEY]: ProxyResolver;
};
export interface ApiContext {
readonly api: ClientApi;
resolveApi: (proxyApi: ApiProxy) => void;
setApi: (key: ClientApiKeys, newApi: any) => Promise<void>;
}
export declare const RESOLVE_QUEUE_KEY = "__resolveQueue";
export declare function createApiContext(): ApiContext;
export {};