@tef-novum/webview-bridge
Advanced tools
Comparing version 1.3.0 to 1.3.1
# CHANGELOG | ||
## v.1.3.1 - 2019-03-05 | ||
- Remove visibility from navigation bar options | ||
## v.1.3.0 - 2019-02-27 | ||
@@ -4,0 +8,0 @@ |
@@ -12,4 +12,3 @@ export declare const attachToEmail: ({ url, subject, fileName, recipient, body, }: { | ||
export declare const setWebViewTitle: (title: string) => Promise<void>; | ||
export declare const updateNavigationBar: ({ visible, title, showBackButton, showReloadButton, backgroundColor, }: { | ||
visible?: boolean | undefined; | ||
export declare const updateNavigationBar: ({ title, showBackButton, showReloadButton, backgroundColor, }: { | ||
title?: string | undefined; | ||
@@ -16,0 +15,0 @@ showBackButton?: boolean | undefined; |
@@ -197,3 +197,3 @@ define(['exports'], function (exports) { 'use strict'; | ||
var updateNavigationBar = function (_a) { | ||
var visible = _a.visible, title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
if (isWebViewBridgeAvailable()) { | ||
@@ -203,3 +203,2 @@ return postMessageToNativeApp({ | ||
payload: { | ||
visible: visible, | ||
title: title, | ||
@@ -206,0 +205,0 @@ showBackButton: showBackButton, |
@@ -199,3 +199,3 @@ 'use strict'; | ||
var updateNavigationBar = function (_a) { | ||
var visible = _a.visible, title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
if (isWebViewBridgeAvailable()) { | ||
@@ -205,3 +205,2 @@ return postMessageToNativeApp({ | ||
payload: { | ||
visible: visible, | ||
title: title, | ||
@@ -208,0 +207,0 @@ showBackButton: showBackButton, |
@@ -198,3 +198,3 @@ var webviewBridge = (function (exports) { | ||
var updateNavigationBar = function (_a) { | ||
var visible = _a.visible, title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
if (isWebViewBridgeAvailable()) { | ||
@@ -204,3 +204,2 @@ return postMessageToNativeApp({ | ||
payload: { | ||
visible: visible, | ||
title: title, | ||
@@ -207,0 +206,0 @@ showBackButton: showBackButton, |
@@ -1,1 +0,1 @@ | ||
var webviewBridge=function(e){"use strict";var n=1,t=function(){return""+n++},r="__tuenti_webview_bridge",o=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return o()||i()},c=function(e,n){var r=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var m=JSON.stringify({type:r,id:c,payload:l});return setTimeout(function(){d(m)}),new Promise(function(e,t){var o=!1,i=function(n){n.id!==c||o||(n.type===r?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+r}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){o=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[r]=window[r]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};var m,f=function(e){var n=e.onAndroid,t=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15};return e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,r=e.acceptText,o=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,r=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:r}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,r=e.buttonText,o=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:r,type:o}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,r=e.fileName,o=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:r,recipient:o,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.visible,t=e.title,r=e.showBackButton,o=e.showReloadButton,i=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{visible:n,title:t,showBackButton:r,showReloadButton:o,backgroundColor:i}}):(void 0!==t&&(document.title=t),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,r=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:r}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,r=e.label,o=e.value,i=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&(t[r[o]]=e[r[o]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;r||(r="null_label"),o||(o=0);var s=d({eventCategory:n,eventAction:t,eventLabel:r,eventValue:o},i);return f({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,r=e.variable,o=e.value,i=e.label;if(!t||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:r,value:o}),Promise.resolve();var a={timingCategory:t,timingVar:r,timingValue:o,timingLabel:i},s=t;return f({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(o),t),a))})}})},e.setScreenName=function(e,n){return e?f({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==m?(m=o,t(function(){t.getAll().forEach(function(e){e.set("page",o),e.send("pageView",d({},n,{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),f({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var r,o=v[e];return o?(t("set",((r={})["dimension"+o]=String(n),r)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,e}({}); | ||
var webviewBridge=function(e){"use strict";var n=1,t=function(){return""+n++},r="__tuenti_webview_bridge",o=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return o()||i()},c=function(e,n){var r=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var m=JSON.stringify({type:r,id:c,payload:l});return setTimeout(function(){d(m)}),new Promise(function(e,t){var o=!1,i=function(n){n.id!==c||o||(n.type===r?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+r}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){o=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[r]=window[r]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};var m,f=function(e){var n=e.onAndroid,t=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15};return e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,r=e.acceptText,o=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,r=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:r}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,r=e.buttonText,o=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:r,type:o}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,r=e.fileName,o=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:r,recipient:o,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.title,t=e.showBackButton,r=e.showReloadButton,o=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{title:n,showBackButton:t,showReloadButton:r,backgroundColor:o}}):(void 0!==n&&(document.title=n),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,r=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:r}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,r=e.label,o=e.value,i=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&(t[r[o]]=e[r[o]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;r||(r="null_label"),o||(o=0);var s=d({eventCategory:n,eventAction:t,eventLabel:r,eventValue:o},i);return f({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,r=e.variable,o=e.value,i=e.label;if(!t||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:r,value:o}),Promise.resolve();var a={timingCategory:t,timingVar:r,timingValue:o,timingLabel:i},s=t;return f({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(o),t),a))})}})},e.setScreenName=function(e,n){return e?f({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==m?(m=o,t(function(){t.getAll().forEach(function(e){e.set("page",o),e.send("pageView",d({},n,{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),f({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var r,o=v[e];return o?(t("set",((r={})["dimension"+o]=String(n),r)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,e}({}); |
@@ -201,3 +201,3 @@ (function (global, factory) { | ||
var updateNavigationBar = function (_a) { | ||
var visible = _a.visible, title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
if (isWebViewBridgeAvailable()) { | ||
@@ -207,3 +207,2 @@ return postMessageToNativeApp({ | ||
payload: { | ||
visible: visible, | ||
title: title, | ||
@@ -210,0 +209,0 @@ showBackButton: showBackButton, |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return""+n++},o="__tuenti_webview_bridge",r=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return r()||i()},c=function(e,n){var o=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var f=JSON.stringify({type:o,id:c,payload:l});return setTimeout(function(){d(f)}),new Promise(function(e,t){var r=!1,i=function(n){n.id!==c||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+o}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){r=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};var f,m=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?o(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15};e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.visible,t=e.title,o=e.showBackButton,r=e.showReloadButton,i=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{visible:n,title:t,showBackButton:o,showReloadButton:r,backgroundColor:i}}):(void 0!==t&&(document.title=t),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,o=e.label,r=e.value,i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&(t[o[r]]=e[o[r]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;o||(o="null_label"),r||(r=0);var s=d({eventCategory:n,eventAction:t,eventLabel:o,eventValue:r},i);return m({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,o=e.variable,r=e.value,i=e.label;if(!t||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:o,value:r}),Promise.resolve();var a={timingCategory:t,timingVar:o,timingValue:r,timingLabel:i},s=t;return m({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(r),t),a))})}})},e.setScreenName=function(e,n){return e?m({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(o){var r=e.startsWith("/")?e:"/"+e;r!==f?(f=r,t(function(){t.getAll().forEach(function(e){e.set("page",r),e.send("pageView",d({},n,{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),m({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var o,r=v[e];return r?(t("set",((o={})["dimension"+r]=String(n),o)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return""+n++},o="__tuenti_webview_bridge",r=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return r()||i()},c=function(e,n){var o=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var f=JSON.stringify({type:o,id:c,payload:l});return setTimeout(function(){d(f)}),new Promise(function(e,t){var r=!1,i=function(n){n.id!==c||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+o}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){r=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};var f,m=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?o(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15};e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.title,t=e.showBackButton,o=e.showReloadButton,r=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{title:n,showBackButton:t,showReloadButton:o,backgroundColor:r}}):(void 0!==n&&(document.title=n),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,o=e.label,r=e.value,i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&(t[o[r]]=e[o[r]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;o||(o="null_label"),r||(r=0);var s=d({eventCategory:n,eventAction:t,eventLabel:o,eventValue:r},i);return m({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,o=e.variable,r=e.value,i=e.label;if(!t||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:o,value:r}),Promise.resolve();var a={timingCategory:t,timingVar:o,timingValue:r,timingLabel:i},s=t;return m({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(r),t),a))})}})},e.setScreenName=function(e,n){return e?m({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(o){var r=e.startsWith("/")?e:"/"+e;r!==f?(f=r,t(function(){t.getAll().forEach(function(e){e.set("page",r),e.send("pageView",d({},n,{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),m({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var o,r=v[e];return r?(t("set",((o={})["dimension"+r]=String(n),o)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "JavaScript library to access to native functionality. Requires a webview with a postMessage bridge.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/webview-bridge-cjs.js", |
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
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
2091856
2611