@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
25 lines (22 loc) • 934 B
JavaScript
import { __assign } from 'tslib';
import { isAppBridgeAction } from '@shopify/app-bridge-core/actions/validator';
import { API_CLIENT_LOAD } from '../../../../actions.js';
import { getReducers, defaultStore } from '../store.js';
var combinedReducers = getReducers();
function isPrivateAppAction(action) {
return (Boolean(action) &&
Boolean(action.type) &&
(action.type.indexOf('PRIVATE_APP::') === 0 || action.type === API_CLIENT_LOAD));
}
function appBridgeReducer(state, action) {
if (state === void 0) { state = defaultStore; }
var appBridgeAction = isAppBridgeAction(action);
if (appBridgeAction || isPrivateAppAction(action)) {
if (appBridgeAction) {
window.postMessage(JSON.stringify(action), '*');
}
return __assign(__assign({}, state), combinedReducers(state, action));
}
return state;
}
export { appBridgeReducer as default, isPrivateAppAction };