@btsd/aitu-bridge 0.2.11 → 0.2.12
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -6
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i=null!=n?n:t.next();return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),function(){var n=arguments;return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e.apply(void 0,[r].concat([].slice.call(n)))})}}var n;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={}));var t="invoke",o="storage",i="undefined"!=typeof window&&window.AndroidBridge,r="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,a="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(a){var s=window.AITU_ORIGIN||"https://aitu.io";[t,o].forEach(function(e){a[e]||(a[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),s)})}),window.addEventListener("message",function(e){if(e.origin===s&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var d=function(){var s=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(s).map(function(n){return n.call(null,e)})});var d,l,c,u=function(e){s.push(e)},f=(d={current:0,next:function(){return++this.current}},l={},c={add:function(e,n){var t=null!=n?n:d.next();return l[t]=e,t},resolve:function(e,n,t,o){var i=l[e];i&&(t(o)?i.resolve(n):i.reject(o),l[e]=null)}},u(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&c.resolve(t,n.data,function(e){return!e},n.error)}}),function(e,n){return void 0===n&&(n={}),new Promise(function(o,s){!function(e,n,o){void 0===o&&(o={});var s=r&&r[t],d=a&&a[t];i&&i[t]?i[t](e,n,JSON.stringify(o)):s?r[t].postMessage({reqId:e,method:n,data:o}):d?a[t](e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:o,reject:s},n.reqId),e,n)})}),p=function(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i="s"+(null!=n?n:t.next());return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),{setItem:function(n,t){return new Promise(function(o,r){var a=i.add({resolve:o,reject:r});e(a,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var o=i.add({resolve:n,reject:t});e(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var s=r&&r[o],d=a&&a[o];i&&i[o]?i[o](e,n,JSON.stringify(t)):s?r[o].postMessage({reqId:e,method:n,data:t}):d?a[o](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=e(function(e){var n=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):n?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=e(function(e){var n=r&&r.getQr;i&&i.getQr?i.getQr(e):n?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=e(function(e){var n=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):n?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=e(function(e){var n=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):n?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),y=e(function(e){var n=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):n?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=e(function(e){var n=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):n?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),S=e(function(e,n){var t=r&&r.share;i&&i.share?i.share(e,n):t?r.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),C=e(function(e,n){var t=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,n):t?r.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=e(function(e,n){var t=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,n):t?r.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),M=e(function(e,n,t){var o=i&&i.shareFile,a=r&&r.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?i.shareFile(e,n,s,d):a?r.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=e(function(e,n,t,o){var a=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,n,t,o):a?r.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),q=e(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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(n)):t?r.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),A=e(function(){var
|
|
1
|
+
function e(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i=null!=n?n:t.next();return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),function(){var n=arguments;return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e.apply(void 0,[r].concat([].slice.call(n)))})}}var n;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={}));var t="invoke",o="storage",i="undefined"!=typeof window&&window.AndroidBridge,r="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,a="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(a){var s=window.AITU_ORIGIN||"https://aitu.io";[t,o].forEach(function(e){a[e]||(a[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),s)})}),window.addEventListener("message",function(e){if(e.origin===s&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var d=function(){var s=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(s).map(function(n){return n.call(null,e)})});var d,l,c,u=function(e){s.push(e)},f=(d={current:0,next:function(){return++this.current}},l={},c={add:function(e,n){var t=null!=n?n:d.next();return l[t]=e,t},resolve:function(e,n,t,o){var i=l[e];i&&(t(o)?i.resolve(n):i.reject(o),l[e]=null)}},u(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&c.resolve(t,n.data,function(e){return!e},n.error)}}),function(e,n){return void 0===n&&(n={}),new Promise(function(o,s){!function(e,n,o){void 0===o&&(o={});var s=r&&r[t],d=a&&a[t];i&&i[t]?i[t](e,n,JSON.stringify(o)):s?r[t].postMessage({reqId:e,method:n,data:o}):d?a[t](e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:o,reject:s},n.reqId),e,n)})}),p=function(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i="s"+(null!=n?n:t.next());return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),{setItem:function(n,t){return new Promise(function(o,r){var a=i.add({resolve:o,reject:r});e(a,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var o=i.add({resolve:n,reject:t});e(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var s=r&&r[o],d=a&&a[o];i&&i[o]?i[o](e,n,JSON.stringify(t)):s?r[o].postMessage({reqId:e,method:n,data:t}):d?a[o](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=e(function(e){var n=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):n?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=e(function(e){var n=r&&r.getQr;i&&i.getQr?i.getQr(e):n?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=e(function(e){var n=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):n?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=e(function(e){var n=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):n?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),y=e(function(e){var n=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):n?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=e(function(e){var n=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):n?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),S=e(function(e,n){var t=r&&r.share;i&&i.share?i.share(e,n):t?r.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),C=e(function(e,n){var t=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,n):t?r.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=e(function(e,n){var t=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,n):t?r.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),M=e(function(e,n,t){var o=i&&i.shareFile,a=r&&r.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?i.shareFile(e,n,s,d):a?r.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=e(function(e,n,t,o){var a=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,n,t,o):a?r.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),q=e(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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(n)):t?r.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),A=e(function(e){var n=r&&r.enableScreenCapture;i&&i.enableScreenCapture?i.enableScreenCapture(e):n?r.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},u),T=e(function(e){var n=r&&r.disableScreenCapture;i&&i.disableScreenCapture?i.disableScreenCapture(e):n?r.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},u);return{copyToClipboard:I,invoke:f,storage:p,getMe:function(){return f(n.getMe)},getPhone:function(){return f(n.getPhone)},getContacts:function(){return f(n.getContacts)},getGeo:g,getQr:w,getSMSCode:v,getUserProfile:function(e){return f(n.getUserProfile,{id:e})},selectContact:b,enableNotifications:function(){return f(n.enableNotifications)},disableNotifications:function(){return f(n.disableNotifications)},openSettings:y,closeApplication:h,setTitle:C,share:S,shareImage:M,shareFile:m,setShakeHandler:function(e){i&&i.setShakeHandler||r&&r.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:function(e){i&&i.setTabActiveHandler||r&&r.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:q,isSupported:function(){var e=r&&window.webkit.messageHandlers.invoke;return Boolean(i||e||a)},supports:function(e){return i&&"function"==typeof i[e]||r&&r[e]&&"function"==typeof r[e].postMessage||a&&"function"==typeof a[e]},sub:u,enableScreenCapture:A,disableScreenCapture:T}}();module.exports=d;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\n }\n }\n\n const enableScreenCapture = () => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod]();\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\n }\n }\n\n const disableScreenCapture = () => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod]();\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invokeId","props","isIos","isWeb","console","log","invoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"AA0CA,SAASA,EAAgBC,EAAQC,GAC/B,IA5BMC,EACAC,EA2BAC,GA5BAF,EAdC,CACLG,QAAS,EACTC,gBACE,QAASC,KAAKF,UAYZF,EAA+D,GAE9D,CACLK,aAAIC,EAA+BC,GACjC,IACMC,EADiB,MAAZD,EAAmBA,EAAWR,EAAQI,OAGjD,OADAH,EAAmBQ,GAAYF,EACxBE,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AO,CACLmD,gBAAiBtB,EACjBnB,OAAQP,EACRS,QAASD,EACTyC,MAAO,kBAAMjD,EAAcjC,EAAekF,QAC1CC,SAAU,kBAAMlD,EAAcjC,EAAemF,WAC7CC,YAAa,kBAAMnD,EAAcjC,EAAeoF,cAChDC,OAAQnC,EACRoC,MAAOnC,EACPoC,WAAYnC,EACZoC,eAAgB,SAACC,UAAexD,EAAcjC,EAAewF,eAAgB,CAAEC,GAAAA,KAC/EC,cAAerC,EACfsC,oBA3F0B,kBAAM1D,EAAcjC,EAAe2F,sBA4F7DC,qBA1F2B,kBAAM3D,EAAcjC,EAAe4F,uBA2F9DC,aAAcvC,EACdwC,iBAAkBvC,EAClBwC,SAAUrC,EACVsC,MAAOxC,EACPyC,WAAYrC,EACZsC,UAAW9B,EACX+B,gBA/FsB,SAACC,GACLjG,GAAWA,EAAO,iBACtBG,GAAOA,EAAG,gBAGrBF,OAAeiG,kBAAoBD,EACT,oBAAXhG,QAChBkC,QAAQC,IAAI,4BAyFd+D,oBArF0B,SAACF,GACTjG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAemG,sBAAwBH,EACb,oBAAXhG,QAChBkC,QAAQC,IAAI,gCA+EdiE,QAASnC,EACToC,YAtDkB,WAClB,IAAMC,EAASpG,GAAQF,OAAeG,OAAOC,gBAAgBgC,OAC7D,OAAOmE,QAAQxG,GAAWuG,GAAUjG,IAqDpCmG,SAlDe,SAAClI,UACfyB,GAAsC,mBAApBA,EAAQzB,IAC1B4B,GAAOA,EAAI5B,IAA8C,mBAA5B4B,EAAI5B,GAAQqC,aACzCN,GAA8B,mBAAhBA,EAAI/B,IAgDnBoD,IAAAA,EACA+E,oBAAqB9B,EACrB+B,qBAAsB9B,GAIX+B"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invokeId","props","isIos","isWeb","console","log","invoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"AA0CA,SAASA,EAAgBC,EAAQC,GAC/B,IA5BMC,EACAC,EA2BAC,GA5BAF,EAdC,CACLG,QAAS,EACTC,gBACE,QAASC,KAAKF,UAYZF,EAA+D,GAE9D,CACLK,aAAIC,EAA+BC,GACjC,IACMC,EADiB,MAAZD,EAAmBA,EAAWR,EAAQI,OAGjD,OADAH,EAAmBQ,GAAYF,EACxBE,GAGTC,iBAAWC,EAAwBC,EAASC,EAAiCC,GAC3E,IAAMC,EAAi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E1E,MAAO,CACLmD,gBAAiBtB,EACjBnB,OAAQP,EACRS,QAASD,EACTyC,MAAO,kBAAMjD,EAAcjC,EAAekF,QAC1CC,SAAU,kBAAMlD,EAAcjC,EAAemF,WAC7CC,YAAa,kBAAMnD,EAAcjC,EAAeoF,cAChDC,OAAQnC,EACRoC,MAAOnC,EACPoC,WAAYnC,EACZoC,eAAgB,SAACC,UAAexD,EAAcjC,EAAewF,eAAgB,CAAEC,GAAAA,KAC/EC,cAAerC,EACfsC,oBA3F0B,kBAAM1D,EAAcjC,EAAe2F,sBA4F7DC,qBA1F2B,kBAAM3D,EAAcjC,EAAe4F,uBA2F9DC,aAAcvC,EACdwC,iBAAkBvC,EAClBwC,SAAUrC,EACVsC,MAAOxC,EACPyC,WAAYrC,EACZsC,UAAW9B,EACX+B,gBA/FsB,SAACC,GACLjG,GAAWA,EAAO,iBACtBG,GAAOA,EAAG,gBAGrBF,OAAeiG,kBAAoBD,EACT,oBAAXhG,QAChBkC,QAAQC,IAAI,4BAyFd+D,oBArF0B,SAACF,GACTjG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAemG,sBAAwBH,EACb,oBAAXhG,QAChBkC,QAAQC,IAAI,gCA+EdiE,QAASnC,EACToC,YAtDkB,WAClB,IAAMC,EAASpG,GAAQF,OAAeG,OAAOC,gBAAgBgC,OAC7D,OAAOmE,QAAQxG,GAAWuG,GAAUjG,IAqDpCmG,SAlDe,SAAClI,UACfyB,GAAsC,mBAApBA,EAAQzB,IAC1B4B,GAAOA,EAAI5B,IAA8C,mBAA5B4B,EAAI5B,GAAQqC,aACzCN,GAA8B,mBAAhBA,EAAI/B,IAgDnBoD,IAAAA,EACA+E,oBAAqB9B,EACrB+B,qBAAsB9B,GAIX+B"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){const o=function(){const e={current:0,next(){return++this.current}},t={};return{add(o,n){const s=null!=n?n:e.next();return t[s]=o,s},resolve(e,o,n,s){const i=t[e];i&&(n(s)?i.resolve(o):i.reject(s),t[e]=null)}}}();return t(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:t,data:n,error:s}=e.detail;t&&o.resolve(t,n,e=>!e,s)}}),function(...t){return new Promise((n,s)=>{const i=o.add({resolve:n,reject:s});e(i,...t)})}}var t;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(t||(t={}));const o="invoke",n="storage",s="undefined"!=typeof window&&window.AndroidBridge,i="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,r="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(r){const e=window.AITU_ORIGIN||"https://aitu.io";[o,n].forEach(t=>{r[t]||(r[t]=(...o)=>window.top.postMessage(JSON.stringify({method:t,payload:o}),e))}),window.addEventListener("message",t=>{if(t.origin===e&&t.data)try{const e=JSON.parse(t.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:e}))}catch(e){}})}const a=(()=>{const a=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",e=>{[...a].map(t=>t.call(null,e))});const d=e=>{a.push(e)},l=function(e,t){const n=function(){const e={current:0,next(){return++this.current}},t={};return{add(o,n){const s=null!=n?n:e.next();return t[s]=o,s},resolve(e,o,n,s){const i=t[e];i&&(n(s)?i.resolve(o):i.reject(s),t[e]=null)}}}();return t(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:t,data:o,error:s}=e.detail;t&&n.resolve(t,o,e=>!e,s)}}),function(e,t={}){return new Promise((a,d)=>{((e,t,n={})=>{const a=i&&i[o],d=r&&r[o];s&&s[o]?s[o](e,t,JSON.stringify(n)):a?i[o].postMessage({reqId:e,method:t,data:n}):d?r[o](e,t,n):"undefined"!=typeof window&&console.log("--invoke-isUnknown")})(n.add({resolve:a,reject:d},t.reqId),e,t)})}}(0,d),c=function(e,t){const o=function(){const e={current:0,next(){return++this.current}},t={};return{add(o,n){const s="s"+(null!=n?n:e.next());return t[s]=o,s},resolve(e,o,n,s){const i=t[e];i&&(n(s)?i.resolve(o):i.reject(s),t[e]=null)}}}();return t(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:t,data:n,error:s}=e.detail;t&&o.resolve(t,n,e=>!e,s)}}),{setItem:(t,n)=>new Promise((s,i)=>{const r=o.add({resolve:s,reject:i});e(r,"setItem",{keyName:t,keyValue:n})}),getItem:t=>new Promise((n,s)=>{const i=o.add({resolve:n,reject:s});e(i,"getItem",{keyName:t})}),clear:()=>new Promise((t,n)=>{const s=o.add({resolve:t,reject:n});e(s,"clear",{})})}}((e,t,o={})=>{const a=i&&i[n],d=r&&r[n];s&&s[n]?s[n](e,t,JSON.stringify(o)):a?i[n].postMessage({reqId:e,method:t,data:o}):d?r[n](e,t,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},d),p=e(e=>{const t=i&&i.getGeo;s&&s.getGeo?s.getGeo(e):t?i.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},d),g=e(e=>{const t=i&&i.getQr;s&&s.getQr?s.getQr(e):t?i.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},d),u=e(e=>{const t=i&&i.getSMSCode;s&&s.getSMSCode?s.getSMSCode(e):t?i.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},d),f=e(e=>{const t=i&&i.selectContact;s&&s.selectContact?s.selectContact(e):t?i.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},d),w=e(e=>{const t=i&&i.openSettings;s&&s.openSettings?s.openSettings(e):t?i.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},d),b=e(e=>{const t=i&&i.closeApplication;s&&s.closeApplication?s.closeApplication(e):t?i.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},d),y=e((e,t)=>{const o=i&&i.share;s&&s.share?s.share(e,t):o?i.share.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--share-isWeb")},d),h=e((e,t)=>{const o=i&&i.setTitle;s&&s.setTitle?s.setTitle(e,t):o?i.setTitle.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},d),S=e((e,t)=>{const o=i&&i.copyToClipboard;s&&s.copyToClipboard?s.copyToClipboard(e,t):o?i.copyToClipboard.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},d),v=e((e,t,o)=>{const n=s&&s.shareFile,r=i&&i.shareFile,a="image."+o.split(";")[0].split("/")[1],d=o.substr(o.indexOf(",")+1);n?s.shareFile(e,t,a,d):r?i.shareFile.postMessage({reqId:e,text:t,filename:a,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},d),C=e((e,t,o,n)=>{const r=i&&i.shareFile;s&&s.shareFile?s.shareFile(e,t,o,n):r?i.shareFile.postMessage({reqId:e,text:t,filename:o,base64Data:n}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},d),I=e((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=i&&i.vibrate;s&&s.vibrate?s.vibrate(e,JSON.stringify(t)):o?i.vibrate.postMessage({reqId:e,pattern:t}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")},d),M=e(
|
|
1
|
+
function e(e,t){const o=function(){const e={current:0,next(){return++this.current}},t={};return{add(o,n){const s=null!=n?n:e.next();return t[s]=o,s},resolve(e,o,n,s){const i=t[e];i&&(n(s)?i.resolve(o):i.reject(s),t[e]=null)}}}();return t(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:t,data:n,error:s}=e.detail;t&&o.resolve(t,n,e=>!e,s)}}),function(...t){return new Promise((n,s)=>{const i=o.add({resolve:n,reject:s});e(i,...t)})}}var t;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(t||(t={}));const o="invoke",n="storage",s="undefined"!=typeof window&&window.AndroidBridge,i="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,r="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(r){const e=window.AITU_ORIGIN||"https://aitu.io";[o,n].forEach(t=>{r[t]||(r[t]=(...o)=>window.top.postMessage(JSON.stringify({method:t,payload:o}),e))}),window.addEventListener("message",t=>{if(t.origin===e&&t.data)try{const e=JSON.parse(t.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:e}))}catch(e){}})}const a=(()=>{const a=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",e=>{[...a].map(t=>t.call(null,e))});const d=e=>{a.push(e)},l=function(e,t){const n=function(){const e={current:0,next(){return++this.current}},t={};return{add(o,n){const s=null!=n?n:e.next();return t[s]=o,s},resolve(e,o,n,s){const i=t[e];i&&(n(s)?i.resolve(o):i.reject(s),t[e]=null)}}}();return t(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:t,data:o,error:s}=e.detail;t&&n.resolve(t,o,e=>!e,s)}}),function(e,t={}){return new Promise((a,d)=>{((e,t,n={})=>{const a=i&&i[o],d=r&&r[o];s&&s[o]?s[o](e,t,JSON.stringify(n)):a?i[o].postMessage({reqId:e,method:t,data:n}):d?r[o](e,t,n):"undefined"!=typeof window&&console.log("--invoke-isUnknown")})(n.add({resolve:a,reject:d},t.reqId),e,t)})}}(0,d),c=function(e,t){const o=function(){const e={current:0,next(){return++this.current}},t={};return{add(o,n){const s="s"+(null!=n?n:e.next());return t[s]=o,s},resolve(e,o,n,s){const i=t[e];i&&(n(s)?i.resolve(o):i.reject(s),t[e]=null)}}}();return t(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:t,data:n,error:s}=e.detail;t&&o.resolve(t,n,e=>!e,s)}}),{setItem:(t,n)=>new Promise((s,i)=>{const r=o.add({resolve:s,reject:i});e(r,"setItem",{keyName:t,keyValue:n})}),getItem:t=>new Promise((n,s)=>{const i=o.add({resolve:n,reject:s});e(i,"getItem",{keyName:t})}),clear:()=>new Promise((t,n)=>{const s=o.add({resolve:t,reject:n});e(s,"clear",{})})}}((e,t,o={})=>{const a=i&&i[n],d=r&&r[n];s&&s[n]?s[n](e,t,JSON.stringify(o)):a?i[n].postMessage({reqId:e,method:t,data:o}):d?r[n](e,t,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},d),p=e(e=>{const t=i&&i.getGeo;s&&s.getGeo?s.getGeo(e):t?i.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},d),g=e(e=>{const t=i&&i.getQr;s&&s.getQr?s.getQr(e):t?i.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},d),u=e(e=>{const t=i&&i.getSMSCode;s&&s.getSMSCode?s.getSMSCode(e):t?i.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},d),f=e(e=>{const t=i&&i.selectContact;s&&s.selectContact?s.selectContact(e):t?i.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},d),w=e(e=>{const t=i&&i.openSettings;s&&s.openSettings?s.openSettings(e):t?i.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},d),b=e(e=>{const t=i&&i.closeApplication;s&&s.closeApplication?s.closeApplication(e):t?i.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},d),y=e((e,t)=>{const o=i&&i.share;s&&s.share?s.share(e,t):o?i.share.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--share-isWeb")},d),h=e((e,t)=>{const o=i&&i.setTitle;s&&s.setTitle?s.setTitle(e,t):o?i.setTitle.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},d),S=e((e,t)=>{const o=i&&i.copyToClipboard;s&&s.copyToClipboard?s.copyToClipboard(e,t):o?i.copyToClipboard.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},d),v=e((e,t,o)=>{const n=s&&s.shareFile,r=i&&i.shareFile,a="image."+o.split(";")[0].split("/")[1],d=o.substr(o.indexOf(",")+1);n?s.shareFile(e,t,a,d):r?i.shareFile.postMessage({reqId:e,text:t,filename:a,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},d),C=e((e,t,o,n)=>{const r=i&&i.shareFile;s&&s.shareFile?s.shareFile(e,t,o,n):r?i.shareFile.postMessage({reqId:e,text:t,filename:o,base64Data:n}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},d),I=e((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=i&&i.vibrate;s&&s.vibrate?s.vibrate(e,JSON.stringify(t)):o?i.vibrate.postMessage({reqId:e,pattern:t}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")},d),M=e(e=>{const t=i&&i.enableScreenCapture;s&&s.enableScreenCapture?s.enableScreenCapture(e):t?i.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},d),m=e(e=>{const t=i&&i.disableScreenCapture;s&&s.disableScreenCapture?s.disableScreenCapture(e):t?i.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},d);return{copyToClipboard:S,invoke:l,storage:c,getMe:()=>l(t.getMe),getPhone:()=>l(t.getPhone),getContacts:()=>l(t.getContacts),getGeo:p,getQr:g,getSMSCode:u,getUserProfile:e=>l(t.getUserProfile,{id:e}),selectContact:f,enableNotifications:()=>l(t.enableNotifications),disableNotifications:()=>l(t.disableNotifications),openSettings:w,closeApplication:b,setTitle:h,share:y,shareImage:v,shareFile:C,setShakeHandler:e=>{s&&s.setShakeHandler||i&&i.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:e=>{s&&s.setTabActiveHandler||i&&i.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:I,isSupported:()=>{const e=i&&window.webkit.messageHandlers.invoke;return Boolean(s||e||r)},supports:e=>s&&"function"==typeof s[e]||i&&i[e]&&"function"==typeof i[e].postMessage||r&&"function"==typeof r[e],sub:d,enableScreenCapture:M,disableScreenCapture:m}})();export default a;
|
|
2
2
|
//# sourceMappingURL=index.modern.js.map
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\n }\n }\n\n const enableScreenCapture = () => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod]();\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\n }\n }\n\n const disableScreenCapture = () => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod]();\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","requestResolver","counter","current","next","this","promiseControllers","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","createRequestResolver","event","detail","args","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invoke","invokeId","props","isIos","isWeb","console","log","promisifyInvoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"AA0CA,SAASA,EAAgBC,EAAQC,GAC/B,MAAMC,EAlCR,WAME,MAAMC,EAdC,CACLC,QAAS,EACTC,OACE,QAASC,KAAKF,UAYZG,EAA+D,GAErE,MAAO,CACLC,IAAIC,EAA+BC,GACjC,MACMC,EADiB,MAAZD,EAAmBA,EAAWP,EAAQE,OAGjD,OADAE,EAAmBI,GAAYF,EACxBE,GAGTC,QAAWC,EAAwBC,EAASC,EAAiCC,GAC3E,MAAMC,EAAiBV,EAAmBM,GAEtCI,IACEF,EAAUC,GACZC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAGxBT,EAAmBM,GAAS,QAOVM,GAgBxB,OAdAlB,EAAWmB,IACT,GAAKA,EAAMC,QAIP,UAAWD,EAAMC,OAAQ,CAC3B,MAAMR,MAAEA,EAAFC,KAASA,EAATE,MAAeA,GAAUI,EAAMC,OAEjCR,GACFX,EAAgBU,QAAQC,EAAOC,EAAOE,IAAYA,EAAQA,kBAK7BM,GACjC,WAAWC,QAAQ,CAACX,EAASM,KAC3B,MAAML,EAAQX,EAAgBM,IAAI,CAAEI,QAAAA,EAASM,OAAAA,IAE7ClB,EAAOa,KAAUS,MC3DvB,IAAKE,GAAL,SAAKA,GACHA,gBACAA,sBACAA,4BACAA,kCACAA,2CACAA,8CANF,CAAKA,IAAAA,OA0GL,MAAMC,E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EACT,oBAAXjG,QAChBmC,QAAQC,IAAI,4BAyFd+D,oBArF2BF,IACTlG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAeoG,sBAAwBH,EACb,oBAAXjG,QAChBmC,QAAQC,IAAI,gCA+EdiE,QAASnC,EACToC,YAtDkB,KAClB,MAAMC,EAASrG,GAAQF,OAAeG,OAAOC,gBAAgB0B,OAC7D,OAAO0E,QAAQzG,GAAWwG,GAAUlG,IAqDpCoG,SAlDgBrI,GACf2B,GAAsC,mBAApBA,EAAQ3B,IAC1B8B,GAAOA,EAAI9B,IAA8C,mBAA5B8B,EAAI9B,GAAQuC,aACzCN,GAA8B,mBAAhBA,EAAIjC,GAgDnBsD,IAAAA,EACAgF,oBAAqB9B,EACrB+B,qBAAsB9B,IAIX+B"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","requestResolver","counter","current","next","this","promiseControllers","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","createRequestResolver","event","detail","args","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invoke","invokeId","props","isIos","isWeb","console","log","promisifyInvoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"AA0CA,SAASA,EAAgBC,EAAQC,GAC/B,MAAMC,EAlCR,WAME,MAAMC,EAdC,CACLC,QAAS,EACTC,OACE,QAASC,KAAKF,UAYZG,EAA+D,GAErE,MAAO,CACLC,IAAIC,EAA+BC,GACjC,MACMC,EADiB,MAAZD,EAAmBA,EAAWP,EAAQE,OAGjD,OADAE,EAAmBI,GAAYF,EACxBE,GAGTC,QAAWC,EAAwBC,EAASC,EAAiCC,GAC3E,MAAMC,EAAiBV,EAAmBM,GAEtCI,IACEF,EAAUC,GACZC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAGxBT,EAAmBM,GAAS,QAOVM,GAgBxB,OAdAlB,EAAWmB,IACT,GAAKA,EAAMC,QAIP,UAAWD,EAAMC,OAAQ,CAC3B,MAAMR,MAAEA,EAAFC,KAASA,EAATE,MAAeA,GAAUI,EAAMC,OAEjCR,GACFX,EAAgBU,QAAQC,EAAOC,EAAOE,IAAYA,EAAQA,kBAK7BM,GACjC,WAAWC,QAAQ,CAACX,EAASM,KAC3B,MAAML,EAAQX,EAAgBM,IAAI,CAAEI,QAAAA,EAASM,OAAAA,IAE7ClB,EAAOa,KAAUS,MC3DvB,IAAKE,GAAL,SAAKA,GACHA,gBACAA,sBACAA,4BACAA,kCACAA,2CACAA,8CANF,CAAKA,IAAAA,OA0GL,MAAMC,EAAe,SACfC,EAAgB,UAkBhBC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AG,gBAGrBF,OAAekG,kBAAoBD,EACT,oBAAXjG,QAChBmC,QAAQC,IAAI,4BAyFd+D,oBArF2BF,IACTlG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAeoG,sBAAwBH,EACb,oBAAXjG,QAChBmC,QAAQC,IAAI,gCA+EdiE,QAASnC,EACToC,YAtDkB,KAClB,MAAMC,EAASrG,GAAQF,OAAeG,OAAOC,gBAAgB0B,OAC7D,OAAO0E,QAAQzG,GAAWwG,GAAUlG,IAqDpCoG,SAlDgBrI,GACf2B,GAAsC,mBAApBA,EAAQ3B,IAC1B8B,GAAOA,EAAI9B,IAA8C,mBAA5B8B,EAAI9B,GAAQuC,aACzCN,GAA8B,mBAAhBA,EAAIjC,GAgDnBsD,IAAAA,EACAgF,oBAAqB9B,EACrB+B,qBAAsB9B,IAIX+B"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i=null!=n?n:t.next();return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),function(){var n=arguments;return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e.apply(void 0,[r].concat([].slice.call(n)))})}}var n;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={}));var t="invoke",o="storage",i="undefined"!=typeof window&&window.AndroidBridge,r="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,a="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(a){var s=window.AITU_ORIGIN||"https://aitu.io";[t,o].forEach(function(e){a[e]||(a[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),s)})}),window.addEventListener("message",function(e){if(e.origin===s&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var d=function(){var s=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(s).map(function(n){return n.call(null,e)})});var d,l,c,u=function(e){s.push(e)},f=(d={current:0,next:function(){return++this.current}},l={},c={add:function(e,n){var t=null!=n?n:d.next();return l[t]=e,t},resolve:function(e,n,t,o){var i=l[e];i&&(t(o)?i.resolve(n):i.reject(o),l[e]=null)}},u(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&c.resolve(t,n.data,function(e){return!e},n.error)}}),function(e,n){return void 0===n&&(n={}),new Promise(function(o,s){!function(e,n,o){void 0===o&&(o={});var s=r&&r[t],d=a&&a[t];i&&i[t]?i[t](e,n,JSON.stringify(o)):s?r[t].postMessage({reqId:e,method:n,data:o}):d?a[t](e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:o,reject:s},n.reqId),e,n)})}),p=function(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i="s"+(null!=n?n:t.next());return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),{setItem:function(n,t){return new Promise(function(o,r){var a=i.add({resolve:o,reject:r});e(a,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var o=i.add({resolve:n,reject:t});e(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var s=r&&r[o],d=a&&a[o];i&&i[o]?i[o](e,n,JSON.stringify(t)):s?r[o].postMessage({reqId:e,method:n,data:t}):d?a[o](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=e(function(e){var n=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):n?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=e(function(e){var n=r&&r.getQr;i&&i.getQr?i.getQr(e):n?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=e(function(e){var n=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):n?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=e(function(e){var n=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):n?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),y=e(function(e){var n=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):n?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=e(function(e){var n=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):n?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),S=e(function(e,n){var t=r&&r.share;i&&i.share?i.share(e,n):t?r.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),C=e(function(e,n){var t=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,n):t?r.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=e(function(e,n){var t=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,n):t?r.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),M=e(function(e,n,t){var o=i&&i.shareFile,a=r&&r.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?i.shareFile(e,n,s,d):a?r.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=e(function(e,n,t,o){var a=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,n,t,o):a?r.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),q=e(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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(n)):t?r.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),A=e(function(){var
|
|
1
|
+
function e(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i=null!=n?n:t.next();return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),function(){var n=arguments;return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e.apply(void 0,[r].concat([].slice.call(n)))})}}var n;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={}));var t="invoke",o="storage",i="undefined"!=typeof window&&window.AndroidBridge,r="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,a="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(a){var s=window.AITU_ORIGIN||"https://aitu.io";[t,o].forEach(function(e){a[e]||(a[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),s)})}),window.addEventListener("message",function(e){if(e.origin===s&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var d=function(){var s=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(s).map(function(n){return n.call(null,e)})});var d,l,c,u=function(e){s.push(e)},f=(d={current:0,next:function(){return++this.current}},l={},c={add:function(e,n){var t=null!=n?n:d.next();return l[t]=e,t},resolve:function(e,n,t,o){var i=l[e];i&&(t(o)?i.resolve(n):i.reject(o),l[e]=null)}},u(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&c.resolve(t,n.data,function(e){return!e},n.error)}}),function(e,n){return void 0===n&&(n={}),new Promise(function(o,s){!function(e,n,o){void 0===o&&(o={});var s=r&&r[t],d=a&&a[t];i&&i[t]?i[t](e,n,JSON.stringify(o)):s?r[t].postMessage({reqId:e,method:n,data:o}):d?a[t](e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:o,reject:s},n.reqId),e,n)})}),p=function(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i="s"+(null!=n?n:t.next());return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),{setItem:function(n,t){return new Promise(function(o,r){var a=i.add({resolve:o,reject:r});e(a,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var o=i.add({resolve:n,reject:t});e(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var s=r&&r[o],d=a&&a[o];i&&i[o]?i[o](e,n,JSON.stringify(t)):s?r[o].postMessage({reqId:e,method:n,data:t}):d?a[o](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=e(function(e){var n=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):n?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=e(function(e){var n=r&&r.getQr;i&&i.getQr?i.getQr(e):n?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=e(function(e){var n=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):n?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=e(function(e){var n=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):n?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),y=e(function(e){var n=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):n?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=e(function(e){var n=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):n?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),S=e(function(e,n){var t=r&&r.share;i&&i.share?i.share(e,n):t?r.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),C=e(function(e,n){var t=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,n):t?r.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=e(function(e,n){var t=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,n):t?r.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),M=e(function(e,n,t){var o=i&&i.shareFile,a=r&&r.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?i.shareFile(e,n,s,d):a?r.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=e(function(e,n,t,o){var a=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,n,t,o):a?r.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),q=e(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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(n)):t?r.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),A=e(function(e){var n=r&&r.enableScreenCapture;i&&i.enableScreenCapture?i.enableScreenCapture(e):n?r.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},u),T=e(function(e){var n=r&&r.disableScreenCapture;i&&i.disableScreenCapture?i.disableScreenCapture(e):n?r.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},u);return{copyToClipboard:I,invoke:f,storage:p,getMe:function(){return f(n.getMe)},getPhone:function(){return f(n.getPhone)},getContacts:function(){return f(n.getContacts)},getGeo:g,getQr:w,getSMSCode:v,getUserProfile:function(e){return f(n.getUserProfile,{id:e})},selectContact:b,enableNotifications:function(){return f(n.enableNotifications)},disableNotifications:function(){return f(n.disableNotifications)},openSettings:y,closeApplication:h,setTitle:C,share:S,shareImage:M,shareFile:m,setShakeHandler:function(e){i&&i.setShakeHandler||r&&r.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:function(e){i&&i.setTabActiveHandler||r&&r.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:q,isSupported:function(){var e=r&&window.webkit.messageHandlers.invoke;return Boolean(i||e||a)},supports:function(e){return i&&"function"==typeof i[e]||r&&r[e]&&"function"==typeof r[e].postMessage||a&&"function"==typeof a[e]},sub:u,enableScreenCapture:A,disableScreenCapture:T}}();export default d;
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\n }\n }\n\n const enableScreenCapture = () => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod]();\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\n }\n }\n\n const disableScreenCapture = () => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod]();\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invokeId","props","isIos","isWeb","console","log","invoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"AA0CA,SAASA,EAAgBC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EAAI/B,IAgDnBoD,IAAAA,EACA+E,oBAAqB9B,EACrB+B,qBAAsB9B,GAIX+B"}
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invokeId","props","isIos","isWeb","console","log","invoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"AA0CA,SAASA,EAAgBC,EAAQC,GAC/B,IA5BMC,EACAC,EA2BAC,GA5BAF,EAdC,CAC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mBAAhBA,EAAI/B,IAgDnBoD,IAAAA,EACA+E,oBAAqB9B,EACrB+B,qBAAsB9B,GAIX+B"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).aituBridge=n()}(this,function(){function e(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i=null!=n?n:t.next();return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),function(){var n=arguments;return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e.apply(void 0,[r].concat([].slice.call(n)))})}}var n;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={}));var t="invoke",o="storage",i="undefined"!=typeof window&&window.AndroidBridge,r="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,a="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(a){var s=window.AITU_ORIGIN||"https://aitu.io";[t,o].forEach(function(e){a[e]||(a[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),s)})}),window.addEventListener("message",function(e){if(e.origin===s&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}return function(){var s=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(s).map(function(n){return n.call(null,e)})});var d,c,l,u=function(e){s.push(e)},f=(d={current:0,next:function(){return++this.current}},c={},l={add:function(e,n){var t=null!=n?n:d.next();return c[t]=e,t},resolve:function(e,n,t,o){var i=c[e];i&&(t(o)?i.resolve(n):i.reject(o),c[e]=null)}},u(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&l.resolve(t,n.data,function(e){return!e},n.error)}}),function(e,n){return void 0===n&&(n={}),new Promise(function(o,s){!function(e,n,o){void 0===o&&(o={});var s=r&&r[t],d=a&&a[t];i&&i[t]?i[t](e,n,JSON.stringify(o)):s?r[t].postMessage({reqId:e,method:n,data:o}):d?a[t](e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(l.add({resolve:o,reject:s},n.reqId),e,n)})}),p=function(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i="s"+(null!=n?n:t.next());return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),{setItem:function(n,t){return new Promise(function(o,r){var a=i.add({resolve:o,reject:r});e(a,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var o=i.add({resolve:n,reject:t});e(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var s=r&&r[o],d=a&&a[o];i&&i[o]?i[o](e,n,JSON.stringify(t)):s?r[o].postMessage({reqId:e,method:n,data:t}):d?a[o](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=e(function(e){var n=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):n?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=e(function(e){var n=r&&r.getQr;i&&i.getQr?i.getQr(e):n?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=e(function(e){var n=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):n?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=e(function(e){var n=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):n?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),y=e(function(e){var n=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):n?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=e(function(e){var n=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):n?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),S=e(function(e,n){var t=r&&r.share;i&&i.share?i.share(e,n):t?r.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),C=e(function(e,n){var t=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,n):t?r.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=e(function(e,n){var t=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,n):t?r.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),M=e(function(e,n,t){var o=i&&i.shareFile,a=r&&r.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?i.shareFile(e,n,s,d):a?r.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=e(function(e,n,t,o){var a=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,n,t,o):a?r.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),q=e(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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(n)):t?r.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),A=e(function(){var
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).aituBridge=n()}(this,function(){function e(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i=null!=n?n:t.next();return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),function(){var n=arguments;return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e.apply(void 0,[r].concat([].slice.call(n)))})}}var n;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={}));var t="invoke",o="storage",i="undefined"!=typeof window&&window.AndroidBridge,r="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,a="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(a){var s=window.AITU_ORIGIN||"https://aitu.io";[t,o].forEach(function(e){a[e]||(a[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),s)})}),window.addEventListener("message",function(e){if(e.origin===s&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}return function(){var s=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(s).map(function(n){return n.call(null,e)})});var d,c,l,u=function(e){s.push(e)},f=(d={current:0,next:function(){return++this.current}},c={},l={add:function(e,n){var t=null!=n?n:d.next();return c[t]=e,t},resolve:function(e,n,t,o){var i=c[e];i&&(t(o)?i.resolve(n):i.reject(o),c[e]=null)}},u(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&l.resolve(t,n.data,function(e){return!e},n.error)}}),function(e,n){return void 0===n&&(n={}),new Promise(function(o,s){!function(e,n,o){void 0===o&&(o={});var s=r&&r[t],d=a&&a[t];i&&i[t]?i[t](e,n,JSON.stringify(o)):s?r[t].postMessage({reqId:e,method:n,data:o}):d?a[t](e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(l.add({resolve:o,reject:s},n.reqId),e,n)})}),p=function(e,n){var t,o,i=(t={current:0,next:function(){return++this.current}},o={},{add:function(e,n){var i="s"+(null!=n?n:t.next());return o[i]=e,i},resolve:function(e,n,t,i){var r=o[e];r&&(t(i)?r.resolve(n):r.reject(i),o[e]=null)}});return n(function(e){if(e.detail&&"reqId"in e.detail){var n=e.detail,t=n.reqId;t&&i.resolve(t,n.data,function(e){return!e},n.error)}}),{setItem:function(n,t){return new Promise(function(o,r){var a=i.add({resolve:o,reject:r});e(a,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,o){var r=i.add({resolve:t,reject:o});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var o=i.add({resolve:n,reject:t});e(o,"clear",{})})}}}(function(e,n,t){void 0===t&&(t={});var s=r&&r[o],d=a&&a[o];i&&i[o]?i[o](e,n,JSON.stringify(t)):s?r[o].postMessage({reqId:e,method:n,data:t}):d?a[o](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=e(function(e){var n=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):n?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=e(function(e){var n=r&&r.getQr;i&&i.getQr?i.getQr(e):n?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=e(function(e){var n=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):n?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=e(function(e){var n=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):n?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),y=e(function(e){var n=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):n?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=e(function(e){var n=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):n?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),S=e(function(e,n){var t=r&&r.share;i&&i.share?i.share(e,n):t?r.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),C=e(function(e,n){var t=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,n):t?r.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=e(function(e,n){var t=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,n):t?r.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),M=e(function(e,n,t){var o=i&&i.shareFile,a=r&&r.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?i.shareFile(e,n,s,d):a?r.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=e(function(e,n,t,o){var a=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,n,t,o):a?r.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),q=e(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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(n)):t?r.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),A=e(function(e){var n=r&&r.enableScreenCapture;i&&i.enableScreenCapture?i.enableScreenCapture(e):n?r.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},u),T=e(function(e){var n=r&&r.disableScreenCapture;i&&i.disableScreenCapture?i.disableScreenCapture(e):n?r.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},u);return{copyToClipboard:I,invoke:f,storage:p,getMe:function(){return f(n.getMe)},getPhone:function(){return f(n.getPhone)},getContacts:function(){return f(n.getContacts)},getGeo:g,getQr:w,getSMSCode:v,getUserProfile:function(e){return f(n.getUserProfile,{id:e})},selectContact:b,enableNotifications:function(){return f(n.enableNotifications)},disableNotifications:function(){return f(n.disableNotifications)},openSettings:y,closeApplication:h,setTitle:C,share:S,shareImage:M,shareFile:m,setShakeHandler:function(e){i&&i.setShakeHandler||r&&r.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:function(e){i&&i.setTabActiveHandler||r&&r.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:q,isSupported:function(){var e=r&&window.webkit.messageHandlers.invoke;return Boolean(i||e||a)},supports:function(e){return i&&"function"==typeof i[e]||r&&r[e]&&"function"==typeof r[e].postMessage||a&&"function"==typeof a[e]},sub:u,enableScreenCapture:A,disableScreenCapture:T}}()});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\n }\n }\n\n const enableScreenCapture = () => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod]();\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\n }\n }\n\n const disableScreenCapture = () => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod]();\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({});\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","subs","map","fn","call","sub","listener","push","invokePromise","invokeId","props","isIos","isWeb","console","log","invoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"mLA0CA,SAASA,EAAgBC,EAAQC,GAC/B,IA5BMC,EACAC,EA2BAC,GA5BAF,EAdC,CACLG,QAAS,EACTC,gBACE,QAASC,KAAKF,UAYZF,EAA+D,GAE9D,CACLK,aAAIC,EAA+BC,GACjC,IACMC,EADiB,MAAZD,EAAmBA,EAAWR,EAAQI,OAGjD,OADAH,EAAmBQ,GAAYF,EACxBE,GAGTC,iBAAWC,EAAwBC,EAASC,EAAiCC,GAC3E,IA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AAMjD,EAAchC,EAAeiF,QAC1CC,SAAU,kBAAMlD,EAAchC,EAAekF,WAC7CC,YAAa,kBAAMnD,EAAchC,EAAemF,cAChDC,OAAQnC,EACRoC,MAAOnC,EACPoC,WAAYnC,EACZoC,eAAgB,SAACC,UAAexD,EAAchC,EAAeuF,eAAgB,CAAEC,GAAAA,KAC/EC,cAAerC,EACfsC,oBA3F0B,kBAAM1D,EAAchC,EAAe0F,sBA4F7DC,qBA1F2B,kBAAM3D,EAAchC,EAAe2F,uBA2F9DC,aAAcvC,EACdwC,iBAAkBvC,EAClBwC,SAAUrC,EACVsC,MAAOxC,EACPyC,WAAYrC,EACZsC,UAAW9B,EACX+B,gBA/FsB,SAACC,GACLhG,GAAWA,EAAO,iBACtBG,GAAOA,EAAG,gBAGrBF,OAAegG,kBAAoBD,EACT,oBAAX/F,QAChBiC,QAAQC,IAAI,4BAyFd+D,oBArF0B,SAACF,GACThG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAekG,sBAAwBH,EACb,oBAAX/F,QAChBiC,QAAQC,IAAI,gCA+EdiE,QAASnC,EACToC,YAtDkB,WAClB,IAAMC,EAASnG,GAAQF,OAAeG,OAAOC,gBAAgB+B,OAC7D,OAAOmE,QAAQvG,GAAWsG,GAAUhG,IAqDpCkG,SAlDe,SAACjI,UACfyB,GAAsC,mBAApBA,EAAQzB,IAC1B4B,GAAOA,EAAI5B,IAA8C,mBAA5B4B,EAAI5B,GAAQqC,aACzCN,GAA8B,mBAAhBA,EAAI/B,IAgDnBmD,IAAAA,EACA+E,oBAAqB9B,EACrB+B,qBAAsB9B,GAIX+B"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts"],"sourcesContent":["function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const methodId = id;\n promiseControllers[methodId] = controller;\n return methodId;\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 promisifyMethod(method, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n\n method(reqId, ...args);\n });\n };\n}\n\nexport default promisifyMethod;\n","import promisifyInvoke from './promisifyInvoke';\nimport promisifyStorage from './promisifyStorage';\nimport promisifyMethod from './promisifyMethod';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications'\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => 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\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\ninterface AituBridge {\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 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}\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';\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) && ((window as any).WebBridge = (window as any).WebBridge || {});\n\nif (web) {\n const aituOrigin = (window as any).AITU_ORIGIN || 'https://aitu.io';\n\n [invokeMethod, storageMethod].forEach((method) => {\n if (!web[method]) {\n web[method] = (...args) => window.top.postMessage(JSON.stringify({\n method,\n payload: args,\n }), aituOrigin);\n }\n });\n\n window.addEventListener('message', (event) => {\n if (event.origin === aituOrigin && event.data) {\n try {\n const detail = JSON.parse(event.data);\n window.dispatchEvent(new CustomEvent('aituEvents', { detail }));\n } catch (e) { }\n }\n });\n}\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\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n const isWeb = web && web[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 (isWeb) {\n web[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 const isWeb = web && web[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 (isWeb) {\n web[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 (typeof window !== 'undefined') {\n console.log('--getGeo-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getQr-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--getSMSCode-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--selectContact-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--openSettings-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--closeApplication-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--share-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--setTitle-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--shareFile-isWeb');\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) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isWeb');\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) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isWeb');\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 (typeof window !== 'undefined') {\n console.log('--vibrate-isWeb');\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 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 invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, sub);\n const getQrPromise = promisifyMethod(getQr, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, sub);\n const selectContactPromise = promisifyMethod(selectContact, sub);\n const openSettingsPromise = promisifyMethod(openSettings, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, sub);\n const sharePromise = promisifyMethod(share, sub);\n const setTitlePromise = promisifyMethod(setTitle, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, sub);\n const shareImagePromise = promisifyMethod(shareImage, sub);\n const shareFilePromise = promisifyMethod(shareFile, sub);\n const vibratePromise = promisifyMethod(vibrate, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);\n\n return {\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 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 }\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n}\n\nfunction createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const invokeId = id;\n promiseControllers[invokeId] = controller;\n return invokeId;\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 promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n\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 return function promisifiedFunc(method: any, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, props.reqId);\n\n invoke(reqId, method, props);\n });\n };\n}\n\nexport default promisifyInvoke;\n","function createCounter() {\n return {\n current: 0,\n next() {\n return ++this.current;\n },\n };\n }\n \n function createRequestResolver() {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n \n const counter = createCounter();\n const promiseControllers: Record<string, PromiseController | null> = {};\n \n return {\n add(controller: PromiseController, customId?: number | string): number | string {\n const id = customId != null ? customId : counter.next();\n const storageId = `s${id}`;\n promiseControllers[storageId] = controller;\n return storageId;\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 \n function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver();\n \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 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 \n export default promisifyStorage;\n "],"names":["promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","EInvokeRequest","invokeMethod","storageMethod","android","window","AndroidBridge","ios","webkit","messageHandlers","web","top","WebBridge","aituOrigin","AITU_ORIGIN","forEach","postMessage","JSON","stringify","payload","addEventListener","origin","parse","dispatchEvent","CustomEvent","e","subs","map","fn","call","sub","listener","push","invokePromise","invokeId","props","isIos","isWeb","console","log","invoke","storagePromise","storage","storageId","setItem","keyName","keyValue","getItem","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","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","id","selectContact","enableNotifications","disableNotifications","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","buildBridge"],"mappings":"mLA0CA,SAASA,EAAgBC,EAAQC,GAC/B,IA5BMC,EACAC,EA2BAC,GA5BAF,EAdC,CACLG,QAAS,EACTC,gBACE,QAASC,KAAKF,UAYZF,EAA+D,GAE9D,CACLK,aAAIC,EAA+BC,GACjC,IACMC,EADiB,MAAZD,EAAmBA,EAAWR,EAAQI,OAGjD,OADAH,EAAmBQ,GAAYF,EACxBE,GAGTC,iBAAWC,EAAwBC,EAASC,EAAiCC,GAC3E,IAAMC,EAAiBd,EAAmBU,GAEtCI,IACEF,EAAUC,GACZC,EAAeL,QAAQE,GAEvBG,EAAeC,OAA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eiF,QAC1CC,SAAU,kBAAMlD,EAAchC,EAAekF,WAC7CC,YAAa,kBAAMnD,EAAchC,EAAemF,cAChDC,OAAQnC,EACRoC,MAAOnC,EACPoC,WAAYnC,EACZoC,eAAgB,SAACC,UAAexD,EAAchC,EAAeuF,eAAgB,CAAEC,GAAAA,KAC/EC,cAAerC,EACfsC,oBA3F0B,kBAAM1D,EAAchC,EAAe0F,sBA4F7DC,qBA1F2B,kBAAM3D,EAAchC,EAAe2F,uBA2F9DC,aAAcvC,EACdwC,iBAAkBvC,EAClBwC,SAAUrC,EACVsC,MAAOxC,EACPyC,WAAYrC,EACZsC,UAAW9B,EACX+B,gBA/FsB,SAACC,GACLhG,GAAWA,EAAO,iBACtBG,GAAOA,EAAG,gBAGrBF,OAAegG,kBAAoBD,EACT,oBAAX/F,QAChBiC,QAAQC,IAAI,4BAyFd+D,oBArF0B,SAACF,GACThG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAekG,sBAAwBH,EACb,oBAAX/F,QAChBiC,QAAQC,IAAI,gCA+EdiE,QAASnC,EACToC,YAtDkB,WAClB,IAAMC,EAASnG,GAAQF,OAAeG,OAAOC,gBAAgB+B,OAC7D,OAAOmE,QAAQvG,GAAWsG,GAAUhG,IAqDpCkG,SAlDe,SAACjI,UACfyB,GAAsC,mBAApBA,EAAQzB,IAC1B4B,GAAOA,EAAI5B,IAA8C,mBAA5B4B,EAAI5B,GAAQqC,aACzCN,GAA8B,mBAAhBA,EAAI/B,IAgDnBmD,IAAAA,EACA+E,oBAAqB9B,EACrB+B,qBAAsB9B,GAIX+B"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -311,27 +311,27 @@ const buildBridge = (): AituBridge => {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
const enableScreenCapture = () => {
|
|
314
|
+
const enableScreenCapture = (reqId) => {
|
|
315
315
|
const isAndroid = android && android[enableScreenCaptureMethod];
|
|
316
316
|
const isIos = ios && ios[enableScreenCaptureMethod];
|
|
317
317
|
|
|
318
318
|
if (isAndroid) {
|
|
319
|
-
android[enableScreenCaptureMethod]();
|
|
319
|
+
android[enableScreenCaptureMethod](reqId);
|
|
320
320
|
} else if (isIos) {
|
|
321
|
-
ios[enableScreenCaptureMethod].postMessage({});
|
|
321
|
+
ios[enableScreenCaptureMethod].postMessage({ reqId });
|
|
322
322
|
} else if (typeof window !== 'undefined') {
|
|
323
323
|
console.log('--enableScreenCapture-isWeb');
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
const disableScreenCapture = () => {
|
|
327
|
+
const disableScreenCapture = (reqId) => {
|
|
328
328
|
const isAndroid = android && android[disableScreenCaptureMethod];
|
|
329
329
|
const isIos = ios && ios[disableScreenCaptureMethod];
|
|
330
330
|
|
|
331
331
|
if (isAndroid) {
|
|
332
|
-
android[disableScreenCaptureMethod]();
|
|
332
|
+
android[disableScreenCaptureMethod](reqId);
|
|
333
333
|
} else if (isIos) {
|
|
334
|
-
ios[disableScreenCaptureMethod].postMessage({});
|
|
334
|
+
ios[disableScreenCaptureMethod].postMessage({ reqId });
|
|
335
335
|
} else if (typeof window !== 'undefined') {
|
|
336
336
|
console.log('--disableScreenCapture-isWeb');
|
|
337
337
|
}
|