@btsd/aitu-bridge 0.2.12 → 0.2.15
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/.github/CODEOWNERS +1 -0
- package/dist/index.d.ts +21 -0
- 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/dist/version.d.ts +1 -0
- package/package.json +2 -1
- package/src/index.ts +57 -1
- package/src/version.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.github/workflows @btsdigital/aitu-bridge
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare enum EInvokeRequest {
|
|
|
9
9
|
declare type SetItemType = (keyName: string, keyValue: string) => Promise<void>;
|
|
10
10
|
declare type GetItemType = (keyName: string) => Promise<string | null>;
|
|
11
11
|
declare type ClearType = () => Promise<void>;
|
|
12
|
+
declare type HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;
|
|
12
13
|
interface GetPhoneResponse {
|
|
13
14
|
phone: string;
|
|
14
15
|
sign: string;
|
|
@@ -50,6 +51,23 @@ interface GetUserProfileResponse {
|
|
|
50
51
|
avatar?: string;
|
|
51
52
|
avatarThumb?: string;
|
|
52
53
|
}
|
|
54
|
+
export declare enum HeaderMenuIcon {
|
|
55
|
+
Search = "Search",
|
|
56
|
+
ShoppingCart = "ShoppingCart",
|
|
57
|
+
Menu = "Menu",
|
|
58
|
+
Share = "Share",
|
|
59
|
+
Notifications = "Notifications",
|
|
60
|
+
Help = "Help",
|
|
61
|
+
Error = "Error",
|
|
62
|
+
Person = "Person",
|
|
63
|
+
Sort = "Sort",
|
|
64
|
+
Filter = "Filter"
|
|
65
|
+
}
|
|
66
|
+
interface HeaderMenuItem {
|
|
67
|
+
id: string;
|
|
68
|
+
icon: HeaderMenuIcon;
|
|
69
|
+
badge?: string;
|
|
70
|
+
}
|
|
53
71
|
declare type OpenSettingsResponse = 'success' | 'failed';
|
|
54
72
|
declare type ShareResponse = 'success' | 'failed';
|
|
55
73
|
declare type CopyToClipboardResponse = 'success' | 'failed';
|
|
@@ -61,6 +79,7 @@ interface BridgeStorage {
|
|
|
61
79
|
clear: ClearType;
|
|
62
80
|
}
|
|
63
81
|
interface AituBridge {
|
|
82
|
+
version: string;
|
|
64
83
|
invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;
|
|
65
84
|
storage: BridgeStorage;
|
|
66
85
|
getMe: () => Promise<GetMeResponse>;
|
|
@@ -88,6 +107,8 @@ interface AituBridge {
|
|
|
88
107
|
sub: any;
|
|
89
108
|
enableScreenCapture: () => Promise<{}>;
|
|
90
109
|
disableScreenCapture: () => Promise<{}>;
|
|
110
|
+
setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;
|
|
111
|
+
setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;
|
|
91
112
|
}
|
|
92
113
|
declare const bridge: AituBridge;
|
|
93
114
|
export default bridge;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
var e,n;function t(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)))})}}!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(e||(e={})),(n=exports.HeaderMenuIcon||(exports.HeaderMenuIcon={})).Search="Search",n.ShoppingCart="ShoppingCart",n.Menu="Menu",n.Share="Share",n.Notifications="Notifications",n.Help="Help",n.Error="Error",n.Person="Person",n.Sort="Sort",n.Filter="Filter";var o="invoke",i="storage",r="undefined"!=typeof window&&window.AndroidBridge,a="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,s="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(s){var d=window.AITU_ORIGIN||"https://aitu.io";[o,i].forEach(function(e){s[e]||(s[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),d)})}),window.addEventListener("message",function(e){if(e.origin===d&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var l=function(){var n=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(n).map(function(n){return n.call(null,e)})});var d,l,c,u=function(e){n.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(t,i){!function(e,n,t){void 0===t&&(t={});var i=a&&a[o],d=s&&s[o];r&&r[o]?r[o](e,n,JSON.stringify(t)):i?a[o].postMessage({reqId:e,method:n,data:t}):d?s[o](e,n,t):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:t,reject:i},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 o=a&&a[i],d=s&&s[i];r&&r[i]?r[i](e,n,JSON.stringify(t)):o?a[i].postMessage({reqId:e,method:n,data:t}):d?s[i](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=t(function(e){var n=a&&a.getGeo;r&&r.getGeo?r.getGeo(e):n?a.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=t(function(e){var n=a&&a.getQr;r&&r.getQr?r.getQr(e):n?a.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=t(function(e){var n=a&&a.getSMSCode;r&&r.getSMSCode?r.getSMSCode(e):n?a.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=t(function(e){var n=a&&a.selectContact;r&&r.selectContact?r.selectContact(e):n?a.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),S=t(function(e){var n=a&&a.openSettings;r&&r.openSettings?r.openSettings(e):n?a.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=t(function(e){var n=a&&a.closeApplication;r&&r.closeApplication?r.closeApplication(e):n?a.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),y=t(function(e,n){var t=a&&a.share;r&&r.share?r.share(e,n):t?a.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),M=t(function(e,n){var t=a&&a.setTitle;r&&r.setTitle?r.setTitle(e,n):t?a.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=t(function(e,n){var t=a&&a.copyToClipboard;r&&r.copyToClipboard?r.copyToClipboard(e,n):t?a.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),C=t(function(e,n,t){var o=r&&r.shareFile,i=a&&a.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?r.shareFile(e,n,s,d):i?a.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=t(function(e,n,t,o){var i=a&&a.shareFile;r&&r.shareFile?r.shareFile(e,n,t,o):i?a.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),H=t(function(e,n){if(!Array.isArray(n)||n.some(function(e){return e<1||e!==Math.floor(e)})||n.reduce(function(e,n){return e+n})>1e4)console.error("Pattern should be an array of positive integers no longer than 10000ms total");else{var t=a&&a.vibrate;r&&r.vibrate?r.vibrate(e,JSON.stringify(n)):t?a.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),q=t(function(e){var n=a&&a.enableScreenCapture;r&&r.enableScreenCapture?r.enableScreenCapture(e):n?a.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},u),k=t(function(e){var n=a&&a.disableScreenCapture;r&&r.disableScreenCapture?r.disableScreenCapture(e):n?a.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},u),W=t(function(e){var n=a&&a.setHeaderMenuItems;r&&r.setHeaderMenuItems?r.setHeaderMenuItems(e):n?a.setHeaderMenuItems.postMessage({items:e}):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isWeb")},u);return{version:String("0.2.15"),copyToClipboard:I,invoke:f,storage:p,getMe:function(){return f(e.getMe)},getPhone:function(){return f(e.getPhone)},getContacts:function(){return f(e.getContacts)},getGeo:g,getQr:w,getSMSCode:v,getUserProfile:function(n){return f(e.getUserProfile,{id:n})},selectContact:b,enableNotifications:function(){return f(e.enableNotifications)},disableNotifications:function(){return f(e.disableNotifications)},openSettings:S,closeApplication:h,setTitle:M,share:y,shareImage:C,shareFile:m,setShakeHandler:function(e){r&&r.setShakeHandler||a&&a.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:function(e){r&&r.setTabActiveHandler||a&&a.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:H,isSupported:function(){var e=a&&window.webkit.messageHandlers.invoke;return Boolean(r||e||s)},supports:function(e){return r&&"function"==typeof r[e]||a&&a[e]&&"function"==typeof a[e].postMessage||s&&"function"==typeof s[e]},sub:u,enableScreenCapture:q,disableScreenCapture:k,setHeaderMenuItems:W,setHeaderMenuItemClickHandler:function(e){r&&r.setHeaderMenuItemClickHandler||a&&a.setHeaderMenuItemClickHandler?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isWeb")}}}();exports.default=l;
|
|
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 = (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,EAAiBd,EAAmBU,GAEtCI,IACEF,EAAUC,GACZC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAGxBb,EAAmBU,GAAS,SAuBlC,OAdAZ,EAAU,SAACkB,GACT,GAAKA,EAAMC,QAIP,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nD,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/index.ts","../src/promisifyMethod.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts","../src/version.ts"],"sourcesContent":["import { LIB_VERSION } from './version';\n\nimport 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\ntype HeaderMenuItemClickHandlerType = (id: string) => 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\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\ninterface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\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 setHeaderMenuItems = (items: Array<HeaderMenuItem>) => {\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](items);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ items });\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isWeb');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isWeb');\n }\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 const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler\n }\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 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","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 ","export const LIB_VERSION = \"0.2.15\";\n"],"names":["EInvokeRequest","HeaderMenuIcon","promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","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","setHeaderMenuItemsPromise","items","version","String","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","setHeaderMenuItems","setHeaderMenuItemClickHandler","onAituBridgeHeaderMenuItemClick","buildBridge"],"mappings":"IAMKA,EA+DOC,EC3BZ,SAASC,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,OAAOF,GAGxBb,EAAmBU,G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BAAhBA,EAAI9B,IA0EnBmD,IAAAA,EACAmF,oBAAqBlC,EACrBmC,qBAAsBlC,EACtBmC,mBAAoBlC,EACpBmC,8BA3DoC,SAACZ,GACnBrG,GAAWA,EAAO,+BACtBG,GAAOA,EAAG,8BAGrBF,OAAeiH,gCAAkCb,EACvB,oBAAXpG,QAChBkC,QAAQC,IAAI,2CAwDH+E"}
|
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
|
|
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,o;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(t||(t={})),function(e){e.Search="Search",e.ShoppingCart="ShoppingCart",e.Menu="Menu",e.Share="Share",e.Notifications="Notifications",e.Help="Help",e.Error="Error",e.Person="Person",e.Sort="Sort",e.Filter="Filter"}(o||(o={}));const n="invoke",s="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){const e=window.AITU_ORIGIN||"https://aitu.io";[n,s].forEach(t=>{a[t]||(a[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 d=(()=>{const o=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",e=>{[...o].map(t=>t.call(null,e))});const d=e=>{o.push(e)},l=function(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(e,t={}){return new Promise((s,d)=>{((e,t,o={})=>{const s=r&&r[n],d=a&&a[n];i&&i[n]?i[n](e,t,JSON.stringify(o)):s?r[n].postMessage({reqId:e,method:t,data:o}):d?a[n](e,t,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")})(o.add({resolve:s,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 n=r&&r[s],d=a&&a[s];i&&i[s]?i[s](e,t,JSON.stringify(o)):n?r[s].postMessage({reqId:e,method:t,data:o}):d?a[s](e,t,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},d),p=e(e=>{const t=r&&r.getGeo;i&&i.getGeo?i.getGeo(e):t?r.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},d),u=e(e=>{const t=r&&r.getQr;i&&i.getQr?i.getQr(e):t?r.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},d),g=e(e=>{const t=r&&r.getSMSCode;i&&i.getSMSCode?i.getSMSCode(e):t?r.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},d),f=e(e=>{const t=r&&r.selectContact;i&&i.selectContact?i.selectContact(e):t?r.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},d),w=e(e=>{const t=r&&r.openSettings;i&&i.openSettings?i.openSettings(e):t?r.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},d),b=e(e=>{const t=r&&r.closeApplication;i&&i.closeApplication?i.closeApplication(e):t?r.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},d),S=e((e,t)=>{const o=r&&r.share;i&&i.share?i.share(e,t):o?r.share.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--share-isWeb")},d),h=e((e,t)=>{const o=r&&r.setTitle;i&&i.setTitle?i.setTitle(e,t):o?r.setTitle.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},d),y=e((e,t)=>{const o=r&&r.copyToClipboard;i&&i.copyToClipboard?i.copyToClipboard(e,t):o?r.copyToClipboard.postMessage({reqId:e,text:t}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},d),M=e((e,t,o)=>{const n=i&&i.shareFile,s=r&&r.shareFile,a="image."+o.split(";")[0].split("/")[1],d=o.substr(o.indexOf(",")+1);n?i.shareFile(e,t,a,d):s?r.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 s=r&&r.shareFile;i&&i.shareFile?i.shareFile(e,t,o,n):s?r.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=r&&r.vibrate;i&&i.vibrate?i.vibrate(e,JSON.stringify(t)):o?r.vibrate.postMessage({reqId:e,pattern:t}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")},d),v=e(e=>{const t=r&&r.enableScreenCapture;i&&i.enableScreenCapture?i.enableScreenCapture(e):t?r.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},d),m=e(e=>{const t=r&&r.disableScreenCapture;i&&i.disableScreenCapture?i.disableScreenCapture(e):t?r.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},d),H=e(e=>{const t=r&&r.setHeaderMenuItems;i&&i.setHeaderMenuItems?i.setHeaderMenuItems(e):t?r.setHeaderMenuItems.postMessage({items:e}):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isWeb")},d);return{version:String("0.2.15"),copyToClipboard:y,invoke:l,storage:c,getMe:()=>l(t.getMe),getPhone:()=>l(t.getPhone),getContacts:()=>l(t.getContacts),getGeo:p,getQr:u,getSMSCode:g,getUserProfile:e=>l(t.getUserProfile,{id:e}),selectContact:f,enableNotifications:()=>l(t.enableNotifications),disableNotifications:()=>l(t.disableNotifications),openSettings:w,closeApplication:b,setTitle:h,share:S,shareImage:M,shareFile:C,setShakeHandler:e=>{i&&i.setShakeHandler||r&&r.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:e=>{i&&i.setTabActiveHandler||r&&r.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:I,isSupported:()=>{const e=r&&window.webkit.messageHandlers.invoke;return Boolean(i||e||a)},supports:e=>i&&"function"==typeof i[e]||r&&r[e]&&"function"==typeof r[e].postMessage||a&&"function"==typeof a[e],sub:d,enableScreenCapture:v,disableScreenCapture:m,setHeaderMenuItems:H,setHeaderMenuItemClickHandler:e=>{i&&i.setHeaderMenuItemClickHandler||r&&r.setHeaderMenuItemClickHandler?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isWeb")}}})();export default d;export{o as HeaderMenuIcon};
|
|
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 = (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,I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CAAEC,GAAAA,IAC/EC,cAAerC,EACfsC,oBA3F0B,IAAM3D,EAAcjC,EAAe4F,qBA4F7DC,qBA1F2B,IAAM5D,EAAcjC,EAAe6F,sBA2F9DC,aAAcvC,EACdwC,iBAAkBvC,EAClBwC,SAAUrC,EACVsC,MAAOxC,EACPyC,WAAYrC,EACZsC,UAAW9B,EACX+B,gBA/FuBC,IACLlG,GAAWA,EAAO,iBACtBG,GAAOA,EAAG,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"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/promisifyMethod.ts","../src/index.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts","../src/version.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 { LIB_VERSION } from './version';\n\nimport 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\ntype HeaderMenuItemClickHandlerType = (id: string) => 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\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\ninterface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\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 setHeaderMenuItems = (items: Array<HeaderMenuItem>) => {\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](items);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ items });\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isWeb');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isWeb');\n }\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 const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler\n }\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 ","export const LIB_VERSION = \"0.2.15\";\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","HeaderMenuIcon","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","setHeaderMenuItemsPromise","items","version","String","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","setHeaderMenuItems","setHeaderMenuItemClickHandler","onAituBridgeHeaderMenuItemClick","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,M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oBlC,EACpBmC,8BA3DqCZ,IACnBtG,GAAWA,EAAO,+BACtBG,GAAOA,EAAG,8BAGrBF,OAAekH,gCAAkCb,EACvB,oBAAXrG,QAChBmC,QAAQC,IAAI,4CAwDH+E"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
var e,n;function t(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)))})}}!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(e||(e={})),function(e){e.Search="Search",e.ShoppingCart="ShoppingCart",e.Menu="Menu",e.Share="Share",e.Notifications="Notifications",e.Help="Help",e.Error="Error",e.Person="Person",e.Sort="Sort",e.Filter="Filter"}(n||(n={}));var o="invoke",i="storage",r="undefined"!=typeof window&&window.AndroidBridge,a="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,s="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(s){var d=window.AITU_ORIGIN||"https://aitu.io";[o,i].forEach(function(e){s[e]||(s[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),d)})}),window.addEventListener("message",function(e){if(e.origin===d&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var l=function(){var n=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(e){[].concat(n).map(function(n){return n.call(null,e)})});var d,l,c,u=function(e){n.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(t,i){!function(e,n,t){void 0===t&&(t={});var i=a&&a[o],d=s&&s[o];r&&r[o]?r[o](e,n,JSON.stringify(t)):i?a[o].postMessage({reqId:e,method:n,data:t}):d?s[o](e,n,t):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:t,reject:i},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 o=a&&a[i],d=s&&s[i];r&&r[i]?r[i](e,n,JSON.stringify(t)):o?a[i].postMessage({reqId:e,method:n,data:t}):d?s[i](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=t(function(e){var n=a&&a.getGeo;r&&r.getGeo?r.getGeo(e):n?a.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=t(function(e){var n=a&&a.getQr;r&&r.getQr?r.getQr(e):n?a.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=t(function(e){var n=a&&a.getSMSCode;r&&r.getSMSCode?r.getSMSCode(e):n?a.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=t(function(e){var n=a&&a.selectContact;r&&r.selectContact?r.selectContact(e):n?a.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),S=t(function(e){var n=a&&a.openSettings;r&&r.openSettings?r.openSettings(e):n?a.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),h=t(function(e){var n=a&&a.closeApplication;r&&r.closeApplication?r.closeApplication(e):n?a.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),y=t(function(e,n){var t=a&&a.share;r&&r.share?r.share(e,n):t?a.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),M=t(function(e,n){var t=a&&a.setTitle;r&&r.setTitle?r.setTitle(e,n):t?a.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),C=t(function(e,n){var t=a&&a.copyToClipboard;r&&r.copyToClipboard?r.copyToClipboard(e,n):t?a.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),I=t(function(e,n,t){var o=r&&r.shareFile,i=a&&a.shareFile,s="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?r.shareFile(e,n,s,d):i?a.shareFile.postMessage({reqId:e,text:n,filename:s,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=t(function(e,n,t,o){var i=a&&a.shareFile;r&&r.shareFile?r.shareFile(e,n,t,o):i?a.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),H=t(function(e,n){if(!Array.isArray(n)||n.some(function(e){return e<1||e!==Math.floor(e)})||n.reduce(function(e,n){return e+n})>1e4)console.error("Pattern should be an array of positive integers no longer than 10000ms total");else{var t=a&&a.vibrate;r&&r.vibrate?r.vibrate(e,JSON.stringify(n)):t?a.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),q=t(function(e){var n=a&&a.enableScreenCapture;r&&r.enableScreenCapture?r.enableScreenCapture(e):n?a.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},u),k=t(function(e){var n=a&&a.disableScreenCapture;r&&r.disableScreenCapture?r.disableScreenCapture(e):n?a.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},u),W=t(function(e){var n=a&&a.setHeaderMenuItems;r&&r.setHeaderMenuItems?r.setHeaderMenuItems(e):n?a.setHeaderMenuItems.postMessage({items:e}):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isWeb")},u);return{version:String("0.2.15"),copyToClipboard:C,invoke:f,storage:p,getMe:function(){return f(e.getMe)},getPhone:function(){return f(e.getPhone)},getContacts:function(){return f(e.getContacts)},getGeo:g,getQr:w,getSMSCode:v,getUserProfile:function(n){return f(e.getUserProfile,{id:n})},selectContact:b,enableNotifications:function(){return f(e.enableNotifications)},disableNotifications:function(){return f(e.disableNotifications)},openSettings:S,closeApplication:h,setTitle:M,share:y,shareImage:I,shareFile:m,setShakeHandler:function(e){r&&r.setShakeHandler||a&&a.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:function(e){r&&r.setTabActiveHandler||a&&a.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:H,isSupported:function(){var e=a&&window.webkit.messageHandlers.invoke;return Boolean(r||e||s)},supports:function(e){return r&&"function"==typeof r[e]||a&&a[e]&&"function"==typeof a[e].postMessage||s&&"function"==typeof s[e]},sub:u,enableScreenCapture:q,disableScreenCapture:k,setHeaderMenuItems:W,setHeaderMenuItemClickHandler:function(e){r&&r.setHeaderMenuItemClickHandler||a&&a.setHeaderMenuItemClickHandler?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isWeb")}}}();export default l;export{n as HeaderMenuIcon};
|
|
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 = (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,EAAiBd,EAAmBU,GAEtCI,IACEF,EAAUC,GACZC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAGxBb,EAAmBU,GAAS,SAuBlC,OAdAZ,EAAU,SAACkB,GACT,GAAKA,EAAMC,QAIP,UAAWD,EAAMC,OAAQ,OACID,EAAMC,OAA7BP,IAAAA,MAEJA,GACFT,EAAgBQ,QAAQC,IAHXC,KAGwB,SAACE,UAAYA,KAH/BA,qCASvB,WAAWK,QAAQ,SAACT,EAASM,GAC3B,IAAML,EAAQT,EAAgBI,IAAI,CAAEI,QAAAA,EAASM,OAAAA,IAE7ClB,gBAAOa,gCC3Db,IAAKS,GAAL,SAAKA,GACHA,gBACAA,sBACAA,4BACAA,kCACAA,2CACAA,8CANF,CAAKA,IAAAA,OA0GL,IAAMC,EAAe,SACfC,EAAgB,UAkBhBC,EAA4B,oBAAXC,QAA2BA,OAAeC,cAC3DC,EAAwB,oBAAXF,QAA2BA,OAAeG,QAAWH,OAAeG,OAAOC,gBACxFC,EAAwB,oBAAXL,QAA2BA,OAAOM,MAAQN,SAAaA,OAAeO,UAAaP,OAAeO,WAAa,IAElI,GAAIF,EAAK,CACP,IAAMG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AAXhG,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.module.js","sources":["../src/index.ts","../src/promisifyMethod.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts","../src/version.ts"],"sourcesContent":["import { LIB_VERSION } from './version';\n\nimport 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\ntype HeaderMenuItemClickHandlerType = (id: string) => 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\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\ninterface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\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 setHeaderMenuItems = (items: Array<HeaderMenuItem>) => {\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](items);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ items });\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isWeb');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isWeb');\n }\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 const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler\n }\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 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","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 ","export const LIB_VERSION = \"0.2.15\";\n"],"names":["EInvokeRequest","HeaderMenuIcon","promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","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","setHeaderMenuItemsPromise","items","version","String","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","setHeaderMenuItems","setHeaderMenuItemClickHandler","onAituBridgeHeaderMenuItemClick","buildBridge"],"mappings":"IAMKA,EA+DOC,EC3BZ,SAASC,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,OAAOF,GAGxBb,EAAmBU,GAAS,SAuBlC,OAdAZ,EAAU,SAACkB,GACT,GAAKA,EAAMC,QAIP,UAAWD,EAAMC,OAAQ,OACID,EAAMC,OAA7BP,IAAAA,MAEJA,GACFT,EAAgBQ,QAAQC,IAHXC,KAGwB,SAACE,UAAYA,KAH/BA,qCASvB,WAAWK,QAAQ,SAACT,EAASM,GAC3B,IAAML,EAAQT,EAAgBI,IAAI,CAAEI,QAAAA,EAASM,OAAAA,IAE7ClB,gBAAOa,iCDzDb,SAAKhB,GACHA,gBACAA,sBACAA,4BACAA,kCACAA,2CACAA,8CANF,CAAKA,IAAAA,OA+DL,SAAYC,GACVA,kBACAA,8BACAA,cACAA,gBACAA,gCACAA,cACAA,gBACAA,kBACAA,cACAA,kBAVF,CAAYA,IAAAA,OAmEZ,IAAMwB,EAAe,SACfC,EAAgB,UAoBhBC,EAA4B,oBAAXC,QAA2BA,OAAeC,cAC3DC,EAAwB,o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AczD,EAAeuH,sBAsH7DC,qBApH2B,kBAAM/D,EAAczD,EAAewH,uBAqH9DC,aAAc3C,EACd4C,iBAAkB3C,EAClB4C,SAAUzC,EACV0C,MAAO5C,EACP6C,WAAYzC,EACZ0C,UAAWlC,EACXmC,gBAzHsB,SAACC,GACLrG,GAAWA,EAAO,iBACtBG,GAAOA,EAAG,gBAGrBF,OAAeqG,kBAAoBD,EACT,oBAAXpG,QAChBkC,QAAQC,IAAI,4BAmHdmE,oBA/G0B,SAACF,GACTrG,GAAWA,EAAO,qBACtBG,GAAOA,EAAG,oBAGrBF,OAAeuG,sBAAwBH,EACb,oBAAXpG,QAChBkC,QAAQC,IAAI,gCAyGdqE,QAASvC,EACTwC,YAhFkB,WAClB,IAAMC,EAASxG,GAAQF,OAAeG,OAAOC,gBAAgBgC,OAC7D,OAAOuE,QAAQ5G,GAAW2G,GAAUrG,IA+EpCuG,SA5Ee,SAACrI,UACfwB,GAAsC,mBAApBA,EAAQxB,IAC1B2B,GAAOA,EAAI3B,IAA8C,mBAA5B2B,EAAI3B,GAAQoC,aACzCN,GAA8B,mBAAhBA,EAAI9B,IA0EnBmD,IAAAA,EACAmF,oBAAqBlC,EACrBmC,qBAAsBlC,EACtBmC,mBAAoBlC,EACpBmC,8BA3DoC,SAACZ,GACnBrG,GAAWA,EAAO,+BACtBG,GAAOA,EAAG,8BAGrBF,OAAeiH,gCAAkCb,EACvB,oBAAXpG,QAChBkC,QAAQC,IAAI,2CAwDH+E"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).aituBridge={})}(this,function(e){var n,t;function o(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)))})}}!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications"}(n||(n={})),(t=e.HeaderMenuIcon||(e.HeaderMenuIcon={})).Search="Search",t.ShoppingCart="ShoppingCart",t.Menu="Menu",t.Share="Share",t.Notifications="Notifications",t.Help="Help",t.Error="Error",t.Person="Person",t.Sort="Sort",t.Filter="Filter";var i="invoke",r="storage",a="undefined"!=typeof window&&window.AndroidBridge,s="undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers,d="undefined"!=typeof window&&window.top!==window&&(window.WebBridge=window.WebBridge||{});if(d){var l=window.AITU_ORIGIN||"https://aitu.io";[i,r].forEach(function(e){d[e]||(d[e]=function(){return window.top.postMessage(JSON.stringify({method:e,payload:[].slice.call(arguments)}),l)})}),window.addEventListener("message",function(e){if(e.origin===l&&e.data)try{var n=JSON.parse(e.data);window.dispatchEvent(new CustomEvent("aituEvents",{detail:n}))}catch(e){}})}var c=function(){var e=[];"undefined"!=typeof window&&window.addEventListener("aituEvents",function(n){[].concat(e).map(function(e){return e.call(null,n)})});var t,l,c,u=function(n){e.push(n)},f=(t={current:0,next:function(){return++this.current}},l={},c={add:function(e,n){var o=null!=n?n:t.next();return l[o]=e,o},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(t,o){!function(e,n,t){void 0===t&&(t={});var o=s&&s[i],r=d&&d[i];a&&a[i]?a[i](e,n,JSON.stringify(t)):o?s[i].postMessage({reqId:e,method:n,data:t}):r?d[i](e,n,t):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(c.add({resolve:t,reject:o},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 o=s&&s[r],i=d&&d[r];a&&a[r]?a[r](e,n,JSON.stringify(t)):o?s[r].postMessage({reqId:e,method:n,data:t}):i?d[r](e,n,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},u),g=o(function(e){var n=s&&s.getGeo;a&&a.getGeo?a.getGeo(e):n?s.getGeo.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getGeo-isWeb")},u),w=o(function(e){var n=s&&s.getQr;a&&a.getQr?a.getQr(e):n?s.getQr.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getQr-isWeb")},u),v=o(function(e){var n=s&&s.getSMSCode;a&&a.getSMSCode?a.getSMSCode(e):n?s.getSMSCode.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--getSMSCode-isWeb")},u),b=o(function(e){var n=s&&s.selectContact;a&&a.selectContact?a.selectContact(e):n?s.selectContact.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--selectContact-isWeb")},u),S=o(function(e){var n=s&&s.openSettings;a&&a.openSettings?a.openSettings(e):n?s.openSettings.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--openSettings-isWeb")},u),y=o(function(e){var n=s&&s.closeApplication;a&&a.closeApplication?a.closeApplication(e):n?s.closeApplication.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--closeApplication-isWeb")},u),h=o(function(e,n){var t=s&&s.share;a&&a.share?a.share(e,n):t?s.share.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--share-isWeb")},u),M=o(function(e,n){var t=s&&s.setTitle;a&&a.setTitle?a.setTitle(e,n):t?s.setTitle.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--setTitle-isWeb")},u),I=o(function(e,n){var t=s&&s.copyToClipboard;a&&a.copyToClipboard?a.copyToClipboard(e,n):t?s.copyToClipboard.postMessage({reqId:e,text:n}):"undefined"!=typeof window&&console.log("--copyToClipboard-isWeb")},u),C=o(function(e,n,t){var o=a&&a.shareFile,i=s&&s.shareFile,r="image."+t.split(";")[0].split("/")[1],d=t.substr(t.indexOf(",")+1);o?a.shareFile(e,n,r,d):i?s.shareFile.postMessage({reqId:e,text:n,filename:r,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),m=o(function(e,n,t,o){var i=s&&s.shareFile;a&&a.shareFile?a.shareFile(e,n,t,o):i?s.shareFile.postMessage({reqId:e,text:n,filename:t,base64Data:o}):"undefined"!=typeof window&&console.log("--shareFile-isWeb")},u),H=o(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=s&&s.vibrate;a&&a.vibrate?a.vibrate(e,JSON.stringify(n)):t?s.vibrate.postMessage({reqId:e,pattern:n}):"undefined"!=typeof window&&console.log("--vibrate-isWeb")}},u),q=o(function(e){var n=s&&s.enableScreenCapture;a&&a.enableScreenCapture?a.enableScreenCapture(e):n?s.enableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--enableScreenCapture-isWeb")},u),k=o(function(e){var n=s&&s.disableScreenCapture;a&&a.disableScreenCapture?a.disableScreenCapture(e):n?s.disableScreenCapture.postMessage({reqId:e}):"undefined"!=typeof window&&console.log("--disableScreenCapture-isWeb")},u),W=o(function(e){var n=s&&s.setHeaderMenuItems;a&&a.setHeaderMenuItems?a.setHeaderMenuItems(e):n?s.setHeaderMenuItems.postMessage({items:e}):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isWeb")},u);return{version:String("0.2.15"),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:S,closeApplication:y,setTitle:M,share:h,shareImage:C,shareFile:m,setShakeHandler:function(e){a&&a.setShakeHandler||s&&s.setShakeHandler?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isWeb")},setTabActiveHandler:function(e){a&&a.setTabActiveHandler||s&&s.setTabActiveHandler?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isWeb")},vibrate:H,isSupported:function(){var e=s&&window.webkit.messageHandlers.invoke;return Boolean(a||e||d)},supports:function(e){return a&&"function"==typeof a[e]||s&&s[e]&&"function"==typeof s[e].postMessage||d&&"function"==typeof d[e]},sub:u,enableScreenCapture:q,disableScreenCapture:k,setHeaderMenuItems:W,setHeaderMenuItemClickHandler:function(e){a&&a.setHeaderMenuItemClickHandler||s&&s.setHeaderMenuItemClickHandler?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isWeb")}}}();e.default=c});
|
|
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 = (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,KAAK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B+B,qBAAsB9B,GAIX+B"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/index.ts","../src/promisifyMethod.ts","../src/promisifyInvoke.ts","../src/promisifyStorage.ts","../src/version.ts"],"sourcesContent":["import { LIB_VERSION } from './version';\n\nimport 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\ntype HeaderMenuItemClickHandlerType = (id: string) => 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\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\"\n}\n\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\ninterface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\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 setHeaderMenuItems = (items: Array<HeaderMenuItem>) => {\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](items);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ items });\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isWeb');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isWeb');\n }\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 const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler\n }\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 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","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 ","export const LIB_VERSION = \"0.2.15\";\n"],"names":["EInvokeRequest","HeaderMenuIcon","promisifyMethod","method","subscribe","counter","promiseControllers","requestResolver","current","next","this","add","controller","customId","methodId","resolve","reqId","data","isSuccess","error","requestPromise","reject","event","detail","Promise","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","setHeaderMenuItemsPromise","items","version","String","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","setHeaderMenuItems","setHeaderMenuItemClickHandler","onAituBridgeHeaderMenuItemClick","buildBridge"],"mappings":"8LAMKA,EA+DOC,EC3BZ,SAASC,EAAgBC,EAAQC,GAC/B,IA5BMC,EACAC,EA2BAC,GA5BAF,E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AGrBF,OAAeuG,sBAAwBH,EACb,oBAAXpG,QAChBkC,QAAQC,IAAI,gCAyGdqE,QAASvC,EACTwC,YAhFkB,WAClB,IAAMC,EAASxG,GAAQF,OAAeG,OAAOC,gBAAgBgC,OAC7D,OAAOuE,QAAQ5G,GAAW2G,GAAUrG,IA+EpCuG,SA5Ee,SAACrI,UACfwB,GAAsC,mBAApBA,EAAQxB,IAC1B2B,GAAOA,EAAI3B,IAA8C,mBAA5B2B,EAAI3B,GAAQoC,aACzCN,GAA8B,mBAAhBA,EAAI9B,IA0EnBmD,IAAAA,EACAmF,oBAAqBlC,EACrBmC,qBAAsBlC,EACtBmC,mBAAoBlC,EACpBmC,8BA3DoC,SAACZ,GACnBrG,GAAWA,EAAO,+BACtBG,GAAOA,EAAG,8BAGrBF,OAAeiH,gCAAkCb,EACvB,oBAAXpG,QAChBkC,QAAQC,IAAI,2CAwDH+E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIB_VERSION = "0.2.15";
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btsd/aitu-bridge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.module.js",
|
|
8
8
|
"unpkg": "dist/index.umd.js",
|
|
9
9
|
"scripts": {
|
|
10
|
+
"prebuild": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
|
|
10
11
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
12
|
"build": "microbundle",
|
|
12
13
|
"dev": "microbundle watch"
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIB_VERSION } from './version';
|
|
2
|
+
|
|
1
3
|
import promisifyInvoke from './promisifyInvoke';
|
|
2
4
|
import promisifyStorage from './promisifyStorage';
|
|
3
5
|
import promisifyMethod from './promisifyMethod';
|
|
@@ -15,6 +17,8 @@ type SetItemType = (keyName: string, keyValue: string) => Promise<void>;
|
|
|
15
17
|
type GetItemType = (keyName: string) => Promise<string | null>;
|
|
16
18
|
type ClearType = () => Promise<void>;
|
|
17
19
|
|
|
20
|
+
type HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;
|
|
21
|
+
|
|
18
22
|
interface GetPhoneResponse {
|
|
19
23
|
phone: string;
|
|
20
24
|
sign: string;
|
|
@@ -63,6 +67,25 @@ interface GetUserProfileResponse {
|
|
|
63
67
|
avatarThumb?: string;
|
|
64
68
|
}
|
|
65
69
|
|
|
70
|
+
export enum HeaderMenuIcon {
|
|
71
|
+
Search = "Search",
|
|
72
|
+
ShoppingCart = "ShoppingCart",
|
|
73
|
+
Menu = "Menu",
|
|
74
|
+
Share = "Share",
|
|
75
|
+
Notifications = "Notifications",
|
|
76
|
+
Help = "Help",
|
|
77
|
+
Error = "Error",
|
|
78
|
+
Person = "Person",
|
|
79
|
+
Sort = "Sort",
|
|
80
|
+
Filter = "Filter"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface HeaderMenuItem {
|
|
84
|
+
id: string;
|
|
85
|
+
icon: HeaderMenuIcon;
|
|
86
|
+
badge?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
66
89
|
type OpenSettingsResponse = 'success' | 'failed';
|
|
67
90
|
type ShareResponse = 'success' | 'failed';
|
|
68
91
|
type CopyToClipboardResponse = 'success' | 'failed';
|
|
@@ -79,6 +102,7 @@ interface BridgeStorage {
|
|
|
79
102
|
}
|
|
80
103
|
|
|
81
104
|
interface AituBridge {
|
|
105
|
+
version: string;
|
|
82
106
|
invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;
|
|
83
107
|
storage: BridgeStorage;
|
|
84
108
|
getMe: () => Promise<GetMeResponse>;
|
|
@@ -106,6 +130,8 @@ interface AituBridge {
|
|
|
106
130
|
sub: any;
|
|
107
131
|
enableScreenCapture: () => Promise<{}>;
|
|
108
132
|
disableScreenCapture: () => Promise<{}>;
|
|
133
|
+
setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;
|
|
134
|
+
setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;
|
|
109
135
|
}
|
|
110
136
|
|
|
111
137
|
const invokeMethod = 'invoke';
|
|
@@ -126,6 +152,8 @@ const vibrateMethod = 'vibrate';
|
|
|
126
152
|
const enableScreenCaptureMethod = 'enableScreenCapture';
|
|
127
153
|
const disableScreenCaptureMethod = 'disableScreenCapture';
|
|
128
154
|
const setTabActiveHandlerMethod = 'setTabActiveHandler';
|
|
155
|
+
const setHeaderMenuItemsMethod = 'setHeaderMenuItems';
|
|
156
|
+
const setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';
|
|
129
157
|
|
|
130
158
|
const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
|
|
131
159
|
const ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;
|
|
@@ -447,6 +475,30 @@ const buildBridge = (): AituBridge => {
|
|
|
447
475
|
subs.push(listener);
|
|
448
476
|
}
|
|
449
477
|
|
|
478
|
+
const setHeaderMenuItems = (items: Array<HeaderMenuItem>) => {
|
|
479
|
+
const isAndroid = android && android[setHeaderMenuItemsMethod];
|
|
480
|
+
const isIos = ios && ios[setHeaderMenuItemsMethod];
|
|
481
|
+
|
|
482
|
+
if (isAndroid) {
|
|
483
|
+
android[setHeaderMenuItemsMethod](items);
|
|
484
|
+
} else if (isIos) {
|
|
485
|
+
ios[setHeaderMenuItemsMethod].postMessage({ items });
|
|
486
|
+
} else if (typeof window !== 'undefined') {
|
|
487
|
+
console.log('--setHeaderMenuItems-isWeb');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {
|
|
492
|
+
const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];
|
|
493
|
+
const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];
|
|
494
|
+
|
|
495
|
+
if (isAndroid || isIos) {
|
|
496
|
+
(window as any).onAituBridgeHeaderMenuItemClick = handler;
|
|
497
|
+
} else if (typeof window !== 'undefined') {
|
|
498
|
+
console.log('--setHeaderMenuItemClickHandler-isWeb');
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
450
502
|
const invokePromise = promisifyInvoke(invoke, sub);
|
|
451
503
|
const storagePromise = promisifyStorage(storage, sub);
|
|
452
504
|
const getGeoPromise = promisifyMethod(getGeo, sub);
|
|
@@ -463,8 +515,10 @@ const buildBridge = (): AituBridge => {
|
|
|
463
515
|
const vibratePromise = promisifyMethod(vibrate, sub);
|
|
464
516
|
const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, sub);
|
|
465
517
|
const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, sub);
|
|
518
|
+
const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, sub);
|
|
466
519
|
|
|
467
520
|
return {
|
|
521
|
+
version: String(LIB_VERSION),
|
|
468
522
|
copyToClipboard: copyToClipboardPromise,
|
|
469
523
|
invoke: invokePromise,
|
|
470
524
|
storage: storagePromise,
|
|
@@ -491,7 +545,9 @@ const buildBridge = (): AituBridge => {
|
|
|
491
545
|
supports,
|
|
492
546
|
sub,
|
|
493
547
|
enableScreenCapture: enableScreenCapturePromise,
|
|
494
|
-
disableScreenCapture: disableScreenCapturePromise
|
|
548
|
+
disableScreenCapture: disableScreenCapturePromise,
|
|
549
|
+
setHeaderMenuItems: setHeaderMenuItemsPromise,
|
|
550
|
+
setHeaderMenuItemClickHandler
|
|
495
551
|
}
|
|
496
552
|
}
|
|
497
553
|
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LIB_VERSION = "0.2.15";
|