@shopgate/pwa-common 7.23.6 → 7.23.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,9 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
2
2
  * The MediaProvider base class.
3
3
  */var MediaProvider=/*#__PURE__*/function(){/**
4
4
  * Constructor.
5
- */function MediaProvider(){_classCallCheck(this,MediaProvider);this.containers=new Map();this.isPending=false;this.remoteScriptUrl=null;}/**
5
+ * @param {Object} options The provider options.
6
+ * @param {boolean} [options.responsify=true] Whether to responsify the video containers.
7
+ */function MediaProvider(options){var _ref;_classCallCheck(this,MediaProvider);this.containers=new Map();this.isPending=false;this.remoteScriptUrl=null;this.options={responsify:(_ref=options===null||options===void 0?void 0:options.responsify)!==null&&_ref!==void 0?_ref:true};}/**
6
8
  * Callback for when Provider script is loaded
7
9
  * @callback
8
10
  * @abstract
@@ -14,7 +16,8 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
14
16
  * Optimizes video container to make it responsive.
15
17
  * @param {Element} container A DOM container.
16
18
  * @returns {MediaProvider}
17
- */},{key:"responsify",value:function responsify(container){// Remove fixed dimensions from the container.
19
+ */},{key:"responsify",value:function responsify(container){// Do not proceed when video responsify is disabled.
20
+ if(!this.options.responsify)return this;// Remove fixed dimensions from the container.
18
21
  container.removeAttribute('height');container.removeAttribute('width');if(isRelativePosition(container.parentNode)&&isAbsolutePosition(container)){// Assume responsive embed code
19
22
  container.parentNode.removeAttribute('style');}// Create the wrapper and apply styling.
20
23
  var wrapper=document.createElement('div');wrapper.className=styles.responsiveContainer;// Add the wrapper right before the container into the DOM.
@@ -2,7 +2,9 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
2
2
  * The Vimeo media provider class.
3
3
  */var VimeoMediaProvider=/*#__PURE__*/function(_MediaProvider){/**
4
4
  * Constructor.
5
- */function VimeoMediaProvider(){var _this2;_classCallCheck(this,VimeoMediaProvider);_this2=_callSuper(this,VimeoMediaProvider);// Need to check Vimeo.Player presence later
5
+ * @param {Object} options The provider options.
6
+ * @param {boolean} [options.responsify=true] Whether to responsify the video containers.
7
+ */function VimeoMediaProvider(options){var _this2;_classCallCheck(this,VimeoMediaProvider);_this2=_callSuper(this,VimeoMediaProvider,[options]);// Need to check Vimeo.Player presence later
6
8
  _this2.isPending=true;_this2.remoteScriptUrl=scriptUrl;_this2.deferred=[];return _this2;}/**
7
9
  * Retrieves a list of media containers for Vimeo.
8
10
  * @param {ParentNode} container A DOM container that may contain Vimeo iframes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.23.6",
3
+ "version": "7.23.7",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@redux-devtools/extension": "^3.3.0",
19
19
  "@sentry/browser": "6.0.1",
20
- "@shopgate/pwa-benchmark": "7.23.6",
20
+ "@shopgate/pwa-benchmark": "7.23.7",
21
21
  "@virtuous/conductor": "~2.5.0",
22
22
  "@virtuous/react-conductor": "~2.5.0",
23
23
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -43,7 +43,7 @@
43
43
  "url-search-params": "^0.10.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@shopgate/pwa-core": "7.23.6",
46
+ "@shopgate/pwa-core": "7.23.7",
47
47
  "@types/react-portal": "^3.0.9",
48
48
  "lodash": "^4.17.4",
49
49
  "prop-types": "~15.8.1",
@@ -1,8 +1,8 @@
1
- import{event,emitter as errorEmitter,registerEvents,closeInAppBrowser,onload}from'@shopgate/pwa-core';import{EVENT_KEYBOARD_WILL_CHANGE,APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_DID_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR,APP_EVENT_VIEW_DID_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import{SOURCE_APP,SOURCE_PIPELINE}from'@shopgate/pwa-core/constants/ErrorManager';import pipelineManager from'@shopgate/pwa-core/classes/PipelineManager';import*as errorCodes from'@shopgate/pwa-core/constants/Pipeline';import{onWillPush,onDidPush,onWillPop,onDidPop,onWillReplace,onDidReplace,onWillReset,onDidReset,onUpdate}from'@virtuous/conductor';import{UI_VISIBILITY_CHANGE}from"../constants/ui";import{appError,pipelineError,pwaDidAppear,pwaDidDisappear}from"../action-creators";import{historyPush,routeWillPush,routeDidPush,routeWillPop,routeDidPop,routeWillReplace,routeDidReplace,routeWillReset,routeDidReset,routeDidUpdate}from"../actions/router";import{receiveClientConnectivity}from"../action-creators/client";import{appWillStart$,appDidStart$,clientInformationDidUpdate$,navigate$}from"../streams";import registerLinkEvents from"../actions/app/registerLinkEvents";import{APP_PLATFORM}from"../constants/Configuration";import{getPlatform,isAndroid}from"../selectors/client";import{prepareLegacyNavigation,showPreviousTab,pageContext}from"../helpers/legacy";import{embeddedMedia,configuration}from"../collections";import{Vimeo,YouTube}from"../collections/media-providers";import clearUpInAppBrowser from"./helpers/clearUpInAppBrowser";/**
1
+ import{event,emitter as errorEmitter,registerEvents,closeInAppBrowser,onload}from'@shopgate/pwa-core';import{EVENT_KEYBOARD_WILL_CHANGE,APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_DID_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR,APP_EVENT_VIEW_DID_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import{SOURCE_APP,SOURCE_PIPELINE}from'@shopgate/pwa-core/constants/ErrorManager';import pipelineManager from'@shopgate/pwa-core/classes/PipelineManager';import*as errorCodes from'@shopgate/pwa-core/constants/Pipeline';import{onWillPush,onDidPush,onWillPop,onDidPop,onWillReplace,onDidReplace,onWillReset,onDidReset,onUpdate}from'@virtuous/conductor';import{appConfig}from'@shopgate/engage';import{UI_VISIBILITY_CHANGE}from"../constants/ui";import{appError,pipelineError,pwaDidAppear,pwaDidDisappear}from"../action-creators";import{historyPush,routeWillPush,routeDidPush,routeWillPop,routeDidPop,routeWillReplace,routeDidReplace,routeWillReset,routeDidReset,routeDidUpdate}from"../actions/router";import{receiveClientConnectivity}from"../action-creators/client";import{appWillStart$,appDidStart$,clientInformationDidUpdate$,navigate$}from"../streams";import registerLinkEvents from"../actions/app/registerLinkEvents";import{APP_PLATFORM}from"../constants/Configuration";import{getPlatform,isAndroid}from"../selectors/client";import{prepareLegacyNavigation,showPreviousTab,pageContext}from"../helpers/legacy";import{embeddedMedia,configuration}from"../collections";import{Vimeo,YouTube}from"../collections/media-providers";import clearUpInAppBrowser from"./helpers/clearUpInAppBrowser";/**
2
2
  * App subscriptions.
3
3
  * @param {Function} subscribe The subscribe function.
4
4
  */export default function app(subscribe){// Gets triggered before the app starts.
5
- subscribe(appWillStart$,function(_ref){var dispatch=_ref.dispatch,action=_ref.action,getState=_ref.getState,events=_ref.events;embeddedMedia.addProvider(new Vimeo());embeddedMedia.addProvider(new YouTube());dispatch(registerLinkEvents(action.location));onWillPush(function(_ref2){var prev=_ref2.prev,next=_ref2.next;return dispatch(routeWillPush(prev,next));});onDidPush(function(_ref3){var prev=_ref3.prev,next=_ref3.next;return dispatch(routeDidPush(prev,next));});onWillPop(function(_ref4){var prev=_ref4.prev,next=_ref4.next;return dispatch(routeWillPop(prev,next));});onDidPop(function(_ref5){var prev=_ref5.prev,next=_ref5.next;return dispatch(routeDidPop(prev,next));});onWillReplace(function(_ref6){var prev=_ref6.prev,next=_ref6.next;return dispatch(routeWillReplace(prev,next));});onDidReplace(function(_ref7){var prev=_ref7.prev,next=_ref7.next;return dispatch(routeDidReplace(prev,next));});onWillReset(function(_ref8){var prev=_ref8.prev,next=_ref8.next;return dispatch(routeWillReset(prev,next));});onDidReset(function(_ref9){var prev=_ref9.prev,next=_ref9.next;return dispatch(routeDidReset(prev,next));});onUpdate(function(updated){return dispatch(routeDidUpdate(updated));});// Suppress errors globally
5
+ subscribe(appWillStart$,function(_ref){var _appConfig$responsify,_appConfig$responsify2;var dispatch=_ref.dispatch,action=_ref.action,getState=_ref.getState,events=_ref.events;embeddedMedia.addProvider(new Vimeo({responsify:appConfig===null||appConfig===void 0?void 0:(_appConfig$responsify=appConfig.responsifyVideos)===null||_appConfig$responsify===void 0?void 0:_appConfig$responsify.vimeo}));embeddedMedia.addProvider(new YouTube({responsify:appConfig===null||appConfig===void 0?void 0:(_appConfig$responsify2=appConfig.responsifyVideos)===null||_appConfig$responsify2===void 0?void 0:_appConfig$responsify2.youTube}));dispatch(registerLinkEvents(action.location));onWillPush(function(_ref2){var prev=_ref2.prev,next=_ref2.next;return dispatch(routeWillPush(prev,next));});onDidPush(function(_ref3){var prev=_ref3.prev,next=_ref3.next;return dispatch(routeDidPush(prev,next));});onWillPop(function(_ref4){var prev=_ref4.prev,next=_ref4.next;return dispatch(routeWillPop(prev,next));});onDidPop(function(_ref5){var prev=_ref5.prev,next=_ref5.next;return dispatch(routeDidPop(prev,next));});onWillReplace(function(_ref6){var prev=_ref6.prev,next=_ref6.next;return dispatch(routeWillReplace(prev,next));});onDidReplace(function(_ref7){var prev=_ref7.prev,next=_ref7.next;return dispatch(routeDidReplace(prev,next));});onWillReset(function(_ref8){var prev=_ref8.prev,next=_ref8.next;return dispatch(routeWillReset(prev,next));});onDidReset(function(_ref9){var prev=_ref9.prev,next=_ref9.next;return dispatch(routeDidReset(prev,next));});onUpdate(function(updated){return dispatch(routeDidUpdate(updated));});// Suppress errors globally
6
6
  pipelineManager.addSuppressedErrors([errorCodes.EACCESS,errorCodes.ENOTFOUND,errorCodes.EVALIDATION]);// Map the error events into the Observable streams.
7
7
  errorEmitter.addListener(SOURCE_APP,function(error){return dispatch(appError(error));});errorEmitter.addListener(SOURCE_PIPELINE,function(error){return dispatch(pipelineError(error));});/** @returns {*} */var viewVisibility=function viewVisibility(){return events.emit(UI_VISIBILITY_CHANGE);};event.addCallback('routeDidChange',viewVisibility);event.addCallback(APP_EVENT_VIEW_DID_DISAPPEAR,function(){dispatch(pwaDidDisappear());viewVisibility();});event.addCallback(APP_EVENT_VIEW_DID_APPEAR,function(){dispatch(pwaDidAppear());clearUpInAppBrowser(isAndroid(getState()));});});/**
8
8
  * Gets triggered when the app starts.