@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
73 lines (70 loc) • 2.01 kB
JavaScript
import { __assign } from 'tslib';
var API_CLIENT_LOAD = 'APICLIENT::LOAD';
var API_CLIENT_UNLOAD = 'APICLIENT::UNLOAD';
var REDUCER_LOAD = 'REDUCER::LOAD';
var REDUCER_LOAD_COMPLETE = 'REDUCER::LOAD_COMPLETE';
function apiClientLoad(payload) {
return {
payload: payload,
type: API_CLIENT_LOAD,
};
}
function apiClientUnload(payload) {
return {
payload: payload,
type: API_CLIENT_UNLOAD,
};
}
/**
* Creates an load reducer action
* @internal
*/
function hostLoadReducer(feature) {
return {
payload: {
feature: feature,
},
type: REDUCER_LOAD,
};
}
/**
* Creates an add reducer action
* @internal
*/
function hostLoadCompleteReducer(feature) {
return {
payload: {
feature: feature,
},
type: REDUCER_LOAD_COMPLETE,
};
}
/**
* Predicate to determine if an action is an load reducer action
* @internal
*/
function isLoadReducerAction(action) {
return (action instanceof Object &&
action.type === REDUCER_LOAD &&
action.payload &&
typeof action.payload.feature === 'string');
}
/**
* Predicate to determine if an action is an load reducer complete action
* @internal
*/
function isLoadReducerCompleteAction(action) {
return (action instanceof Object &&
action.type === REDUCER_LOAD_COMPLETE &&
action.payload &&
typeof action.payload.feature === 'string');
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
var packageJson = require('./package.json');
function actionWrapper(action) {
return __assign(__assign({}, action), { version: packageJson.version, clientInterface: {
name: packageJson.name,
version: packageJson.version,
} });
}
export { API_CLIENT_LOAD, API_CLIENT_UNLOAD, REDUCER_LOAD, REDUCER_LOAD_COMPLETE, actionWrapper, apiClientLoad, apiClientUnload, hostLoadCompleteReducer, hostLoadReducer, isLoadReducerAction, isLoadReducerCompleteAction };