@bloomreach/navapp-communication
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -27,3 +27,3 @@ /** | ||
/** | ||
* A required string to whitelist the parent origin to form a connection with. | ||
* A required string to allow the parent origin to form a connection with. | ||
*/ | ||
@@ -62,3 +62,4 @@ parentOrigin: string; | ||
language: string; | ||
/** The time zone the user specified at login. Where applicable, the app should display its date fields using that time zone. | ||
/** The time zone the user specified at login. | ||
* Where applicable, the app should display its date fields using that time zone. | ||
* Format: TZ database names in the form "Area/Location", e.g. "America/New_York" as specified by the TZDB group. | ||
@@ -72,2 +73,6 @@ * See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones from more examples. | ||
accountId: string; | ||
/** | ||
* True if user has 'xm.channel.admin' user role. | ||
*/ | ||
channelAdmin: boolean; | ||
} | ||
@@ -95,4 +100,4 @@ interface ChildConfig { | ||
/** | ||
* Is called by an application to perform internal or cross-app navigation. It **does** trigger the nav-app to perform a | ||
* ‘beforeNavigation’ and ‘navigate’ to route to the provided location. | ||
* Is called by an application to perform internal or cross-app navigation. | ||
* It **does** trigger the nav-app to perform a ‘beforeNavigation’ and ‘navigate’ to route to the provided location. | ||
* **Do not set locations to other applications for navigation ** | ||
@@ -117,4 +122,4 @@ * @param location The NavLocation navigated to | ||
/** | ||
* Is called by an application when it needs to show the busy indicator to indicate the user has to wait until the application has | ||
* changed its ui state. | ||
* Is called by an application when it needs to show the busy indicator to indicate | ||
* the user has to wait until the application has changed its ui state. | ||
* For each call to the application should make a @{link {ParentApi.hideBusyIndicator}} call. | ||
@@ -124,3 +129,4 @@ */ | ||
/** | ||
* Is called by an application when it needs to hide the busy indicator to indicate the user can interact with the application again | ||
* Is called by an application when it needs to hide the busy indicator to indicate | ||
* the user can interact with the application again. | ||
* For each call to the application should make a @{link {ParentApi.showBusyIndicator}} call. | ||
@@ -196,3 +202,4 @@ */ | ||
* @param location the NavLocation to navigate to | ||
* @param triggeredBy The source of the navigate call so the client app is able to react appropriately on a specific source | ||
* @param triggeredBy The source of the navigate call so the client app is able to react | ||
* appropriately on a specific source | ||
*/ | ||
@@ -352,3 +359,4 @@ navigate?: (location: NavLocation, triggeredBy: NavigationTrigger) => Promise<void>; | ||
* @param connectionTimeout The time in ms after which an error will be thrown if the child has failed to connect | ||
* @param methodInvocationTimeout The time in ms after which an error will be thrown if a method doesn't return a response | ||
* @param methodInvocationTimeout The time in ms after which an error will be thrown | ||
* if a method doesn't return a response | ||
*/ | ||
@@ -363,3 +371,3 @@ declare function connectToChild({ iframe, methods, connectionTimeout, methodInvocationTimeout, }: ChildConnectConfig): Promise<ChildApi>; | ||
*/ | ||
declare function connectToParent({ parentOrigin, methods, }: ParentConnectConfig): Promise<ParentApi>; | ||
declare function connectToParent({ parentOrigin, methods }: ParentConnectConfig): Promise<ParentApi>; | ||
@@ -366,0 +374,0 @@ declare function getVersion(): string; |
import Penpal from 'penpal'; | ||
/* | ||
* Copyright 2019-2021 BloomReach. All rights reserved. (https://www.bloomreach.com/) | ||
* Copyright 2019-2022 Bloomreach. All rights reserved. (https://www.bloomreach.com/) | ||
* | ||
@@ -92,4 +92,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
*/ | ||
const wrapMethod = (method, methodName, timeout) => (...args) => new Promise(async (resolve, reject) => { | ||
const wrapMethod = (method, methodName, timeout) => (...args) => | ||
// eslint-disable-next-line no-async-promise-executor | ||
new Promise(async (resolve, reject) => { | ||
const timer = setTimeout(() => { | ||
// eslint-disable-next-line prefer-promise-reject-errors | ||
reject(`${methodName} call timed out`); | ||
@@ -110,7 +113,6 @@ }, timeout); | ||
} | ||
const wrappedApi = {}; | ||
for (const methodName of Object.keys(api)) { | ||
return Object.keys(api).reduce((wrappedApi, methodName) => { | ||
wrappedApi[methodName] = wrapMethod(api[methodName].bind(api), methodName, timeout); | ||
} | ||
return wrappedApi; | ||
return wrappedApi; | ||
}, {}); | ||
} | ||
@@ -134,3 +136,3 @@ | ||
const wrapChildMethodsWithTimeout = (methods, timeout) => { | ||
const beforeNavigation = methods.beforeNavigation; | ||
const { beforeNavigation } = methods; | ||
delete methods.beforeNavigation; | ||
@@ -148,3 +150,4 @@ const wrappedMethods = wrapWithTimeout(methods, timeout); | ||
* @param connectionTimeout The time in ms after which an error will be thrown if the child has failed to connect | ||
* @param methodInvocationTimeout The time in ms after which an error will be thrown if a method doesn't return a response | ||
* @param methodInvocationTimeout The time in ms after which an error will be thrown | ||
* if a method doesn't return a response | ||
*/ | ||
@@ -177,7 +180,7 @@ async function connectToChild({ iframe, methods, connectionTimeout, methodInvocationTimeout, }) { | ||
*/ | ||
async function connectToParent({ parentOrigin, methods, }) { | ||
async function connectToParent({ parentOrigin, methods }) { | ||
return Penpal.connectToParent({ parentOrigin, methods }).promise; | ||
} | ||
var version="3.1.0"; | ||
var version="3.2.0"; | ||
@@ -184,0 +187,0 @@ /* |
@@ -16,3 +16,3 @@ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("penpal")):"function"==typeof define&&define.amd?define(["exports","penpal"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).brNavappCommunication={},e.Penpal)}(this,(function(e,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t,o,i=r(n); | ||
***************************************************************************** */ | ||
function a(e,n,r,t){return new(r||(r=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function u(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,u)}c((t=t.apply(e,n||[])).next())}))}function u(e,n){var r,t,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,t&&(o=2&i[0]?t.return:i[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,i[1])).done)return o;switch(t=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,t=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],t=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}e.ClientErrorCodes=void 0,(t=e.ClientErrorCodes||(e.ClientErrorCodes={}))[t.UnknownError=0]="UnknownError",t[t.GenericCommunicationError=1]="GenericCommunicationError",t[t.NotAuthorizedError=403]="NotAuthorizedError",t[t.PageNotFoundError=404]="PageNotFoundError",t[t.InternalError=500]="InternalError",t[t.UnableToConnectToServerError=501]="UnableToConnectToServerError",e.NavigationTrigger=void 0,(o=e.NavigationTrigger||(e.NavigationTrigger={})).NotDefined="NotDefined",o.InitialNavigation="InitialNavigation",o.Menu="Menu",o.Breadcrumbs="Breadcrumbs",o.FastTravel="FastTravel",o.AnotherApp="AnotherApp",o.PopState="PopState";var c=function(e,n,r){return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return new Promise((function(o,i){return a(void 0,void 0,void 0,(function(){var a,c,l;return u(this,(function(u){switch(u.label){case 0:a=setTimeout((function(){i(n+" call timed out")}),r),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,e.apply(void 0,t)];case 2:return c=u.sent(),clearTimeout(a),o(c),[3,4];case 3:return l=u.sent(),i(l),[3,4];case 4:return[2]}}))}))}))}};var l=function(e,n){var r=e.beforeNavigation;delete e.beforeNavigation;var t=function(e,n){if(void 0===n&&(n=3e5),!n||n<0)return e;for(var r={},t=0,o=Object.keys(e);t<o.length;t++){var i=o[t];r[i]=c(e[i].bind(e),i,n)}return r}(e,n);return t.beforeNavigation=r,t};e.connectToChild=function(e){var n=e.iframe,r=e.methods,t=e.connectionTimeout,o=e.methodInvocationTimeout;return a(this,void 0,void 0,(function(){var e;return u(this,(function(a){switch(a.label){case 0:return[4,i.default.connectToChild({iframe:n,methods:r,timeout:t}).promise];case 1:return e=a.sent(),[2,l(e,o)]}}))}))},e.connectToParent=function(e){var n=e.parentOrigin,r=e.methods;return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,i.default.connectToParent({parentOrigin:n,methods:r}).promise]}))}))},e.getVersion=function(){return"3.1.0"},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
function a(e,n,r,t){return new(r||(r=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function u(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,u)}c((t=t.apply(e,n||[])).next())}))}function u(e,n){var r,t,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,t&&(o=2&i[0]?t.return:i[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,i[1])).done)return o;switch(t=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,t=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],t=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}e.ClientErrorCodes=void 0,(t=e.ClientErrorCodes||(e.ClientErrorCodes={}))[t.UnknownError=0]="UnknownError",t[t.GenericCommunicationError=1]="GenericCommunicationError",t[t.NotAuthorizedError=403]="NotAuthorizedError",t[t.PageNotFoundError=404]="PageNotFoundError",t[t.InternalError=500]="InternalError",t[t.UnableToConnectToServerError=501]="UnableToConnectToServerError",e.NavigationTrigger=void 0,(o=e.NavigationTrigger||(e.NavigationTrigger={})).NotDefined="NotDefined",o.InitialNavigation="InitialNavigation",o.Menu="Menu",o.Breadcrumbs="Breadcrumbs",o.FastTravel="FastTravel",o.AnotherApp="AnotherApp",o.PopState="PopState";function c(e,n){return void 0===n&&(n=3e5),!n||n<0?e:Object.keys(e).reduce((function(r,t){return r[t]=function(e,n,r){return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return new Promise((function(o,i){return a(void 0,void 0,void 0,(function(){var a,c,l;return u(this,(function(u){switch(u.label){case 0:a=setTimeout((function(){i(n+" call timed out")}),r),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,e.apply(void 0,t)];case 2:return c=u.sent(),clearTimeout(a),o(c),[3,4];case 3:return l=u.sent(),i(l),[3,4];case 4:return[2]}}))}))}))}}(e[t].bind(e),t,n),r}),{})}var l=function(e,n){var r=e.beforeNavigation;delete e.beforeNavigation;var t=c(e,n);return t.beforeNavigation=r,t};e.connectToChild=function(e){var n=e.iframe,r=e.methods,t=e.connectionTimeout,o=e.methodInvocationTimeout;return a(this,void 0,void 0,(function(){var e;return u(this,(function(a){switch(a.label){case 0:return[4,i.default.connectToChild({iframe:n,methods:r,timeout:t}).promise];case 1:return e=a.sent(),[2,l(e,o)]}}))}))},e.connectToParent=function(e){var n=e.parentOrigin,r=e.methods;return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,i.default.connectToParent({parentOrigin:n,methods:r}).promise]}))}))},e.getVersion=function(){return"3.2.0"},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@bloomreach/navapp-communication", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"main": "dist/index.umd.js", | ||
@@ -23,5 +23,7 @@ "browser": "dist/index.umd.js", | ||
"build": "rollup -c", | ||
"build:dev": "rollup -c", | ||
"docs": "typedoc", | ||
"test": "jest --coverage --watch", | ||
"test:single-run": "jest" | ||
"test:single-run": "jest", | ||
"lint": "eslint src" | ||
}, | ||
@@ -44,2 +46,3 @@ "jest": { | ||
"@babel/preset-env": "7.14.2", | ||
"@bloomreach/eslint-config-base": "1.0.4", | ||
"@rollup/plugin-babel": "5.3.0", | ||
@@ -57,3 +60,15 @@ "@rollup/plugin-json": "4.1.0", | ||
"typescript": "4.2.4" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@bloomreach/eslint-config-base", | ||
"parserOptions": { | ||
"project": [ | ||
"tsconfig.json" | ||
], | ||
"createDefaultProgram": true | ||
}, | ||
"env": { | ||
"es2020": true | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95516
585
14
1