@tef-novum/webview-bridge
Advanced tools
Comparing version 2.3.2 to 2.3.3
# CHANGELOG | ||
## v.2.3.3 - 2019-10-02 | ||
- Update setWebViewTitle implementation | ||
## v.2.3.2 - 2019-10-02 | ||
@@ -4,0 +8,0 @@ |
@@ -16,6 +16,2 @@ export declare const attachToEmail: ({ url, subject, fileName, recipient, body, }: { | ||
export declare const share: (options: ShareOptions) => Promise<void>; | ||
/** | ||
* @deprecated | ||
*/ | ||
export declare const setWebViewTitle: (title: string) => Promise<void>; | ||
export declare const updateNavigationBar: ({ title, showBackButton, showReloadButton, backgroundColor, }: { | ||
@@ -27,2 +23,6 @@ title?: string | undefined; | ||
}) => Promise<void>; | ||
/** | ||
* @deprecated | ||
*/ | ||
export declare const setWebViewTitle: (title: string) => Promise<void>; | ||
export declare const notifyPageLoaded: () => Promise<void>; | ||
@@ -29,0 +29,0 @@ export declare const isABTestingAvailable: (key: string) => Promise<boolean>; |
@@ -213,14 +213,2 @@ define(['exports'], function (exports) { 'use strict'; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ type: 'SET_TITLE', payload: { title: title } }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var updateNavigationBar = function (_a) { | ||
@@ -246,2 +234,14 @@ var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return updateNavigationBar({ title: title }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var notifyPageLoaded = function () { | ||
@@ -248,0 +248,0 @@ return postMessageToNativeApp({ type: 'PAGE_LOADED' }); |
@@ -215,14 +215,2 @@ 'use strict'; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ type: 'SET_TITLE', payload: { title: title } }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var updateNavigationBar = function (_a) { | ||
@@ -248,2 +236,14 @@ var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return updateNavigationBar({ title: title }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var notifyPageLoaded = function () { | ||
@@ -250,0 +250,0 @@ return postMessageToNativeApp({ type: 'PAGE_LOADED' }); |
@@ -214,14 +214,2 @@ var webviewBridge = (function (exports) { | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ type: 'SET_TITLE', payload: { title: title } }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var updateNavigationBar = function (_a) { | ||
@@ -247,2 +235,14 @@ var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return updateNavigationBar({ title: title }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var notifyPageLoaded = function () { | ||
@@ -249,0 +249,0 @@ return postMessageToNativeApp({ type: 'PAGE_LOADED' }); |
@@ -1,1 +0,1 @@ | ||
var webviewBridge=function(e){"use strict";var t=1,n=function(){return""+t++},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=function(){return o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},s=[],u=function(e){s.push(e)},c=function(e){s=s.filter(function(t){return t!==e})},l=function(){return o()||i()},d=function(e,t){var r=e.type,o=e.id,i=void 0===o?n():o,s=e.payload,l=a(),d=JSON.stringify({type:r,id:i,payload:s});return l?(setTimeout(function(){l(d)}),new Promise(function(e,n){var o=!1,a=function(t){t.id!==i||o||(t.type===r?e(t.payload):"ERROR"===t.type?n(t.payload):n({code:500,reason:"bad type: "+t.type+". Expecting "+r}),c(a))};u(a),t&&setTimeout(function(){o=!0,c(a),n({code:408,reason:"request timeout"})},t)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};window[r]=window[r]||{postMessage:function(e){var t;try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: "+e)}s.forEach(function(e){return e(t)})}};var f=null,m=function(e){return"true"===f.result[e]},v=function(e){return Math.floor(e/1e3)},p=function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var y,w=["NovumTracker","OBARGTracker"],g=function(e){return w.indexOf(e.get("name"))>=0},b=function(e){var t=e.onAndroid,n=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},T={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,webviewBrowserVersion:16};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,r=e.fileName,o=e.recipient,i=e.body;return d({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:r,recipient:o,body:i}})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,r=e.title;return d({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:v(t),endTime:v(n),title:r}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return l()?d({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.isABTestingAvailable=function(e){return f?Promise.resolve(m(e)):d({type:"GET_REMOTE_CONFIG"}).then(function(t){return f=t,m(e)})},e.isWebViewBridgeAvailable=l,e.logEvent=function(e){var t=e.category,n=e.action,r=e.label,o=e.value,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["category","action","label","value"]);if(!t||!n)return console.warn('Analytics event should have "category" and "action"',{category:t,action:n}),Promise.resolve();var a=t;r||(r="null_label"),o||(o=0);var s=p({eventCategory:t,eventAction:n,eventLabel:r,eventValue:o},i);return b({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(t){e("NovumTracker.send","event",p(p({},s),{hitCallback:t}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,r=e.variable,o=e.value,i=e.label;if(!n||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:r,value:o}),Promise.resolve();var a={timingCategory:n,timingVar:r,timingValue:o,timingLabel:i},s=n;return b({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(t){var n;e("NovumTracker.send",p(((n={hitType:"timing",hitCallback:t}).dimension8=String(o),n),a))})}})},e.nativeAlert=function(e){var t=e.message,n=e.title,r=e.buttonText;return l()?d({type:"ALERT",payload:{title:n,message:t,buttonText:r}}):(window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,r=e.acceptText,o=e.cancelText;return l()?d({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,r=e.buttonText,o=e.type;return l()?d({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,type:o}}):(window.alert(t),Promise.resolve())},e.notifyPageLoaded=function(){return d({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){var t=function(t){if("NATIVE_EVENT"===t.type){var n=e({event:t.payload.event}),r=a();r&&r(JSON.stringify({type:"NATIVE_EVENT",id:t.id,payload:{action:n.action||"default"}}))}};return u(t),function(){c(t)}},e.reportStatus=function(e){var t=e.feature,n=e.status,r=e.reason;return d({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:r}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return d({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return d({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return d({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return d({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.setScreenName=function(e,t){return e?b({onAndroid:function(t){return t.setScreenName&&t.setScreenName(e),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(n){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==y?(y=o,n(function(){n.getAll().filter(g).forEach(function(e){e.set("page",o),e.send("pageView",p(p({},t),{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,t){return e&&t?(t=String(t),b({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var r,o=T[e];return o?(n("NovumTracker.set",((r={})["dimension"+o]=String(t),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,t),Promise.resolve())},e.setWebViewTitle=function(e){return l()?d({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.share=function(e){return d({type:"SHARE",payload:e})},e.updateNavigationBar=function(e){var t=e.title,n=e.showBackButton,r=e.showReloadButton,o=e.backgroundColor;return l()?d({type:"NAVIGATION_BAR",payload:{title:t,showBackButton:n,showReloadButton:r,backgroundColor:o}}):(void 0!==t&&(document.title=t),Promise.resolve())},e}({}); | ||
var webviewBridge=function(e){"use strict";var t=1,n=function(){return""+t++},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=function(){return o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},s=[],u=function(e){s.push(e)},c=function(e){s=s.filter(function(t){return t!==e})},l=function(){return o()||i()},d=function(e,t){var r=e.type,o=e.id,i=void 0===o?n():o,s=e.payload,l=a(),d=JSON.stringify({type:r,id:i,payload:s});return l?(setTimeout(function(){l(d)}),new Promise(function(e,n){var o=!1,a=function(t){t.id!==i||o||(t.type===r?e(t.payload):"ERROR"===t.type?n(t.payload):n({code:500,reason:"bad type: "+t.type+". Expecting "+r}),c(a))};u(a),t&&setTimeout(function(){o=!0,c(a),n({code:408,reason:"request timeout"})},t)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};window[r]=window[r]||{postMessage:function(e){var t;try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: "+e)}s.forEach(function(e){return e(t)})}};var f=function(e){var t=e.title,n=e.showBackButton,r=e.showReloadButton,o=e.backgroundColor;return l()?d({type:"NAVIGATION_BAR",payload:{title:t,showBackButton:n,showReloadButton:r,backgroundColor:o}}):(void 0!==t&&(document.title=t),Promise.resolve())},m=null,v=function(e){return"true"===m.result[e]},p=function(e){return Math.floor(e/1e3)},w=function(){return(w=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var y,g=["NovumTracker","OBARGTracker"],b=function(e){return g.indexOf(e.get("name"))>=0},T=function(e){var t=e.onAndroid,n=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},E={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,webviewBrowserVersion:16};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,r=e.fileName,o=e.recipient,i=e.body;return d({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:r,recipient:o,body:i}})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,r=e.title;return d({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:p(t),endTime:p(n),title:r}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return l()?d({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.isABTestingAvailable=function(e){return m?Promise.resolve(v(e)):d({type:"GET_REMOTE_CONFIG"}).then(function(t){return m=t,v(e)})},e.isWebViewBridgeAvailable=l,e.logEvent=function(e){var t=e.category,n=e.action,r=e.label,o=e.value,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["category","action","label","value"]);if(!t||!n)return console.warn('Analytics event should have "category" and "action"',{category:t,action:n}),Promise.resolve();var a=t;r||(r="null_label"),o||(o=0);var s=w({eventCategory:t,eventAction:n,eventLabel:r,eventValue:o},i);return T({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(t){e("NovumTracker.send","event",w(w({},s),{hitCallback:t}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,r=e.variable,o=e.value,i=e.label;if(!n||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:r,value:o}),Promise.resolve();var a={timingCategory:n,timingVar:r,timingValue:o,timingLabel:i},s=n;return T({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(t){var n;e("NovumTracker.send",w(((n={hitType:"timing",hitCallback:t}).dimension8=String(o),n),a))})}})},e.nativeAlert=function(e){var t=e.message,n=e.title,r=e.buttonText;return l()?d({type:"ALERT",payload:{title:n,message:t,buttonText:r}}):(window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,r=e.acceptText,o=e.cancelText;return l()?d({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,r=e.buttonText,o=e.type;return l()?d({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,type:o}}):(window.alert(t),Promise.resolve())},e.notifyPageLoaded=function(){return d({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){var t=function(t){if("NATIVE_EVENT"===t.type){var n=e({event:t.payload.event}),r=a();r&&r(JSON.stringify({type:"NATIVE_EVENT",id:t.id,payload:{action:n.action||"default"}}))}};return u(t),function(){c(t)}},e.reportStatus=function(e){var t=e.feature,n=e.status,r=e.reason;return d({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:r}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return d({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return d({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return d({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return d({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.setScreenName=function(e,t){return e?T({onAndroid:function(t){return t.setScreenName&&t.setScreenName(e),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(n){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==y?(y=o,n(function(){n.getAll().filter(b).forEach(function(e){e.set("page",o),e.send("pageView",w(w({},t),{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,t){return e&&t?(t=String(t),T({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var r,o=E[e];return o?(n("NovumTracker.set",((r={})["dimension"+o]=String(t),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,t),Promise.resolve())},e.setWebViewTitle=function(e){return l()?f({title:e}):(document.title=e,Promise.resolve())},e.share=function(e){return d({type:"SHARE",payload:e})},e.updateNavigationBar=f,e}({}); |
@@ -217,14 +217,2 @@ (function (global, factory) { | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ type: 'SET_TITLE', payload: { title: title } }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var updateNavigationBar = function (_a) { | ||
@@ -250,2 +238,14 @@ var title = _a.title, showBackButton = _a.showBackButton, showReloadButton = _a.showReloadButton, backgroundColor = _a.backgroundColor; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
var setWebViewTitle = function (title) { | ||
if (isWebViewBridgeAvailable()) { | ||
return updateNavigationBar({ title: title }); | ||
} | ||
else { | ||
document.title = title; | ||
return Promise.resolve(); | ||
} | ||
}; | ||
var notifyPageLoaded = function () { | ||
@@ -252,0 +252,0 @@ return postMessageToNativeApp({ type: 'PAGE_LOADED' }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).webviewBridge={})}(this,function(e){"use strict";var t=1,n=function(){return""+t++},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=function(){return o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},s=[],u=function(e){s.push(e)},c=function(e){s=s.filter(function(t){return t!==e})},l=function(){return o()||i()},d=function(e,t){var r=e.type,o=e.id,i=void 0===o?n():o,s=e.payload,l=a(),d=JSON.stringify({type:r,id:i,payload:s});return l?(setTimeout(function(){l(d)}),new Promise(function(e,n){var o=!1,a=function(t){t.id!==i||o||(t.type===r?e(t.payload):"ERROR"===t.type?n(t.payload):n({code:500,reason:"bad type: "+t.type+". Expecting "+r}),c(a))};u(a),t&&setTimeout(function(){o=!0,c(a),n({code:408,reason:"request timeout"})},t)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};window[r]=window[r]||{postMessage:function(e){var t;try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: "+e)}s.forEach(function(e){return e(t)})}};var f=null,m=function(e){return"true"===f.result[e]},v=function(e){return Math.floor(e/1e3)},p=function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var y,w=["NovumTracker","OBARGTracker"],g=function(e){return w.indexOf(e.get("name"))>=0},b=function(e){var t=e.onAndroid,n=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},T={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,webviewBrowserVersion:16};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,r=e.fileName,o=e.recipient,i=e.body;return d({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:r,recipient:o,body:i}})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,r=e.title;return d({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:v(t),endTime:v(n),title:r}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return l()?d({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.isABTestingAvailable=function(e){return f?Promise.resolve(m(e)):d({type:"GET_REMOTE_CONFIG"}).then(function(t){return f=t,m(e)})},e.isWebViewBridgeAvailable=l,e.logEvent=function(e){var t=e.category,n=e.action,r=e.label,o=e.value,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["category","action","label","value"]);if(!t||!n)return console.warn('Analytics event should have "category" and "action"',{category:t,action:n}),Promise.resolve();var a=t;r||(r="null_label"),o||(o=0);var s=p({eventCategory:t,eventAction:n,eventLabel:r,eventValue:o},i);return b({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(t){e("NovumTracker.send","event",p(p({},s),{hitCallback:t}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,r=e.variable,o=e.value,i=e.label;if(!n||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:r,value:o}),Promise.resolve();var a={timingCategory:n,timingVar:r,timingValue:o,timingLabel:i},s=n;return b({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(t){var n;e("NovumTracker.send",p(((n={hitType:"timing",hitCallback:t}).dimension8=String(o),n),a))})}})},e.nativeAlert=function(e){var t=e.message,n=e.title,r=e.buttonText;return l()?d({type:"ALERT",payload:{title:n,message:t,buttonText:r}}):(window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,r=e.acceptText,o=e.cancelText;return l()?d({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,r=e.buttonText,o=e.type;return l()?d({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,type:o}}):(window.alert(t),Promise.resolve())},e.notifyPageLoaded=function(){return d({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){var t=function(t){if("NATIVE_EVENT"===t.type){var n=e({event:t.payload.event}),r=a();r&&r(JSON.stringify({type:"NATIVE_EVENT",id:t.id,payload:{action:n.action||"default"}}))}};return u(t),function(){c(t)}},e.reportStatus=function(e){var t=e.feature,n=e.status,r=e.reason;return d({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:r}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return d({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return d({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return d({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return d({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.setScreenName=function(e,t){return e?b({onAndroid:function(t){return t.setScreenName&&t.setScreenName(e),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(n){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==y?(y=o,n(function(){n.getAll().filter(g).forEach(function(e){e.set("page",o),e.send("pageView",p(p({},t),{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,t){return e&&t?(t=String(t),b({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var r,o=T[e];return o?(n("NovumTracker.set",((r={})["dimension"+o]=String(t),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,t),Promise.resolve())},e.setWebViewTitle=function(e){return l()?d({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.share=function(e){return d({type:"SHARE",payload:e})},e.updateNavigationBar=function(e){var t=e.title,n=e.showBackButton,r=e.showReloadButton,o=e.backgroundColor;return l()?d({type:"NAVIGATION_BAR",payload:{title:t,showBackButton:n,showReloadButton:r,backgroundColor:o}}):(void 0!==t&&(document.title=t),Promise.resolve())},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).webviewBridge={})}(this,function(e){"use strict";var t=1,n=function(){return""+t++},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=function(){return o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},s=[],u=function(e){s.push(e)},c=function(e){s=s.filter(function(t){return t!==e})},l=function(){return o()||i()},d=function(e,t){var r=e.type,o=e.id,i=void 0===o?n():o,s=e.payload,l=a(),d=JSON.stringify({type:r,id:i,payload:s});return l?(setTimeout(function(){l(d)}),new Promise(function(e,n){var o=!1,a=function(t){t.id!==i||o||(t.type===r?e(t.payload):"ERROR"===t.type?n(t.payload):n({code:500,reason:"bad type: "+t.type+". Expecting "+r}),c(a))};u(a),t&&setTimeout(function(){o=!0,c(a),n({code:408,reason:"request timeout"})},t)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};window[r]=window[r]||{postMessage:function(e){var t;try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: "+e)}s.forEach(function(e){return e(t)})}};var f=function(e){var t=e.title,n=e.showBackButton,r=e.showReloadButton,o=e.backgroundColor;return l()?d({type:"NAVIGATION_BAR",payload:{title:t,showBackButton:n,showReloadButton:r,backgroundColor:o}}):(void 0!==t&&(document.title=t),Promise.resolve())},m=null,v=function(e){return"true"===m.result[e]},p=function(e){return Math.floor(e/1e3)},y=function(){return(y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var w,g=["NovumTracker","OBARGTracker"],b=function(e){return g.indexOf(e.get("name"))>=0},T=function(e){var t=e.onAndroid,n=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},h={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,webviewBrowserVersion:16};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,r=e.fileName,o=e.recipient,i=e.body;return d({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:r,recipient:o,body:i}})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,r=e.title;return d({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:p(t),endTime:p(n),title:r}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return l()?d({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.isABTestingAvailable=function(e){return m?Promise.resolve(v(e)):d({type:"GET_REMOTE_CONFIG"}).then(function(t){return m=t,v(e)})},e.isWebViewBridgeAvailable=l,e.logEvent=function(e){var t=e.category,n=e.action,r=e.label,o=e.value,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["category","action","label","value"]);if(!t||!n)return console.warn('Analytics event should have "category" and "action"',{category:t,action:n}),Promise.resolve();var a=t;r||(r="null_label"),o||(o=0);var s=y({eventCategory:t,eventAction:n,eventLabel:r,eventValue:o},i);return T({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(t){e("NovumTracker.send","event",y(y({},s),{hitCallback:t}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,r=e.variable,o=e.value,i=e.label;if(!n||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:r,value:o}),Promise.resolve();var a={timingCategory:n,timingVar:r,timingValue:o,timingLabel:i},s=n;return T({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(t){var n;e("NovumTracker.send",y(((n={hitType:"timing",hitCallback:t}).dimension8=String(o),n),a))})}})},e.nativeAlert=function(e){var t=e.message,n=e.title,r=e.buttonText;return l()?d({type:"ALERT",payload:{title:n,message:t,buttonText:r}}):(window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,r=e.acceptText,o=e.cancelText;return l()?d({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,r=e.buttonText,o=e.type;return l()?d({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,type:o}}):(window.alert(t),Promise.resolve())},e.notifyPageLoaded=function(){return d({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){var t=function(t){if("NATIVE_EVENT"===t.type){var n=e({event:t.payload.event}),r=a();r&&r(JSON.stringify({type:"NATIVE_EVENT",id:t.id,payload:{action:n.action||"default"}}))}};return u(t),function(){c(t)}},e.reportStatus=function(e){var t=e.feature,n=e.status,r=e.reason;return d({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:r}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return d({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return d({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return d({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return d({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.setScreenName=function(e,t){return e?T({onAndroid:function(t){return t.setScreenName&&t.setScreenName(e),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(n){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==w?(w=o,n(function(){n.getAll().filter(b).forEach(function(e){e.set("page",o),e.send("pageView",y(y({},t),{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,t){return e&&t?(t=String(t),T({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var r,o=h[e];return o?(n("NovumTracker.set",((r={})["dimension"+o]=String(t),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,t),Promise.resolve())},e.setWebViewTitle=function(e){return l()?f({title:e}):(document.title=e,Promise.resolve())},e.share=function(e){return d({type:"SHARE",payload:e})},e.updateNavigationBar=f,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"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
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
2116274