@btsd/aitu-bridge 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -117,6 +117,7 @@ export interface AituBridge {
117
117
  setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;
118
118
  getCustomBackArrowMode: () => Promise<boolean>;
119
119
  setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
120
+ openPayment: (transactionId: string) => Promise<ResponseType>;
120
121
  setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
121
122
  }
122
123
  declare const bridge: AituBridge;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){var n=function(e){return void 0===e&&(e="m:"),{current:0,next:function(){return e+ ++this.current}}}(e),t={};return{add:function(e,o){void 0===o&&(o="");var i=o+n.next();return t[i]=e,i},resolve:function(e,n,o,i){var r=t[e];r&&(o(i)?r.resolve(n):r.reject(i),t[e]=null)}}}function n(e,n){e(function(e){if(e.detail&&"reqId"in e.detail){var t=e.detail,o=t.reqId;o&&n.resolve(o,t.data,function(e){return!e},t.error)}})}function t(t,o,i){var r=e(o+":");return n(i,r),function(){var e=arguments;return new Promise(function(n,o){var i=r.add({resolve:n,reject:o});t.apply(void 0,[i].concat([].slice.call(e)))})}}var o=new URLSearchParams(window.location.search).get("__aitu-domain");o?localStorage.setItem("mini-app-domain",o):o=localStorage.getItem("mini-app-domain");var i=null;o&&(i={origin:o,execute:function(e,n){window.top.postMessage({source:"aitu-bridge",method:e,reqId:n,payload:[].concat([].slice.call(arguments,2))},i.origin)}},window.addEventListener("message",function(e){e.origin===o&&e.data&&window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data}))}));var r,s,a=i;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(r||(r={})),(s=exports.HeaderMenuIcon||(exports.HeaderMenuIcon={})).Search="Search",s.ShoppingCart="ShoppingCart",s.Menu="Menu",s.Share="Share",s.Notifications="Notifications",s.Help="Help",s.Error="Error",s.Person="Person",s.Sort="Sort",s.Filter="Filter";var d="undefined"!=typeof window&&window.AndroidBridge,c="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,l="undefined"!=typeof window&&window.top!==window&&a,u=function(){var o=[];"undefined"!=typeof window&&(window.addEventListener("aituEvents",function(e){[].concat(o).map(function(n){return n.call(null,e)})}),window.addEventListener("message",function(e){if("string"==typeof e.data){var n=JSON.parse(e.data);n&&n.method&&("setCustomBackArrowOnClickHandler"===n.method?window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===n.method&&window.onAituBridgeHeaderMenuItemClick(n.param))}}));var i,s=function(e){o.push(e)},a=(n(s,i=e("invoke:")),function(e,n){return void 0===n&&(n={}),new Promise(function(t,o){!function(e,n,t){void 0===t&&(t={});var o=c&&c.invoke;d&&d.invoke?d.invoke(e,n,JSON.stringify(t)):o?c.invoke.postMessage({reqId:e,method:n,data:t}):l?l.execute("invoke",e,n,t):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(i.add({resolve:t,reject:o},e+":"),e,n)})}),u=function(t,o){var i=e("storage:");return n(o,i),{setItem:function(e,n){return new Promise(function(o,r){var s=i.add({resolve:o,reject:r});t(s,"setItem",{keyName:e,keyValue:n})})},getItem:function(e){return new Promise(function(n,o){var r=i.add({resolve:n,reject:o});t(r,"getItem",{keyName:e})})},clear:function(){return new Promise(function(e,n){var o=i.add({resolve:e,reject:n});t(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var o=c&&c.storage;d&&d.storage?d.storage(e,n,JSON.stringify(t)):o?c.storage.postMessage({reqId:e,method:n,data:t}):l?l.execute("storage",e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},s),w=t(function(e){var n=c&&c.getGeo;d&&d.getGeo?d.getGeo(e):n?c.getGeo.postMessage({reqId:e}):l?l.execute("getGeo",e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},"getGeo",s),g=t(function(e){var n=c&&c.getQr;d&&d.getQr?d.getQr(e):n?c.getQr.postMessage({reqId:e}):l?l.execute("getQr",e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},"getQr",s),f=t(function(e){var n=c&&c.getSMSCode;d&&d.getSMSCode?d.getSMSCode(e):n?c.getSMSCode.postMessage({reqId:e}):l?l.execute("getSMSCode",e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},"getSMSCode",s),p=t(function(e){var n=c&&c.selectContact;d&&d.selectContact?d.selectContact(e):n?c.selectContact.postMessage({reqId:e}):l?l.execute("selectContact",e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},"selectContact",s),v=t(function(e){var n=c&&c.openSettings;d&&d.openSettings?d.openSettings(e):n?c.openSettings.postMessage({reqId:e}):l?l.execute("openSettings",e):"undefined"!=typeof window&&console.log("--openSettings-isUnknown")},"openSettings",s),C=t(function(e){var n=c&&c.closeApplication;d&&d.closeApplication?d.closeApplication(e):n?c.closeApplication.postMessage({reqId:e}):l?l.execute("closeApplication",e):"undefined"!=typeof window&&console.log("--closeApplication-isUnknown")},"closeApplication",s),k=t(function(e,n){var t=c&&c.share;d&&d.share?d.share(e,n):t?c.share.postMessage({reqId:e,text:n}):l?l.execute("share",e,n):"undefined"!=typeof window&&console.log("--share-isUnknown")},"share",s),m=t(function(e,n){var t=c&&c.setTitle;d&&d.setTitle?d.setTitle(e,n):t?c.setTitle.postMessage({reqId:e,text:n}):l?l.execute("setTitle",e,n):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},"setTitle",s),M=t(function(e,n){var t=c&&c.copyToClipboard;d&&d.copyToClipboard?d.copyToClipboard(e,n):t?c.copyToClipboard.postMessage({reqId:e,text:n}):l?l.execute("copyToClipboard",e,n):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},"copyToClipboard",s),b=t(function(e,n,t){var o=d&&d.shareFile,i=c&&c.shareFile,r="image."+t.split(";")[0].split("/")[1],s=t.substr(t.indexOf(",")+1);o?d.shareFile(e,n,r,s):i?c.shareFile.postMessage({reqId:e,text:n,filename:r,base64Data:s}):l?l.execute("shareFile",e,{text:n,filename:r,base64Data:s}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",s),S=t(function(e,n,t,o){var i=c&&c.shareFile;d&&d.shareFile?d.shareFile(e,n,t,o):i?c.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):l?l.execute("shareFile",e,n,t,o):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareFile",s),h=t(function(e,n){if(!Array.isArray(n)||n.some(function(e){return e<1||e!==Math.floor(e)})||n.reduce(function(e,n){return e+n})>1e4)console.error("Pattern should be an array of positive integers no longer than 10000ms total");else{var t=c&&c.vibrate;d&&d.vibrate?d.vibrate(e,JSON.stringify(n)):t?c.vibrate.postMessage({reqId:e,pattern:n}):l?l.execute("vibrate",e,n):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")}},"vibrate",s),A=t(function(e){var n=c&&c.enableScreenCapture;d&&d.enableScreenCapture?d.enableScreenCapture(e):n?c.enableScreenCapture.postMessage({reqId:e}):l?l.execute("enableScreenCapture",e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},"enableScreenCapture",s),y=t(function(e){var n=c&&c.disableScreenCapture;d&&d.disableScreenCapture?d.disableScreenCapture(e):n?c.disableScreenCapture.postMessage({reqId:e}):l?l.execute("disableScreenCapture",e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},"disableScreenCapture",s),I=t(function(e,n){if(n.length>3)console.error("SetHeaderMenuItems: items count should not be more than 3");else{var t=d&&d.setHeaderMenuItems,o=c&&c.setHeaderMenuItems,i=JSON.stringify(n);t?d.setHeaderMenuItems(e,i):o?c.setHeaderMenuItems.postMessage({reqId:e,itemsJsonArray:i}):l?l.execute("setHeaderMenuItems",e,i):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")}},"setHeaderMenuItems",s),H=t(function(e,n){var t=c&&c.setCustomBackArrowMode;d&&d.setCustomBackArrowMode?d.setCustomBackArrowMode(e,n):t?c.setCustomBackArrowMode.postMessage({reqId:e,enabled:n}):l?l.execute("setCustomBackArrowMode",e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},"setCustomBackArrowMode",s),B=t(function(e){var n=c&&c.getCustomBackArrowMode;d&&d.getCustomBackArrowMode?d.getCustomBackArrowMode(e):n?c.getCustomBackArrowMode.postMessage({reqId:e}):l?l.execute("getCustomBackArrowMode",e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},"getCustomBackArrowMode",s),x=t(function(e,n){var t=c&&c.setCustomBackArrowVisible;d&&d.setCustomBackArrowVisible?d.setCustomBackArrowVisible(e,n):t?c.setCustomBackArrowVisible.postMessage({reqId:e,visible:n}):l?l.execute("setCustomBackArrowVisible",e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},"setCustomBackArrowVisible",s);return{version:String("0.3.3"),copyToClipboard:M,invoke:a,storage:u,getMe:function(){return a(r.getMe)},getPhone:function(){return a(r.getPhone)},getContacts:function(){return a(r.getContacts)},getGeo:w,getQr:g,getSMSCode:f,getUserProfile:function(e){return a(r.getUserProfile,{id:e})},selectContact:p,enableNotifications:function(){return a(r.enableNotifications)},disableNotifications:function(){return a(r.disableNotifications)},enablePrivateMessaging:function(e){return a(r.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return a(r.disablePrivateMessaging,{appId:e})},openSettings:v,closeApplication:C,setTitle:m,share:k,shareImage:b,shareFile:S,setShakeHandler:function(e){d&&d.setShakeHandler||c&&c.setShakeHandler||l?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:function(e){d&&d.setTabActiveHandler||c&&c.setTabActiveHandler||l?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:h,isSupported:function(){var e=c&&window.webkit.messageHandlers.invoke;return Boolean(d||e||l)},supports:function(e){return d&&"function"==typeof d[e]||c&&c[e]&&"function"==typeof c[e].postMessage||l&&"function"==typeof l[e]},sub:s,enableScreenCapture:A,disableScreenCapture:y,setHeaderMenuItems:I,setHeaderMenuItemClickHandler:function(e){d&&d.setHeaderMenuItemClickHandler||c&&c.setHeaderMenuItemClickHandler||l?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:H,getCustomBackArrowMode:B,setCustomBackArrowVisible:x,setCustomBackArrowOnClickHandler:function(e){d&&d.setCustomBackArrowOnClickHandler||c&&c.setCustomBackArrowOnClickHandler||l?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")}}}();exports.default=u;
1
+ function e(e){var n=function(e){return void 0===e&&(e="m:"),{current:0,next:function(){return e+ ++this.current}}}(e),t={};return{add:function(e,o){void 0===o&&(o="");var i=o+n.next();return t[i]=e,i},resolve:function(e,n,o,i){var r=t[e];r&&(o(i)?r.resolve(n):r.reject(i),t[e]=null)}}}function n(e,n){e(function(e){if(e.detail&&"reqId"in e.detail){var t=e.detail,o=t.reqId;o&&n.resolve(o,t.data,function(e){return!e},t.error)}})}function t(t,o,i){var r=e(o+":");return n(i,r),function(){var e=arguments;return new Promise(function(n,o){var i=r.add({resolve:n,reject:o});t.apply(void 0,[i].concat([].slice.call(e)))})}}var o=new URLSearchParams(window.location.search).get("__aitu-domain");o?localStorage.setItem("mini-app-domain",o):o=localStorage.getItem("mini-app-domain");var i=null;o&&(i={origin:o,execute:function(e,n){window.top.postMessage({source:"aitu-bridge",method:e,reqId:n,payload:[].concat([].slice.call(arguments,2))},i.origin)}},window.addEventListener("message",function(e){e.origin===o&&e.data&&window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data}))}));var r,s,a=i;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(r||(r={})),(s=exports.HeaderMenuIcon||(exports.HeaderMenuIcon={})).Search="Search",s.ShoppingCart="ShoppingCart",s.Menu="Menu",s.Share="Share",s.Notifications="Notifications",s.Help="Help",s.Error="Error",s.Person="Person",s.Sort="Sort",s.Filter="Filter";var d="undefined"!=typeof window&&window.AndroidBridge,c="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,l="undefined"!=typeof window&&window.top!==window&&a,u=function(){var o=[];"undefined"!=typeof window&&(window.addEventListener("aituEvents",function(e){[].concat(o).map(function(n){return n.call(null,e)})}),window.addEventListener("message",function(e){if("string"==typeof e.data){var n=JSON.parse(e.data);n&&n.method&&("setCustomBackArrowOnClickHandler"===n.method?window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===n.method&&window.onAituBridgeHeaderMenuItemClick(n.param))}}));var i,s=function(e){o.push(e)},a=(n(s,i=e("invoke:")),function(e,n){return void 0===n&&(n={}),new Promise(function(t,o){!function(e,n,t){void 0===t&&(t={});var o=c&&c.invoke;d&&d.invoke?d.invoke(e,n,JSON.stringify(t)):o?c.invoke.postMessage({reqId:e,method:n,data:t}):l?l.execute("invoke",e,n,t):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(i.add({resolve:t,reject:o},e+":"),e,n)})}),u=function(t,o){var i=e("storage:");return n(o,i),{setItem:function(e,n){return new Promise(function(o,r){var s=i.add({resolve:o,reject:r});t(s,"setItem",{keyName:e,keyValue:n})})},getItem:function(e){return new Promise(function(n,o){var r=i.add({resolve:n,reject:o});t(r,"getItem",{keyName:e})})},clear:function(){return new Promise(function(e,n){var o=i.add({resolve:e,reject:n});t(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var o=c&&c.storage;d&&d.storage?d.storage(e,n,JSON.stringify(t)):o?c.storage.postMessage({reqId:e,method:n,data:t}):l?l.execute("storage",e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},s),g=t(function(e){var n=c&&c.getGeo;d&&d.getGeo?d.getGeo(e):n?c.getGeo.postMessage({reqId:e}):l?l.execute("getGeo",e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},"getGeo",s),w=t(function(e){var n=c&&c.getQr;d&&d.getQr?d.getQr(e):n?c.getQr.postMessage({reqId:e}):l?l.execute("getQr",e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},"getQr",s),f=t(function(e){var n=c&&c.getSMSCode;d&&d.getSMSCode?d.getSMSCode(e):n?c.getSMSCode.postMessage({reqId:e}):l?l.execute("getSMSCode",e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},"getSMSCode",s),p=t(function(e){var n=c&&c.selectContact;d&&d.selectContact?d.selectContact(e):n?c.selectContact.postMessage({reqId:e}):l?l.execute("selectContact",e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},"selectContact",s),m=t(function(e){var n=c&&c.openSettings;d&&d.openSettings?d.openSettings(e):n?c.openSettings.postMessage({reqId:e}):l?l.execute("openSettings",e):"undefined"!=typeof window&&console.log("--openSettings-isUnknown")},"openSettings",s),v=t(function(e){var n=c&&c.closeApplication;d&&d.closeApplication?d.closeApplication(e):n?c.closeApplication.postMessage({reqId:e}):l?l.execute("closeApplication",e):"undefined"!=typeof window&&console.log("--closeApplication-isUnknown")},"closeApplication",s),k=t(function(e,n){var t=c&&c.share;d&&d.share?d.share(e,n):t?c.share.postMessage({reqId:e,text:n}):l?l.execute("share",e,n):"undefined"!=typeof window&&console.log("--share-isUnknown")},"share",s),C=t(function(e,n){var t=c&&c.setTitle;d&&d.setTitle?d.setTitle(e,n):t?c.setTitle.postMessage({reqId:e,text:n}):l?l.execute("setTitle",e,n):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},"setTitle",s),M=t(function(e,n){var t=c&&c.copyToClipboard;d&&d.copyToClipboard?d.copyToClipboard(e,n):t?c.copyToClipboard.postMessage({reqId:e,text:n}):l?l.execute("copyToClipboard",e,n):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},"copyToClipboard",s),b=t(function(e,n,t){var o=d&&d.shareFile,i=c&&c.shareFile,r="image."+t.split(";")[0].split("/")[1],s=t.substr(t.indexOf(",")+1);o?d.shareFile(e,n,r,s):i?c.shareFile.postMessage({reqId:e,text:n,filename:r,base64Data:s}):l?l.execute("shareFile",e,{text:n,filename:r,base64Data:s}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",s),S=t(function(e,n,t,o){var i=c&&c.shareFile;d&&d.shareFile?d.shareFile(e,n,t,o):i?c.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):l?l.execute("shareFile",e,n,t,o):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareFile",s),y=t(function(e,n){if(!Array.isArray(n)||n.some(function(e){return e<1||e!==Math.floor(e)})||n.reduce(function(e,n){return e+n})>1e4)console.error("Pattern should be an array of positive integers no longer than 10000ms total");else{var t=c&&c.vibrate;d&&d.vibrate?d.vibrate(e,JSON.stringify(n)):t?c.vibrate.postMessage({reqId:e,pattern:n}):l?l.execute("vibrate",e,n):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")}},"vibrate",s),h=t(function(e){var n=c&&c.enableScreenCapture;d&&d.enableScreenCapture?d.enableScreenCapture(e):n?c.enableScreenCapture.postMessage({reqId:e}):l?l.execute("enableScreenCapture",e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},"enableScreenCapture",s),A=t(function(e){var n=c&&c.disableScreenCapture;d&&d.disableScreenCapture?d.disableScreenCapture(e):n?c.disableScreenCapture.postMessage({reqId:e}):l?l.execute("disableScreenCapture",e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},"disableScreenCapture",s),I=t(function(e,n){if(n.length>3)console.error("SetHeaderMenuItems: items count should not be more than 3");else{var t=d&&d.setHeaderMenuItems,o=c&&c.setHeaderMenuItems,i=JSON.stringify(n);t?d.setHeaderMenuItems(e,i):o?c.setHeaderMenuItems.postMessage({reqId:e,itemsJsonArray:i}):l?l.execute("setHeaderMenuItems",e,i):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")}},"setHeaderMenuItems",s),H=t(function(e,n){var t=c&&c.setCustomBackArrowMode;d&&d.setCustomBackArrowMode?d.setCustomBackArrowMode(e,n):t?c.setCustomBackArrowMode.postMessage({reqId:e,enabled:n}):l?l.execute("setCustomBackArrowMode",e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},"setCustomBackArrowMode",s),B=t(function(e){var n=c&&c.getCustomBackArrowMode;d&&d.getCustomBackArrowMode?d.getCustomBackArrowMode(e):n?c.getCustomBackArrowMode.postMessage({reqId:e}):l?l.execute("getCustomBackArrowMode",e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},"getCustomBackArrowMode",s),x=t(function(e,n){var t=c&&c.setCustomBackArrowVisible;d&&d.setCustomBackArrowVisible?d.setCustomBackArrowVisible(e,n):t?c.setCustomBackArrowVisible.postMessage({reqId:e,visible:n}):l?l.execute("setCustomBackArrowVisible",e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},"setCustomBackArrowVisible",s),P=t(function(e,n){var t=c&&c.openPayment;d&&d.openPayment?d.openPayment(e,n):t?c.openPayment.postMessage({reqId:e,transactionId:n}):console.log("--openPayment-isUnknown")},"openPayment",s);return{version:String("0.3.4"),copyToClipboard:M,invoke:a,storage:u,getMe:function(){return a(r.getMe)},getPhone:function(){return a(r.getPhone)},getContacts:function(){return a(r.getContacts)},getGeo:g,getQr:w,getSMSCode:f,getUserProfile:function(e){return a(r.getUserProfile,{id:e})},selectContact:p,enableNotifications:function(){return a(r.enableNotifications)},disableNotifications:function(){return a(r.disableNotifications)},enablePrivateMessaging:function(e){return a(r.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return a(r.disablePrivateMessaging,{appId:e})},openSettings:m,closeApplication:v,setTitle:C,share:k,shareImage:b,shareFile:S,setShakeHandler:function(e){d&&d.setShakeHandler||c&&c.setShakeHandler||l?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:function(e){d&&d.setTabActiveHandler||c&&c.setTabActiveHandler||l?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:y,isSupported:function(){var e=c&&window.webkit.messageHandlers.invoke;return Boolean(d||e||l)},supports:function(e){return d&&"function"==typeof d[e]||c&&c[e]&&"function"==typeof c[e].postMessage||l&&"function"==typeof l[e]},sub:s,enableScreenCapture:h,disableScreenCapture:A,setHeaderMenuItems:I,setHeaderMenuItemClickHandler:function(e){d&&d.setHeaderMenuItemClickHandler||c&&c.setHeaderMenuItemClickHandler||l?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:H,getCustomBackArrowMode:B,setCustomBackArrowVisible:x,openPayment:P,setCustomBackArrowOnClickHandler:function(e){d&&d.setCustomBackArrowOnClickHandler||c&&c.setCustomBackArrowOnClickHandler||l?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")}}}();exports.default=u;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/webBridge.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["function createCounter(prefix = 'm:') {\n return {\n current: 0,\n next() {\n return prefix + ++this.current;\n },\n };\n}\n\nfunction createRequestResolver(prefix: string) {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter(prefix);\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId = ''): number | string {\n const id = customId + counter.next()\n promiseControllers[id] = controller;\n return id;\n },\n\n resolve<T>(reqId: number | string, data: T, isSuccess: (data: T) => boolean, error: any) {\n const requestPromise = promiseControllers[reqId];\n\n if (requestPromise) {\n if (isSuccess(error)) {\n requestPromise.resolve(data);\n } else {\n requestPromise.reject(error);\n }\n\n promiseControllers[reqId] = null;\n }\n },\n };\n}\n\nfunction handleSubscribe(subscribe: (handler: (event: any) => void) => void, requestResolver: ReturnType<typeof createRequestResolver>) {\n subscribe(event => {\n if (!event.detail) {\n return;\n }\n\n if ('reqId' in event.detail) {\n const { reqId, data, error } = event.detail;\n\n if (reqId) {\n requestResolver.resolve(reqId, data, (error) => !(error), error);\n }\n }\n })\n}\n\nexport function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('storage:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return {\n setItem: (keyName: string, keyValue: string): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'setItem', { keyName, keyValue });\n });\n },\n getItem: (keyName: string): Promise<string | null> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'getItem', { keyName });\n });\n },\n clear: (): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'clear', {});\n });\n },\n }\n}\n\nexport function promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('invoke:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(invokeMethodName: string, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, invokeMethodName + ':');\n\n invoke(reqId, invokeMethodName, props);\n });\n };\n}\n\nexport function promisifyMethod(method: Function, methodName: string, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver(methodName + ':');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n method(reqId, ...args);\n });\n };\n}\n\n\n\n","import type { AituBridge } from './index';\n\nconst AITU_DOMAIN_PARAM = '__aitu-domain'\n\nconst searchParams = new URLSearchParams(window.location.search)\n\nlet aituOrigin = searchParams.get(AITU_DOMAIN_PARAM)\n\nif(aituOrigin){\n localStorage.setItem('mini-app-domain', aituOrigin)\n}else{\n aituOrigin = localStorage.getItem('mini-app-domain')\n}\ninterface WebBridge {\n execute(method: keyof AituBridge, reqId: string, ...payload: any[] ): void\n origin: string\n}\n\nlet WebBridge: WebBridge | null = null\n\nif (aituOrigin) {\n WebBridge = {\n origin: aituOrigin,\n execute: (method, reqId, ...payload) => {\n window.top.postMessage({\n source: 'aitu-bridge',\n method,\n reqId,\n payload: [...payload],\n },\n WebBridge.origin\n )\n }\n\n }\n window.addEventListener('message', event => {\n if (event.origin === aituOrigin && event.data) {\n window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));\n }\n })\n}\n\nexport default WebBridge\n","import { LIB_VERSION } from './version';\n\nimport {\n promisifyMethod,\n promisifyStorage,\n promisifyInvoke,\n} from './utils'\n\nimport WebBridge from './webBridge';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications',\n enablePrivateMessaging = 'EnablePrivateMessaging',\n disablePrivateMessaging = 'DisablePrivateMessaging',\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => Promise<void>;\n\ntype HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;\ntype BackArrowClickHandlerType = () => Promise<void>;\n\ninterface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\ninterface GetMeResponse {\n name: string;\n lastname: string;\n id: string;\n avatar?: string;\n avatarThumb?: string;\n sign: string;\n}\n\ninterface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\ninterface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\ninterface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\ninterface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\ninterface GetUserProfileResponse {\n name: string;\n lastname?: string;\n phone?: string;\n avatar?: string;\n avatarThumb?: string;\n}\n\nconst MAX_HEADER_MENU_ITEMS_COUNT = 3;\n\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\nexport interface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n enablePrivateMessaging: (appId: string) => Promise<string>;\n disablePrivateMessaging: (appId: string) => Promise<string>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;\n getCustomBackArrowMode: () => Promise<boolean>;\n setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;\n setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\nconst setCustomBackArrowModeMethod = 'setCustomBackArrowMode';\nconst getCustomBackArrowModeMethod = 'getCustomBackArrowMode';\nconst setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';\nconst setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';\n\nconst android = typeof window !== 'undefined' && (window as any).AndroidBridge;\nconst ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;\nconst web = typeof window !== 'undefined' && (window.top !== window) && WebBridge;\n\nconst buildBridge = (): AituBridge => {\n const subs = [];\n\n if (typeof window !== 'undefined') {\n window.addEventListener('aituEvents', (e: any) => {\n [...subs].map((fn) => fn.call(null, e));\n })\n\n window.addEventListener('message', (e) => {\n if(typeof e.data !== 'string') {\n return;\n }\n\n const message = JSON.parse(e.data)\n\n if (message && message['method']) {\n if (message.method === 'setCustomBackArrowOnClickHandler') {\n (window as any).onAituBridgeBackArrowClick()\n } else if (message.method === 'setHeaderMenuItemClickHandler') {\n (window as any).onAituBridgeHeaderMenuItemClick(message.param)\n }\n }\n })\n }\n\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n\n if (isAndroid) {\n android[invokeMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[invokeMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(invokeMethod, reqId, method, data)\n } else if (typeof window !== 'undefined') {\n console.log('--invoke-isUnknown');\n }\n };\n\n const storage = (reqId, method, data = {}) => {\n const isAndroid = android && android[storageMethod];\n const isIos = ios && ios[storageMethod];\n\n if (isAndroid) {\n android[storageMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[storageMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(storageMethod, reqId, method, data);\n } else if (typeof window !== 'undefined') {\n console.log('--storage-isUnknown');\n }\n }\n\n const getGeo = (reqId) => {\n const isAndroid = android && android[getGeoMethod];\n const isIos = ios && ios[getGeoMethod];\n\n if (isAndroid) {\n android[getGeoMethod](reqId);\n } else if (isIos) {\n ios[getGeoMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getGeoMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getGeo-isUnknown');\n }\n }\n\n const getQr = (reqId) => {\n const isAndroid = android && android[getQrMethod];\n const isIos = ios && ios[getQrMethod];\n\n if (isAndroid) {\n android[getQrMethod](reqId);\n } else if (isIos) {\n ios[getQrMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getQrMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getQr-isUnknown');\n }\n }\n\n const getSMSCode = (reqId) => {\n const isAndroid = android && android[getSMSCodeMethod];\n const isIos = ios && ios[getSMSCodeMethod];\n\n if (isAndroid) {\n android[getSMSCodeMethod](reqId);\n } else if (isIos) {\n ios[getSMSCodeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getSMSCodeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getSMSCode-isUnknown');\n }\n }\n\n const selectContact = (reqId) => {\n const isAndroid = android && android[selectContactMethod];\n const isIos = ios && ios[selectContactMethod];\n\n if (isAndroid) {\n android[selectContactMethod](reqId);\n } else if (isIos) {\n ios[selectContactMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(selectContactMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--selectContact-isUnknown');\n }\n }\n\n const openSettings = (reqId) => {\n const isAndroid = android && android[openSettingsMethod];\n const isIos = ios && ios[openSettingsMethod];\n\n if (isAndroid) {\n android[openSettingsMethod](reqId);\n } else if (isIos) {\n ios[openSettingsMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(openSettingsMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--openSettings-isUnknown');\n }\n }\n\n const closeApplication = (reqId) => {\n const isAndroid = android && android[closeApplicationMethod];\n const isIos = ios && ios[closeApplicationMethod];\n\n if (isAndroid) {\n android[closeApplicationMethod](reqId);\n } else if (isIos) {\n ios[closeApplicationMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(closeApplicationMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--closeApplication-isUnknown');\n }\n }\n\n const share = (reqId, text) => {\n const isAndroid = android && android[shareMethod];\n const isIos = ios && ios[shareMethod];\n\n if (isAndroid) {\n android[shareMethod](reqId, text);\n } else if (isIos) {\n ios[shareMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(shareMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--share-isUnknown');\n }\n }\n\n const setTitle = (reqId, text) => {\n const isAndroid = android && android[setTitleMethod];\n const isIos = ios && ios[setTitleMethod];\n\n if (isAndroid) {\n android[setTitleMethod](reqId, text);\n } else if (isIos) {\n ios[setTitleMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(setTitleMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--setTitle-isUnknown');\n }\n }\n\n const copyToClipboard = (reqId, text) => {\n const isAndroid = android && android[copyToClipboardMethod];\n const isIos = ios && ios[copyToClipboardMethod];\n\n if (isAndroid) {\n android[copyToClipboardMethod](reqId, text);\n } else if (isIos) {\n ios[copyToClipboardMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(copyToClipboardMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isUnknown');\n }\n }\n\n const enableScreenCapture = (reqId) => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isUnknown');\n }\n }\n\n const disableScreenCapture = (reqId) => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isUnknown');\n }\n }\n\n const shareImage = (reqId, text, image) => {\n // !!!======================!!!\n // !!!===== Deprecated =====!!!\n // !!!======================!!!\n\n // const isAndroid = android && android[shareImageMethod];\n // const isIos = ios && ios[shareImageMethod];\n\n // if (isAndroid) {\n // android[shareImageMethod](reqId, text, image);\n // } else if (isIos) {\n // ios[shareImageMethod].postMessage({ reqId, text, image });\n // } else if (typeof window !== 'undefined') {\n // console.log('--shareImage-isWeb');\n // }\n\n // new one - fallback to shareFile\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n // get extension from base64 mime type and merge with name\n const ext = image.split(';')[0].split('/')[1];\n const filename = 'image.' + ext;\n // remove mime type\n const base64Data = image.substr(image.indexOf(',') + 1);\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, { text, filename, base64Data });\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const shareFile = (reqId, text, filename, base64Data) => {\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, text, filename, base64Data);\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const enableNotifications = () => invokePromise(EInvokeRequest.enableNotifications);\n\n const disableNotifications = () => invokePromise(EInvokeRequest.disableNotifications);\n\n const setShakeHandler = (handler) => {\n const isAndroid = android && android[setShakeHandlerMethod];\n const isIos = ios && ios[setShakeHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isUnknown');\n }\n };\n\n const setTabActiveHandler = (handler: (tabname: string) => void) => {\n const isAndroid = android && android[setTabActiveHandlerMethod];\n const isIos = ios && ios[setTabActiveHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isUnknown');\n }\n };\n\n const vibrate = (reqId, pattern) => {\n if (\n !Array.isArray(pattern) ||\n pattern.some((timing) => timing < 1 || timing !== Math.floor(timing)) ||\n pattern.reduce((total, timing) => total + timing) > 10000\n ) {\n console.error('Pattern should be an array of positive integers no longer than 10000ms total');\n return;\n }\n\n const isAndroid = android && android[vibrateMethod];\n const isIos = ios && ios[vibrateMethod];\n\n if (isAndroid) {\n android[vibrateMethod](reqId, JSON.stringify(pattern));\n } else if (isIos) {\n ios[vibrateMethod].postMessage({ reqId, pattern });\n } else if (web) {\n web.execute(vibrateMethod, reqId, pattern);\n } else if (typeof window !== 'undefined') {\n console.log('--vibrate-isUnknown');\n }\n }\n\n const isSupported = () => {\n const iosSup = ios && (window as any).webkit.messageHandlers.invoke;\n return Boolean(android || iosSup || web);\n }\n\n // TODO: implement web support\n const supports = (method) =>\n (android && typeof android[method] === 'function') ||\n (ios && ios[method] && typeof ios[method].postMessage === 'function') ||\n (web && typeof web[method] === 'function');\n\n const sub = (listener: any) => {\n subs.push(listener);\n }\n\n const setHeaderMenuItems = (reqId, items: Array<HeaderMenuItem>) => {\n if (items.length > MAX_HEADER_MENU_ITEMS_COUNT) {\n console.error('SetHeaderMenuItems: items count should not be more than ' + MAX_HEADER_MENU_ITEMS_COUNT);\n return;\n }\n\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n const itemsJsonArray = JSON.stringify(items);\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](reqId, itemsJsonArray);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ reqId, itemsJsonArray });\n } else if (web) {\n web.execute(setHeaderMenuItemsMethod, reqId, itemsJsonArray);\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isUnknown');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isUnknown');\n }\n }\n\n const setCustomBackArrowMode = (reqId, enabled: boolean) => {\n const isAndroid = android && android[setCustomBackArrowModeMethod];\n const isIos = ios && ios[setCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowModeMethod](reqId, enabled);\n } else if (isIos) {\n ios[setCustomBackArrowModeMethod].postMessage({ reqId, enabled });\n } else if (web) {\n web.execute(setCustomBackArrowModeMethod, reqId, enabled);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowMode-isUnknown');\n }\n }\n\n const getCustomBackArrowMode = (reqId) => {\n const isAndroid = android && android[getCustomBackArrowModeMethod];\n const isIos = ios && ios[getCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[getCustomBackArrowModeMethod](reqId);\n } else if (isIos) {\n ios[getCustomBackArrowModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getCustomBackArrowModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getCustomBackArrowMode-isUnknown');\n }\n }\n\n const setCustomBackArrowVisible = (reqId, visible: boolean) => {\n const isAndroid = android && android[setCustomBackArrowVisibleMethod];\n const isIos = ios && ios[setCustomBackArrowVisibleMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowVisibleMethod](reqId, visible);\n } else if (isIos) {\n ios[setCustomBackArrowVisibleMethod].postMessage({ reqId, visible });\n } else if (web) {\n web.execute(setCustomBackArrowVisibleMethod, reqId, visible);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowVisible-isUnknown');\n }\n }\n\n const setCustomBackArrowOnClickHandler = (handler: BackArrowClickHandlerType) => {\n const isAndroid = android && android[setCustomBackArrowOnClickHandlerMethod];\n const isIos = ios && ios[setCustomBackArrowOnClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeBackArrowClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowOnClickHandler-isUnknown');\n }\n }\n\n\n const invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, getGeoMethod, sub);\n const getQrPromise = promisifyMethod(getQr, getQrMethod, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, getSMSCodeMethod, sub);\n const selectContactPromise = promisifyMethod(selectContact, selectContactMethod, sub);\n const openSettingsPromise = promisifyMethod(openSettings, openSettingsMethod, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, closeApplicationMethod, sub);\n const sharePromise = promisifyMethod(share, shareMethod, sub);\n const setTitlePromise = promisifyMethod(setTitle, setTitleMethod, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, copyToClipboardMethod, sub);\n const shareImagePromise = promisifyMethod(shareImage, shareImageMethod, sub);\n const shareFilePromise = promisifyMethod(shareFile, shareFileMethod, sub);\n const vibratePromise = promisifyMethod(vibrate, vibrateMethod, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, enableScreenCaptureMethod, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, disableScreenCaptureMethod, sub);\n const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);\n const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);\n const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);\n const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n enablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),\n disablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler,\n setCustomBackArrowMode: setCustomBackArrowModePromise,\n getCustomBackArrowMode: getCustomBackArrowModePromise,\n setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,\n setCustomBackArrowOnClickHandler,\n }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","export const LIB_VERSION = \"0.3.3\";\n"],"names":["createRequestResolver","prefix","counter","current","next","this","createCounter","promiseControllers","add","controller","customId","id","resolve","reqId","data","isSuccess","error","requestPromise","reject","handleSubscribe","subscribe","requestResolver","event","detail","promisifyMethod","method","methodName","Promise","aituOrigin","URLSearchParams","window","location","search","get","localStorage","setItem","getItem","WebBridge","origin","execute","top","postMessage","source","payload","addEventListener","dispatchEvent","CustomEvent","EInvokeRequest","HeaderMenuIcon","android","AndroidBridge","ios","webkit","messageHandlers","web","bridge","subs","e","map","fn","call","message","JSON","parse","onAituBridgeBackArrowClick","onAituBridgeHeaderMenuItemClick","param","sub","listener","push","invokePromise","invokeMethodName","props","isIos","stringify","console","log","invoke","storagePromise","storage","keyName","keyValue","clear","promisifyStorage","getGeoPromise","getQrPromise","getSMSCodePromise","selectContactPromise","openSettingsPromise","closeApplicationPromise","sharePromise","text","setTitlePromise","copyToClipboardPromise","shareImagePromise","image","isAndroid","filename","split","base64Data","substr","indexOf","shareFilePromise","vibratePromise","pattern","Array","isArray","some","timing","Math","floor","reduce","total","enableScreenCapturePromise","disableScreenCapturePromise","setHeaderMenuItemsPromise","items","length","itemsJsonArray","setCustomBackArrowModePromise","enabled","getCustomBackArrowModePromise","setCustomBackArrowVisiblePromise","visible","version","String","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","selectContact","enableNotifications","disableNotifications","enablePrivateMessaging","appId","disablePrivateMessaging","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","setHeaderMenuItems","setHeaderMenuItemClickHandler","setCustomBackArrowMode","getCustomBackArrowMode","setCustomBackArrowVisible","setCustomBackArrowOnClickHandler","buildBridge"],"mappings":"AASA,SAASA,EAAsBC,GAM3B,IAAMC,EAfV,SAAuBD,GACnB,gBADmBA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SAACC,GACLlG,GAAWA,EAAO,iBACtBE,GAAOA,EAAG,iBAEEG,EACvBxB,OAAesH,kBAAoBD,EACT,oBAAXrH,QAChB6C,QAAQC,IAAI,gCA6LdyE,oBAzL0B,SAACF,GACTlG,GAAWA,EAAO,qBACtBE,GAAOA,EAAG,qBAEEG,EACvBxB,OAAewH,sBAAwBH,EACb,oBAAXrH,QAChB6C,QAAQC,IAAI,oCAmLd2E,QAAShD,EACTiD,YAxJkB,WAClB,IAAMC,EAAStG,GAAQrB,OAAesB,OAAOC,gBAAgBwB,OAC7D,OAAO6E,QAAQzG,GAAWwG,GAAUnG,IAuJpCqG,SAnJe,SAAClI,UACfwB,GAAsC,mBAApBA,EAAQxB,IAC1B0B,GAAOA,EAAI1B,IAA8C,mBAA5B0B,EAAI1B,GAAQgB,aACzCa,GAA8B,mBAAhBA,EAAI7B,IAiJnB0C,IAAAA,EACAyF,oBAAqB3C,EACrB4C,qBAAsB3C,EACtB4C,mBAAoB3C,EACpB4C,8BAzHoC,SAACZ,GACnBlG,GAAWA,EAAO,+BACtBE,GAAOA,EAAG,+BAEEG,EACvBxB,OAAemC,gCAAkCkF,EACvB,oBAAXrH,QAChB6C,QAAQC,IAAI,8CAmHdoF,uBAAwBzC,EACxB0C,uBAAwBxC,EACxByC,0BAA2BxC,EAC3ByC,iCArEuC,SAAChB,GACtBlG,GAAWA,EAAO,kCACtBE,GAAOA,EAAG,kCAEEG,EACvBxB,OAAekC,2BAA6BmF,EAClB,oBAAXrH,QAChB6C,QAAQC,IAAI,kDAkEHwF"}
1
+ {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/webBridge.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["function createCounter(prefix = 'm:') {\n return {\n current: 0,\n next() {\n return prefix + ++this.current;\n },\n };\n}\n\nfunction createRequestResolver(prefix: string) {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter(prefix);\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId = ''): number | string {\n const id = customId + counter.next()\n promiseControllers[id] = controller;\n return id;\n },\n\n resolve<T>(reqId: number | string, data: T, isSuccess: (data: T) => boolean, error: any) {\n const requestPromise = promiseControllers[reqId];\n\n if (requestPromise) {\n if (isSuccess(error)) {\n requestPromise.resolve(data);\n } else {\n requestPromise.reject(error);\n }\n\n promiseControllers[reqId] = null;\n }\n },\n };\n}\n\nfunction handleSubscribe(subscribe: (handler: (event: any) => void) => void, requestResolver: ReturnType<typeof createRequestResolver>) {\n subscribe(event => {\n if (!event.detail) {\n return;\n }\n\n if ('reqId' in event.detail) {\n const { reqId, data, error } = event.detail;\n\n if (reqId) {\n requestResolver.resolve(reqId, data, (error) => !(error), error);\n }\n }\n })\n}\n\nexport function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('storage:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return {\n setItem: (keyName: string, keyValue: string): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'setItem', { keyName, keyValue });\n });\n },\n getItem: (keyName: string): Promise<string | null> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'getItem', { keyName });\n });\n },\n clear: (): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'clear', {});\n });\n },\n }\n}\n\nexport function promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('invoke:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(invokeMethodName: string, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, invokeMethodName + ':');\n\n invoke(reqId, invokeMethodName, props);\n });\n };\n}\n\nexport function promisifyMethod(method: Function, methodName: string, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver(methodName + ':');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n method(reqId, ...args);\n });\n };\n}\n\n\n\n","import type { AituBridge } from './index';\n\nconst AITU_DOMAIN_PARAM = '__aitu-domain'\n\nconst searchParams = new URLSearchParams(window.location.search)\n\nlet aituOrigin = searchParams.get(AITU_DOMAIN_PARAM)\n\nif(aituOrigin){\n localStorage.setItem('mini-app-domain', aituOrigin)\n}else{\n aituOrigin = localStorage.getItem('mini-app-domain')\n}\ninterface WebBridge {\n execute(method: keyof AituBridge, reqId: string, ...payload: any[] ): void\n origin: string\n}\n\nlet WebBridge: WebBridge | null = null\n\nif (aituOrigin) {\n WebBridge = {\n origin: aituOrigin,\n execute: (method, reqId, ...payload) => {\n window.top.postMessage({\n source: 'aitu-bridge',\n method,\n reqId,\n payload: [...payload],\n },\n WebBridge.origin\n )\n }\n\n }\n window.addEventListener('message', event => {\n if (event.origin === aituOrigin && event.data) {\n window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));\n }\n })\n}\n\nexport default WebBridge\n","import { LIB_VERSION } from './version';\n\nimport {\n promisifyMethod,\n promisifyStorage,\n promisifyInvoke,\n} from './utils'\n\nimport WebBridge from './webBridge';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications',\n enablePrivateMessaging = 'EnablePrivateMessaging',\n disablePrivateMessaging = 'DisablePrivateMessaging',\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => Promise<void>;\n\ntype HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;\ntype BackArrowClickHandlerType = () => Promise<void>;\n\ninterface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\ninterface GetMeResponse {\n name: string;\n lastname: string;\n id: string;\n avatar?: string;\n avatarThumb?: string;\n sign: string;\n}\n\ninterface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\ninterface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\ninterface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\ninterface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\ninterface GetUserProfileResponse {\n name: string;\n lastname?: string;\n phone?: string;\n avatar?: string;\n avatarThumb?: string;\n}\n\nconst MAX_HEADER_MENU_ITEMS_COUNT = 3;\n\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\nexport interface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n enablePrivateMessaging: (appId: string) => Promise<string>;\n disablePrivateMessaging: (appId: string) => Promise<string>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;\n getCustomBackArrowMode: () => Promise<boolean>;\n setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;\n openPayment: (transactionId: string) => Promise<ResponseType>;\n setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\nconst setCustomBackArrowModeMethod = 'setCustomBackArrowMode';\nconst getCustomBackArrowModeMethod = 'getCustomBackArrowMode';\nconst setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';\nconst openPaymentMethod = 'openPayment'\nconst setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';\n\nconst android = typeof window !== 'undefined' && (window as any).AndroidBridge;\nconst ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;\nconst web = typeof window !== 'undefined' && (window.top !== window) && WebBridge;\n\nconst buildBridge = (): AituBridge => {\n const subs = [];\n\n if (typeof window !== 'undefined') {\n window.addEventListener('aituEvents', (e: any) => {\n [...subs].map((fn) => fn.call(null, e));\n })\n\n window.addEventListener('message', (e) => {\n if(typeof e.data !== 'string') {\n return;\n }\n\n const message = JSON.parse(e.data)\n\n if (message && message['method']) {\n if (message.method === 'setCustomBackArrowOnClickHandler') {\n (window as any).onAituBridgeBackArrowClick()\n } else if (message.method === 'setHeaderMenuItemClickHandler') {\n (window as any).onAituBridgeHeaderMenuItemClick(message.param)\n }\n }\n })\n }\n\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n\n if (isAndroid) {\n android[invokeMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[invokeMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(invokeMethod, reqId, method, data)\n } else if (typeof window !== 'undefined') {\n console.log('--invoke-isUnknown');\n }\n };\n\n const storage = (reqId, method, data = {}) => {\n const isAndroid = android && android[storageMethod];\n const isIos = ios && ios[storageMethod];\n\n if (isAndroid) {\n android[storageMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[storageMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(storageMethod, reqId, method, data);\n } else if (typeof window !== 'undefined') {\n console.log('--storage-isUnknown');\n }\n }\n\n const getGeo = (reqId) => {\n const isAndroid = android && android[getGeoMethod];\n const isIos = ios && ios[getGeoMethod];\n\n if (isAndroid) {\n android[getGeoMethod](reqId);\n } else if (isIos) {\n ios[getGeoMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getGeoMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getGeo-isUnknown');\n }\n }\n\n const getQr = (reqId) => {\n const isAndroid = android && android[getQrMethod];\n const isIos = ios && ios[getQrMethod];\n\n if (isAndroid) {\n android[getQrMethod](reqId);\n } else if (isIos) {\n ios[getQrMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getQrMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getQr-isUnknown');\n }\n }\n\n const getSMSCode = (reqId) => {\n const isAndroid = android && android[getSMSCodeMethod];\n const isIos = ios && ios[getSMSCodeMethod];\n\n if (isAndroid) {\n android[getSMSCodeMethod](reqId);\n } else if (isIos) {\n ios[getSMSCodeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getSMSCodeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getSMSCode-isUnknown');\n }\n }\n\n const selectContact = (reqId) => {\n const isAndroid = android && android[selectContactMethod];\n const isIos = ios && ios[selectContactMethod];\n\n if (isAndroid) {\n android[selectContactMethod](reqId);\n } else if (isIos) {\n ios[selectContactMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(selectContactMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--selectContact-isUnknown');\n }\n }\n\n const openSettings = (reqId) => {\n const isAndroid = android && android[openSettingsMethod];\n const isIos = ios && ios[openSettingsMethod];\n\n if (isAndroid) {\n android[openSettingsMethod](reqId);\n } else if (isIos) {\n ios[openSettingsMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(openSettingsMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--openSettings-isUnknown');\n }\n }\n\n const closeApplication = (reqId) => {\n const isAndroid = android && android[closeApplicationMethod];\n const isIos = ios && ios[closeApplicationMethod];\n\n if (isAndroid) {\n android[closeApplicationMethod](reqId);\n } else if (isIos) {\n ios[closeApplicationMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(closeApplicationMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--closeApplication-isUnknown');\n }\n }\n\n const share = (reqId, text) => {\n const isAndroid = android && android[shareMethod];\n const isIos = ios && ios[shareMethod];\n\n if (isAndroid) {\n android[shareMethod](reqId, text);\n } else if (isIos) {\n ios[shareMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(shareMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--share-isUnknown');\n }\n }\n\n const setTitle = (reqId, text) => {\n const isAndroid = android && android[setTitleMethod];\n const isIos = ios && ios[setTitleMethod];\n\n if (isAndroid) {\n android[setTitleMethod](reqId, text);\n } else if (isIos) {\n ios[setTitleMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(setTitleMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--setTitle-isUnknown');\n }\n }\n\n const copyToClipboard = (reqId, text) => {\n const isAndroid = android && android[copyToClipboardMethod];\n const isIos = ios && ios[copyToClipboardMethod];\n\n if (isAndroid) {\n android[copyToClipboardMethod](reqId, text);\n } else if (isIos) {\n ios[copyToClipboardMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(copyToClipboardMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isUnknown');\n }\n }\n\n const enableScreenCapture = (reqId) => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isUnknown');\n }\n }\n\n const disableScreenCapture = (reqId) => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isUnknown');\n }\n }\n\n const shareImage = (reqId, text, image) => {\n // !!!======================!!!\n // !!!===== Deprecated =====!!!\n // !!!======================!!!\n\n // const isAndroid = android && android[shareImageMethod];\n // const isIos = ios && ios[shareImageMethod];\n\n // if (isAndroid) {\n // android[shareImageMethod](reqId, text, image);\n // } else if (isIos) {\n // ios[shareImageMethod].postMessage({ reqId, text, image });\n // } else if (typeof window !== 'undefined') {\n // console.log('--shareImage-isWeb');\n // }\n\n // new one - fallback to shareFile\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n // get extension from base64 mime type and merge with name\n const ext = image.split(';')[0].split('/')[1];\n const filename = 'image.' + ext;\n // remove mime type\n const base64Data = image.substr(image.indexOf(',') + 1);\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, { text, filename, base64Data });\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const shareFile = (reqId, text, filename, base64Data) => {\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, text, filename, base64Data);\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const enableNotifications = () => invokePromise(EInvokeRequest.enableNotifications);\n\n const disableNotifications = () => invokePromise(EInvokeRequest.disableNotifications);\n\n const setShakeHandler = (handler) => {\n const isAndroid = android && android[setShakeHandlerMethod];\n const isIos = ios && ios[setShakeHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isUnknown');\n }\n };\n\n const setTabActiveHandler = (handler: (tabname: string) => void) => {\n const isAndroid = android && android[setTabActiveHandlerMethod];\n const isIos = ios && ios[setTabActiveHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isUnknown');\n }\n };\n\n const vibrate = (reqId, pattern) => {\n if (\n !Array.isArray(pattern) ||\n pattern.some((timing) => timing < 1 || timing !== Math.floor(timing)) ||\n pattern.reduce((total, timing) => total + timing) > 10000\n ) {\n console.error('Pattern should be an array of positive integers no longer than 10000ms total');\n return;\n }\n\n const isAndroid = android && android[vibrateMethod];\n const isIos = ios && ios[vibrateMethod];\n\n if (isAndroid) {\n android[vibrateMethod](reqId, JSON.stringify(pattern));\n } else if (isIos) {\n ios[vibrateMethod].postMessage({ reqId, pattern });\n } else if (web) {\n web.execute(vibrateMethod, reqId, pattern);\n } else if (typeof window !== 'undefined') {\n console.log('--vibrate-isUnknown');\n }\n }\n\n const isSupported = () => {\n const iosSup = ios && (window as any).webkit.messageHandlers.invoke;\n return Boolean(android || iosSup || web);\n }\n\n // TODO: implement web support\n const supports = (method) =>\n (android && typeof android[method] === 'function') ||\n (ios && ios[method] && typeof ios[method].postMessage === 'function') ||\n (web && typeof web[method] === 'function');\n\n const sub = (listener: any) => {\n subs.push(listener);\n }\n\n const setHeaderMenuItems = (reqId, items: Array<HeaderMenuItem>) => {\n if (items.length > MAX_HEADER_MENU_ITEMS_COUNT) {\n console.error('SetHeaderMenuItems: items count should not be more than ' + MAX_HEADER_MENU_ITEMS_COUNT);\n return;\n }\n\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n const itemsJsonArray = JSON.stringify(items);\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](reqId, itemsJsonArray);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ reqId, itemsJsonArray });\n } else if (web) {\n web.execute(setHeaderMenuItemsMethod, reqId, itemsJsonArray);\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isUnknown');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isUnknown');\n }\n }\n\n const setCustomBackArrowMode = (reqId, enabled: boolean) => {\n const isAndroid = android && android[setCustomBackArrowModeMethod];\n const isIos = ios && ios[setCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowModeMethod](reqId, enabled);\n } else if (isIos) {\n ios[setCustomBackArrowModeMethod].postMessage({ reqId, enabled });\n } else if (web) {\n web.execute(setCustomBackArrowModeMethod, reqId, enabled);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowMode-isUnknown');\n }\n }\n\n const getCustomBackArrowMode = (reqId) => {\n const isAndroid = android && android[getCustomBackArrowModeMethod];\n const isIos = ios && ios[getCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[getCustomBackArrowModeMethod](reqId);\n } else if (isIos) {\n ios[getCustomBackArrowModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getCustomBackArrowModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getCustomBackArrowMode-isUnknown');\n }\n }\n\n const setCustomBackArrowVisible = (reqId, visible: boolean) => {\n const isAndroid = android && android[setCustomBackArrowVisibleMethod];\n const isIos = ios && ios[setCustomBackArrowVisibleMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowVisibleMethod](reqId, visible);\n } else if (isIos) {\n ios[setCustomBackArrowVisibleMethod].postMessage({ reqId, visible });\n } else if (web) {\n web.execute(setCustomBackArrowVisibleMethod, reqId, visible);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowVisible-isUnknown');\n }\n }\n\n const setCustomBackArrowOnClickHandler = (handler: BackArrowClickHandlerType) => {\n const isAndroid = android && android[setCustomBackArrowOnClickHandlerMethod];\n const isIos = ios && ios[setCustomBackArrowOnClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeBackArrowClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowOnClickHandler-isUnknown');\n }\n }\n\n const openPayment = (reqId, transactionId: string) => {\n const isAndroid = android && android[openPaymentMethod];\n const isIos = ios && ios[openPaymentMethod];\n\n if (isAndroid) {\n android[openPaymentMethod](reqId, transactionId);\n } else if (isIos) {\n ios[openPaymentMethod].postMessage({ reqId, transactionId });\n } else {\n console.log('--openPayment-isUnknown');\n }\n }\n\n\n const invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, getGeoMethod, sub);\n const getQrPromise = promisifyMethod(getQr, getQrMethod, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, getSMSCodeMethod, sub);\n const selectContactPromise = promisifyMethod(selectContact, selectContactMethod, sub);\n const openSettingsPromise = promisifyMethod(openSettings, openSettingsMethod, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, closeApplicationMethod, sub);\n const sharePromise = promisifyMethod(share, shareMethod, sub);\n const setTitlePromise = promisifyMethod(setTitle, setTitleMethod, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, copyToClipboardMethod, sub);\n const shareImagePromise = promisifyMethod(shareImage, shareImageMethod, sub);\n const shareFilePromise = promisifyMethod(shareFile, shareFileMethod, sub);\n const vibratePromise = promisifyMethod(vibrate, vibrateMethod, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, enableScreenCaptureMethod, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, disableScreenCaptureMethod, sub);\n const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);\n const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);\n const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);\n const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);\n const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n enablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),\n disablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler,\n setCustomBackArrowMode: setCustomBackArrowModePromise,\n getCustomBackArrowMode: getCustomBackArrowModePromise,\n setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,\n openPayment: openPaymentPromise,\n setCustomBackArrowOnClickHandler,\n }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","export const LIB_VERSION = \"0.3.4\";\n"],"names":["createRequestResolver","prefix","counter","current","next","this","createCounter","promiseControllers","add","controller","customId","id","resolve","reqId","data","isSuccess","error","requestPromise","reject","handleSubscribe","subscribe","requestResolver","event","detail","promisifyMethod","method","methodName","Promise","aituOrigin","URLSearchParams","window","location","search","get","localStorage","setItem","getItem","WebBridge","origin","execute","top","postMessage","source","payload","addEventListener","dispatchEvent","CustomEvent","EInvokeRequest","HeaderMenuIcon","android","AndroidBridge","ios","webkit","messageHandlers","web","bridge","subs","e","map","fn","call","message","JSON","parse","onAituBridgeBackArrowClick","onAituBridgeHeaderMenuItemClick","param","sub","listener","push","invokePromise","invokeMethodName","props","isIos","stringify","console","log","invoke","storagePromise","storage","keyName","keyValue","clear","promisifyStorage","getGeoPromise","getQrPromise","getSMSCodePromise","selectContactPromise","openSettingsPromise","closeApplicationPromise","sharePromise","text","setTitlePromise","copyToClipboardPromise","shareImagePromise","image","isAndroid","filename","split","base64Data","substr","indexOf","shareFilePromise","vibratePromise","pattern","Array","isArray","some","timing","Math","floor","reduce","total","enableScreenCapturePromise","disableScreenCapturePromise","setHeaderMenuItemsPromise","items","length","itemsJsonArray","setCustomBackArrowModePromise","enabled","getCustomBackArrowModePromise","setCustomBackArrowVisiblePromise","visible","openPaymentPromise","transactionId","version","String","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","selectContact","enableNotifications","disableNotifications","enablePrivateMessaging","appId","disablePrivateMessaging","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","setHeaderMenuItems","setHeaderMenuItemClickHandler","setCustomBackArrowMode","getCustomBackArrowMode","setCustomBackArrowVisible","openPayment","setCustomBackArrowOnClickHandler","buildBridge"],"mappings":"AASA,SAASA,EAAsBC,GAM3B,IAAMC,EAfV,SAAuBD,GACnB,gBADmBA,IAAAA,EAAS,MACrB,CACHE,QAAS,EACTC,gBACI,OAAOH,KAAWI,KAAKF,UAWfG,CAAcL,GACxBM,EAA+D,GAErE,MAAO,CACHC,aAAIC,EAA+BC,YAAAA,IAAAA,EAAW,IAC1C,IAAMC,EAAKD,EAAWR,EAAQE,OAE9B,OADAG,EAAmBI,GAAMF,EAClBE,GAGXC,iBAAWC,EAAwBC,EAASC,EAAiCC,GACzE,IAAMC,EAAiBV,EAAmBM,GAEtCI,IACIF,EAAUC,GACVC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAG1BT,EAAmBM,GAAS,QAM5C,SAASM,EAAgBC,EAAoDC,GACzED,EAAU,SAAAE,GACN,GAAKA,EAAMC,QAIP,UAAWD,EAAMC,OAAQ,OACMD,EAAMC,OAA7BV,IAAAA,MAEJA,GACAQ,EAAgBT,QAAQC,IAHbC,KAG0B,SAACE,UAAYA,KAHjCA,mBAkDjBQ,EAAgBC,EAAkBC,EAAoBN,GAClE,IAAMC,EAAkBrB,EAAsB0B,EAAa,KAI3D,OAFAP,EAAgBC,EAAWC,8BAGvB,WAAWM,QAAQ,SAACf,EAASM,GACzB,IAAML,EAAQQ,EAAgBb,IAAI,CAAEI,QAAAA,EAASM,OAAAA,IAC7CO,gBAAOZ,gCCxGnB,IAIIe,EAFiB,IAAIC,gBAAgBC,OAAOC,SAASC,QAE3BC,IAJJ,iBAMvBL,EACCM,aAAaC,QAAQ,kBAAmBP,GAExCA,EAAaM,aAAaE,QAAQ,mBAOtC,IAAIC,EAA8B,KAE9BT,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BAAXvH,QAChB6C,QAAQC,IAAI,8CAiIdsF,uBAAwB3C,EACxB4C,uBAAwB1C,EACxB2C,0BAA2B1C,EAC3B2C,YAAazC,EACb0C,iCApFuC,SAACjB,GACtBpG,GAAWA,EAAO,kCACtBE,GAAOA,EAAG,kCAEEG,EACvBxB,OAAekC,2BAA6BqF,EAClB,oBAAXvH,QAChB6C,QAAQC,IAAI,kDAiFH2F"}
@@ -1,2 +1,2 @@
1
- function e(e){const t=function(e="m:"){return{current:0,next(){return e+ ++this.current}}}(e),o={};return{add(e,n=""){const s=n+t.next();return o[s]=e,s},resolve(e,t,n,s){const i=o[e];i&&(n(s)?i.resolve(t):i.reject(s),o[e]=null)}}}function t(e,t){e(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:o,data:n,error:s}=e.detail;o&&t.resolve(o,n,e=>!e,s)}})}function o(o,n,s){const i=e(n+":");return t(s,i),function(...e){return new Promise((t,n)=>{const s=i.add({resolve:t,reject:n});o(s,...e)})}}let n=new URLSearchParams(window.location.search).get("__aitu-domain");n?localStorage.setItem("mini-app-domain",n):n=localStorage.getItem("mini-app-domain");let s=null;n&&(s={origin:n,execute:(e,t,...o)=>{window.top.postMessage({source:"aitu-bridge",method:e,reqId:t,payload:[...o]},s.origin)}},window.addEventListener("message",e=>{e.origin===n&&e.data&&window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data}))}));var i,r,a=s;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(i||(i={})),function(e){e.Search="Search",e.ShoppingCart="ShoppingCart",e.Menu="Menu",e.Share="Share",e.Notifications="Notifications",e.Help="Help",e.Error="Error",e.Person="Person",e.Sort="Sort",e.Filter="Filter"}(r||(r={}));const d="undefined"!=typeof window&&window.AndroidBridge,c="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,l="undefined"!=typeof window&&window.top!==window&&a,u=(()=>{const n=[];"undefined"!=typeof window&&(window.addEventListener("aituEvents",e=>{[...n].map(t=>t.call(null,e))}),window.addEventListener("message",e=>{if("string"!=typeof e.data)return;const t=JSON.parse(e.data);t&&t.method&&("setCustomBackArrowOnClickHandler"===t.method?window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===t.method&&window.onAituBridgeHeaderMenuItemClick(t.param))}));const s=e=>{n.push(e)},r=function(o,n){const s=e("invoke:");return t(n,s),function(e,t={}){return new Promise((o,n)=>{((e,t,o={})=>{const n=c&&c.invoke;d&&d.invoke?d.invoke(e,t,JSON.stringify(o)):n?c.invoke.postMessage({reqId:e,method:t,data:o}):l?l.execute("invoke",e,t,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")})(s.add({resolve:o,reject:n},e+":"),e,t)})}}(0,s),a=function(o,n){const s=e("storage:");return t(n,s),{setItem:(e,t)=>new Promise((n,i)=>{const r=s.add({resolve:n,reject:i});o(r,"setItem",{keyName:e,keyValue:t})}),getItem:e=>new Promise((t,n)=>{const i=s.add({resolve:t,reject:n});o(i,"getItem",{keyName:e})}),clear:()=>new Promise((e,t)=>{const n=s.add({resolve:e,reject:t});o(n,"clear",{})})}}((e,t,o={})=>{const n=c&&c.storage;d&&d.storage?d.storage(e,t,JSON.stringify(o)):n?c.storage.postMessage({reqId:e,method:t,data:o}):l?l.execute("storage",e,t,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},s),u=o(e=>{const t=c&&c.getGeo;d&&d.getGeo?d.getGeo(e):t?c.getGeo.postMessage({reqId:e}):l?l.execute("getGeo",e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},"getGeo",s),w=o(e=>{const t=c&&c.getQr;d&&d.getQr?d.getQr(e):t?c.getQr.postMessage({reqId:e}):l?l.execute("getQr",e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},"getQr",s),g=o(e=>{const t=c&&c.getSMSCode;d&&d.getSMSCode?d.getSMSCode(e):t?c.getSMSCode.postMessage({reqId:e}):l?l.execute("getSMSCode",e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},"getSMSCode",s),p=o(e=>{const t=c&&c.selectContact;d&&d.selectContact?d.selectContact(e):t?c.selectContact.postMessage({reqId:e}):l?l.execute("selectContact",e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},"selectContact",s),f=o(e=>{const t=c&&c.openSettings;d&&d.openSettings?d.openSettings(e):t?c.openSettings.postMessage({reqId:e}):l?l.execute("openSettings",e):"undefined"!=typeof window&&console.log("--openSettings-isUnknown")},"openSettings",s),C=o(e=>{const t=c&&c.closeApplication;d&&d.closeApplication?d.closeApplication(e):t?c.closeApplication.postMessage({reqId:e}):l?l.execute("closeApplication",e):"undefined"!=typeof window&&console.log("--closeApplication-isUnknown")},"closeApplication",s),k=o((e,t)=>{const o=c&&c.share;d&&d.share?d.share(e,t):o?c.share.postMessage({reqId:e,text:t}):l?l.execute("share",e,t):"undefined"!=typeof window&&console.log("--share-isUnknown")},"share",s),m=o((e,t)=>{const o=c&&c.setTitle;d&&d.setTitle?d.setTitle(e,t):o?c.setTitle.postMessage({reqId:e,text:t}):l?l.execute("setTitle",e,t):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},"setTitle",s),M=o((e,t)=>{const o=c&&c.copyToClipboard;d&&d.copyToClipboard?d.copyToClipboard(e,t):o?c.copyToClipboard.postMessage({reqId:e,text:t}):l?l.execute("copyToClipboard",e,t):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},"copyToClipboard",s),b=o((e,t,o)=>{const n=d&&d.shareFile,s=c&&c.shareFile,i="image."+o.split(";")[0].split("/")[1],r=o.substr(o.indexOf(",")+1);n?d.shareFile(e,t,i,r):s?c.shareFile.postMessage({reqId:e,text:t,filename:i,base64Data:r}):l?l.execute("shareFile",e,{text:t,filename:i,base64Data:r}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",s),S=o((e,t,o,n)=>{const s=c&&c.shareFile;d&&d.shareFile?d.shareFile(e,t,o,n):s?c.shareFile.postMessage({reqId:e,text:t,filename:o,base64Data:n}):l?l.execute("shareFile",e,t,o,n):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareFile",s),h=o((e,t)=>{if(!Array.isArray(t)||t.some(e=>e<1||e!==Math.floor(e))||t.reduce((e,t)=>e+t)>1e4)return void console.error("Pattern should be an array of positive integers no longer than 10000ms total");const o=c&&c.vibrate;d&&d.vibrate?d.vibrate(e,JSON.stringify(t)):o?c.vibrate.postMessage({reqId:e,pattern:t}):l?l.execute("vibrate",e,t):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")},"vibrate",s),A=o(e=>{const t=c&&c.enableScreenCapture;d&&d.enableScreenCapture?d.enableScreenCapture(e):t?c.enableScreenCapture.postMessage({reqId:e}):l?l.execute("enableScreenCapture",e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},"enableScreenCapture",s),y=o(e=>{const t=c&&c.disableScreenCapture;d&&d.disableScreenCapture?d.disableScreenCapture(e):t?c.disableScreenCapture.postMessage({reqId:e}):l?l.execute("disableScreenCapture",e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},"disableScreenCapture",s),v=o((e,t)=>{if(t.length>3)return void console.error("SetHeaderMenuItems: items count should not be more than 3");const o=d&&d.setHeaderMenuItems,n=c&&c.setHeaderMenuItems,s=JSON.stringify(t);o?d.setHeaderMenuItems(e,s):n?c.setHeaderMenuItems.postMessage({reqId:e,itemsJsonArray:s}):l?l.execute("setHeaderMenuItems",e,s):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")},"setHeaderMenuItems",s),I=o((e,t)=>{const o=c&&c.setCustomBackArrowMode;d&&d.setCustomBackArrowMode?d.setCustomBackArrowMode(e,t):o?c.setCustomBackArrowMode.postMessage({reqId:e,enabled:t}):l?l.execute("setCustomBackArrowMode",e,t):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},"setCustomBackArrowMode",s),B=o(e=>{const t=c&&c.getCustomBackArrowMode;d&&d.getCustomBackArrowMode?d.getCustomBackArrowMode(e):t?c.getCustomBackArrowMode.postMessage({reqId:e}):l?l.execute("getCustomBackArrowMode",e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},"getCustomBackArrowMode",s),H=o((e,t)=>{const o=c&&c.setCustomBackArrowVisible;d&&d.setCustomBackArrowVisible?d.setCustomBackArrowVisible(e,t):o?c.setCustomBackArrowVisible.postMessage({reqId:e,visible:t}):l?l.execute("setCustomBackArrowVisible",e,t):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},"setCustomBackArrowVisible",s);return{version:String("0.3.3"),copyToClipboard:M,invoke:r,storage:a,getMe:()=>r(i.getMe),getPhone:()=>r(i.getPhone),getContacts:()=>r(i.getContacts),getGeo:u,getQr:w,getSMSCode:g,getUserProfile:e=>r(i.getUserProfile,{id:e}),selectContact:p,enableNotifications:()=>r(i.enableNotifications),disableNotifications:()=>r(i.disableNotifications),enablePrivateMessaging:e=>r(i.enablePrivateMessaging,{appId:e}),disablePrivateMessaging:e=>r(i.disablePrivateMessaging,{appId:e}),openSettings:f,closeApplication:C,setTitle:m,share:k,shareImage:b,shareFile:S,setShakeHandler:e=>{d&&d.setShakeHandler||c&&c.setShakeHandler||l?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:e=>{d&&d.setTabActiveHandler||c&&c.setTabActiveHandler||l?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:h,isSupported:()=>{const e=c&&window.webkit.messageHandlers.invoke;return Boolean(d||e||l)},supports:e=>d&&"function"==typeof d[e]||c&&c[e]&&"function"==typeof c[e].postMessage||l&&"function"==typeof l[e],sub:s,enableScreenCapture:A,disableScreenCapture:y,setHeaderMenuItems:v,setHeaderMenuItemClickHandler:e=>{d&&d.setHeaderMenuItemClickHandler||c&&c.setHeaderMenuItemClickHandler||l?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:I,getCustomBackArrowMode:B,setCustomBackArrowVisible:H,setCustomBackArrowOnClickHandler:e=>{d&&d.setCustomBackArrowOnClickHandler||c&&c.setCustomBackArrowOnClickHandler||l?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")}}})();export default u;export{r as HeaderMenuIcon};
1
+ function e(e){const t=function(e="m:"){return{current:0,next(){return e+ ++this.current}}}(e),o={};return{add(e,n=""){const s=n+t.next();return o[s]=e,s},resolve(e,t,n,s){const i=o[e];i&&(n(s)?i.resolve(t):i.reject(s),o[e]=null)}}}function t(e,t){e(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:o,data:n,error:s}=e.detail;o&&t.resolve(o,n,e=>!e,s)}})}function o(o,n,s){const i=e(n+":");return t(s,i),function(...e){return new Promise((t,n)=>{const s=i.add({resolve:t,reject:n});o(s,...e)})}}let n=new URLSearchParams(window.location.search).get("__aitu-domain");n?localStorage.setItem("mini-app-domain",n):n=localStorage.getItem("mini-app-domain");let s=null;n&&(s={origin:n,execute:(e,t,...o)=>{window.top.postMessage({source:"aitu-bridge",method:e,reqId:t,payload:[...o]},s.origin)}},window.addEventListener("message",e=>{e.origin===n&&e.data&&window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data}))}));var i,r,a=s;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(i||(i={})),function(e){e.Search="Search",e.ShoppingCart="ShoppingCart",e.Menu="Menu",e.Share="Share",e.Notifications="Notifications",e.Help="Help",e.Error="Error",e.Person="Person",e.Sort="Sort",e.Filter="Filter"}(r||(r={}));const d="undefined"!=typeof window&&window.AndroidBridge,c="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,l="undefined"!=typeof window&&window.top!==window&&a,u=(()=>{const n=[];"undefined"!=typeof window&&(window.addEventListener("aituEvents",e=>{[...n].map(t=>t.call(null,e))}),window.addEventListener("message",e=>{if("string"!=typeof e.data)return;const t=JSON.parse(e.data);t&&t.method&&("setCustomBackArrowOnClickHandler"===t.method?window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===t.method&&window.onAituBridgeHeaderMenuItemClick(t.param))}));const s=e=>{n.push(e)},r=function(o,n){const s=e("invoke:");return t(n,s),function(e,t={}){return new Promise((o,n)=>{((e,t,o={})=>{const n=c&&c.invoke;d&&d.invoke?d.invoke(e,t,JSON.stringify(o)):n?c.invoke.postMessage({reqId:e,method:t,data:o}):l?l.execute("invoke",e,t,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")})(s.add({resolve:o,reject:n},e+":"),e,t)})}}(0,s),a=function(o,n){const s=e("storage:");return t(n,s),{setItem:(e,t)=>new Promise((n,i)=>{const r=s.add({resolve:n,reject:i});o(r,"setItem",{keyName:e,keyValue:t})}),getItem:e=>new Promise((t,n)=>{const i=s.add({resolve:t,reject:n});o(i,"getItem",{keyName:e})}),clear:()=>new Promise((e,t)=>{const n=s.add({resolve:e,reject:t});o(n,"clear",{})})}}((e,t,o={})=>{const n=c&&c.storage;d&&d.storage?d.storage(e,t,JSON.stringify(o)):n?c.storage.postMessage({reqId:e,method:t,data:o}):l?l.execute("storage",e,t,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},s),u=o(e=>{const t=c&&c.getGeo;d&&d.getGeo?d.getGeo(e):t?c.getGeo.postMessage({reqId:e}):l?l.execute("getGeo",e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},"getGeo",s),g=o(e=>{const t=c&&c.getQr;d&&d.getQr?d.getQr(e):t?c.getQr.postMessage({reqId:e}):l?l.execute("getQr",e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},"getQr",s),w=o(e=>{const t=c&&c.getSMSCode;d&&d.getSMSCode?d.getSMSCode(e):t?c.getSMSCode.postMessage({reqId:e}):l?l.execute("getSMSCode",e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},"getSMSCode",s),p=o(e=>{const t=c&&c.selectContact;d&&d.selectContact?d.selectContact(e):t?c.selectContact.postMessage({reqId:e}):l?l.execute("selectContact",e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},"selectContact",s),f=o(e=>{const t=c&&c.openSettings;d&&d.openSettings?d.openSettings(e):t?c.openSettings.postMessage({reqId:e}):l?l.execute("openSettings",e):"undefined"!=typeof window&&console.log("--openSettings-isUnknown")},"openSettings",s),m=o(e=>{const t=c&&c.closeApplication;d&&d.closeApplication?d.closeApplication(e):t?c.closeApplication.postMessage({reqId:e}):l?l.execute("closeApplication",e):"undefined"!=typeof window&&console.log("--closeApplication-isUnknown")},"closeApplication",s),k=o((e,t)=>{const o=c&&c.share;d&&d.share?d.share(e,t):o?c.share.postMessage({reqId:e,text:t}):l?l.execute("share",e,t):"undefined"!=typeof window&&console.log("--share-isUnknown")},"share",s),C=o((e,t)=>{const o=c&&c.setTitle;d&&d.setTitle?d.setTitle(e,t):o?c.setTitle.postMessage({reqId:e,text:t}):l?l.execute("setTitle",e,t):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},"setTitle",s),M=o((e,t)=>{const o=c&&c.copyToClipboard;d&&d.copyToClipboard?d.copyToClipboard(e,t):o?c.copyToClipboard.postMessage({reqId:e,text:t}):l?l.execute("copyToClipboard",e,t):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},"copyToClipboard",s),b=o((e,t,o)=>{const n=d&&d.shareFile,s=c&&c.shareFile,i="image."+o.split(";")[0].split("/")[1],r=o.substr(o.indexOf(",")+1);n?d.shareFile(e,t,i,r):s?c.shareFile.postMessage({reqId:e,text:t,filename:i,base64Data:r}):l?l.execute("shareFile",e,{text:t,filename:i,base64Data:r}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",s),S=o((e,t,o,n)=>{const s=c&&c.shareFile;d&&d.shareFile?d.shareFile(e,t,o,n):s?c.shareFile.postMessage({reqId:e,text:t,filename:o,base64Data:n}):l?l.execute("shareFile",e,t,o,n):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareFile",s),y=o((e,t)=>{if(!Array.isArray(t)||t.some(e=>e<1||e!==Math.floor(e))||t.reduce((e,t)=>e+t)>1e4)return void console.error("Pattern should be an array of positive integers no longer than 10000ms total");const o=c&&c.vibrate;d&&d.vibrate?d.vibrate(e,JSON.stringify(t)):o?c.vibrate.postMessage({reqId:e,pattern:t}):l?l.execute("vibrate",e,t):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")},"vibrate",s),h=o(e=>{const t=c&&c.enableScreenCapture;d&&d.enableScreenCapture?d.enableScreenCapture(e):t?c.enableScreenCapture.postMessage({reqId:e}):l?l.execute("enableScreenCapture",e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},"enableScreenCapture",s),A=o(e=>{const t=c&&c.disableScreenCapture;d&&d.disableScreenCapture?d.disableScreenCapture(e):t?c.disableScreenCapture.postMessage({reqId:e}):l?l.execute("disableScreenCapture",e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},"disableScreenCapture",s),v=o((e,t)=>{if(t.length>3)return void console.error("SetHeaderMenuItems: items count should not be more than 3");const o=d&&d.setHeaderMenuItems,n=c&&c.setHeaderMenuItems,s=JSON.stringify(t);o?d.setHeaderMenuItems(e,s):n?c.setHeaderMenuItems.postMessage({reqId:e,itemsJsonArray:s}):l?l.execute("setHeaderMenuItems",e,s):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")},"setHeaderMenuItems",s),I=o((e,t)=>{const o=c&&c.setCustomBackArrowMode;d&&d.setCustomBackArrowMode?d.setCustomBackArrowMode(e,t):o?c.setCustomBackArrowMode.postMessage({reqId:e,enabled:t}):l?l.execute("setCustomBackArrowMode",e,t):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},"setCustomBackArrowMode",s),B=o(e=>{const t=c&&c.getCustomBackArrowMode;d&&d.getCustomBackArrowMode?d.getCustomBackArrowMode(e):t?c.getCustomBackArrowMode.postMessage({reqId:e}):l?l.execute("getCustomBackArrowMode",e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},"getCustomBackArrowMode",s),H=o((e,t)=>{const o=c&&c.setCustomBackArrowVisible;d&&d.setCustomBackArrowVisible?d.setCustomBackArrowVisible(e,t):o?c.setCustomBackArrowVisible.postMessage({reqId:e,visible:t}):l?l.execute("setCustomBackArrowVisible",e,t):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},"setCustomBackArrowVisible",s),x=o((e,t)=>{const o=c&&c.openPayment;d&&d.openPayment?d.openPayment(e,t):o?c.openPayment.postMessage({reqId:e,transactionId:t}):console.log("--openPayment-isUnknown")},"openPayment",s);return{version:String("0.3.4"),copyToClipboard:M,invoke:r,storage:a,getMe:()=>r(i.getMe),getPhone:()=>r(i.getPhone),getContacts:()=>r(i.getContacts),getGeo:u,getQr:g,getSMSCode:w,getUserProfile:e=>r(i.getUserProfile,{id:e}),selectContact:p,enableNotifications:()=>r(i.enableNotifications),disableNotifications:()=>r(i.disableNotifications),enablePrivateMessaging:e=>r(i.enablePrivateMessaging,{appId:e}),disablePrivateMessaging:e=>r(i.disablePrivateMessaging,{appId:e}),openSettings:f,closeApplication:m,setTitle:C,share:k,shareImage:b,shareFile:S,setShakeHandler:e=>{d&&d.setShakeHandler||c&&c.setShakeHandler||l?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:e=>{d&&d.setTabActiveHandler||c&&c.setTabActiveHandler||l?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:y,isSupported:()=>{const e=c&&window.webkit.messageHandlers.invoke;return Boolean(d||e||l)},supports:e=>d&&"function"==typeof d[e]||c&&c[e]&&"function"==typeof c[e].postMessage||l&&"function"==typeof l[e],sub:s,enableScreenCapture:h,disableScreenCapture:A,setHeaderMenuItems:v,setHeaderMenuItemClickHandler:e=>{d&&d.setHeaderMenuItemClickHandler||c&&c.setHeaderMenuItemClickHandler||l?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:I,getCustomBackArrowMode:B,setCustomBackArrowVisible:H,openPayment:x,setCustomBackArrowOnClickHandler:e=>{d&&d.setCustomBackArrowOnClickHandler||c&&c.setCustomBackArrowOnClickHandler||l?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")}}})();export default u;export{r as HeaderMenuIcon};
2
2
  //# sourceMappingURL=index.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/utils.ts","../src/webBridge.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["function createCounter(prefix = 'm:') {\n return {\n current: 0,\n next() {\n return prefix + ++this.current;\n },\n };\n}\n\nfunction createRequestResolver(prefix: string) {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter(prefix);\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId = ''): number | string {\n const id = customId + counter.next()\n promiseControllers[id] = controller;\n return id;\n },\n\n resolve<T>(reqId: number | string, data: T, isSuccess: (data: T) => boolean, error: any) {\n const requestPromise = promiseControllers[reqId];\n\n if (requestPromise) {\n if (isSuccess(error)) {\n requestPromise.resolve(data);\n } else {\n requestPromise.reject(error);\n }\n\n promiseControllers[reqId] = null;\n }\n },\n };\n}\n\nfunction handleSubscribe(subscribe: (handler: (event: any) => void) => void, requestResolver: ReturnType<typeof createRequestResolver>) {\n subscribe(event => {\n if (!event.detail) {\n return;\n }\n\n if ('reqId' in event.detail) {\n const { reqId, data, error } = event.detail;\n\n if (reqId) {\n requestResolver.resolve(reqId, data, (error) => !(error), error);\n }\n }\n })\n}\n\nexport function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('storage:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return {\n setItem: (keyName: string, keyValue: string): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'setItem', { keyName, keyValue });\n });\n },\n getItem: (keyName: string): Promise<string | null> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'getItem', { keyName });\n });\n },\n clear: (): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'clear', {});\n });\n },\n }\n}\n\nexport function promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('invoke:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(invokeMethodName: string, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, invokeMethodName + ':');\n\n invoke(reqId, invokeMethodName, props);\n });\n };\n}\n\nexport function promisifyMethod(method: Function, methodName: string, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver(methodName + ':');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n method(reqId, ...args);\n });\n };\n}\n\n\n\n","import type { AituBridge } from './index';\n\nconst AITU_DOMAIN_PARAM = '__aitu-domain'\n\nconst searchParams = new URLSearchParams(window.location.search)\n\nlet aituOrigin = searchParams.get(AITU_DOMAIN_PARAM)\n\nif(aituOrigin){\n localStorage.setItem('mini-app-domain', aituOrigin)\n}else{\n aituOrigin = localStorage.getItem('mini-app-domain')\n}\ninterface WebBridge {\n execute(method: keyof AituBridge, reqId: string, ...payload: any[] ): void\n origin: string\n}\n\nlet WebBridge: WebBridge | null = null\n\nif (aituOrigin) {\n WebBridge = {\n origin: aituOrigin,\n execute: (method, reqId, ...payload) => {\n window.top.postMessage({\n source: 'aitu-bridge',\n method,\n reqId,\n payload: [...payload],\n },\n WebBridge.origin\n )\n }\n\n }\n window.addEventListener('message', event => {\n if (event.origin === aituOrigin && event.data) {\n window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));\n }\n })\n}\n\nexport default WebBridge\n","import { LIB_VERSION } from './version';\n\nimport {\n promisifyMethod,\n promisifyStorage,\n promisifyInvoke,\n} from './utils'\n\nimport WebBridge from './webBridge';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications',\n enablePrivateMessaging = 'EnablePrivateMessaging',\n disablePrivateMessaging = 'DisablePrivateMessaging',\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => Promise<void>;\n\ntype HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;\ntype BackArrowClickHandlerType = () => Promise<void>;\n\ninterface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\ninterface GetMeResponse {\n name: string;\n lastname: string;\n id: string;\n avatar?: string;\n avatarThumb?: string;\n sign: string;\n}\n\ninterface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\ninterface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\ninterface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\ninterface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\ninterface GetUserProfileResponse {\n name: string;\n lastname?: string;\n phone?: string;\n avatar?: string;\n avatarThumb?: string;\n}\n\nconst MAX_HEADER_MENU_ITEMS_COUNT = 3;\n\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\nexport interface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n enablePrivateMessaging: (appId: string) => Promise<string>;\n disablePrivateMessaging: (appId: string) => Promise<string>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;\n getCustomBackArrowMode: () => Promise<boolean>;\n setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;\n setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\nconst setCustomBackArrowModeMethod = 'setCustomBackArrowMode';\nconst getCustomBackArrowModeMethod = 'getCustomBackArrowMode';\nconst setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';\nconst setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';\n\nconst android = typeof window !== 'undefined' && (window as any).AndroidBridge;\nconst ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;\nconst web = typeof window !== 'undefined' && (window.top !== window) && WebBridge;\n\nconst buildBridge = (): AituBridge => {\n const subs = [];\n\n if (typeof window !== 'undefined') {\n window.addEventListener('aituEvents', (e: any) => {\n [...subs].map((fn) => fn.call(null, e));\n })\n\n window.addEventListener('message', (e) => {\n if(typeof e.data !== 'string') {\n return;\n }\n\n const message = JSON.parse(e.data)\n\n if (message && message['method']) {\n if (message.method === 'setCustomBackArrowOnClickHandler') {\n (window as any).onAituBridgeBackArrowClick()\n } else if (message.method === 'setHeaderMenuItemClickHandler') {\n (window as any).onAituBridgeHeaderMenuItemClick(message.param)\n }\n }\n })\n }\n\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n\n if (isAndroid) {\n android[invokeMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[invokeMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(invokeMethod, reqId, method, data)\n } else if (typeof window !== 'undefined') {\n console.log('--invoke-isUnknown');\n }\n };\n\n const storage = (reqId, method, data = {}) => {\n const isAndroid = android && android[storageMethod];\n const isIos = ios && ios[storageMethod];\n\n if (isAndroid) {\n android[storageMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[storageMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(storageMethod, reqId, method, data);\n } else if (typeof window !== 'undefined') {\n console.log('--storage-isUnknown');\n }\n }\n\n const getGeo = (reqId) => {\n const isAndroid = android && android[getGeoMethod];\n const isIos = ios && ios[getGeoMethod];\n\n if (isAndroid) {\n android[getGeoMethod](reqId);\n } else if (isIos) {\n ios[getGeoMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getGeoMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getGeo-isUnknown');\n }\n }\n\n const getQr = (reqId) => {\n const isAndroid = android && android[getQrMethod];\n const isIos = ios && ios[getQrMethod];\n\n if (isAndroid) {\n android[getQrMethod](reqId);\n } else if (isIos) {\n ios[getQrMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getQrMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getQr-isUnknown');\n }\n }\n\n const getSMSCode = (reqId) => {\n const isAndroid = android && android[getSMSCodeMethod];\n const isIos = ios && ios[getSMSCodeMethod];\n\n if (isAndroid) {\n android[getSMSCodeMethod](reqId);\n } else if (isIos) {\n ios[getSMSCodeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getSMSCodeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getSMSCode-isUnknown');\n }\n }\n\n const selectContact = (reqId) => {\n const isAndroid = android && android[selectContactMethod];\n const isIos = ios && ios[selectContactMethod];\n\n if (isAndroid) {\n android[selectContactMethod](reqId);\n } else if (isIos) {\n ios[selectContactMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(selectContactMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--selectContact-isUnknown');\n }\n }\n\n const openSettings = (reqId) => {\n const isAndroid = android && android[openSettingsMethod];\n const isIos = ios && ios[openSettingsMethod];\n\n if (isAndroid) {\n android[openSettingsMethod](reqId);\n } else if (isIos) {\n ios[openSettingsMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(openSettingsMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--openSettings-isUnknown');\n }\n }\n\n const closeApplication = (reqId) => {\n const isAndroid = android && android[closeApplicationMethod];\n const isIos = ios && ios[closeApplicationMethod];\n\n if (isAndroid) {\n android[closeApplicationMethod](reqId);\n } else if (isIos) {\n ios[closeApplicationMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(closeApplicationMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--closeApplication-isUnknown');\n }\n }\n\n const share = (reqId, text) => {\n const isAndroid = android && android[shareMethod];\n const isIos = ios && ios[shareMethod];\n\n if (isAndroid) {\n android[shareMethod](reqId, text);\n } else if (isIos) {\n ios[shareMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(shareMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--share-isUnknown');\n }\n }\n\n const setTitle = (reqId, text) => {\n const isAndroid = android && android[setTitleMethod];\n const isIos = ios && ios[setTitleMethod];\n\n if (isAndroid) {\n android[setTitleMethod](reqId, text);\n } else if (isIos) {\n ios[setTitleMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(setTitleMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--setTitle-isUnknown');\n }\n }\n\n const copyToClipboard = (reqId, text) => {\n const isAndroid = android && android[copyToClipboardMethod];\n const isIos = ios && ios[copyToClipboardMethod];\n\n if (isAndroid) {\n android[copyToClipboardMethod](reqId, text);\n } else if (isIos) {\n ios[copyToClipboardMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(copyToClipboardMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isUnknown');\n }\n }\n\n const enableScreenCapture = (reqId) => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isUnknown');\n }\n }\n\n const disableScreenCapture = (reqId) => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isUnknown');\n }\n }\n\n const shareImage = (reqId, text, image) => {\n // !!!======================!!!\n // !!!===== Deprecated =====!!!\n // !!!======================!!!\n\n // const isAndroid = android && android[shareImageMethod];\n // const isIos = ios && ios[shareImageMethod];\n\n // if (isAndroid) {\n // android[shareImageMethod](reqId, text, image);\n // } else if (isIos) {\n // ios[shareImageMethod].postMessage({ reqId, text, image });\n // } else if (typeof window !== 'undefined') {\n // console.log('--shareImage-isWeb');\n // }\n\n // new one - fallback to shareFile\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n // get extension from base64 mime type and merge with name\n const ext = image.split(';')[0].split('/')[1];\n const filename = 'image.' + ext;\n // remove mime type\n const base64Data = image.substr(image.indexOf(',') + 1);\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, { text, filename, base64Data });\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const shareFile = (reqId, text, filename, base64Data) => {\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, text, filename, base64Data);\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const enableNotifications = () => invokePromise(EInvokeRequest.enableNotifications);\n\n const disableNotifications = () => invokePromise(EInvokeRequest.disableNotifications);\n\n const setShakeHandler = (handler) => {\n const isAndroid = android && android[setShakeHandlerMethod];\n const isIos = ios && ios[setShakeHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isUnknown');\n }\n };\n\n const setTabActiveHandler = (handler: (tabname: string) => void) => {\n const isAndroid = android && android[setTabActiveHandlerMethod];\n const isIos = ios && ios[setTabActiveHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isUnknown');\n }\n };\n\n const vibrate = (reqId, pattern) => {\n if (\n !Array.isArray(pattern) ||\n pattern.some((timing) => timing < 1 || timing !== Math.floor(timing)) ||\n pattern.reduce((total, timing) => total + timing) > 10000\n ) {\n console.error('Pattern should be an array of positive integers no longer than 10000ms total');\n return;\n }\n\n const isAndroid = android && android[vibrateMethod];\n const isIos = ios && ios[vibrateMethod];\n\n if (isAndroid) {\n android[vibrateMethod](reqId, JSON.stringify(pattern));\n } else if (isIos) {\n ios[vibrateMethod].postMessage({ reqId, pattern });\n } else if (web) {\n web.execute(vibrateMethod, reqId, pattern);\n } else if (typeof window !== 'undefined') {\n console.log('--vibrate-isUnknown');\n }\n }\n\n const isSupported = () => {\n const iosSup = ios && (window as any).webkit.messageHandlers.invoke;\n return Boolean(android || iosSup || web);\n }\n\n // TODO: implement web support\n const supports = (method) =>\n (android && typeof android[method] === 'function') ||\n (ios && ios[method] && typeof ios[method].postMessage === 'function') ||\n (web && typeof web[method] === 'function');\n\n const sub = (listener: any) => {\n subs.push(listener);\n }\n\n const setHeaderMenuItems = (reqId, items: Array<HeaderMenuItem>) => {\n if (items.length > MAX_HEADER_MENU_ITEMS_COUNT) {\n console.error('SetHeaderMenuItems: items count should not be more than ' + MAX_HEADER_MENU_ITEMS_COUNT);\n return;\n }\n\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n const itemsJsonArray = JSON.stringify(items);\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](reqId, itemsJsonArray);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ reqId, itemsJsonArray });\n } else if (web) {\n web.execute(setHeaderMenuItemsMethod, reqId, itemsJsonArray);\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isUnknown');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isUnknown');\n }\n }\n\n const setCustomBackArrowMode = (reqId, enabled: boolean) => {\n const isAndroid = android && android[setCustomBackArrowModeMethod];\n const isIos = ios && ios[setCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowModeMethod](reqId, enabled);\n } else if (isIos) {\n ios[setCustomBackArrowModeMethod].postMessage({ reqId, enabled });\n } else if (web) {\n web.execute(setCustomBackArrowModeMethod, reqId, enabled);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowMode-isUnknown');\n }\n }\n\n const getCustomBackArrowMode = (reqId) => {\n const isAndroid = android && android[getCustomBackArrowModeMethod];\n const isIos = ios && ios[getCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[getCustomBackArrowModeMethod](reqId);\n } else if (isIos) {\n ios[getCustomBackArrowModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getCustomBackArrowModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getCustomBackArrowMode-isUnknown');\n }\n }\n\n const setCustomBackArrowVisible = (reqId, visible: boolean) => {\n const isAndroid = android && android[setCustomBackArrowVisibleMethod];\n const isIos = ios && ios[setCustomBackArrowVisibleMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowVisibleMethod](reqId, visible);\n } else if (isIos) {\n ios[setCustomBackArrowVisibleMethod].postMessage({ reqId, visible });\n } else if (web) {\n web.execute(setCustomBackArrowVisibleMethod, reqId, visible);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowVisible-isUnknown');\n }\n }\n\n const setCustomBackArrowOnClickHandler = (handler: BackArrowClickHandlerType) => {\n const isAndroid = android && android[setCustomBackArrowOnClickHandlerMethod];\n const isIos = ios && ios[setCustomBackArrowOnClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeBackArrowClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowOnClickHandler-isUnknown');\n }\n }\n\n\n const invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, getGeoMethod, sub);\n const getQrPromise = promisifyMethod(getQr, getQrMethod, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, getSMSCodeMethod, sub);\n const selectContactPromise = promisifyMethod(selectContact, selectContactMethod, sub);\n const openSettingsPromise = promisifyMethod(openSettings, openSettingsMethod, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, closeApplicationMethod, sub);\n const sharePromise = promisifyMethod(share, shareMethod, sub);\n const setTitlePromise = promisifyMethod(setTitle, setTitleMethod, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, copyToClipboardMethod, sub);\n const shareImagePromise = promisifyMethod(shareImage, shareImageMethod, sub);\n const shareFilePromise = promisifyMethod(shareFile, shareFileMethod, sub);\n const vibratePromise = promisifyMethod(vibrate, vibrateMethod, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, enableScreenCaptureMethod, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, disableScreenCaptureMethod, sub);\n const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);\n const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);\n const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);\n const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n enablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),\n disablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler,\n setCustomBackArrowMode: setCustomBackArrowModePromise,\n getCustomBackArrowMode: getCustomBackArrowModePromise,\n setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,\n setCustomBackArrowOnClickHandler,\n }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","export const LIB_VERSION = \"0.3.3\";\n"],"names":["createRequestResolver","prefix","counter","current","next","this","createCounter","promiseControllers","add","controller","customId","id","resolve","reqId","data","isSuccess","error","requestPromise","reject","handleSubscribe","subscribe","requestResolver","event","detail","promisifyMethod","method","methodName","args","Promise","aituOrigin","URLSearchParams","window","location","search","get","localStorage","setItem","getItem","WebBridge","origin","execute","payload","top","postMessage","source","addEventListener","dispatchEvent","CustomEvent","EInvokeRequest","HeaderMenuIcon","android","AndroidBridge","ios","webkit","messageHandlers","web","bridge","subs","e","map","fn","call","message","JSON","parse","onAituBridgeBackArrowClick","onAituBridgeHeaderMenuItemClick","param","sub","listener","push","invokePromise","invoke","invokeMethodName","props","isIos","stringify","console","log","promisifyInvoke","storagePromise","storage","keyName","keyValue","clear","promisifyStorage","getGeoPromise","getQrPromise","getSMSCodePromise","selectContactPromise","openSettingsPromise","closeApplicationPromise","sharePromise","text","setTitlePromise","copyToClipboardPromise","shareImagePromise","image","isAndroid","filename","split","base64Data","substr","indexOf","shareFilePromise","vibratePromise","pattern","Array","isArray","some","timing","Math","floor","reduce","total","enableScreenCapturePromise","disableScreenCapturePromise","setHeaderMenuItemsPromise","items","length","itemsJsonArray","setCustomBackArrowModePromise","enabled","getCustomBackArrowModePromise","setCustomBackArrowVisiblePromise","visible","version","String","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","selectContact","enableNotifications","disableNotifications","enablePrivateMessaging","appId","disablePrivateMessaging","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","setHeaderMenuItems","setHeaderMenuItemClickHandler","setCustomBackArrowMode","getCustomBackArrowMode","setCustomBackArrowVisible","setCustomBackArrowOnClickHandler","buildBridge"],"mappings":"AASA,SAASA,EAAsBC,GAM3B,MAAMC,EAfV,SAAuBD,EAAS,MAC5B,MAAO,CACHE,QAAS,EACTC,OACI,OAAOH,KAAWI,KAAKF,UAWfG,CAAcL,GACxBM,EAA+D,GAErE,MAAO,CACHC,IAAIC,EAA+BC,EAAW,IAC1C,MAAMC,EAAKD,EAAWR,EAAQE,OAE9B,OADAG,EAAmBI,GAAMF,EAClBE,GAGXC,QAAWC,EAAwBC,EAASC,EAAiCC,GACzE,MAAMC,EAAiBV,EAAmBM,GAEtCI,IACIF,EAAUC,GACVC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAG1BT,EAAmBM,GAAS,QAM5C,SAASM,EAAgBC,EAAoDC,GACzED,EAAUE,IACN,GAAK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B2B,EAAI3B,GAAQkB,aACzCY,GAA8B,mBAAhBA,EAAI9B,GAiJnB2C,IAAAA,EACA0F,oBAAqB3C,EACrB4C,qBAAsB3C,EACtB4C,mBAAoB3C,EACpB4C,8BAzHqCZ,IACnBnG,GAAWA,EAAO,+BACtBE,GAAOA,EAAG,+BAEEG,EACvBxB,OAAemC,gCAAkCmF,EACvB,oBAAXtH,QAChB8C,QAAQC,IAAI,8CAmHdoF,uBAAwBzC,EACxB0C,uBAAwBxC,EACxByC,0BAA2BxC,EAC3ByC,iCArEwChB,IACtBnG,GAAWA,EAAO,kCACtBE,GAAOA,EAAG,kCAEEG,EACvBxB,OAAekC,2BAA6BoF,EAClB,oBAAXtH,QAChB8C,QAAQC,IAAI,mDAkEHwF"}
1
+ {"version":3,"file":"index.modern.js","sources":["../src/utils.ts","../src/webBridge.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["function createCounter(prefix = 'm:') {\n return {\n current: 0,\n next() {\n return prefix + ++this.current;\n },\n };\n}\n\nfunction createRequestResolver(prefix: string) {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter(prefix);\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId = ''): number | string {\n const id = customId + counter.next()\n promiseControllers[id] = controller;\n return id;\n },\n\n resolve<T>(reqId: number | string, data: T, isSuccess: (data: T) => boolean, error: any) {\n const requestPromise = promiseControllers[reqId];\n\n if (requestPromise) {\n if (isSuccess(error)) {\n requestPromise.resolve(data);\n } else {\n requestPromise.reject(error);\n }\n\n promiseControllers[reqId] = null;\n }\n },\n };\n}\n\nfunction handleSubscribe(subscribe: (handler: (event: any) => void) => void, requestResolver: ReturnType<typeof createRequestResolver>) {\n subscribe(event => {\n if (!event.detail) {\n return;\n }\n\n if ('reqId' in event.detail) {\n const { reqId, data, error } = event.detail;\n\n if (reqId) {\n requestResolver.resolve(reqId, data, (error) => !(error), error);\n }\n }\n })\n}\n\nexport function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('storage:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return {\n setItem: (keyName: string, keyValue: string): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'setItem', { keyName, keyValue });\n });\n },\n getItem: (keyName: string): Promise<string | null> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'getItem', { keyName });\n });\n },\n clear: (): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'clear', {});\n });\n },\n }\n}\n\nexport function promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('invoke:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(invokeMethodName: string, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, invokeMethodName + ':');\n\n invoke(reqId, invokeMethodName, props);\n });\n };\n}\n\nexport function promisifyMethod(method: Function, methodName: string, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver(methodName + ':');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n method(reqId, ...args);\n });\n };\n}\n\n\n\n","import type { AituBridge } from './index';\n\nconst AITU_DOMAIN_PARAM = '__aitu-domain'\n\nconst searchParams = new URLSearchParams(window.location.search)\n\nlet aituOrigin = searchParams.get(AITU_DOMAIN_PARAM)\n\nif(aituOrigin){\n localStorage.setItem('mini-app-domain', aituOrigin)\n}else{\n aituOrigin = localStorage.getItem('mini-app-domain')\n}\ninterface WebBridge {\n execute(method: keyof AituBridge, reqId: string, ...payload: any[] ): void\n origin: string\n}\n\nlet WebBridge: WebBridge | null = null\n\nif (aituOrigin) {\n WebBridge = {\n origin: aituOrigin,\n execute: (method, reqId, ...payload) => {\n window.top.postMessage({\n source: 'aitu-bridge',\n method,\n reqId,\n payload: [...payload],\n },\n WebBridge.origin\n )\n }\n\n }\n window.addEventListener('message', event => {\n if (event.origin === aituOrigin && event.data) {\n window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));\n }\n })\n}\n\nexport default WebBridge\n","import { LIB_VERSION } from './version';\n\nimport {\n promisifyMethod,\n promisifyStorage,\n promisifyInvoke,\n} from './utils'\n\nimport WebBridge from './webBridge';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications',\n enablePrivateMessaging = 'EnablePrivateMessaging',\n disablePrivateMessaging = 'DisablePrivateMessaging',\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => Promise<void>;\n\ntype HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;\ntype BackArrowClickHandlerType = () => Promise<void>;\n\ninterface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\ninterface GetMeResponse {\n name: string;\n lastname: string;\n id: string;\n avatar?: string;\n avatarThumb?: string;\n sign: string;\n}\n\ninterface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\ninterface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\ninterface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\ninterface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\ninterface GetUserProfileResponse {\n name: string;\n lastname?: string;\n phone?: string;\n avatar?: string;\n avatarThumb?: string;\n}\n\nconst MAX_HEADER_MENU_ITEMS_COUNT = 3;\n\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\nexport interface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n enablePrivateMessaging: (appId: string) => Promise<string>;\n disablePrivateMessaging: (appId: string) => Promise<string>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;\n getCustomBackArrowMode: () => Promise<boolean>;\n setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;\n openPayment: (transactionId: string) => Promise<ResponseType>;\n setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\nconst setCustomBackArrowModeMethod = 'setCustomBackArrowMode';\nconst getCustomBackArrowModeMethod = 'getCustomBackArrowMode';\nconst setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';\nconst openPaymentMethod = 'openPayment'\nconst setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';\n\nconst android = typeof window !== 'undefined' && (window as any).AndroidBridge;\nconst ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;\nconst web = typeof window !== 'undefined' && (window.top !== window) && WebBridge;\n\nconst buildBridge = (): AituBridge => {\n const subs = [];\n\n if (typeof window !== 'undefined') {\n window.addEventListener('aituEvents', (e: any) => {\n [...subs].map((fn) => fn.call(null, e));\n })\n\n window.addEventListener('message', (e) => {\n if(typeof e.data !== 'string') {\n return;\n }\n\n const message = JSON.parse(e.data)\n\n if (message && message['method']) {\n if (message.method === 'setCustomBackArrowOnClickHandler') {\n (window as any).onAituBridgeBackArrowClick()\n } else if (message.method === 'setHeaderMenuItemClickHandler') {\n (window as any).onAituBridgeHeaderMenuItemClick(message.param)\n }\n }\n })\n }\n\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n\n if (isAndroid) {\n android[invokeMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[invokeMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(invokeMethod, reqId, method, data)\n } else if (typeof window !== 'undefined') {\n console.log('--invoke-isUnknown');\n }\n };\n\n const storage = (reqId, method, data = {}) => {\n const isAndroid = android && android[storageMethod];\n const isIos = ios && ios[storageMethod];\n\n if (isAndroid) {\n android[storageMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[storageMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(storageMethod, reqId, method, data);\n } else if (typeof window !== 'undefined') {\n console.log('--storage-isUnknown');\n }\n }\n\n const getGeo = (reqId) => {\n const isAndroid = android && android[getGeoMethod];\n const isIos = ios && ios[getGeoMethod];\n\n if (isAndroid) {\n android[getGeoMethod](reqId);\n } else if (isIos) {\n ios[getGeoMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getGeoMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getGeo-isUnknown');\n }\n }\n\n const getQr = (reqId) => {\n const isAndroid = android && android[getQrMethod];\n const isIos = ios && ios[getQrMethod];\n\n if (isAndroid) {\n android[getQrMethod](reqId);\n } else if (isIos) {\n ios[getQrMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getQrMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getQr-isUnknown');\n }\n }\n\n const getSMSCode = (reqId) => {\n const isAndroid = android && android[getSMSCodeMethod];\n const isIos = ios && ios[getSMSCodeMethod];\n\n if (isAndroid) {\n android[getSMSCodeMethod](reqId);\n } else if (isIos) {\n ios[getSMSCodeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getSMSCodeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getSMSCode-isUnknown');\n }\n }\n\n const selectContact = (reqId) => {\n const isAndroid = android && android[selectContactMethod];\n const isIos = ios && ios[selectContactMethod];\n\n if (isAndroid) {\n android[selectContactMethod](reqId);\n } else if (isIos) {\n ios[selectContactMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(selectContactMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--selectContact-isUnknown');\n }\n }\n\n const openSettings = (reqId) => {\n const isAndroid = android && android[openSettingsMethod];\n const isIos = ios && ios[openSettingsMethod];\n\n if (isAndroid) {\n android[openSettingsMethod](reqId);\n } else if (isIos) {\n ios[openSettingsMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(openSettingsMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--openSettings-isUnknown');\n }\n }\n\n const closeApplication = (reqId) => {\n const isAndroid = android && android[closeApplicationMethod];\n const isIos = ios && ios[closeApplicationMethod];\n\n if (isAndroid) {\n android[closeApplicationMethod](reqId);\n } else if (isIos) {\n ios[closeApplicationMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(closeApplicationMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--closeApplication-isUnknown');\n }\n }\n\n const share = (reqId, text) => {\n const isAndroid = android && android[shareMethod];\n const isIos = ios && ios[shareMethod];\n\n if (isAndroid) {\n android[shareMethod](reqId, text);\n } else if (isIos) {\n ios[shareMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(shareMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--share-isUnknown');\n }\n }\n\n const setTitle = (reqId, text) => {\n const isAndroid = android && android[setTitleMethod];\n const isIos = ios && ios[setTitleMethod];\n\n if (isAndroid) {\n android[setTitleMethod](reqId, text);\n } else if (isIos) {\n ios[setTitleMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(setTitleMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--setTitle-isUnknown');\n }\n }\n\n const copyToClipboard = (reqId, text) => {\n const isAndroid = android && android[copyToClipboardMethod];\n const isIos = ios && ios[copyToClipboardMethod];\n\n if (isAndroid) {\n android[copyToClipboardMethod](reqId, text);\n } else if (isIos) {\n ios[copyToClipboardMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(copyToClipboardMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isUnknown');\n }\n }\n\n const enableScreenCapture = (reqId) => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isUnknown');\n }\n }\n\n const disableScreenCapture = (reqId) => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isUnknown');\n }\n }\n\n const shareImage = (reqId, text, image) => {\n // !!!======================!!!\n // !!!===== Deprecated =====!!!\n // !!!======================!!!\n\n // const isAndroid = android && android[shareImageMethod];\n // const isIos = ios && ios[shareImageMethod];\n\n // if (isAndroid) {\n // android[shareImageMethod](reqId, text, image);\n // } else if (isIos) {\n // ios[shareImageMethod].postMessage({ reqId, text, image });\n // } else if (typeof window !== 'undefined') {\n // console.log('--shareImage-isWeb');\n // }\n\n // new one - fallback to shareFile\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n // get extension from base64 mime type and merge with name\n const ext = image.split(';')[0].split('/')[1];\n const filename = 'image.' + ext;\n // remove mime type\n const base64Data = image.substr(image.indexOf(',') + 1);\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, { text, filename, base64Data });\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const shareFile = (reqId, text, filename, base64Data) => {\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, text, filename, base64Data);\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const enableNotifications = () => invokePromise(EInvokeRequest.enableNotifications);\n\n const disableNotifications = () => invokePromise(EInvokeRequest.disableNotifications);\n\n const setShakeHandler = (handler) => {\n const isAndroid = android && android[setShakeHandlerMethod];\n const isIos = ios && ios[setShakeHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isUnknown');\n }\n };\n\n const setTabActiveHandler = (handler: (tabname: string) => void) => {\n const isAndroid = android && android[setTabActiveHandlerMethod];\n const isIos = ios && ios[setTabActiveHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isUnknown');\n }\n };\n\n const vibrate = (reqId, pattern) => {\n if (\n !Array.isArray(pattern) ||\n pattern.some((timing) => timing < 1 || timing !== Math.floor(timing)) ||\n pattern.reduce((total, timing) => total + timing) > 10000\n ) {\n console.error('Pattern should be an array of positive integers no longer than 10000ms total');\n return;\n }\n\n const isAndroid = android && android[vibrateMethod];\n const isIos = ios && ios[vibrateMethod];\n\n if (isAndroid) {\n android[vibrateMethod](reqId, JSON.stringify(pattern));\n } else if (isIos) {\n ios[vibrateMethod].postMessage({ reqId, pattern });\n } else if (web) {\n web.execute(vibrateMethod, reqId, pattern);\n } else if (typeof window !== 'undefined') {\n console.log('--vibrate-isUnknown');\n }\n }\n\n const isSupported = () => {\n const iosSup = ios && (window as any).webkit.messageHandlers.invoke;\n return Boolean(android || iosSup || web);\n }\n\n // TODO: implement web support\n const supports = (method) =>\n (android && typeof android[method] === 'function') ||\n (ios && ios[method] && typeof ios[method].postMessage === 'function') ||\n (web && typeof web[method] === 'function');\n\n const sub = (listener: any) => {\n subs.push(listener);\n }\n\n const setHeaderMenuItems = (reqId, items: Array<HeaderMenuItem>) => {\n if (items.length > MAX_HEADER_MENU_ITEMS_COUNT) {\n console.error('SetHeaderMenuItems: items count should not be more than ' + MAX_HEADER_MENU_ITEMS_COUNT);\n return;\n }\n\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n const itemsJsonArray = JSON.stringify(items);\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](reqId, itemsJsonArray);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ reqId, itemsJsonArray });\n } else if (web) {\n web.execute(setHeaderMenuItemsMethod, reqId, itemsJsonArray);\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isUnknown');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isUnknown');\n }\n }\n\n const setCustomBackArrowMode = (reqId, enabled: boolean) => {\n const isAndroid = android && android[setCustomBackArrowModeMethod];\n const isIos = ios && ios[setCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowModeMethod](reqId, enabled);\n } else if (isIos) {\n ios[setCustomBackArrowModeMethod].postMessage({ reqId, enabled });\n } else if (web) {\n web.execute(setCustomBackArrowModeMethod, reqId, enabled);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowMode-isUnknown');\n }\n }\n\n const getCustomBackArrowMode = (reqId) => {\n const isAndroid = android && android[getCustomBackArrowModeMethod];\n const isIos = ios && ios[getCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[getCustomBackArrowModeMethod](reqId);\n } else if (isIos) {\n ios[getCustomBackArrowModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getCustomBackArrowModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getCustomBackArrowMode-isUnknown');\n }\n }\n\n const setCustomBackArrowVisible = (reqId, visible: boolean) => {\n const isAndroid = android && android[setCustomBackArrowVisibleMethod];\n const isIos = ios && ios[setCustomBackArrowVisibleMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowVisibleMethod](reqId, visible);\n } else if (isIos) {\n ios[setCustomBackArrowVisibleMethod].postMessage({ reqId, visible });\n } else if (web) {\n web.execute(setCustomBackArrowVisibleMethod, reqId, visible);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowVisible-isUnknown');\n }\n }\n\n const setCustomBackArrowOnClickHandler = (handler: BackArrowClickHandlerType) => {\n const isAndroid = android && android[setCustomBackArrowOnClickHandlerMethod];\n const isIos = ios && ios[setCustomBackArrowOnClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeBackArrowClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowOnClickHandler-isUnknown');\n }\n }\n\n const openPayment = (reqId, transactionId: string) => {\n const isAndroid = android && android[openPaymentMethod];\n const isIos = ios && ios[openPaymentMethod];\n\n if (isAndroid) {\n android[openPaymentMethod](reqId, transactionId);\n } else if (isIos) {\n ios[openPaymentMethod].postMessage({ reqId, transactionId });\n } else {\n console.log('--openPayment-isUnknown');\n }\n }\n\n\n const invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, getGeoMethod, sub);\n const getQrPromise = promisifyMethod(getQr, getQrMethod, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, getSMSCodeMethod, sub);\n const selectContactPromise = promisifyMethod(selectContact, selectContactMethod, sub);\n const openSettingsPromise = promisifyMethod(openSettings, openSettingsMethod, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, closeApplicationMethod, sub);\n const sharePromise = promisifyMethod(share, shareMethod, sub);\n const setTitlePromise = promisifyMethod(setTitle, setTitleMethod, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, copyToClipboardMethod, sub);\n const shareImagePromise = promisifyMethod(shareImage, shareImageMethod, sub);\n const shareFilePromise = promisifyMethod(shareFile, shareFileMethod, sub);\n const vibratePromise = promisifyMethod(vibrate, vibrateMethod, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, enableScreenCaptureMethod, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, disableScreenCaptureMethod, sub);\n const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);\n const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);\n const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);\n const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);\n const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n enablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),\n disablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler,\n setCustomBackArrowMode: setCustomBackArrowModePromise,\n getCustomBackArrowMode: getCustomBackArrowModePromise,\n setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,\n openPayment: openPaymentPromise,\n setCustomBackArrowOnClickHandler,\n }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","export const LIB_VERSION = \"0.3.4\";\n"],"names":["createRequestResolver","prefix","counter","current","next","this","createCounter","promiseControllers","add","controller","customId","id","resolve","reqId","data","isSuccess","error","requestPromise","reject","handleSubscribe","subscribe","requestResolver","event","detail","promisifyMethod","method","methodName","args","Promise","aituOrigin","URLSearchParams","window","location","search","get","localStorage","setItem","getItem","WebBridge","origin","execute","payload","top","postMessage","source","addEventListener","dispatchEvent","CustomEvent","EInvokeRequest","HeaderMenuIcon","android","AndroidBridge","ios","webkit","messageHandlers","web","bridge","subs","e","map","fn","call","message","JSON","parse","onAituBridgeBackArrowClick","onAituBridgeHeaderMenuItemClick","param","sub","listener","push","invokePromise","invoke","invokeMethodName","props","isIos","stringify","console","log","promisifyInvoke","storagePromise","storage","keyName","keyValue","clear","promisifyStorage","getGeoPromise","getQrPromise","getSMSCodePromise","selectContactPromise","openSettingsPromise","closeApplicationPromise","sharePromise","text","setTitlePromise","copyToClipboardPromise","shareImagePromise","image","isAndroid","filename","split","base64Data","substr","indexOf","shareFilePromise","vibratePromise","pattern","Array","isArray","some","timing","Math","floor","reduce","total","enableScreenCapturePromise","disableScreenCapturePromise","setHeaderMenuItemsPromise","items","length","itemsJsonArray","setCustomBackArrowModePromise","enabled","getCustomBackArrowModePromise","setCustomBackArrowVisiblePromise","visible","openPaymentPromise","transactionId","version","String","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","selectContact","enableNotifications","disableNotifications","enablePrivateMessaging","appId","disablePrivateMessaging","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","setHeaderMenuItems","setHeaderMenuItemClickHandler","setCustomBackArrowMode","getCustomBackArrowMode","setCustomBackArrowVisible","openPayment","setCustomBackArrowOnClickHandler","buildBridge"],"mappings":"AASA,SAASA,EAAsBC,GAM3B,MAAMC,EAfV,SAAuBD,EAAS,MAC5B,MAAO,CACHE,QAAS,EACTC,OACI,OAAOH,KAAWI,KAAKF,UAWfG,CAAcL,GACxBM,EAA+D,GAErE,MAAO,CACHC,IAAIC,EAA+BC,EAAW,IAC1C,MAAMC,EAAKD,EAAWR,EAAQE,OAE9B,OADAG,EAAmBI,GAAMF,EAClBE,GAGXC,QAA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