UNPKG

@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

85 lines (81 loc) 2.33 kB
'use strict'; var tslib = require('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 tslib.__assign(tslib.__assign({}, action), { version: packageJson.version, clientInterface: { name: packageJson.name, version: packageJson.version, } }); } exports.API_CLIENT_LOAD = API_CLIENT_LOAD; exports.API_CLIENT_UNLOAD = API_CLIENT_UNLOAD; exports.REDUCER_LOAD = REDUCER_LOAD; exports.REDUCER_LOAD_COMPLETE = REDUCER_LOAD_COMPLETE; exports.actionWrapper = actionWrapper; exports.apiClientLoad = apiClientLoad; exports.apiClientUnload = apiClientUnload; exports.hostLoadCompleteReducer = hostLoadCompleteReducer; exports.hostLoadReducer = hostLoadReducer; exports.isLoadReducerAction = isLoadReducerAction; exports.isLoadReducerCompleteAction = isLoadReducerCompleteAction;