@tef-novum/webview-bridge
Advanced tools
Comparing version 3.5.0 to 3.6.0
# CHANGELOG | ||
## v.3.6.0 - 2022-05-23 | ||
- BRIDGE_READY message | ||
## v.3.5.0 - 2022-05-17 | ||
@@ -4,0 +8,0 @@ |
export { isWebViewBridgeAvailable, onNativeEvent, NativeEventHandler, } from './src/post-message'; | ||
export { nativeConfirm, nativeAlert, nativeMessage } from './src/dialogs'; | ||
export { requestSimIcc, requestSimImsi, requestDeviceImei, internalNavigation, dismiss, requestVibration, getDiskSpaceInfo, getEsimInfo, } from './src/device'; | ||
export { attachToEmail, share, setWebViewTitle, updateNavigationBar, notifyPageLoaded, isABTestingAvailable, reportStatus, fetch, checkPermissionStatus, getAppMetadata, setActionBehavior, } from './src/utils'; | ||
export { attachToEmail, share, setWebViewTitle, updateNavigationBar, notifyPageLoaded, notifyBridgeReady, isABTestingAvailable, reportStatus, fetch, checkPermissionStatus, getAppMetadata, setActionBehavior, } from './src/utils'; | ||
export type { ShareOptions } from './src/utils'; | ||
@@ -6,0 +6,0 @@ export { createCalendarEvent } from './src/calendar'; |
@@ -59,2 +59,7 @@ /** | ||
}; | ||
BRIDGE_READY: { | ||
id: string; | ||
type: 'BRIDGE_READY'; | ||
payload: void; | ||
}; | ||
ALERT: { | ||
@@ -61,0 +66,0 @@ id: string; |
@@ -30,2 +30,3 @@ import { NativeAppResponsePayload } from './post-message'; | ||
export declare const notifyPageLoaded: () => Promise<void>; | ||
export declare const notifyBridgeReady: () => Promise<void>; | ||
export declare const isABTestingAvailable: (key: string) => Promise<boolean>; | ||
@@ -32,0 +33,0 @@ export declare const reportStatus: ({ feature, status, reason, }: { |
@@ -327,2 +327,5 @@ define(['exports'], (function (exports) { 'use strict'; | ||
}; | ||
var notifyBridgeReady = function () { | ||
return postMessageToNativeApp({ type: 'BRIDGE_READY' }); | ||
}; | ||
var remoteConfig = null; | ||
@@ -847,2 +850,3 @@ var isRemoteConfigAvailable = function (key) { | ||
exports.nativeMessage = nativeMessage; | ||
exports.notifyBridgeReady = notifyBridgeReady; | ||
exports.notifyPageLoaded = notifyPageLoaded; | ||
@@ -849,0 +853,0 @@ exports.onNativeEvent = onNativeEvent; |
@@ -329,2 +329,5 @@ 'use strict'; | ||
}; | ||
var notifyBridgeReady = function () { | ||
return postMessageToNativeApp({ type: 'BRIDGE_READY' }); | ||
}; | ||
var remoteConfig = null; | ||
@@ -849,2 +852,3 @@ var isRemoteConfigAvailable = function (key) { | ||
exports.nativeMessage = nativeMessage; | ||
exports.notifyBridgeReady = notifyBridgeReady; | ||
exports.notifyPageLoaded = notifyPageLoaded; | ||
@@ -851,0 +855,0 @@ exports.onNativeEvent = onNativeEvent; |
@@ -328,2 +328,5 @@ var webviewBridge = (function (exports) { | ||
}; | ||
var notifyBridgeReady = function () { | ||
return postMessageToNativeApp({ type: 'BRIDGE_READY' }); | ||
}; | ||
var remoteConfig = null; | ||
@@ -848,2 +851,3 @@ var isRemoteConfigAvailable = function (key) { | ||
exports.nativeMessage = nativeMessage; | ||
exports.notifyBridgeReady = notifyBridgeReady; | ||
exports.notifyPageLoaded = notifyPageLoaded; | ||
@@ -850,0 +854,0 @@ exports.onNativeEvent = onNativeEvent; |
@@ -1,1 +0,1 @@ | ||
var webviewBridge=function(e){"use strict";var n=1,t=function(){return"webapp-".concat(n++)},o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(n){return n!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=function(){return!l()&&(r()||i())},f=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),d=JSON.stringify({type:o,id:i,payload:u});return l?(setTimeout(function(){l(d)}),new Promise(function(e,t){var r=!1,a=function(n){n.id!==i||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: ".concat(n.type,". Expecting ").concat(o)}),c(a))};s(a),n&&setTimeout(function(){r=!0,c(a),t({code:408,reason:"request timeout"})},n)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var p=function(e,n){var t=function(t){t.type===e&&Promise.resolve(n(t.payload)).then(function(e){var n=a();n&&n(JSON.stringify({type:t.type,id:t.id,payload:e}))})};return s(t),function(){c(t)}},y=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?f({type:"NAVIGATION_BAR",payload:{title:n,expandedTitle:t,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==n&&"undefined"!=typeof document&&(document.title=n),Promise.resolve())},m=null,v=function(e){return"true"===m.result[e]},w=function(e){return Math.floor(e/1e3)},g=function(){return(g=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)};function b(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&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}var T,h=["NovumTracker","OBARGTracker"],E=function(e){return h.indexOf(e.get("name"))>=0},A=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():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()},P=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S={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,activatedRoles:17,appInstanceId:18,experimentflag:20,friendsApps:24,accountLineSelector:25,OneClickDisplayed:26};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return f({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return f({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:n}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return f({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:w(n),endTime:w(t),title:o}})},e.dismiss=function(e){return f({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return d()?f({type:"FETCH",payload:{url:n,method:t,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return f({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return f({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return f({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return f({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return f({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return f({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return f({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(m)return Promise.resolve(v(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=f({type:"GET_REMOTE_CONFIG"}).then(function(n){return m=n,v(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,n){return A({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=b(e,["name"]);if(u)Object.entries(s).forEach(function(e){var n=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(e,2),t=n[0],o=n[1];"string"==typeof o&&(s[t]=P(o))});else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=b(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=g({eventCategory:t,eventAction:o,eventLabel:P(r),eventValue:i},a),u=e.category}return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",g(g({},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=Math.round(r),timingLabel:i},u=t;return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("NovumTracker.send",g(((t={hitType:"timing",hitCallback:n})["dimension".concat(8)]=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return d()?f({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return d()?f({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(n))},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return d()?f({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyPageLoaded=function(){return f({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return p("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return p("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e){return f({type:"RENEW_SESSION",payload:{accessToken:e||null}}).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return f({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return f({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return f({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return f({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return f({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return f({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return f({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return f({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setScreenName=function(e,n){return e?A({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:"/".concat(e);r!==T?(T=r,t(function(){t.getAll().filter(E).forEach(function(e){e.set("page",r),e.send("pageView",g(g({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return f({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),A({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=S[e];return r?(t("NovumTracker.set",((o={})["dimension".concat(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.setWebViewTitle=function(e){return d()?y({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return f({type:"SHARE",payload:e})},e.updateNavigationBar=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var webviewBridge=function(e){"use strict";var n=1,t=function(){return"webapp-".concat(n++)},o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(n){return n!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=function(){return!l()&&(r()||i())},f=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),d=JSON.stringify({type:o,id:i,payload:u});return l?(setTimeout(function(){l(d)}),new Promise(function(e,t){var r=!1,a=function(n){n.id!==i||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: ".concat(n.type,". Expecting ").concat(o)}),c(a))};s(a),n&&setTimeout(function(){r=!0,c(a),t({code:408,reason:"request timeout"})},n)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var p=function(e,n){var t=function(t){t.type===e&&Promise.resolve(n(t.payload)).then(function(e){var n=a();n&&n(JSON.stringify({type:t.type,id:t.id,payload:e}))})};return s(t),function(){c(t)}},y=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?f({type:"NAVIGATION_BAR",payload:{title:n,expandedTitle:t,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==n&&"undefined"!=typeof document&&(document.title=n),Promise.resolve())},m=null,v=function(e){return"true"===m.result[e]},w=function(e){return Math.floor(e/1e3)},g=function(){return(g=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)};function b(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&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}var T,E=["NovumTracker","OBARGTracker"],h=function(e){return E.indexOf(e.get("name"))>=0},A=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():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()},P=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S={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,activatedRoles:17,appInstanceId:18,experimentflag:20,friendsApps:24,accountLineSelector:25,OneClickDisplayed:26};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return f({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return f({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:n}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return f({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:w(n),endTime:w(t),title:o}})},e.dismiss=function(e){return f({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return d()?f({type:"FETCH",payload:{url:n,method:t,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return f({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return f({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return f({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return f({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return f({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return f({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return f({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(m)return Promise.resolve(v(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=f({type:"GET_REMOTE_CONFIG"}).then(function(n){return m=n,v(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,n){return A({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=b(e,["name"]);if(u)Object.entries(s).forEach(function(e){var n=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(e,2),t=n[0],o=n[1];"string"==typeof o&&(s[t]=P(o))});else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=b(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=g({eventCategory:t,eventAction:o,eventLabel:P(r),eventValue:i},a),u=e.category}return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",g(g({},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=Math.round(r),timingLabel:i},u=t;return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("NovumTracker.send",g(((t={hitType:"timing",hitCallback:n})["dimension".concat(8)]=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return d()?f({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return d()?f({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(n))},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return d()?f({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyBridgeReady=function(){return f({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return f({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return p("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return p("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e){return f({type:"RENEW_SESSION",payload:{accessToken:e||null}}).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return f({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return f({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return f({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return f({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return f({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return f({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return f({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return f({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setScreenName=function(e,n){return e?A({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:"/".concat(e);r!==T?(T=r,t(function(){t.getAll().filter(h).forEach(function(e){e.set("page",r),e.send("pageView",g(g({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return f({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),A({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=S[e];return r?(t("NovumTracker.set",((o={})["dimension".concat(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.setWebViewTitle=function(e){return d()?y({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return f({type:"SHARE",payload:e})},e.updateNavigationBar=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -331,2 +331,5 @@ (function (global, factory) { | ||
}; | ||
var notifyBridgeReady = function () { | ||
return postMessageToNativeApp({ type: 'BRIDGE_READY' }); | ||
}; | ||
var remoteConfig = null; | ||
@@ -851,2 +854,3 @@ var isRemoteConfigAvailable = function (key) { | ||
exports.nativeMessage = nativeMessage; | ||
exports.notifyBridgeReady = notifyBridgeReady; | ||
exports.notifyPageLoaded = notifyPageLoaded; | ||
@@ -853,0 +857,0 @@ exports.onNativeEvent = onNativeEvent; |
@@ -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="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return"webapp-".concat(n++)},o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(n){return n!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=function(){return!l()&&(r()||i())},f=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),d=JSON.stringify({type:o,id:i,payload:u});return l?(setTimeout(function(){l(d)}),new Promise(function(e,t){var r=!1,a=function(n){n.id!==i||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: ".concat(n.type,". Expecting ").concat(o)}),c(a))};s(a),n&&setTimeout(function(){r=!0,c(a),t({code:408,reason:"request timeout"})},n)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var p=function(e,n){var t=function(t){t.type===e&&Promise.resolve(n(t.payload)).then(function(e){var n=a();n&&n(JSON.stringify({type:t.type,id:t.id,payload:e}))})};return s(t),function(){c(t)}},y=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?f({type:"NAVIGATION_BAR",payload:{title:n,expandedTitle:t,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==n&&"undefined"!=typeof document&&(document.title=n),Promise.resolve())},m=null,v=function(e){return"true"===m.result[e]},w=function(e){return Math.floor(e/1e3)},g=function(){return(g=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)};function b(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&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}var T,h=["NovumTracker","OBARGTracker"],E=function(e){return h.indexOf(e.get("name"))>=0},A=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():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()},P=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S={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,activatedRoles:17,appInstanceId:18,experimentflag:20,friendsApps:24,accountLineSelector:25,OneClickDisplayed:26};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return f({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return f({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:n}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return f({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:w(n),endTime:w(t),title:o}})},e.dismiss=function(e){return f({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return d()?f({type:"FETCH",payload:{url:n,method:t,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return f({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return f({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return f({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return f({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return f({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return f({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return f({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(m)return Promise.resolve(v(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=f({type:"GET_REMOTE_CONFIG"}).then(function(n){return m=n,v(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,n){return A({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=b(e,["name"]);if(u)Object.entries(s).forEach(function(e){var n=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(e,2),t=n[0],o=n[1];"string"==typeof o&&(s[t]=P(o))});else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=b(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=g({eventCategory:t,eventAction:o,eventLabel:P(r),eventValue:i},a),u=e.category}return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",g(g({},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=Math.round(r),timingLabel:i},u=t;return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("NovumTracker.send",g(((t={hitType:"timing",hitCallback:n})["dimension".concat(8)]=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return d()?f({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return d()?f({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(n))},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return d()?f({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyPageLoaded=function(){return f({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return p("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return p("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e){return f({type:"RENEW_SESSION",payload:{accessToken:e||null}}).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return f({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return f({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return f({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return f({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return f({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return f({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return f({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return f({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setScreenName=function(e,n){return e?A({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:"/".concat(e);r!==T?(T=r,t(function(){t.getAll().filter(E).forEach(function(e){e.set("page",r),e.send("pageView",g(g({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return f({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),A({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=S[e];return r?(t("NovumTracker.set",((o={})["dimension".concat(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.setWebViewTitle=function(e){return d()?y({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return f({type:"SHARE",payload:e})},e.updateNavigationBar=y,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="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return"webapp-".concat(n++)},o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(n){return n!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=function(){return!l()&&(r()||i())},f=function(e,n){var o=e.type,r=e.id,i=void 0===r?t():r,u=e.payload,l=a(),d=JSON.stringify({type:o,id:i,payload:u});return l?(setTimeout(function(){l(d)}),new Promise(function(e,t){var r=!1,a=function(n){n.id!==i||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: ".concat(n.type,". Expecting ").concat(o)}),c(a))};s(a),n&&setTimeout(function(){r=!0,c(a),t({code:408,reason:"request timeout"})},n)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(n)})}});var p=function(e,n){var t=function(t){t.type===e&&Promise.resolve(n(t.payload)).then(function(e){var n=a();n&&n(JSON.stringify({type:t.type,id:t.id,payload:e}))})};return s(t),function(){c(t)}},y=function(e){var n=e.title,t=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?f({type:"NAVIGATION_BAR",payload:{title:n,expandedTitle:t,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==n&&"undefined"!=typeof document&&(document.title=n),Promise.resolve())},m=null,v=function(e){return"true"===m.result[e]},w=function(e){return Math.floor(e/1e3)},g=function(){return(g=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)};function b(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&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}var T,h=["NovumTracker","OBARGTracker"],E=function(e){return h.indexOf(e.get("name"))>=0},A=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():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()},P=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S={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,activatedRoles:17,appInstanceId:18,experimentflag:20,friendsApps:24,accountLineSelector:25,OneClickDisplayed:26};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return f({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.checkPermissionStatus=function(e,n){return f({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:n}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return f({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:w(n),endTime:w(t),title:o}})},e.dismiss=function(e){return f({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var n=e.url,t=e.method,o=e.headers,r=e.body;return d()?f({type:"FETCH",payload:{url:n,method:t,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return f({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return f({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return f({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return f({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return f({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.highlightNavigationTab=function(e){var n=e.tab,t=e.highlight,o=e.count;return f({type:"HIGHLIGHT_TAB",payload:{tab:n,highlight:t,count:o}})},e.internalNavigation=function(e){return f({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(m)return Promise.resolve(v(e));var n=new Promise(function(e){setTimeout(function(){e(!1)},500)}),t=f({type:"GET_REMOTE_CONFIG"}).then(function(n){return m=n,v(e)});return Promise.race([n,t])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,n){return A({onAndroid:function(t){return t.logEvent&&t.logEvent(e,JSON.stringify(n)),Promise.resolve()},onIos:function(t){return t.postMessage({command:"logEvent",name:e,parameters:n}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e){var n,t,o,r,i,a,u=e.name,s=b(e,["name"]);if(u)Object.entries(s).forEach(function(e){var n=function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var o,r,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return a}(e,2),t=n[0],o=n[1];"string"==typeof o&&(s[t]=P(o))});else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();t=(n=e).category,o=n.action,r=n.label,i=n.value,a=b(n,["category","action","label","value"]),r||(r="null_label"),i||(i=0),s=g({eventCategory:t,eventAction:o,eventLabel:P(r),eventValue:i},a),u=e.category}return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("NovumTracker.send","event",g(g({},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=Math.round(r),timingLabel:i},u=t;return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("NovumTracker.send",g(((t={hitType:"timing",hitCallback:n})["dimension".concat(8)]=String(r),t),a))})}})},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return d()?f({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return d()?f({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(n))},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return d()?f({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(n),Promise.resolve())},e.notifyBridgeReady=function(){return f({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return f({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return p("NATIVE_EVENT",function(n){return{action:e({event:n.event}).action||"default"}})},e.onSessionRenewed=function(e){return p("SESSION_RENEWED",function(n){var t=n.accessToken;return e(t)})},e.renewSession=function(e){return f({type:"RENEW_SESSION",payload:{accessToken:e||null}}).then(function(e){return e.accessToken})},e.reportStatus=function(e){var n=e.feature,t=e.status,o=e.reason;return f({type:"STATUS_REPORT",payload:{feature:n,status:t,reason:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return f({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.requestDeviceImei=function(){return f({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return f({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return f({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return f({type:"VIBRATION",payload:{type:e}})},e.setActionBehavior=function(e){return f({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return f({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setScreenName=function(e,n){return e?A({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:"/".concat(e);r!==T?(T=r,t(function(){t.getAll().filter(E).forEach(function(e){e.set("page",r),e.send("pageView",g(g({},n),{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setTrackingProperty=function(e,n,t){return f({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:n,value:t}}).catch(function(){})},e.setUserProperty=function(e,n){return e&&n?(n=String(n),A({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=S[e];return r?(t("NovumTracker.set",((o={})["dimension".concat(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.setWebViewTitle=function(e){return d()?y({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return f({type:"SHARE",payload:e})},e.updateNavigationBar=y,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
247665
4693