@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
30 lines (25 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var validator = require('@shopify/app-bridge-core/actions/validator');
var actions = require('../../../../actions.js');
var store = require('../store.js');
var combinedReducers = store.getReducers();
function isPrivateAppAction(action) {
return (Boolean(action) &&
Boolean(action.type) &&
(action.type.indexOf('PRIVATE_APP::') === 0 || action.type === actions.API_CLIENT_LOAD));
}
function appBridgeReducer(state, action) {
if (state === void 0) { state = store.defaultStore; }
var appBridgeAction = validator.isAppBridgeAction(action);
if (appBridgeAction || isPrivateAppAction(action)) {
if (appBridgeAction) {
window.postMessage(JSON.stringify(action), '*');
}
return tslib.__assign(tslib.__assign({}, state), combinedReducers(state, action));
}
return state;
}
exports.default = appBridgeReducer;
exports.isPrivateAppAction = isPrivateAppAction;