@btsd/aitu-bridge 0.8.0-canary.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/createActionFactories.d.ts +26 -0
- package/dist/handlers/android.d.ts +3 -0
- package/dist/handlers/awaitResponse.d.ts +5 -0
- package/dist/handlers/callbacks.d.ts +4 -0
- package/dist/handlers/ios.d.ts +3 -0
- package/dist/handlers/null.d.ts +3 -0
- package/dist/handlers/web.d.ts +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/lib/createIdGenerator.d.ts +2 -0
- package/dist/types.d.ts +73 -14
- package/package.json +2 -1
- package/dist/lib/createCounter.d.ts +0 -4
- package/dist/utils.d.ts +0 -9
- package/dist/waitResponse.d.ts +0 -3
- package/dist/webBridge.d.ts +0 -7
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Action, ActionHandler, AsyncAction } from './types';
|
|
2
|
+
type Options<T extends Action> = {
|
|
3
|
+
validate?: (...payload: T['payload']) => string | true;
|
|
4
|
+
generateId?: (...payload: T['payload']) => string;
|
|
5
|
+
};
|
|
6
|
+
type SelectSyncAction<T> = T extends {
|
|
7
|
+
__result: any;
|
|
8
|
+
} ? never : T;
|
|
9
|
+
type SelectAsyncAction<T> = T extends {
|
|
10
|
+
__result: any;
|
|
11
|
+
} ? T : never;
|
|
12
|
+
export declare const createActionFactories: <T extends import("./types").Action | AsyncAction>(env: {
|
|
13
|
+
handler: ActionHandler<T>;
|
|
14
|
+
generateId: (type: string) => string;
|
|
15
|
+
}) => {
|
|
16
|
+
createHandlerAction: <Type extends SelectSyncAction<T>["type"], Action extends SelectSyncAction<T> = Extract<SelectSyncAction<T>, {
|
|
17
|
+
type: Type;
|
|
18
|
+
}>>(type: Type, options?: Options<Action>) => <Payload extends Action["payload"]>(...payload: Payload) => void;
|
|
19
|
+
createAction: <Type extends SelectAsyncAction<T>["type"], A extends AsyncAction = Extract<SelectAsyncAction<T>, {
|
|
20
|
+
type: Type;
|
|
21
|
+
}>>(type: Type, options?: Options<A>) => <Payload extends A["payload"], Result = Extract<A, {
|
|
22
|
+
payload: Payload;
|
|
23
|
+
}>["__result"]>(...payload: Payload) => Promise<Result>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=createActionFactories.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
export * from './error';
|
|
8
|
-
export type { BackArrowClickHandlerType, HeaderMenuItemClickHandlerType, NFCPassportError, PermissionDeniedError, AppUrlDoesntMatchError, AituEventHandler,
|
|
8
|
+
export type { BackArrowClickHandlerType, HeaderMenuItemClickHandlerType, NFCPassportError, PermissionDeniedError, AppUrlDoesntMatchError, AituEventHandler, GetPhoneResponse, GetMeResponse, ResponseObject, GetGeoResponse, GetContactsResponse, SelectContactResponse, GetUserProfileResponse, HeaderMenuItem, UserStepsPerDay, UserStepInfoResponse, SuccessResponse, BiometryResponse, PassportDataResponse, BridgeInvoke, BridgeStorage, AituBridge, } from './types';
|
|
9
|
+
export { HeaderMenuIcon, NavigationItemMode, EInvokeRequest } from './types';
|
|
9
10
|
/**
|
|
10
11
|
* @public
|
|
11
12
|
* AituBridge instance for interacting with the Aitu mini-app environment.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,n,o,t;function r(){return r=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var t in o)({}).hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},r.apply(null,arguments)}function i(e){void 0===e&&(e="m:");var n=0;return{next:function(){return e+ ++n}}}function s(e){var n=i(e),o={};return{add:function(e,t){void 0===t&&(t="");var r=t+n.next();return o[r]=e,r},resolve:function(e,n,t,r){var i=o[e];i&&(t(r)?i.resolve(n):i.reject(r),o[e]=null)}}}function a(e,n){e(function(e){if(e.detail&&"reqId"in e.detail){var o=e.detail,t=o.reqId;t&&n.resolve(t,o.data,function(e){return!e},o.error)}})}function d(e,n,o){var t=s(n+":");return a(o,t),function(){var n=arguments;return new Promise(function(o,r){var i=t.add({resolve:o,reject:r});e.apply(void 0,[i].concat([].slice.call(n)))})}}exports.BridgeErrors=void 0,(e=exports.BridgeErrors||(exports.BridgeErrors={}))[e.PermissionDenyError=0]="PermissionDenyError",e[e.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",e[e.OtherError=2]="OtherError",function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(n||(n={})),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",e.Close="Close",e.SystemNotifications="SystemNotifications"}(o||(o={})),function(e){e.SystemBackArrow="SystemBackArrow",e.CustomBackArrow="CustomBackArrow",e.NoItem="NoItem",e.UserProfile="UserProfile"}(t||(t={}));var c=function(){var e,o,t="invoke",c="storage",u="getGeo",l="getQr",f="getSMSCode",g="selectContact",w="share",p="setTitle",v="copyToClipboard",m="shareFile",k="setShakeHandler",y="vibrate",b="enableScreenCapture",M="disableScreenCapture",I="setTabActiveHandler",S="setHeaderMenuItems",C="setHeaderMenuItemClickHandler",h="setCustomBackArrowMode",U="getCustomBackArrowMode",x="setCustomBackArrowVisible",B="openPayment",P="setCustomBackArrowOnClickHandler",A="checkBiometry",E="openExternalUrl",N="setNavigationItemMode",q="getNavigationItemMode",H="getUserStepInfo",O="undefined"!=typeof window,T=O&&window.AndroidBridge,D=O&&window.webkit&&window.webkit.messageHandlers,j=O&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()&&((o=new URLSearchParams(window.location.search).get("__aitu-domain"))?localStorage.setItem("mini-app-domain",o):o=localStorage.getItem("mini-app-domain"),o?(e={origin:o,execute:function(e,n){var t;null==(t=window)||null==(t=t.top)||t.postMessage({source:"aitu-bridge",method:e,reqId:n,payload:[].concat([].slice.call(arguments,2))},o)}},window.addEventListener("message",function(e){if(e.origin===o&&e.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data})),"string"!=typeof e.data||""===e.data)return;try{var n=JSON.parse(e.data);n&&n.method&&("setCustomBackArrowOnClickHandler"===n.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===n.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(n.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),e):null),F=[];O&&window.addEventListener("aituEvents",function(e){[].concat(F).map(function(n){return n.call(null,e)})});var G,J=function(e){F.push(e)},L=function(e,n){var o=i(e+":");return function(){var t=[].slice.call(arguments),i=o.next(),s=!!D&&!!D[e],a=!!j;return T&&T[e]?T[e].apply(T,[i].concat(t)):s?D[e].postMessage(r({reqId:i},null==n||null==n.transformToObject?void 0:n.transformToObject(t))):a?j.execute.apply(j,[e,i].concat(t)):"undefined"!=typeof window&&console.log("--"+e+"-isUnknown"),function(e){return new Promise(function(n,o){var t=function(r){var i;if((null==(i=r.detail)?void 0:i.reqId)===e){var s=r.detail,a=s.data,d=s.error;a?n(a):o(d),window.removeEventListener("aituEvents",t)}};window.addEventListener("aituEvents",t)})}(i)}},V=(a(J,G=s("invoke:")),function(e,n){return void 0===n&&(n={}),new Promise(function(o,r){!function(e,n,o){void 0===o&&(o={});var r=D&&D[t];T&&T[t]?T[t](e,n,JSON.stringify(o)):r?D[t].postMessage({reqId:e,method:n,data:o}):j?j.execute(t,e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(G.add({resolve:o,reject:r},e+":"),e,n)})}),Q=function(e,n){var o=s("storage:");return a(n,o),{setItem:function(n,t){return new Promise(function(r,i){var s=o.add({resolve:r,reject:i});e(s,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,r){var i=o.add({resolve:t,reject:r});e(i,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var r=o.add({resolve:n,reject:t});e(r,"clear",{})})}}}(function(e,n,o){void 0===o&&(o={});var t=D&&D[c];T&&T[c]?T[c](e,n,JSON.stringify(o)):t?D[c].postMessage({reqId:e,method:n,data:o}):j?j.execute(c,e,n,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},J),W=d(function(e){var n=D&&D[u];T&&T[u]?T[u](e):n?D[u].postMessage({reqId:e}):j?j.execute(u,e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},u,J),_=d(function(e){var n=D&&D[l];T&&T[l]?T[l](e):n?D[l].postMessage({reqId:e}):j?j.execute(l,e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},l,J),R=d(function(e){var n=D&&D[f];T&&T[f]?T[f](e):n?D[f].postMessage({reqId:e}):j?j.execute(f,e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},f,J),z=d(function(e){var n=D&&D[g];T&&T[g]?T[g](e):n?D[g].postMessage({reqId:e}):j?j.execute(g,e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},g,J),K=d(function(e,n){var o=D&&D[w];T&&T[w]?T[w](e,n):o?D[w].postMessage({reqId:e,text:n}):j?j.execute(w,e,n):"undefined"!=typeof window&&console.log("--share-isUnknown")},w,J),X=d(function(e,n){var o=D&&D[p];T&&T[p]?T[p](e,n):o?D[p].postMessage({reqId:e,text:n}):j?j.execute(p,e,n):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},p,J),Y=d(function(e,n){var o=D&&D[v];T&&T[v]?T[v](e,n):o?D[v].postMessage({reqId:e,text:n}):j?j.execute(v,e,n):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},v,J),Z=d(function(e,n,o){var t,r,i=T&&T[m],s=D&&D[m],a="image."+(null!=(t=null==(r=o.split(";"))||null==(r=r[0])?void 0:r.split("/")[1])?t:""),d=o.substr(o.indexOf(",")+1);i?T[m](e,n,a,d):s?D[m].postMessage({reqId:e,text:n,filename:a,base64Data:d}):j?j.execute(m,e,{text:n,filename:a,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",J),$=d(function(e,n,o,t){var r=D&&D[m];T&&T[m]?T[m](e,n,o,t):r?D[m].postMessage({reqId:e,text:n,filename:o,base64Data:t}):j?j.execute(m,e,n,o,t):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},m,J),ee=d(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 o=D&&D[y];T&&T[y]?T[y](e,JSON.stringify(n)):o?D[y].postMessage({reqId:e,pattern:n}):j?j.execute(y,e,n):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")}},y,J),ne=d(function(e){var n=D&&D[b];T&&T[b]?T[b](e):n?D[b].postMessage({reqId:e}):j?j.execute(b,e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},b,J),oe=d(function(e){var n=D&&D[M];T&&T[M]?T[M](e):n?D[M].postMessage({reqId:e}):j?j.execute(M,e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},M,J),te=d(function(e,n){if(n.length>3)console.error("SetHeaderMenuItems: items count should not be more than 3");else{var o=T&&T[S],t=D&&D[S],r=JSON.stringify(n);o?T[S](e,r):t?D[S].postMessage({reqId:e,itemsJsonArray:r}):j?j.execute(S,e,r):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")}},S,J),re=d(function(e,n){var o=D&&D[h];T&&T[h]?T[h](e,n):o?D[h].postMessage({reqId:e,enabled:n}):j?j.execute(h,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},h,J),ie=d(function(e){var n=D&&D[U];T&&T[U]?T[U](e):n?D[U].postMessage({reqId:e}):j?j.execute(U,e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},U,J),se=d(function(e,n){var o=D&&D[x];T&&T[x]?T[x](e,n):o?D[x].postMessage({reqId:e,visible:n}):j?j.execute(x,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},x,J),ae=d(function(e,n){var o=D&&D[B];T&&T[B]?T[B](e,n):o?D[B].postMessage({reqId:e,transactionId:n}):console.log("--openPayment-isUnknown")},B,J),de=d(function(e){var n=D&&D[A];T&&T[A]?T[A](e):n?D[A].postMessage({reqId:e}):j?j.execute(A,e):"undefined"!=typeof window&&console.log("--checkBiometry-isUnknown")},A,J),ce=d(function(e,n){var o=D&&D[E];T&&T[E]?T[E](e,n):o?D[E].postMessage({reqId:e,url:n}):console.log("--openExternalUrlMethod-isUnknown")},E,J),ue=d(function(e,n){var o=D&&D[N];T&&T[N]?T[N](e,n):o?D[N].postMessage({reqId:e,mode:n}):j?j.execute(N,e,n):"undefined"!=typeof window&&console.log("--setNavigationItemMode-isUnknown")},N,J),le=d(function(e){var n=D&&D[q];T&&T[q]?T[q](e):n?D[q].postMessage({reqId:e}):j?j.execute(q,e):"undefined"!=typeof window&&console.log("--getNavigationItemMode-isUnknown")},q,J),fe=d(function(e){var n=D&&D[H];T&&T[H]?T[H](e):n?D[H].postMessage({reqId:e}):j?console.log("--getUserStepInfo-isWeb"):"undefined"!=typeof window&&console.log("--getUserStepInfo-isUnknown")},H,J),ge=L("isESimSupported"),we=L("activateESim",{transformToObject:function(e){return{activationCode:e[0]}}}),pe=L("readNFCData"),ve=L("readNFCPassport",{transformToObject:function(e){return{passportNumber:e[0],dateOfBirth:e[1],expirationDate:e[2]}}}),me=L("subscribeUserStepInfo"),ke=L("unsubscribeUserStepInfo"),ye=L("openUserProfile"),be=L("openSettings"),Me=L("closeApplication"),Ie=L("enableSwipeBack"),Se=L("disableSwipeBack");return{version:"0.8.0-canary.4",copyToClipboard:Y,invoke:V,storage:Q,getMe:function(){return V(n.getMe)},getPhone:function(){return V(n.getPhone)},getContacts:function(){return V(n.getContacts)},getGeo:W,getQr:_,getSMSCode:R,getUserProfile:function(e){return V(n.getUserProfile,{id:e})},openUserProfile:ye,selectContact:z,enableNotifications:function(){return V(n.enableNotifications)},disableNotifications:function(){return V(n.disableNotifications)},enablePrivateMessaging:function(e){return V(n.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return V(n.disablePrivateMessaging,{appId:e})},openSettings:be,closeApplication:Me,setTitle:X,share:K,shareImage:Z,shareFile:$,setShakeHandler:function(e){T&&T[k]||D&&D[k]||j?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:function(e){T&&T[I]||D&&D[I]||j?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:ee,isSupported:function(){var e,n=D&&(null==(e=window.webkit)||null==(e=e.messageHandlers)?void 0:e.invoke);return Boolean(T||n||j)},supports:function(e){return!!T&&"function"==typeof T[e]||!!D&&!!D[e]&&"function"==typeof D[e].postMessage||!!j&&"function"==typeof j[e]},sub:J,enableScreenCapture:ne,disableScreenCapture:oe,setHeaderMenuItems:te,setHeaderMenuItemClickHandler:function(e){T&&T[C]||D&&D[C]||j?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:re,getCustomBackArrowMode:ie,setCustomBackArrowVisible:se,openPayment:ae,setCustomBackArrowOnClickHandler:function(e){T&&T[P]||D&&D[P]||j?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")},checkBiometry:de,openExternalUrl:ce,enableSwipeBack:Ie,disableSwipeBack:Se,setNavigationItemMode:ue,getNavigationItemMode:le,getUserStepInfo:fe,isESimSupported:ge,activateESim:we,readNFCData:pe,subscribeUserStepInfo:me,unsubscribeUserStepInfo:ke,readNFCPassport:ve}}();exports.classifyBridgeError=function(e){if(e.msg){if(e.msg.startsWith("permission deny"))return exports.BridgeErrors.PermissionDenyError;if(e.msg.startsWith("permission security deny"))return exports.BridgeErrors.PermissionSecurityDenyError}return exports.BridgeErrors.OtherError},exports.default=c;
|
|
1
|
+
var e,t,r,n;function o(){return"undefined"!=typeof window}exports.BridgeErrors=void 0,(e=exports.BridgeErrors||(exports.BridgeErrors={}))[e.PermissionDenyError=0]="PermissionDenyError",e[e.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",e[e.OtherError=2]="OtherError",exports.EInvokeRequest=void 0,(t=exports.EInvokeRequest||(exports.EInvokeRequest={})).getMe="GetMe",t.getPhone="GetPhone",t.getContacts="GetContacts",t.getUserProfile="GetUserProfile",t.enableNotifications="AllowNotifications",t.disableNotifications="DisableNotifications",t.enablePrivateMessaging="EnablePrivateMessaging",t.disablePrivateMessaging="DisablePrivateMessaging",exports.HeaderMenuIcon=void 0,(r=exports.HeaderMenuIcon||(exports.HeaderMenuIcon={})).Search="Search",r.ShoppingCart="ShoppingCart",r.Menu="Menu",r.Share="Share",r.Notifications="Notifications",r.Help="Help",r.Error="Error",r.Person="Person",r.Sort="Sort",r.Filter="Filter",r.Close="Close",r.SystemNotifications="SystemNotifications",exports.NavigationItemMode=void 0,(n=exports.NavigationItemMode||(exports.NavigationItemMode={})).SystemBackArrow="SystemBackArrow",n.CustomBackArrow="CustomBackArrow",n.NoItem="NoItem",n.UserProfile="UserProfile";var i={supports:function(){return!1},handleAction:function(e){console.log("--"+e.type+"-isUnknown")}};function a(e){return["setHeaderMenuItemClickHandler","setCustomBackArrowOnClickHandler","setTabActiveHandler","setShakeHandler"].includes(e.type)}var s=function(e){switch(e.type){case"setShakeHandler":window.onAituBridgeShake=e.payload[0];break;case"setCustomBackArrowOnClickHandler":window.onAituBridgeBackArrowClick=e.payload[0];break;case"setHeaderMenuItemClickHandler":window.onAituBridgeHeaderMenuItemClick=e.payload[0];break;case"setTabActiveHandler":window.onAituBridgeTabActive=e.payload[0]}};function u(e){return{type:"awaitResponse",actionId:e}}var d={isSupported:function(){return o()&&!!window.AndroidBridge},makeActionHandler:function(){return{supports:function(e){var t;return"function"==typeof(null==(t=window)||null==(t=t.AndroidBridge)?void 0:t[e])},handleAction:function(e){var t,r=null==(t=window)?void 0:t.AndroidBridge;return r[e.type]?a(e)?s(e):(r[e.type].apply(r,[e.id].concat(function(e){if("storage"===e.type||"invoke"===e.type){var t=e.payload,r=t[1];return[t[0],JSON.stringify(void 0===r?{}:r)]}return"setHeaderMenuItems"===e.type||"vibrate"===e.type?[JSON.stringify(e.payload[0])]:Array.isArray(e.payload)?e.payload:[]}(e))),u(e.id)):i.handleAction(e)}}}};function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(null,arguments)}var l={isSupported:function(){return o()&&!!window.webkit&&!!window.webkit.messageHandlers},makeActionHandler:function(){return{supports:function(e){var t;return"function"==typeof(null==(t=window.webkit)||null==(t=t.messageHandlers)||null==(t=t[e])?void 0:t.postMessage)},handleAction:function(e){var t,r=null==(t=window)||null==(t=t.webkit)?void 0:t.messageHandlers;return r[e.type]?a(e)?s(e):(r[e.type].postMessage(c({reqId:e.id},function(e){var t=e.payload;switch(e.type){case"storage":case"invoke":var r=t[1];return{method:t[0],data:void 0===r?{}:r};case"activateESim":return{activationCode:t[0]};case"readNFCPassport":return{passportNumber:t[0],dateOfBirth:t[1],expirationDate:t[2]};case"setCustomBackArrowMode":return{enabled:t[0]};case"setCustomBackArrowVisible":return{visible:t[0]};case"setNavigationItemMode":return{mode:t[0]};case"share":case"setTitle":case"copyToClipboard":return{text:t[0]};case"shareFile":return{text:t[0],filename:t[1],base64Data:t[2]};case"openExternalUrl":return{url:t[0]};case"openPayment":return{transactionId:t[0]};case"setHeaderMenuItems":return{itemsJsonArray:JSON.stringify(t[0])};case"vibrate":return{pattern:t[0]};default:return{}}}(e))),u(e.id)):i.handleAction(e)}}}},p=function(e){if("storage"===e.type||"invoke"===e.type){var t=e.payload,r=t[1];return[t[0],void 0===r?{}:r]}return"setHeaderMenuItems"===e.type?[JSON.stringify(e.payload[0])]:e.payload},f={isSupported:function(){return o()&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()},makeActionHandler:function(){var e=new URLSearchParams(window.location.search).get("__aitu-domain");return e?localStorage.setItem("mini-app-domain",e):e=localStorage.getItem("mini-app-domain"),e?(window.addEventListener("message",function(t){if(t.origin===e&&t.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:t.data})),"string"!=typeof t.data||""===t.data)return;try{var r=JSON.parse(t.data);r&&r.method&&("setCustomBackArrowOnClickHandler"===r.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===r.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(r.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),{supports:function(){return!1},handleAction:function(t){var r;return a(t)?s(t):"getUserStepInfo"===t.type||"openExternalUrl"===t.type||"openPayment"===t.type?i.handleAction(t):(null==(r=window)||null==(r=r.top)||r.postMessage({source:"aitu-bridge",method:t.type,reqId:t.id,payload:[].concat(p(t))},e),u(t.id))}}):i}},g=function(){var e,t,r,n,a=[d,l,f].find(function(e){return e.isSupported()}),s=null!=(e=null==a?void 0:a.makeActionHandler())?e:i,u=(t={},function(e){var r,n=(null!=(r=t[e])?r:0)+1;return t[e]=n,e+":"+n}),c=(r={handler:s,generateId:u},n=function(e,t,n){var o,i,a=null!=(o=null==n?void 0:n.generateId)?o:function(){return r.generateId(e)},s=null!=(i=null==n?void 0:n.validate)?i:function(){return!0},u=a.apply(void 0,t),d=s.apply(void 0,t);if("string"!=typeof d)return r.handler.handleAction({type:e,payload:t,id:u});console.error(d)},{createHandlerAction:function(e,t){return function(){n(e,[].slice.call(arguments),t)}},createAction:function(e,t){return function(){var r,o=n(e,[].slice.call(arguments),t);return"awaitResponse"===(null==o?void 0:o.type)?(r=o.actionId,new Promise(function(e,t){var n=function(o){var i;if((null==(i=o.detail)?void 0:i.reqId)===r){var a=o.detail,s=a.data,u=a.error;u?t(u):e(s),window.removeEventListener("aituEvents",n)}};window.addEventListener("aituEvents",n)})):new Promise(function(){})}}}),p=c.createAction,g=c.createHandlerAction,v=[];o()&&window.addEventListener("aituEvents",function(e){[].concat(v).map(function(t){return t.call(null,e)})});var m=s.supports,w=p("isESimSupported"),y=p("activateESim"),k=p("readNFCData"),b=p("readNFCPassport"),I=p("subscribeUserStepInfo"),h=p("unsubscribeUserStepInfo"),S=p("openUserProfile"),A=p("openSettings"),C=p("closeApplication"),E=p("enableSwipeBack"),M=p("disableSwipeBack"),H=p("storage"),B=g("setShakeHandler"),P=g("setTabActiveHandler"),N=g("setHeaderMenuItemClickHandler"),x=g("setCustomBackArrowOnClickHandler"),U=p("enableScreenCapture"),O=p("disableScreenCapture"),q=p("invoke",{generateId:function(e){return u(e+":invoke")}}),R=p("setCustomBackArrowMode"),D=p("getCustomBackArrowMode"),T=p("setCustomBackArrowVisible"),F=p("getNavigationItemMode"),G=p("setNavigationItemMode"),J=p("share"),L=p("shareFile"),V=p("getGeo"),j=p("getQr"),Q=p("getSMSCode"),W=p("selectContact"),_=p("setTitle"),z=p("copyToClipboard"),K=p("checkBiometry"),X=p("getUserStepInfo"),Y=p("openExternalUrl"),Z=p("openPayment"),$=p("setHeaderMenuItems",{validate:function(e){return!(e.length>3)||"SetHeaderMenuItems: items count should not be more than 3"}}),ee=p("vibrate",{validate:function(e){return!(!Array.isArray(e)||e.some(function(e){return e<1||e!==Math.floor(e)})||e.reduce(function(e,t){return e+t})>1e4)||"Pattern should be an array of positive integers no longer than 10000ms total"}});return{version:"0.8.0",copyToClipboard:z,invoke:q,storage:{getItem:function(e){return H("getItem",{keyName:e})},setItem:function(e,t){return H("setItem",{keyName:e,keyValue:t})},clear:function(){return H("clear")}},getMe:function(){return q(exports.EInvokeRequest.getMe)},getPhone:function(){return q(exports.EInvokeRequest.getPhone)},getContacts:function(){return q(exports.EInvokeRequest.getContacts)},getGeo:V,getQr:j,getUserProfile:function(e){return q(exports.EInvokeRequest.getUserProfile,{id:e})},getSMSCode:Q,openUserProfile:S,selectContact:W,enableNotifications:function(){return q(exports.EInvokeRequest.enableNotifications)},disableNotifications:function(){return q(exports.EInvokeRequest.disableNotifications)},enablePrivateMessaging:function(e){return q(exports.EInvokeRequest.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return q(exports.EInvokeRequest.disablePrivateMessaging,{appId:e})},openSettings:A,closeApplication:C,setTitle:_,share:J,shareImage:function(e,t){var r,n,o="image."+(null!=(r=null==(n=t.split(";"))||null==(n=n[0])?void 0:n.split("/")[1])?r:""),i=t.substr(t.indexOf(",")+1);return L(e,o,i)},shareFile:L,setShakeHandler:B,setTabActiveHandler:P,vibrate:ee,isSupported:function(){return s!==i},supports:m,sub:function(e){v.push(e)},enableScreenCapture:U,disableScreenCapture:O,setHeaderMenuItems:$,setHeaderMenuItemClickHandler:N,setCustomBackArrowMode:R,getCustomBackArrowMode:D,setCustomBackArrowVisible:T,openPayment:Z,setCustomBackArrowOnClickHandler:x,checkBiometry:K,openExternalUrl:Y,enableSwipeBack:E,disableSwipeBack:M,setNavigationItemMode:G,getNavigationItemMode:F,getUserStepInfo:X,isESimSupported:w,activateESim:y,readNFCData:k,subscribeUserStepInfo:I,unsubscribeUserStepInfo:h,readNFCPassport:b}}();exports.classifyBridgeError=function(e){if(e.msg){if(e.msg.startsWith("permission deny"))return exports.BridgeErrors.PermissionDenyError;if(e.msg.startsWith("permission security deny"))return exports.BridgeErrors.PermissionSecurityDenyError}return exports.BridgeErrors.OtherError},exports.default=g;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.modern.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e;!function(e){e[e.PermissionDenyError=0]="PermissionDenyError",e[e.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",e[e.OtherError=2]="OtherError"}(e||(e={}));const n=n=>{if(n.msg){if(n.msg.startsWith("permission deny"))return e.PermissionDenyError;if(n.msg.startsWith("permission security deny"))return e.PermissionSecurityDenyError}return e.OtherError};function o(){return o=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var t in o)({}).hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},o.apply(null,arguments)}function t(e="m:"){let n=0;return{next:()=>e+ ++n}}function s(e){const n=t(e),o={};return{add(e,t=""){const s=t+n.next();return o[s]=e,s},resolve(e,n,t,s){const i=o[e];i&&(t(s)?i.resolve(n):i.reject(s),o[e]=null)}}}function i(e,n){e(e=>{if(e.detail&&"reqId"in e.detail){const{reqId:o,data:t,error:s}=e.detail;o&&n.resolve(o,t,e=>!e,s)}})}function r(e,n,o){const t=s(n+":");return i(o,t),function(...n){return new Promise((o,s)=>{const i=t.add({resolve:o,reject:s});e(i,...n)})}}var a,d,c;!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(a||(a={})),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",e.Close="Close",e.SystemNotifications="SystemNotifications"}(d||(d={})),function(e){e.SystemBackArrow="SystemBackArrow",e.CustomBackArrow="CustomBackArrow",e.NoItem="NoItem",e.UserProfile="UserProfile"}(c||(c={}));const l=(()=>{const e="invoke",n="storage",d="getGeo",c="getQr",l="getSMSCode",u="selectContact",w="share",g="setTitle",p="copyToClipboard",f="shareFile",m="setShakeHandler",k="vibrate",y="enableScreenCapture",b="disableScreenCapture",M="setTabActiveHandler",I="setHeaderMenuItems",v="setHeaderMenuItemClickHandler",S="setCustomBackArrowMode",C="getCustomBackArrowMode",h="setCustomBackArrowVisible",U="openPayment",P="setCustomBackArrowOnClickHandler",A="checkBiometry",x="openExternalUrl",B="setNavigationItemMode",N="getNavigationItemMode",E="getUserStepInfo",q="undefined"!=typeof window,H=q&&window.AndroidBridge,O=q&&window.webkit&&window.webkit.messageHandlers,T=q&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()&&(()=>{let e=new URLSearchParams(window.location.search).get("__aitu-domain"),n=null;return e?localStorage.setItem("mini-app-domain",e):e=localStorage.getItem("mini-app-domain"),e?(n={origin:e,execute:(n,o,...t)=>{var s;null==(s=window)||null==(s=s.top)||s.postMessage({source:"aitu-bridge",method:n,reqId:o,payload:[...t]},e)}},window.addEventListener("message",n=>{if(n.origin===e&&n.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:n.data})),"string"!=typeof n.data||""===n.data)return;try{const e=JSON.parse(n.data);e&&e.method&&("setCustomBackArrowOnClickHandler"===e.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===e.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(e.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),n):null})(),D=[];q&&window.addEventListener("aituEvents",e=>{[...D].map(n=>n.call(null,e))});const j=e=>{D.push(e)},F=(e,n)=>{const s=t(e+":");return(...t)=>{const i=s.next(),r=!!O&&!!O[e],a=!!T;return H&&H[e]?H[e](i,...t):r?O[e].postMessage(o({reqId:i},null==n||null==n.transformToObject?void 0:n.transformToObject(t))):a?T.execute(e,i,...t):"undefined"!=typeof window&&console.log(`--${e}-isUnknown`),(e=>new Promise((n,o)=>{const t=s=>{var i;if((null==(i=s.detail)?void 0:i.reqId)!==e)return;const{data:r,error:a}=s.detail;r?n(r):o(a),window.removeEventListener("aituEvents",t)};window.addEventListener("aituEvents",t)}))(i)}},G=function(n,o){const t=s("invoke:");return i(o,t),function(n,o={}){return new Promise((s,i)=>{((n,o,t={})=>{const s=O&&O[e];H&&H[e]?H[e](n,o,JSON.stringify(t)):s?O[e].postMessage({reqId:n,method:o,data:t}):T?T.execute(e,n,o,t):"undefined"!=typeof window&&console.log("--invoke-isUnknown")})(t.add({resolve:s,reject:i},n+":"),n,o)})}}(0,j),J=function(e,n){const o=s("storage:");return i(n,o),{setItem:(n,t)=>new Promise((s,i)=>{const r=o.add({resolve:s,reject:i});e(r,"setItem",{keyName:n,keyValue:t})}),getItem:n=>new Promise((t,s)=>{const i=o.add({resolve:t,reject:s});e(i,"getItem",{keyName:n})}),clear:()=>new Promise((n,t)=>{const s=o.add({resolve:n,reject:t});e(s,"clear",{})})}}((e,o,t={})=>{const s=O&&O[n];H&&H[n]?H[n](e,o,JSON.stringify(t)):s?O[n].postMessage({reqId:e,method:o,data:t}):T?T.execute(n,e,o,t):"undefined"!=typeof window&&console.log("--storage-isUnknown")},j),L=r(e=>{const n=O&&O[d];H&&H[d]?H[d](e):n?O[d].postMessage({reqId:e}):T?T.execute(d,e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},d,j),V=r(e=>{const n=O&&O[c];H&&H[c]?H[c](e):n?O[c].postMessage({reqId:e}):T?T.execute(c,e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},c,j),Q=r(e=>{const n=O&&O[l];H&&H[l]?H[l](e):n?O[l].postMessage({reqId:e}):T?T.execute(l,e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},l,j),W=r(e=>{const n=O&&O[u];H&&H[u]?H[u](e):n?O[u].postMessage({reqId:e}):T?T.execute(u,e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},u,j),_=r((e,n)=>{const o=O&&O[w];H&&H[w]?H[w](e,n):o?O[w].postMessage({reqId:e,text:n}):T?T.execute(w,e,n):"undefined"!=typeof window&&console.log("--share-isUnknown")},w,j),R=r((e,n)=>{const o=O&&O[g];H&&H[g]?H[g](e,n):o?O[g].postMessage({reqId:e,text:n}):T?T.execute(g,e,n):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},g,j),$=r((e,n)=>{const o=O&&O[p];H&&H[p]?H[p](e,n):o?O[p].postMessage({reqId:e,text:n}):T?T.execute(p,e,n):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},p,j),z=r((e,n,o)=>{var t,s;const i=H&&H[f],r=O&&O[f],a="image."+(null!=(t=null==(s=o.split(";"))||null==(s=s[0])?void 0:s.split("/")[1])?t:""),d=o.substr(o.indexOf(",")+1);i?H[f](e,n,a,d):r?O[f].postMessage({reqId:e,text:n,filename:a,base64Data:d}):T?T.execute(f,e,{text:n,filename:a,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",j),K=r((e,n,o,t)=>{const s=O&&O[f];H&&H[f]?H[f](e,n,o,t):s?O[f].postMessage({reqId:e,text:n,filename:o,base64Data:t}):T?T.execute(f,e,n,o,t):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},f,j),X=r((e,n)=>{if(!Array.isArray(n)||n.some(e=>e<1||e!==Math.floor(e))||n.reduce((e,n)=>e+n)>1e4)return void console.error("Pattern should be an array of positive integers no longer than 10000ms total");const o=O&&O[k];H&&H[k]?H[k](e,JSON.stringify(n)):o?O[k].postMessage({reqId:e,pattern:n}):T?T.execute(k,e,n):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")},k,j),Y=r(e=>{const n=O&&O[y];H&&H[y]?H[y](e):n?O[y].postMessage({reqId:e}):T?T.execute(y,e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},y,j),Z=r(e=>{const n=O&&O[b];H&&H[b]?H[b](e):n?O[b].postMessage({reqId:e}):T?T.execute(b,e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},b,j),ee=r((e,n)=>{if(n.length>3)return void console.error("SetHeaderMenuItems: items count should not be more than 3");const o=H&&H[I],t=O&&O[I],s=JSON.stringify(n);o?H[I](e,s):t?O[I].postMessage({reqId:e,itemsJsonArray:s}):T?T.execute(I,e,s):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")},I,j),ne=r((e,n)=>{const o=O&&O[S];H&&H[S]?H[S](e,n):o?O[S].postMessage({reqId:e,enabled:n}):T?T.execute(S,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},S,j),oe=r(e=>{const n=O&&O[C];H&&H[C]?H[C](e):n?O[C].postMessage({reqId:e}):T?T.execute(C,e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},C,j),te=r((e,n)=>{const o=O&&O[h];H&&H[h]?H[h](e,n):o?O[h].postMessage({reqId:e,visible:n}):T?T.execute(h,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},h,j),se=r((e,n)=>{const o=O&&O[U];H&&H[U]?H[U](e,n):o?O[U].postMessage({reqId:e,transactionId:n}):console.log("--openPayment-isUnknown")},U,j),ie=r(e=>{const n=O&&O[A];H&&H[A]?H[A](e):n?O[A].postMessage({reqId:e}):T?T.execute(A,e):"undefined"!=typeof window&&console.log("--checkBiometry-isUnknown")},A,j),re=r((e,n)=>{const o=O&&O[x];H&&H[x]?H[x](e,n):o?O[x].postMessage({reqId:e,url:n}):console.log("--openExternalUrlMethod-isUnknown")},x,j),ae=r((e,n)=>{const o=O&&O[B];H&&H[B]?H[B](e,n):o?O[B].postMessage({reqId:e,mode:n}):T?T.execute(B,e,n):"undefined"!=typeof window&&console.log("--setNavigationItemMode-isUnknown")},B,j),de=r(e=>{const n=O&&O[N];H&&H[N]?H[N](e):n?O[N].postMessage({reqId:e}):T?T.execute(N,e):"undefined"!=typeof window&&console.log("--getNavigationItemMode-isUnknown")},N,j),ce=r(e=>{const n=O&&O[E];H&&H[E]?H[E](e):n?O[E].postMessage({reqId:e}):T?console.log("--getUserStepInfo-isWeb"):"undefined"!=typeof window&&console.log("--getUserStepInfo-isUnknown")},E,j),le=F("isESimSupported"),ue=F("activateESim",{transformToObject:([e])=>({activationCode:e})}),we=F("readNFCData"),ge=F("readNFCPassport",{transformToObject:([e,n,o])=>({passportNumber:e,dateOfBirth:n,expirationDate:o})}),pe=F("subscribeUserStepInfo"),fe=F("unsubscribeUserStepInfo"),me=F("openUserProfile"),ke=F("openSettings"),ye=F("closeApplication"),be=F("enableSwipeBack"),Me=F("disableSwipeBack");return{version:"0.8.0-canary.4",copyToClipboard:$,invoke:G,storage:J,getMe:()=>G(a.getMe),getPhone:()=>G(a.getPhone),getContacts:()=>G(a.getContacts),getGeo:L,getQr:V,getSMSCode:Q,getUserProfile:e=>G(a.getUserProfile,{id:e}),openUserProfile:me,selectContact:W,enableNotifications:()=>G(a.enableNotifications),disableNotifications:()=>G(a.disableNotifications),enablePrivateMessaging:e=>G(a.enablePrivateMessaging,{appId:e}),disablePrivateMessaging:e=>G(a.disablePrivateMessaging,{appId:e}),openSettings:ke,closeApplication:ye,setTitle:R,share:_,shareImage:z,shareFile:K,setShakeHandler:e=>{H&&H[m]||O&&O[m]||T?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:e=>{H&&H[M]||O&&O[M]||T?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:X,isSupported:()=>{var e;const n=O&&(null==(e=window.webkit)||null==(e=e.messageHandlers)?void 0:e.invoke);return Boolean(H||n||T)},supports:e=>!!H&&"function"==typeof H[e]||!!O&&!!O[e]&&"function"==typeof O[e].postMessage||!!T&&"function"==typeof T[e],sub:j,enableScreenCapture:Y,disableScreenCapture:Z,setHeaderMenuItems:ee,setHeaderMenuItemClickHandler:e=>{H&&H[v]||O&&O[v]||T?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:ne,getCustomBackArrowMode:oe,setCustomBackArrowVisible:te,openPayment:se,setCustomBackArrowOnClickHandler:e=>{H&&H[P]||O&&O[P]||T?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")},checkBiometry:ie,openExternalUrl:re,enableSwipeBack:be,disableSwipeBack:Me,setNavigationItemMode:ae,getNavigationItemMode:de,getUserStepInfo:ce,isESimSupported:le,activateESim:ue,readNFCData:we,subscribeUserStepInfo:pe,unsubscribeUserStepInfo:fe,readNFCPassport:ge}})();export{e as BridgeErrors,n as classifyBridgeError,l as default};
|
|
1
|
+
var e;!function(e){e[e.PermissionDenyError=0]="PermissionDenyError",e[e.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",e[e.OtherError=2]="OtherError"}(e||(e={}));const t=t=>{if(t.msg){if(t.msg.startsWith("permission deny"))return e.PermissionDenyError;if(t.msg.startsWith("permission security deny"))return e.PermissionSecurityDenyError}return e.OtherError};var r,n,a;function o(){return"undefined"!=typeof window}!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(r||(r={})),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",e.Close="Close",e.SystemNotifications="SystemNotifications"}(n||(n={})),function(e){e.SystemBackArrow="SystemBackArrow",e.CustomBackArrow="CustomBackArrow",e.NoItem="NoItem",e.UserProfile="UserProfile"}(a||(a={}));const i={supports:()=>!1,handleAction:e=>{console.log(`--${e.type}-isUnknown`)}};function s(e){return["setHeaderMenuItemClickHandler","setCustomBackArrowOnClickHandler","setTabActiveHandler","setShakeHandler"].includes(e.type)}const l=e=>{switch(e.type){case"setShakeHandler":window.onAituBridgeShake=e.payload[0];break;case"setCustomBackArrowOnClickHandler":window.onAituBridgeBackArrowClick=e.payload[0];break;case"setHeaderMenuItemClickHandler":window.onAituBridgeHeaderMenuItemClick=e.payload[0];break;case"setTabActiveHandler":window.onAituBridgeTabActive=e.payload[0]}};function d(e){return{type:"awaitResponse",actionId:e}}const c={isSupported:()=>o()&&!!window.AndroidBridge,makeActionHandler:()=>({supports:e=>{var t;return"function"==typeof(null==(t=window)||null==(t=t.AndroidBridge)?void 0:t[e])},handleAction:e=>{var t;const r=null==(t=window)?void 0:t.AndroidBridge;return r[e.type]?s(e)?l(e):(r[e.type](e.id,...(e=>{if("storage"===e.type||"invoke"===e.type){const[t,r={}]=e.payload;return[t,JSON.stringify(r)]}if("setHeaderMenuItems"===e.type||"vibrate"===e.type){const[t]=e.payload;return[JSON.stringify(t)]}return Array.isArray(e.payload)?e.payload:[]})(e)),d(e.id)):i.handleAction(e)}})};function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(null,arguments)}const p={isSupported:()=>o()&&!!window.webkit&&!!window.webkit.messageHandlers,makeActionHandler:()=>({supports:e=>{var t;return"function"==typeof(null==(t=window.webkit)||null==(t=t.messageHandlers)||null==(t=t[e])?void 0:t.postMessage)},handleAction:e=>{var t;const r=null==(t=window)||null==(t=t.webkit)?void 0:t.messageHandlers;return r[e.type]?s(e)?l(e):(r[e.type].postMessage(u({reqId:e.id},(({type:e,payload:t})=>{switch(e){case"storage":case"invoke":{const[e,r={}]=t;return{method:e,data:r}}case"activateESim":{const[e]=t;return{activationCode:e}}case"readNFCPassport":{const[e,r,n]=t;return{passportNumber:e,dateOfBirth:r,expirationDate:n}}case"setCustomBackArrowMode":{const[e]=t;return{enabled:e}}case"setCustomBackArrowVisible":{const[e]=t;return{visible:e}}case"setNavigationItemMode":{const[e]=t;return{mode:e}}case"share":case"setTitle":case"copyToClipboard":{const[e]=t;return{text:e}}case"shareFile":{const[e,r,n]=t;return{text:e,filename:r,base64Data:n}}case"openExternalUrl":{const[e]=t;return{url:e}}case"openPayment":{const[e]=t;return{transactionId:e}}case"setHeaderMenuItems":{const[e]=t;return{itemsJsonArray:JSON.stringify(e)}}case"vibrate":{const[e]=t;return{pattern:e}}default:return{}}})(e))),d(e.id)):i.handleAction(e)}})},g=e=>{if("storage"===e.type||"invoke"===e.type){const[t,r={}]=e.payload;return[t,r]}if("setHeaderMenuItems"===e.type){const[t]=e.payload;return[JSON.stringify(t)]}return e.payload},m={isSupported:()=>o()&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}(),makeActionHandler:()=>{let e=new URLSearchParams(window.location.search).get("__aitu-domain");return e?localStorage.setItem("mini-app-domain",e):e=localStorage.getItem("mini-app-domain"),e?(window.addEventListener("message",t=>{if(t.origin===e&&t.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:t.data})),"string"!=typeof t.data||""===t.data)return;try{const e=JSON.parse(t.data);e&&e.method&&("setCustomBackArrowOnClickHandler"===e.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===e.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(e.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),{supports:()=>!1,handleAction:t=>{var r;return s(t)?l(t):"getUserStepInfo"===t.type||"openExternalUrl"===t.type||"openPayment"===t.type?i.handleAction(t):(null==(r=window)||null==(r=r.top)||r.postMessage({source:"aitu-bridge",method:t.type,reqId:t.id,payload:[...g(t)]},e),d(t.id))}}):i}},w=(()=>{var e;const t=[c,p,m].find(e=>e.isSupported()),n=null!=(e=null==t?void 0:t.makeActionHandler())?e:i,a=(()=>{const e={};return t=>{var r;const n=(null!=(r=e[t])?r:0)+1;return e[t]=n,`${t}:${n}`}})(),s={handler:n,generateId:a},{createAction:l,createHandlerAction:d}=(e=>{const t=(t,r,n)=>{var a,o;const i=null!=(a=null==n?void 0:n.generateId)?a:()=>e.generateId(t),s=null!=(o=null==n?void 0:n.validate)?o:()=>!0,l=i(...r),d=s(...r);if("string"!=typeof d)return e.handler.handleAction({type:t,payload:r,id:l});console.error(d)};return{createHandlerAction:(e,r)=>(...n)=>{t(e,n,r)},createAction:(e,r)=>(...n)=>{const a=t(e,n,r);return"awaitResponse"===(null==a?void 0:a.type)?(o=a.actionId,new Promise((e,t)=>{const r=n=>{var a;if((null==(a=n.detail)?void 0:a.reqId)!==o)return;const{data:i,error:s}=n.detail;s?t(s):e(i),window.removeEventListener("aituEvents",r)};window.addEventListener("aituEvents",r)})):new Promise(()=>{});var o}}})(s),u=[];o()&&window.addEventListener("aituEvents",e=>{[...u].map(t=>t.call(null,e))});const g=n.supports,w=l("isESimSupported"),y=l("activateESim"),v=l("readNFCData"),f=l("readNFCPassport"),k=l("subscribeUserStepInfo"),b=l("unsubscribeUserStepInfo"),h=l("openUserProfile"),S=l("openSettings"),A=l("closeApplication"),C=l("enableSwipeBack"),I=l("disableSwipeBack"),M=l("storage"),H=d("setShakeHandler"),P=d("setTabActiveHandler"),B=d("setHeaderMenuItemClickHandler"),E=d("setCustomBackArrowOnClickHandler"),N=l("enableScreenCapture"),U=l("disableScreenCapture"),O=l("invoke",{generateId:(e,...t)=>a(`${e}:invoke`)}),D=l("setCustomBackArrowMode"),T=l("getCustomBackArrowMode"),F=l("setCustomBackArrowVisible"),x=l("getNavigationItemMode"),G=l("setNavigationItemMode"),J=l("share"),L=l("shareFile"),V=l("getGeo"),$=l("getQr"),q=l("getSMSCode"),R=l("selectContact"),j=l("setTitle"),Q=l("copyToClipboard"),W=l("checkBiometry"),_=l("getUserStepInfo"),z=l("openExternalUrl"),K=l("openPayment"),X=l("setHeaderMenuItems",{validate:e=>!(e.length>3)||"SetHeaderMenuItems: items count should not be more than 3"}),Y=l("vibrate",{validate:e=>!(!Array.isArray(e)||e.some(e=>e<1||e!==Math.floor(e))||e.reduce((e,t)=>e+t)>1e4)||"Pattern should be an array of positive integers no longer than 10000ms total"});return{version:"0.8.0",copyToClipboard:Q,invoke:O,storage:{getItem:e=>M("getItem",{keyName:e}),setItem:(e,t)=>M("setItem",{keyName:e,keyValue:t}),clear:()=>M("clear")},getMe:()=>O(r.getMe),getPhone:()=>O(r.getPhone),getContacts:()=>O(r.getContacts),getGeo:V,getQr:$,getUserProfile:e=>O(r.getUserProfile,{id:e}),getSMSCode:q,openUserProfile:h,selectContact:R,enableNotifications:()=>O(r.enableNotifications),disableNotifications:()=>O(r.disableNotifications),enablePrivateMessaging:e=>O(r.enablePrivateMessaging,{appId:e}),disablePrivateMessaging:e=>O(r.disablePrivateMessaging,{appId:e}),openSettings:S,closeApplication:A,setTitle:j,share:J,shareImage:(e,t)=>{var r,n;const a="image."+(null!=(r=null==(n=t.split(";"))||null==(n=n[0])?void 0:n.split("/")[1])?r:""),o=t.substr(t.indexOf(",")+1);return L(e,a,o)},shareFile:L,setShakeHandler:H,setTabActiveHandler:P,vibrate:Y,isSupported:()=>n!==i,supports:g,sub:e=>{u.push(e)},enableScreenCapture:N,disableScreenCapture:U,setHeaderMenuItems:X,setHeaderMenuItemClickHandler:B,setCustomBackArrowMode:D,getCustomBackArrowMode:T,setCustomBackArrowVisible:F,openPayment:K,setCustomBackArrowOnClickHandler:E,checkBiometry:W,openExternalUrl:z,enableSwipeBack:C,disableSwipeBack:I,setNavigationItemMode:G,getNavigationItemMode:x,getUserStepInfo:_,isESimSupported:w,activateESim:y,readNFCData:v,subscribeUserStepInfo:k,unsubscribeUserStepInfo:b,readNFCPassport:f}})();export{e as BridgeErrors,r as EInvokeRequest,n as HeaderMenuIcon,a as NavigationItemMode,t as classifyBridgeError,w as default};
|
|
2
2
|
//# sourceMappingURL=index.modern.mjs.map
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e;!function(e){e[e.PermissionDenyError=0]="PermissionDenyError",e[e.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",e[e.OtherError=2]="OtherError"}(e||(e={}));var n,o,t,i=function(n){if(n.msg){if(n.msg.startsWith("permission deny"))return e.PermissionDenyError;if(n.msg.startsWith("permission security deny"))return e.PermissionSecurityDenyError}return e.OtherError};function r(){return r=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var t in o)({}).hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},r.apply(null,arguments)}function s(e){void 0===e&&(e="m:");var n=0;return{next:function(){return e+ ++n}}}function a(e){var n=s(e),o={};return{add:function(e,t){void 0===t&&(t="");var i=t+n.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)}}}function c(e,n){e(function(e){if(e.detail&&"reqId"in e.detail){var o=e.detail,t=o.reqId;t&&n.resolve(t,o.data,function(e){return!e},o.error)}})}function d(e,n,o){var t=a(n+":");return c(o,t),function(){var n=arguments;return new Promise(function(o,i){var r=t.add({resolve:o,reject:i});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.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(n||(n={})),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",e.Close="Close",e.SystemNotifications="SystemNotifications"}(o||(o={})),function(e){e.SystemBackArrow="SystemBackArrow",e.CustomBackArrow="CustomBackArrow",e.NoItem="NoItem",e.UserProfile="UserProfile"}(t||(t={}));var u=function(){var e,o,t="invoke",i="storage",u="getGeo",l="getQr",f="getSMSCode",w="selectContact",g="share",p="setTitle",v="copyToClipboard",m="shareFile",k="setShakeHandler",y="vibrate",b="enableScreenCapture",M="disableScreenCapture",I="setTabActiveHandler",S="setHeaderMenuItems",C="setHeaderMenuItemClickHandler",h="setCustomBackArrowMode",U="getCustomBackArrowMode",P="setCustomBackArrowVisible",A="openPayment",x="setCustomBackArrowOnClickHandler",B="checkBiometry",N="openExternalUrl",E="setNavigationItemMode",q="getNavigationItemMode",H="getUserStepInfo",O="undefined"!=typeof window,T=O&&window.AndroidBridge,D=O&&window.webkit&&window.webkit.messageHandlers,j=O&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()&&((o=new URLSearchParams(window.location.search).get("__aitu-domain"))?localStorage.setItem("mini-app-domain",o):o=localStorage.getItem("mini-app-domain"),o?(e={origin:o,execute:function(e,n){var t;null==(t=window)||null==(t=t.top)||t.postMessage({source:"aitu-bridge",method:e,reqId:n,payload:[].concat([].slice.call(arguments,2))},o)}},window.addEventListener("message",function(e){if(e.origin===o&&e.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data})),"string"!=typeof e.data||""===e.data)return;try{var n=JSON.parse(e.data);n&&n.method&&("setCustomBackArrowOnClickHandler"===n.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===n.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(n.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),e):null),F=[];O&&window.addEventListener("aituEvents",function(e){[].concat(F).map(function(n){return n.call(null,e)})});var G,J=function(e){F.push(e)},L=function(e,n){var o=s(e+":");return function(){var t=[].slice.call(arguments),i=o.next(),s=!!D&&!!D[e],a=!!j;return T&&T[e]?T[e].apply(T,[i].concat(t)):s?D[e].postMessage(r({reqId:i},null==n||null==n.transformToObject?void 0:n.transformToObject(t))):a?j.execute.apply(j,[e,i].concat(t)):"undefined"!=typeof window&&console.log("--"+e+"-isUnknown"),function(e){return new Promise(function(n,o){var t=function(i){var r;if((null==(r=i.detail)?void 0:r.reqId)===e){var s=i.detail,a=s.data,c=s.error;a?n(a):o(c),window.removeEventListener("aituEvents",t)}};window.addEventListener("aituEvents",t)})}(i)}},V=(c(J,G=a("invoke:")),function(e,n){return void 0===n&&(n={}),new Promise(function(o,i){!function(e,n,o){void 0===o&&(o={});var i=D&&D[t];T&&T[t]?T[t](e,n,JSON.stringify(o)):i?D[t].postMessage({reqId:e,method:n,data:o}):j?j.execute(t,e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(G.add({resolve:o,reject:i},e+":"),e,n)})}),Q=function(e,n){var o=a("storage:");return c(n,o),{setItem:function(n,t){return new Promise(function(i,r){var s=o.add({resolve:i,reject:r});e(s,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,i){var r=o.add({resolve:t,reject:i});e(r,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var i=o.add({resolve:n,reject:t});e(i,"clear",{})})}}}(function(e,n,o){void 0===o&&(o={});var t=D&&D[i];T&&T[i]?T[i](e,n,JSON.stringify(o)):t?D[i].postMessage({reqId:e,method:n,data:o}):j?j.execute(i,e,n,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},J),W=d(function(e){var n=D&&D[u];T&&T[u]?T[u](e):n?D[u].postMessage({reqId:e}):j?j.execute(u,e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},u,J),_=d(function(e){var n=D&&D[l];T&&T[l]?T[l](e):n?D[l].postMessage({reqId:e}):j?j.execute(l,e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},l,J),R=d(function(e){var n=D&&D[f];T&&T[f]?T[f](e):n?D[f].postMessage({reqId:e}):j?j.execute(f,e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},f,J),z=d(function(e){var n=D&&D[w];T&&T[w]?T[w](e):n?D[w].postMessage({reqId:e}):j?j.execute(w,e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},w,J),K=d(function(e,n){var o=D&&D[g];T&&T[g]?T[g](e,n):o?D[g].postMessage({reqId:e,text:n}):j?j.execute(g,e,n):"undefined"!=typeof window&&console.log("--share-isUnknown")},g,J),X=d(function(e,n){var o=D&&D[p];T&&T[p]?T[p](e,n):o?D[p].postMessage({reqId:e,text:n}):j?j.execute(p,e,n):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},p,J),Y=d(function(e,n){var o=D&&D[v];T&&T[v]?T[v](e,n):o?D[v].postMessage({reqId:e,text:n}):j?j.execute(v,e,n):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},v,J),Z=d(function(e,n,o){var t,i,r=T&&T[m],s=D&&D[m],a="image."+(null!=(t=null==(i=o.split(";"))||null==(i=i[0])?void 0:i.split("/")[1])?t:""),c=o.substr(o.indexOf(",")+1);r?T[m](e,n,a,c):s?D[m].postMessage({reqId:e,text:n,filename:a,base64Data:c}):j?j.execute(m,e,{text:n,filename:a,base64Data:c}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",J),$=d(function(e,n,o,t){var i=D&&D[m];T&&T[m]?T[m](e,n,o,t):i?D[m].postMessage({reqId:e,text:n,filename:o,base64Data:t}):j?j.execute(m,e,n,o,t):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},m,J),ee=d(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 o=D&&D[y];T&&T[y]?T[y](e,JSON.stringify(n)):o?D[y].postMessage({reqId:e,pattern:n}):j?j.execute(y,e,n):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")}},y,J),ne=d(function(e){var n=D&&D[b];T&&T[b]?T[b](e):n?D[b].postMessage({reqId:e}):j?j.execute(b,e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},b,J),oe=d(function(e){var n=D&&D[M];T&&T[M]?T[M](e):n?D[M].postMessage({reqId:e}):j?j.execute(M,e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},M,J),te=d(function(e,n){if(n.length>3)console.error("SetHeaderMenuItems: items count should not be more than 3");else{var o=T&&T[S],t=D&&D[S],i=JSON.stringify(n);o?T[S](e,i):t?D[S].postMessage({reqId:e,itemsJsonArray:i}):j?j.execute(S,e,i):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")}},S,J),ie=d(function(e,n){var o=D&&D[h];T&&T[h]?T[h](e,n):o?D[h].postMessage({reqId:e,enabled:n}):j?j.execute(h,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},h,J),re=d(function(e){var n=D&&D[U];T&&T[U]?T[U](e):n?D[U].postMessage({reqId:e}):j?j.execute(U,e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},U,J),se=d(function(e,n){var o=D&&D[P];T&&T[P]?T[P](e,n):o?D[P].postMessage({reqId:e,visible:n}):j?j.execute(P,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},P,J),ae=d(function(e,n){var o=D&&D[A];T&&T[A]?T[A](e,n):o?D[A].postMessage({reqId:e,transactionId:n}):console.log("--openPayment-isUnknown")},A,J),ce=d(function(e){var n=D&&D[B];T&&T[B]?T[B](e):n?D[B].postMessage({reqId:e}):j?j.execute(B,e):"undefined"!=typeof window&&console.log("--checkBiometry-isUnknown")},B,J),de=d(function(e,n){var o=D&&D[N];T&&T[N]?T[N](e,n):o?D[N].postMessage({reqId:e,url:n}):console.log("--openExternalUrlMethod-isUnknown")},N,J),ue=d(function(e,n){var o=D&&D[E];T&&T[E]?T[E](e,n):o?D[E].postMessage({reqId:e,mode:n}):j?j.execute(E,e,n):"undefined"!=typeof window&&console.log("--setNavigationItemMode-isUnknown")},E,J),le=d(function(e){var n=D&&D[q];T&&T[q]?T[q](e):n?D[q].postMessage({reqId:e}):j?j.execute(q,e):"undefined"!=typeof window&&console.log("--getNavigationItemMode-isUnknown")},q,J),fe=d(function(e){var n=D&&D[H];T&&T[H]?T[H](e):n?D[H].postMessage({reqId:e}):j?console.log("--getUserStepInfo-isWeb"):"undefined"!=typeof window&&console.log("--getUserStepInfo-isUnknown")},H,J),we=L("isESimSupported"),ge=L("activateESim",{transformToObject:function(e){return{activationCode:e[0]}}}),pe=L("readNFCData"),ve=L("readNFCPassport",{transformToObject:function(e){return{passportNumber:e[0],dateOfBirth:e[1],expirationDate:e[2]}}}),me=L("subscribeUserStepInfo"),ke=L("unsubscribeUserStepInfo"),ye=L("openUserProfile"),be=L("openSettings"),Me=L("closeApplication"),Ie=L("enableSwipeBack"),Se=L("disableSwipeBack");return{version:"0.8.0-canary.4",copyToClipboard:Y,invoke:V,storage:Q,getMe:function(){return V(n.getMe)},getPhone:function(){return V(n.getPhone)},getContacts:function(){return V(n.getContacts)},getGeo:W,getQr:_,getSMSCode:R,getUserProfile:function(e){return V(n.getUserProfile,{id:e})},openUserProfile:ye,selectContact:z,enableNotifications:function(){return V(n.enableNotifications)},disableNotifications:function(){return V(n.disableNotifications)},enablePrivateMessaging:function(e){return V(n.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return V(n.disablePrivateMessaging,{appId:e})},openSettings:be,closeApplication:Me,setTitle:X,share:K,shareImage:Z,shareFile:$,setShakeHandler:function(e){T&&T[k]||D&&D[k]||j?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:function(e){T&&T[I]||D&&D[I]||j?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:ee,isSupported:function(){var e,n=D&&(null==(e=window.webkit)||null==(e=e.messageHandlers)?void 0:e.invoke);return Boolean(T||n||j)},supports:function(e){return!!T&&"function"==typeof T[e]||!!D&&!!D[e]&&"function"==typeof D[e].postMessage||!!j&&"function"==typeof j[e]},sub:J,enableScreenCapture:ne,disableScreenCapture:oe,setHeaderMenuItems:te,setHeaderMenuItemClickHandler:function(e){T&&T[C]||D&&D[C]||j?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:ie,getCustomBackArrowMode:re,setCustomBackArrowVisible:se,openPayment:ae,setCustomBackArrowOnClickHandler:function(e){T&&T[x]||D&&D[x]||j?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")},checkBiometry:ce,openExternalUrl:de,enableSwipeBack:Ie,disableSwipeBack:Se,setNavigationItemMode:ue,getNavigationItemMode:le,getUserStepInfo:fe,isESimSupported:we,activateESim:ge,readNFCData:pe,subscribeUserStepInfo:me,unsubscribeUserStepInfo:ke,readNFCPassport:ve}}();export{e as BridgeErrors,i as classifyBridgeError,u as default};
|
|
1
|
+
var e;!function(e){e[e.PermissionDenyError=0]="PermissionDenyError",e[e.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",e[e.OtherError=2]="OtherError"}(e||(e={}));var t,n,r,i=function(t){if(t.msg){if(t.msg.startsWith("permission deny"))return e.PermissionDenyError;if(t.msg.startsWith("permission security deny"))return e.PermissionSecurityDenyError}return e.OtherError};function a(){return"undefined"!=typeof window}!function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(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",e.Close="Close",e.SystemNotifications="SystemNotifications"}(n||(n={})),function(e){e.SystemBackArrow="SystemBackArrow",e.CustomBackArrow="CustomBackArrow",e.NoItem="NoItem",e.UserProfile="UserProfile"}(r||(r={}));var o={supports:function(){return!1},handleAction:function(e){console.log("--"+e.type+"-isUnknown")}};function s(e){return["setHeaderMenuItemClickHandler","setCustomBackArrowOnClickHandler","setTabActiveHandler","setShakeHandler"].includes(e.type)}var u=function(e){switch(e.type){case"setShakeHandler":window.onAituBridgeShake=e.payload[0];break;case"setCustomBackArrowOnClickHandler":window.onAituBridgeBackArrowClick=e.payload[0];break;case"setHeaderMenuItemClickHandler":window.onAituBridgeHeaderMenuItemClick=e.payload[0];break;case"setTabActiveHandler":window.onAituBridgeTabActive=e.payload[0]}};function c(e){return{type:"awaitResponse",actionId:e}}var l={isSupported:function(){return a()&&!!window.AndroidBridge},makeActionHandler:function(){return{supports:function(e){var t;return"function"==typeof(null==(t=window)||null==(t=t.AndroidBridge)?void 0:t[e])},handleAction:function(e){var t,n=null==(t=window)?void 0:t.AndroidBridge;return n[e.type]?s(e)?u(e):(n[e.type].apply(n,[e.id].concat(function(e){if("storage"===e.type||"invoke"===e.type){var t=e.payload,n=t[1];return[t[0],JSON.stringify(void 0===n?{}:n)]}return"setHeaderMenuItems"===e.type||"vibrate"===e.type?[JSON.stringify(e.payload[0])]:Array.isArray(e.payload)?e.payload:[]}(e))),c(e.id)):o.handleAction(e)}}}};function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d.apply(null,arguments)}var p={isSupported:function(){return a()&&!!window.webkit&&!!window.webkit.messageHandlers},makeActionHandler:function(){return{supports:function(e){var t;return"function"==typeof(null==(t=window.webkit)||null==(t=t.messageHandlers)||null==(t=t[e])?void 0:t.postMessage)},handleAction:function(e){var t,n=null==(t=window)||null==(t=t.webkit)?void 0:t.messageHandlers;return n[e.type]?s(e)?u(e):(n[e.type].postMessage(d({reqId:e.id},function(e){var t=e.payload;switch(e.type){case"storage":case"invoke":var n=t[1];return{method:t[0],data:void 0===n?{}:n};case"activateESim":return{activationCode:t[0]};case"readNFCPassport":return{passportNumber:t[0],dateOfBirth:t[1],expirationDate:t[2]};case"setCustomBackArrowMode":return{enabled:t[0]};case"setCustomBackArrowVisible":return{visible:t[0]};case"setNavigationItemMode":return{mode:t[0]};case"share":case"setTitle":case"copyToClipboard":return{text:t[0]};case"shareFile":return{text:t[0],filename:t[1],base64Data:t[2]};case"openExternalUrl":return{url:t[0]};case"openPayment":return{transactionId:t[0]};case"setHeaderMenuItems":return{itemsJsonArray:JSON.stringify(t[0])};case"vibrate":return{pattern:t[0]};default:return{}}}(e))),c(e.id)):o.handleAction(e)}}}},f=function(e){if("storage"===e.type||"invoke"===e.type){var t=e.payload,n=t[1];return[t[0],void 0===n?{}:n]}return"setHeaderMenuItems"===e.type?[JSON.stringify(e.payload[0])]:e.payload},g={isSupported:function(){return a()&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()},makeActionHandler:function(){var e=new URLSearchParams(window.location.search).get("__aitu-domain");return e?localStorage.setItem("mini-app-domain",e):e=localStorage.getItem("mini-app-domain"),e?(window.addEventListener("message",function(t){if(t.origin===e&&t.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:t.data})),"string"!=typeof t.data||""===t.data)return;try{var n=JSON.parse(t.data);n&&n.method&&("setCustomBackArrowOnClickHandler"===n.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===n.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(n.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),{supports:function(){return!1},handleAction:function(t){var n;return s(t)?u(t):"getUserStepInfo"===t.type||"openExternalUrl"===t.type||"openPayment"===t.type?o.handleAction(t):(null==(n=window)||null==(n=n.top)||n.postMessage({source:"aitu-bridge",method:t.type,reqId:t.id,payload:[].concat(f(t))},e),c(t.id))}}):o}},m=function(){var e,n,r,i,s=[l,p,g].find(function(e){return e.isSupported()}),u=null!=(e=null==s?void 0:s.makeActionHandler())?e:o,c=(n={},function(e){var t,r=(null!=(t=n[e])?t:0)+1;return n[e]=r,e+":"+r}),d=(r={handler:u,generateId:c},i=function(e,t,n){var i,a,o=null!=(i=null==n?void 0:n.generateId)?i:function(){return r.generateId(e)},s=null!=(a=null==n?void 0:n.validate)?a:function(){return!0},u=o.apply(void 0,t),c=s.apply(void 0,t);if("string"!=typeof c)return r.handler.handleAction({type:e,payload:t,id:u});console.error(c)},{createHandlerAction:function(e,t){return function(){i(e,[].slice.call(arguments),t)}},createAction:function(e,t){return function(){var n,r=i(e,[].slice.call(arguments),t);return"awaitResponse"===(null==r?void 0:r.type)?(n=r.actionId,new Promise(function(e,t){var r=function(i){var a;if((null==(a=i.detail)?void 0:a.reqId)===n){var o=i.detail,s=o.data,u=o.error;u?t(u):e(s),window.removeEventListener("aituEvents",r)}};window.addEventListener("aituEvents",r)})):new Promise(function(){})}}}),f=d.createAction,m=d.createHandlerAction,v=[];a()&&window.addEventListener("aituEvents",function(e){[].concat(v).map(function(t){return t.call(null,e)})});var w=u.supports,y=f("isESimSupported"),k=f("activateESim"),b=f("readNFCData"),h=f("readNFCPassport"),S=f("subscribeUserStepInfo"),A=f("unsubscribeUserStepInfo"),C=f("openUserProfile"),I=f("openSettings"),M=f("closeApplication"),H=f("enableSwipeBack"),P=f("disableSwipeBack"),B=f("storage"),E=m("setShakeHandler"),N=m("setTabActiveHandler"),U=m("setHeaderMenuItemClickHandler"),O=m("setCustomBackArrowOnClickHandler"),D=f("enableScreenCapture"),T=f("disableScreenCapture"),F=f("invoke",{generateId:function(e){return c(e+":invoke")}}),x=f("setCustomBackArrowMode"),G=f("getCustomBackArrowMode"),J=f("setCustomBackArrowVisible"),L=f("getNavigationItemMode"),V=f("setNavigationItemMode"),q=f("share"),R=f("shareFile"),j=f("getGeo"),Q=f("getQr"),W=f("getSMSCode"),_=f("selectContact"),z=f("setTitle"),K=f("copyToClipboard"),X=f("checkBiometry"),Y=f("getUserStepInfo"),Z=f("openExternalUrl"),$=f("openPayment"),ee=f("setHeaderMenuItems",{validate:function(e){return!(e.length>3)||"SetHeaderMenuItems: items count should not be more than 3"}}),te=f("vibrate",{validate:function(e){return!(!Array.isArray(e)||e.some(function(e){return e<1||e!==Math.floor(e)})||e.reduce(function(e,t){return e+t})>1e4)||"Pattern should be an array of positive integers no longer than 10000ms total"}});return{version:"0.8.0",copyToClipboard:K,invoke:F,storage:{getItem:function(e){return B("getItem",{keyName:e})},setItem:function(e,t){return B("setItem",{keyName:e,keyValue:t})},clear:function(){return B("clear")}},getMe:function(){return F(t.getMe)},getPhone:function(){return F(t.getPhone)},getContacts:function(){return F(t.getContacts)},getGeo:j,getQr:Q,getUserProfile:function(e){return F(t.getUserProfile,{id:e})},getSMSCode:W,openUserProfile:C,selectContact:_,enableNotifications:function(){return F(t.enableNotifications)},disableNotifications:function(){return F(t.disableNotifications)},enablePrivateMessaging:function(e){return F(t.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return F(t.disablePrivateMessaging,{appId:e})},openSettings:I,closeApplication:M,setTitle:z,share:q,shareImage:function(e,t){var n,r,i="image."+(null!=(n=null==(r=t.split(";"))||null==(r=r[0])?void 0:r.split("/")[1])?n:""),a=t.substr(t.indexOf(",")+1);return R(e,i,a)},shareFile:R,setShakeHandler:E,setTabActiveHandler:N,vibrate:te,isSupported:function(){return u!==o},supports:w,sub:function(e){v.push(e)},enableScreenCapture:D,disableScreenCapture:T,setHeaderMenuItems:ee,setHeaderMenuItemClickHandler:U,setCustomBackArrowMode:x,getCustomBackArrowMode:G,setCustomBackArrowVisible:J,openPayment:$,setCustomBackArrowOnClickHandler:O,checkBiometry:X,openExternalUrl:Z,enableSwipeBack:H,disableSwipeBack:P,setNavigationItemMode:V,getNavigationItemMode:L,getUserStepInfo:Y,isESimSupported:y,activateESim:k,readNFCData:b,subscribeUserStepInfo:S,unsubscribeUserStepInfo:A,readNFCPassport:h}}();export{e as BridgeErrors,t as EInvokeRequest,n as HeaderMenuIcon,r as NavigationItemMode,i as classifyBridgeError,m as default};
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).aituBridge={})}(this,function(e){var n,o,t,r;function i(){return i=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var t in o)({}).hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},i.apply(null,arguments)}function s(e){void 0===e&&(e="m:");var n=0;return{next:function(){return e+ ++n}}}function a(e){var n=s(e),o={};return{add:function(e,t){void 0===t&&(t="");var r=t+n.next();return o[r]=e,r},resolve:function(e,n,t,r){var i=o[e];i&&(t(r)?i.resolve(n):i.reject(r),o[e]=null)}}}function d(e,n){e(function(e){if(e.detail&&"reqId"in e.detail){var o=e.detail,t=o.reqId;t&&n.resolve(t,o.data,function(e){return!e},o.error)}})}function c(e,n,o){var t=a(n+":");return d(o,t),function(){var n=arguments;return new Promise(function(o,r){var i=t.add({resolve:o,reject:r});e.apply(void 0,[i].concat([].slice.call(n)))})}}e.BridgeErrors=void 0,(n=e.BridgeErrors||(e.BridgeErrors={}))[n.PermissionDenyError=0]="PermissionDenyError",n[n.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",n[n.OtherError=2]="OtherError",function(e){e.getMe="GetMe",e.getPhone="GetPhone",e.getContacts="GetContacts",e.getUserProfile="GetUserProfile",e.enableNotifications="AllowNotifications",e.disableNotifications="DisableNotifications",e.enablePrivateMessaging="EnablePrivateMessaging",e.disablePrivateMessaging="DisablePrivateMessaging"}(o||(o={})),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",e.Close="Close",e.SystemNotifications="SystemNotifications"}(t||(t={})),function(e){e.SystemBackArrow="SystemBackArrow",e.CustomBackArrow="CustomBackArrow",e.NoItem="NoItem",e.UserProfile="UserProfile"}(r||(r={}));var u=function(){var e,n,t="invoke",r="storage",u="getGeo",l="getQr",f="getSMSCode",g="selectContact",w="share",p="setTitle",m="copyToClipboard",v="shareFile",k="setShakeHandler",y="vibrate",b="enableScreenCapture",M="disableScreenCapture",I="setTabActiveHandler",S="setHeaderMenuItems",C="setHeaderMenuItemClickHandler",h="setCustomBackArrowMode",U="getCustomBackArrowMode",B="setCustomBackArrowVisible",P="openPayment",x="setCustomBackArrowOnClickHandler",A="checkBiometry",E="openExternalUrl",N="setNavigationItemMode",q="getNavigationItemMode",H="getUserStepInfo",O="undefined"!=typeof window,T=O&&window.AndroidBridge,D=O&&window.webkit&&window.webkit.messageHandlers,j=O&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()&&((n=new URLSearchParams(window.location.search).get("__aitu-domain"))?localStorage.setItem("mini-app-domain",n):n=localStorage.getItem("mini-app-domain"),n?(e={origin:n,execute:function(e,o){var t;null==(t=window)||null==(t=t.top)||t.postMessage({source:"aitu-bridge",method:e,reqId:o,payload:[].concat([].slice.call(arguments,2))},n)}},window.addEventListener("message",function(e){if(e.origin===n&&e.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:e.data})),"string"!=typeof e.data||""===e.data)return;try{var o=JSON.parse(e.data);o&&o.method&&("setCustomBackArrowOnClickHandler"===o.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===o.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(o.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),e):null),F=[];O&&window.addEventListener("aituEvents",function(e){[].concat(F).map(function(n){return n.call(null,e)})});var G,J=function(e){F.push(e)},L=function(e,n){var o=s(e+":");return function(){var t=[].slice.call(arguments),r=o.next(),s=!!D&&!!D[e],a=!!j;return T&&T[e]?T[e].apply(T,[r].concat(t)):s?D[e].postMessage(i({reqId:r},null==n||null==n.transformToObject?void 0:n.transformToObject(t))):a?j.execute.apply(j,[e,r].concat(t)):"undefined"!=typeof window&&console.log("--"+e+"-isUnknown"),function(e){return new Promise(function(n,o){var t=function(r){var i;if((null==(i=r.detail)?void 0:i.reqId)===e){var s=r.detail,a=s.data,d=s.error;a?n(a):o(d),window.removeEventListener("aituEvents",t)}};window.addEventListener("aituEvents",t)})}(r)}},V=(d(J,G=a("invoke:")),function(e,n){return void 0===n&&(n={}),new Promise(function(o,r){!function(e,n,o){void 0===o&&(o={});var r=D&&D[t];T&&T[t]?T[t](e,n,JSON.stringify(o)):r?D[t].postMessage({reqId:e,method:n,data:o}):j?j.execute(t,e,n,o):"undefined"!=typeof window&&console.log("--invoke-isUnknown")}(G.add({resolve:o,reject:r},e+":"),e,n)})}),Q=function(e,n){var o=a("storage:");return d(n,o),{setItem:function(n,t){return new Promise(function(r,i){var s=o.add({resolve:r,reject:i});e(s,"setItem",{keyName:n,keyValue:t})})},getItem:function(n){return new Promise(function(t,r){var i=o.add({resolve:t,reject:r});e(i,"getItem",{keyName:n})})},clear:function(){return new Promise(function(n,t){var r=o.add({resolve:n,reject:t});e(r,"clear",{})})}}}(function(e,n,o){void 0===o&&(o={});var t=D&&D[r];T&&T[r]?T[r](e,n,JSON.stringify(o)):t?D[r].postMessage({reqId:e,method:n,data:o}):j?j.execute(r,e,n,o):"undefined"!=typeof window&&console.log("--storage-isUnknown")},J),W=c(function(e){var n=D&&D[u];T&&T[u]?T[u](e):n?D[u].postMessage({reqId:e}):j?j.execute(u,e):"undefined"!=typeof window&&console.log("--getGeo-isUnknown")},u,J),_=c(function(e){var n=D&&D[l];T&&T[l]?T[l](e):n?D[l].postMessage({reqId:e}):j?j.execute(l,e):"undefined"!=typeof window&&console.log("--getQr-isUnknown")},l,J),R=c(function(e){var n=D&&D[f];T&&T[f]?T[f](e):n?D[f].postMessage({reqId:e}):j?j.execute(f,e):"undefined"!=typeof window&&console.log("--getSMSCode-isUnknown")},f,J),z=c(function(e){var n=D&&D[g];T&&T[g]?T[g](e):n?D[g].postMessage({reqId:e}):j?j.execute(g,e):"undefined"!=typeof window&&console.log("--selectContact-isUnknown")},g,J),K=c(function(e,n){var o=D&&D[w];T&&T[w]?T[w](e,n):o?D[w].postMessage({reqId:e,text:n}):j?j.execute(w,e,n):"undefined"!=typeof window&&console.log("--share-isUnknown")},w,J),X=c(function(e,n){var o=D&&D[p];T&&T[p]?T[p](e,n):o?D[p].postMessage({reqId:e,text:n}):j?j.execute(p,e,n):"undefined"!=typeof window&&console.log("--setTitle-isUnknown")},p,J),Y=c(function(e,n){var o=D&&D[m];T&&T[m]?T[m](e,n):o?D[m].postMessage({reqId:e,text:n}):j?j.execute(m,e,n):"undefined"!=typeof window&&console.log("--copyToClipboard-isUnknown")},m,J),Z=c(function(e,n,o){var t,r,i=T&&T[v],s=D&&D[v],a="image."+(null!=(t=null==(r=o.split(";"))||null==(r=r[0])?void 0:r.split("/")[1])?t:""),d=o.substr(o.indexOf(",")+1);i?T[v](e,n,a,d):s?D[v].postMessage({reqId:e,text:n,filename:a,base64Data:d}):j?j.execute(v,e,{text:n,filename:a,base64Data:d}):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},"shareImage",J),$=c(function(e,n,o,t){var r=D&&D[v];T&&T[v]?T[v](e,n,o,t):r?D[v].postMessage({reqId:e,text:n,filename:o,base64Data:t}):j?j.execute(v,e,n,o,t):"undefined"!=typeof window&&console.log("--shareFile-isUnknown")},v,J),ee=c(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 o=D&&D[y];T&&T[y]?T[y](e,JSON.stringify(n)):o?D[y].postMessage({reqId:e,pattern:n}):j?j.execute(y,e,n):"undefined"!=typeof window&&console.log("--vibrate-isUnknown")}},y,J),ne=c(function(e){var n=D&&D[b];T&&T[b]?T[b](e):n?D[b].postMessage({reqId:e}):j?j.execute(b,e):"undefined"!=typeof window&&console.log("--enableScreenCapture-isUnknown")},b,J),oe=c(function(e){var n=D&&D[M];T&&T[M]?T[M](e):n?D[M].postMessage({reqId:e}):j?j.execute(M,e):"undefined"!=typeof window&&console.log("--disableScreenCapture-isUnknown")},M,J),te=c(function(e,n){if(n.length>3)console.error("SetHeaderMenuItems: items count should not be more than 3");else{var o=T&&T[S],t=D&&D[S],r=JSON.stringify(n);o?T[S](e,r):t?D[S].postMessage({reqId:e,itemsJsonArray:r}):j?j.execute(S,e,r):"undefined"!=typeof window&&console.log("--setHeaderMenuItems-isUnknown")}},S,J),re=c(function(e,n){var o=D&&D[h];T&&T[h]?T[h](e,n):o?D[h].postMessage({reqId:e,enabled:n}):j?j.execute(h,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowMode-isUnknown")},h,J),ie=c(function(e){var n=D&&D[U];T&&T[U]?T[U](e):n?D[U].postMessage({reqId:e}):j?j.execute(U,e):"undefined"!=typeof window&&console.log("--getCustomBackArrowMode-isUnknown")},U,J),se=c(function(e,n){var o=D&&D[B];T&&T[B]?T[B](e,n):o?D[B].postMessage({reqId:e,visible:n}):j?j.execute(B,e,n):"undefined"!=typeof window&&console.log("--setCustomBackArrowVisible-isUnknown")},B,J),ae=c(function(e,n){var o=D&&D[P];T&&T[P]?T[P](e,n):o?D[P].postMessage({reqId:e,transactionId:n}):console.log("--openPayment-isUnknown")},P,J),de=c(function(e){var n=D&&D[A];T&&T[A]?T[A](e):n?D[A].postMessage({reqId:e}):j?j.execute(A,e):"undefined"!=typeof window&&console.log("--checkBiometry-isUnknown")},A,J),ce=c(function(e,n){var o=D&&D[E];T&&T[E]?T[E](e,n):o?D[E].postMessage({reqId:e,url:n}):console.log("--openExternalUrlMethod-isUnknown")},E,J),ue=c(function(e,n){var o=D&&D[N];T&&T[N]?T[N](e,n):o?D[N].postMessage({reqId:e,mode:n}):j?j.execute(N,e,n):"undefined"!=typeof window&&console.log("--setNavigationItemMode-isUnknown")},N,J),le=c(function(e){var n=D&&D[q];T&&T[q]?T[q](e):n?D[q].postMessage({reqId:e}):j?j.execute(q,e):"undefined"!=typeof window&&console.log("--getNavigationItemMode-isUnknown")},q,J),fe=c(function(e){var n=D&&D[H];T&&T[H]?T[H](e):n?D[H].postMessage({reqId:e}):j?console.log("--getUserStepInfo-isWeb"):"undefined"!=typeof window&&console.log("--getUserStepInfo-isUnknown")},H,J),ge=L("isESimSupported"),we=L("activateESim",{transformToObject:function(e){return{activationCode:e[0]}}}),pe=L("readNFCData"),me=L("readNFCPassport",{transformToObject:function(e){return{passportNumber:e[0],dateOfBirth:e[1],expirationDate:e[2]}}}),ve=L("subscribeUserStepInfo"),ke=L("unsubscribeUserStepInfo"),ye=L("openUserProfile"),be=L("openSettings"),Me=L("closeApplication"),Ie=L("enableSwipeBack"),Se=L("disableSwipeBack");return{version:"0.8.0-canary.4",copyToClipboard:Y,invoke:V,storage:Q,getMe:function(){return V(o.getMe)},getPhone:function(){return V(o.getPhone)},getContacts:function(){return V(o.getContacts)},getGeo:W,getQr:_,getSMSCode:R,getUserProfile:function(e){return V(o.getUserProfile,{id:e})},openUserProfile:ye,selectContact:z,enableNotifications:function(){return V(o.enableNotifications)},disableNotifications:function(){return V(o.disableNotifications)},enablePrivateMessaging:function(e){return V(o.enablePrivateMessaging,{appId:e})},disablePrivateMessaging:function(e){return V(o.disablePrivateMessaging,{appId:e})},openSettings:be,closeApplication:Me,setTitle:X,share:K,shareImage:Z,shareFile:$,setShakeHandler:function(e){T&&T[k]||D&&D[k]||j?window.onAituBridgeShake=e:"undefined"!=typeof window&&console.log("--setShakeHandler-isUnknown")},setTabActiveHandler:function(e){T&&T[I]||D&&D[I]||j?window.onAituBridgeTabActive=e:"undefined"!=typeof window&&console.log("--setTabActiveHandler-isUnknown")},vibrate:ee,isSupported:function(){var e,n=D&&(null==(e=window.webkit)||null==(e=e.messageHandlers)?void 0:e.invoke);return Boolean(T||n||j)},supports:function(e){return!!T&&"function"==typeof T[e]||!!D&&!!D[e]&&"function"==typeof D[e].postMessage||!!j&&"function"==typeof j[e]},sub:J,enableScreenCapture:ne,disableScreenCapture:oe,setHeaderMenuItems:te,setHeaderMenuItemClickHandler:function(e){T&&T[C]||D&&D[C]||j?window.onAituBridgeHeaderMenuItemClick=e:"undefined"!=typeof window&&console.log("--setHeaderMenuItemClickHandler-isUnknown")},setCustomBackArrowMode:re,getCustomBackArrowMode:ie,setCustomBackArrowVisible:se,openPayment:ae,setCustomBackArrowOnClickHandler:function(e){T&&T[x]||D&&D[x]||j?window.onAituBridgeBackArrowClick=e:"undefined"!=typeof window&&console.log("--setCustomBackArrowOnClickHandler-isUnknown")},checkBiometry:de,openExternalUrl:ce,enableSwipeBack:Ie,disableSwipeBack:Se,setNavigationItemMode:ue,getNavigationItemMode:le,getUserStepInfo:fe,isESimSupported:ge,activateESim:we,readNFCData:pe,subscribeUserStepInfo:ve,unsubscribeUserStepInfo:ke,readNFCPassport:me}}();e.classifyBridgeError=function(n){if(n.msg){if(n.msg.startsWith("permission deny"))return e.BridgeErrors.PermissionDenyError;if(n.msg.startsWith("permission security deny"))return e.BridgeErrors.PermissionSecurityDenyError}return e.BridgeErrors.OtherError},e.default=u});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).aituBridge={})}(this,function(e){var t,n,r,i;function o(){return"undefined"!=typeof window}e.BridgeErrors=void 0,(t=e.BridgeErrors||(e.BridgeErrors={}))[t.PermissionDenyError=0]="PermissionDenyError",t[t.PermissionSecurityDenyError=1]="PermissionSecurityDenyError",t[t.OtherError=2]="OtherError",e.EInvokeRequest=void 0,(n=e.EInvokeRequest||(e.EInvokeRequest={})).getMe="GetMe",n.getPhone="GetPhone",n.getContacts="GetContacts",n.getUserProfile="GetUserProfile",n.enableNotifications="AllowNotifications",n.disableNotifications="DisableNotifications",n.enablePrivateMessaging="EnablePrivateMessaging",n.disablePrivateMessaging="DisablePrivateMessaging",e.HeaderMenuIcon=void 0,(r=e.HeaderMenuIcon||(e.HeaderMenuIcon={})).Search="Search",r.ShoppingCart="ShoppingCart",r.Menu="Menu",r.Share="Share",r.Notifications="Notifications",r.Help="Help",r.Error="Error",r.Person="Person",r.Sort="Sort",r.Filter="Filter",r.Close="Close",r.SystemNotifications="SystemNotifications",e.NavigationItemMode=void 0,(i=e.NavigationItemMode||(e.NavigationItemMode={})).SystemBackArrow="SystemBackArrow",i.CustomBackArrow="CustomBackArrow",i.NoItem="NoItem",i.UserProfile="UserProfile";var a={supports:function(){return!1},handleAction:function(e){console.log("--"+e.type+"-isUnknown")}};function s(e){return["setHeaderMenuItemClickHandler","setCustomBackArrowOnClickHandler","setTabActiveHandler","setShakeHandler"].includes(e.type)}var u=function(e){switch(e.type){case"setShakeHandler":window.onAituBridgeShake=e.payload[0];break;case"setCustomBackArrowOnClickHandler":window.onAituBridgeBackArrowClick=e.payload[0];break;case"setHeaderMenuItemClickHandler":window.onAituBridgeHeaderMenuItemClick=e.payload[0];break;case"setTabActiveHandler":window.onAituBridgeTabActive=e.payload[0]}};function d(e){return{type:"awaitResponse",actionId:e}}var l={isSupported:function(){return o()&&!!window.AndroidBridge},makeActionHandler:function(){return{supports:function(e){var t;return"function"==typeof(null==(t=window)||null==(t=t.AndroidBridge)?void 0:t[e])},handleAction:function(e){var t,n=null==(t=window)?void 0:t.AndroidBridge;return n[e.type]?s(e)?u(e):(n[e.type].apply(n,[e.id].concat(function(e){if("storage"===e.type||"invoke"===e.type){var t=e.payload,n=t[1];return[t[0],JSON.stringify(void 0===n?{}:n)]}return"setHeaderMenuItems"===e.type||"vibrate"===e.type?[JSON.stringify(e.payload[0])]:Array.isArray(e.payload)?e.payload:[]}(e))),d(e.id)):a.handleAction(e)}}}};function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}var p={isSupported:function(){return o()&&!!window.webkit&&!!window.webkit.messageHandlers},makeActionHandler:function(){return{supports:function(e){var t;return"function"==typeof(null==(t=window.webkit)||null==(t=t.messageHandlers)||null==(t=t[e])?void 0:t.postMessage)},handleAction:function(e){var t,n=null==(t=window)||null==(t=t.webkit)?void 0:t.messageHandlers;return n[e.type]?s(e)?u(e):(n[e.type].postMessage(c({reqId:e.id},function(e){var t=e.payload;switch(e.type){case"storage":case"invoke":var n=t[1];return{method:t[0],data:void 0===n?{}:n};case"activateESim":return{activationCode:t[0]};case"readNFCPassport":return{passportNumber:t[0],dateOfBirth:t[1],expirationDate:t[2]};case"setCustomBackArrowMode":return{enabled:t[0]};case"setCustomBackArrowVisible":return{visible:t[0]};case"setNavigationItemMode":return{mode:t[0]};case"share":case"setTitle":case"copyToClipboard":return{text:t[0]};case"shareFile":return{text:t[0],filename:t[1],base64Data:t[2]};case"openExternalUrl":return{url:t[0]};case"openPayment":return{transactionId:t[0]};case"setHeaderMenuItems":return{itemsJsonArray:JSON.stringify(t[0])};case"vibrate":return{pattern:t[0]};default:return{}}}(e))),d(e.id)):a.handleAction(e)}}}},f=function(e){if("storage"===e.type||"invoke"===e.type){var t=e.payload,n=t[1];return[t[0],void 0===n?{}:n]}return"setHeaderMenuItems"===e.type?[JSON.stringify(e.payload[0])]:e.payload},g={isSupported:function(){return o()&&function(){if(!globalThis.window)return!1;try{return window.self!==window.top}catch(e){return!0}}()},makeActionHandler:function(){var e=new URLSearchParams(window.location.search).get("__aitu-domain");return e?localStorage.setItem("mini-app-domain",e):e=localStorage.getItem("mini-app-domain"),e?(window.addEventListener("message",function(t){if(t.origin===e&&t.data){if(window.dispatchEvent(new CustomEvent("aituEvents",{detail:t.data})),"string"!=typeof t.data||""===t.data)return;try{var n=JSON.parse(t.data);n&&n.method&&("setCustomBackArrowOnClickHandler"===n.method?null==window.onAituBridgeBackArrowClick||window.onAituBridgeBackArrowClick():"setHeaderMenuItemClickHandler"===n.method&&(null==window.onAituBridgeHeaderMenuItemClick||window.onAituBridgeHeaderMenuItemClick(n.param)))}catch(e){console.log("Error parsing message data: "+e)}}}),{supports:function(){return!1},handleAction:function(t){var n;return s(t)?u(t):"getUserStepInfo"===t.type||"openExternalUrl"===t.type||"openPayment"===t.type?a.handleAction(t):(null==(n=window)||null==(n=n.top)||n.postMessage({source:"aitu-bridge",method:t.type,reqId:t.id,payload:[].concat(f(t))},e),d(t.id))}}):a}},m=function(){var t,n,r,i,s=[l,p,g].find(function(e){return e.isSupported()}),u=null!=(t=null==s?void 0:s.makeActionHandler())?t:a,d=(n={},function(e){var t,r=(null!=(t=n[e])?t:0)+1;return n[e]=r,e+":"+r}),c=(r={handler:u,generateId:d},i=function(e,t,n){var i,o,a=null!=(i=null==n?void 0:n.generateId)?i:function(){return r.generateId(e)},s=null!=(o=null==n?void 0:n.validate)?o:function(){return!0},u=a.apply(void 0,t),d=s.apply(void 0,t);if("string"!=typeof d)return r.handler.handleAction({type:e,payload:t,id:u});console.error(d)},{createHandlerAction:function(e,t){return function(){i(e,[].slice.call(arguments),t)}},createAction:function(e,t){return function(){var n,r=i(e,[].slice.call(arguments),t);return"awaitResponse"===(null==r?void 0:r.type)?(n=r.actionId,new Promise(function(e,t){var r=function(i){var o;if((null==(o=i.detail)?void 0:o.reqId)===n){var a=i.detail,s=a.data,u=a.error;u?t(u):e(s),window.removeEventListener("aituEvents",r)}};window.addEventListener("aituEvents",r)})):new Promise(function(){})}}}),f=c.createAction,m=c.createHandlerAction,v=[];o()&&window.addEventListener("aituEvents",function(e){[].concat(v).map(function(t){return t.call(null,e)})});var w=u.supports,y=f("isESimSupported"),k=f("activateESim"),b=f("readNFCData"),h=f("readNFCPassport"),I=f("subscribeUserStepInfo"),S=f("unsubscribeUserStepInfo"),A=f("openUserProfile"),C=f("openSettings"),E=f("closeApplication"),M=f("enableSwipeBack"),B=f("disableSwipeBack"),H=f("storage"),P=m("setShakeHandler"),N=m("setTabActiveHandler"),U=m("setHeaderMenuItemClickHandler"),O=m("setCustomBackArrowOnClickHandler"),q=f("enableScreenCapture"),R=f("disableScreenCapture"),T=f("invoke",{generateId:function(e){return d(e+":invoke")}}),D=f("setCustomBackArrowMode"),x=f("getCustomBackArrowMode"),F=f("setCustomBackArrowVisible"),G=f("getNavigationItemMode"),J=f("setNavigationItemMode"),L=f("share"),V=f("shareFile"),j=f("getGeo"),Q=f("getQr"),W=f("getSMSCode"),_=f("selectContact"),z=f("setTitle"),K=f("copyToClipboard"),X=f("checkBiometry"),Y=f("getUserStepInfo"),Z=f("openExternalUrl"),$=f("openPayment"),ee=f("setHeaderMenuItems",{validate:function(e){return!(e.length>3)||"SetHeaderMenuItems: items count should not be more than 3"}}),te=f("vibrate",{validate:function(e){return!(!Array.isArray(e)||e.some(function(e){return e<1||e!==Math.floor(e)})||e.reduce(function(e,t){return e+t})>1e4)||"Pattern should be an array of positive integers no longer than 10000ms total"}});return{version:"0.8.0",copyToClipboard:K,invoke:T,storage:{getItem:function(e){return H("getItem",{keyName:e})},setItem:function(e,t){return H("setItem",{keyName:e,keyValue:t})},clear:function(){return H("clear")}},getMe:function(){return T(e.EInvokeRequest.getMe)},getPhone:function(){return T(e.EInvokeRequest.getPhone)},getContacts:function(){return T(e.EInvokeRequest.getContacts)},getGeo:j,getQr:Q,getUserProfile:function(t){return T(e.EInvokeRequest.getUserProfile,{id:t})},getSMSCode:W,openUserProfile:A,selectContact:_,enableNotifications:function(){return T(e.EInvokeRequest.enableNotifications)},disableNotifications:function(){return T(e.EInvokeRequest.disableNotifications)},enablePrivateMessaging:function(t){return T(e.EInvokeRequest.enablePrivateMessaging,{appId:t})},disablePrivateMessaging:function(t){return T(e.EInvokeRequest.disablePrivateMessaging,{appId:t})},openSettings:C,closeApplication:E,setTitle:z,share:L,shareImage:function(e,t){var n,r,i="image."+(null!=(n=null==(r=t.split(";"))||null==(r=r[0])?void 0:r.split("/")[1])?n:""),o=t.substr(t.indexOf(",")+1);return V(e,i,o)},shareFile:V,setShakeHandler:P,setTabActiveHandler:N,vibrate:te,isSupported:function(){return u!==a},supports:w,sub:function(e){v.push(e)},enableScreenCapture:q,disableScreenCapture:R,setHeaderMenuItems:ee,setHeaderMenuItemClickHandler:U,setCustomBackArrowMode:D,getCustomBackArrowMode:x,setCustomBackArrowVisible:F,openPayment:$,setCustomBackArrowOnClickHandler:O,checkBiometry:X,openExternalUrl:Z,enableSwipeBack:M,disableSwipeBack:B,setNavigationItemMode:J,getNavigationItemMode:G,getUserStepInfo:Y,isESimSupported:y,activateESim:k,readNFCData:b,subscribeUserStepInfo:I,unsubscribeUserStepInfo:S,readNFCPassport:h}}();e.classifyBridgeError=function(t){if(t.msg){if(t.msg.startsWith("permission deny"))return e.BridgeErrors.PermissionDenyError;if(t.msg.startsWith("permission security deny"))return e.BridgeErrors.PermissionSecurityDenyError}return e.BridgeErrors.OtherError},e.default=m});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -21,13 +21,8 @@ type AndroidBridgeShape<Methods extends string, T extends Record<Methods, unknow
|
|
|
21
21
|
type IosBridgeShape<Methods extends string, T extends Record<Methods, Record<string, unknown>>> = {
|
|
22
22
|
[P in keyof T]: PostMessageMethod<T[P]>;
|
|
23
23
|
};
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
setTabActiveHandler: (handler: (tabname: string) => void) => void;
|
|
27
|
-
setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
|
|
28
|
-
setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;
|
|
29
|
-
};
|
|
30
|
-
export type AndroidBridge = AndroidBridgeShape<RequestMethods, {
|
|
24
|
+
export type HandlerMethods = 'setShakeHandler' | 'setTabActiveHandler' | 'setCustomBackArrowOnClickHandler' | 'setHeaderMenuItemClickHandler';
|
|
25
|
+
export type AndroidBridge = AndroidBridgeShape<RequestMethods | HandlerMethods, {
|
|
31
26
|
copyToClipboard: [text: string];
|
|
32
27
|
invoke: [method: string, data: string];
|
|
33
28
|
storage: [method: string, data: string];
|
|
@@ -62,7 +57,11 @@ export type AndroidBridge = AndroidBridgeShape<RequestMethods, {
|
|
|
62
57
|
subscribeUserStepInfo: [];
|
|
63
58
|
unsubscribeUserStepInfo: [];
|
|
64
59
|
openUserProfile: [];
|
|
65
|
-
|
|
60
|
+
setShakeHandler: [];
|
|
61
|
+
setCustomBackArrowOnClickHandler: [];
|
|
62
|
+
setHeaderMenuItemClickHandler: [];
|
|
63
|
+
setTabActiveHandler: [];
|
|
64
|
+
}>;
|
|
66
65
|
type IosBridgeParamsMap = {
|
|
67
66
|
copyToClipboard: {
|
|
68
67
|
text: string;
|
|
@@ -136,15 +135,17 @@ type IosBridgeParamsMap = {
|
|
|
136
135
|
openUserProfile: {};
|
|
137
136
|
};
|
|
138
137
|
export type IosParams<F extends RequestMethods> = IosBridgeParamsMap[F];
|
|
139
|
-
export type IosBridge = IosBridgeShape<RequestMethods, IosBridgeParamsMap> &
|
|
138
|
+
export type IosBridge = IosBridgeShape<RequestMethods, IosBridgeParamsMap> & {
|
|
139
|
+
[P in HandlerMethods]: PostMessageMethod;
|
|
140
|
+
};
|
|
140
141
|
export type UnsafeAndroidBridge = {
|
|
141
|
-
[K in RequestMethods]: (reqId: string, ...args: unknown[]) => void;
|
|
142
|
-
}
|
|
142
|
+
[K in RequestMethods | HandlerMethods]: (reqId: string, ...args: unknown[]) => void;
|
|
143
|
+
};
|
|
143
144
|
export type UnsafeIosBridge = {
|
|
144
|
-
[key in RequestMethods]: PostMessageMethod<{
|
|
145
|
+
[key in RequestMethods | HandlerMethods]: PostMessageMethod<{
|
|
145
146
|
[key: string]: unknown;
|
|
146
147
|
}>;
|
|
147
|
-
}
|
|
148
|
+
};
|
|
148
149
|
/**
|
|
149
150
|
* @public
|
|
150
151
|
* Represents an event handler for Aitu bridge events.
|
|
@@ -586,18 +587,22 @@ export interface AituBridge {
|
|
|
586
587
|
/**
|
|
587
588
|
* Enables or disables custom back arrow handling.
|
|
588
589
|
*
|
|
590
|
+
* @deprecated Use {@link AituBridge.setNavigationItemMode} instead.
|
|
589
591
|
* @param enabled - Whether custom handling is enabled
|
|
590
592
|
* @returns A promise resolving to a SuccessResponse indicating the result of the operation.
|
|
591
593
|
*/
|
|
592
594
|
setCustomBackArrowMode: (enabled: boolean) => Promise<SuccessResponse>;
|
|
593
595
|
/**
|
|
594
596
|
* Returns whether custom back arrow mode is enabled.
|
|
597
|
+
*
|
|
598
|
+
* @deprecated Use {@link AituBridge.getNavigationItemMode} instead.
|
|
595
599
|
* @returns A promise resolving to a boolean indicating the current mode.
|
|
596
600
|
*/
|
|
597
601
|
getCustomBackArrowMode: () => Promise<boolean>;
|
|
598
602
|
/**
|
|
599
603
|
* Controls the visibility of the custom back arrow.
|
|
600
604
|
*
|
|
605
|
+
* @deprecated Use {@link AituBridge.setNavigationItemMode} instead.
|
|
601
606
|
* @param visible - Arrow visibility state
|
|
602
607
|
* @returns A promise resolving to a {@link SuccessResponse} indicating the result of the operation.
|
|
603
608
|
*/
|
|
@@ -726,9 +731,63 @@ export interface AituBridge {
|
|
|
726
731
|
* @internal
|
|
727
732
|
*/
|
|
728
733
|
export type PublicApiMethods = Exclude<keyof Pick<AituBridge, RequestMethods>, 'storage'>;
|
|
734
|
+
export type Action<Type extends string = string, Payload extends unknown[] = unknown[]> = {
|
|
735
|
+
type: Type;
|
|
736
|
+
payload: Payload;
|
|
737
|
+
} & {
|
|
738
|
+
id: string;
|
|
739
|
+
};
|
|
740
|
+
export type AsyncAction<Type extends string = string, Payload extends unknown[] = unknown[], Result = unknown> = Action<Type, Payload> & {
|
|
741
|
+
__result: Result;
|
|
742
|
+
};
|
|
743
|
+
type SelectActionByType<T> = Extract<BridgeAction, {
|
|
744
|
+
type: T;
|
|
745
|
+
}>;
|
|
746
|
+
/**
|
|
747
|
+
* @internal
|
|
748
|
+
*/
|
|
749
|
+
export type EmptyResponse = Record<string, never>;
|
|
729
750
|
/**
|
|
730
751
|
* @internal
|
|
731
752
|
*/
|
|
732
|
-
export type
|
|
753
|
+
export type ActionPayload<T> = SelectActionByType<T>['payload'];
|
|
754
|
+
export type SetHandlerAction = Action<'setHeaderMenuItemClickHandler', Parameters<AituBridge['setHeaderMenuItemClickHandler']>> | Action<'setCustomBackArrowOnClickHandler', Parameters<AituBridge['setCustomBackArrowOnClickHandler']>> | Action<'setTabActiveHandler', Parameters<AituBridge['setTabActiveHandler']>> | Action<'setShakeHandler', Parameters<AituBridge['setShakeHandler']>>;
|
|
755
|
+
export type InvokableAction = AsyncAction<'storage', [operation: 'getItem', data: {
|
|
756
|
+
keyName: string;
|
|
757
|
+
}], string | null> | AsyncAction<'storage', [operation: 'setItem', data: {
|
|
758
|
+
keyName: string;
|
|
759
|
+
keyValue: string;
|
|
760
|
+
}], SuccessResponse> | AsyncAction<'storage', [operation: 'clear'], SuccessResponse> | AsyncAction<'invoke', [method: EInvokeRequest.getMe], GetMeResponse> | AsyncAction<'invoke', [method: EInvokeRequest.getPhone], GetPhoneResponse> | AsyncAction<'invoke', [method: EInvokeRequest.getContacts], GetContactsResponse> | AsyncAction<'invoke', [method: EInvokeRequest.getUserProfile, data: {
|
|
761
|
+
id: string;
|
|
762
|
+
}], GetUserProfileResponse> | AsyncAction<'invoke', [method: EInvokeRequest.enableNotifications], EmptyResponse> | AsyncAction<'invoke', [method: EInvokeRequest.disableNotifications], EmptyResponse> | AsyncAction<'invoke', [method: EInvokeRequest.enablePrivateMessaging, data: {
|
|
763
|
+
appId: string;
|
|
764
|
+
}], EmptyResponse> | AsyncAction<'invoke', [method: EInvokeRequest.disablePrivateMessaging, data: {
|
|
765
|
+
appId: string;
|
|
766
|
+
}], EmptyResponse> | AsyncAction<'activateESim', [activationCode: string], SuccessResponse> | AsyncAction<'readNFCData', never, string> | AsyncAction<'openUserProfile', never, SuccessResponse> | AsyncAction<'openSettings', never, SuccessResponse> | AsyncAction<'closeApplication', never, SuccessResponse> | AsyncAction<'enableSwipeBack', never, SuccessResponse> | AsyncAction<'disableSwipeBack', never, SuccessResponse> | AsyncAction<'isESimSupported', never, SuccessResponse> | AsyncAction<'subscribeUserStepInfo', never, SuccessResponse> | AsyncAction<'unsubscribeUserStepInfo', never, SuccessResponse> | AsyncAction<'readNFCPassport', [passportNumber: string, dateOfBirth: string, expirationDate: string], PassportDataResponse> | AsyncAction<'enableScreenCapture', never, Record<string, never>> | AsyncAction<'disableScreenCapture', never, Record<string, never>> | AsyncAction<'getCustomBackArrowMode', never, boolean> | AsyncAction<'setCustomBackArrowMode', [enabled: boolean], SuccessResponse> | AsyncAction<'setCustomBackArrowVisible', [visible: boolean], SuccessResponse> | AsyncAction<'getNavigationItemMode', never, NavigationItemMode> | AsyncAction<'setNavigationItemMode', [mode: NavigationItemMode], SuccessResponse> | AsyncAction<'share', [text: string], SuccessResponse> | AsyncAction<'shareFile', [text: string, filename: string, base64Data: string], SuccessResponse> | AsyncAction<'getGeo', never, GetGeoResponse> | AsyncAction<'getQr', never, string> | AsyncAction<'getSMSCode', never, string> | AsyncAction<'selectContact', never, SelectContactResponse> | AsyncAction<'setTitle', [title: string], SuccessResponse> | AsyncAction<'copyToClipboard', [text: string], SuccessResponse> | AsyncAction<'checkBiometry', never, BiometryResponse> | AsyncAction<'getUserStepInfo', never, UserStepInfoResponse> | AsyncAction<'openExternalUrl', [url: string], SuccessResponse> | AsyncAction<'openPayment', [transactionId: string], SuccessResponse> | AsyncAction<'setHeaderMenuItems', [items: HeaderMenuItem[]], SuccessResponse> | AsyncAction<'vibrate', [pattern: number[]], SuccessResponse>;
|
|
767
|
+
/**
|
|
768
|
+
* @internal
|
|
769
|
+
*/
|
|
770
|
+
export type BridgeAction = InvokableAction | SetHandlerAction;
|
|
771
|
+
/**
|
|
772
|
+
* @internal
|
|
773
|
+
*/
|
|
774
|
+
export type HandlerResult = void | {
|
|
775
|
+
type: 'awaitResponse';
|
|
776
|
+
actionId: string;
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* @internal
|
|
780
|
+
*/
|
|
781
|
+
export type ActionHandler<T extends Action = Action> = {
|
|
782
|
+
supports: (methodName: string) => boolean;
|
|
783
|
+
handleAction: (action: T) => HandlerResult;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* @internal
|
|
787
|
+
*/
|
|
788
|
+
export interface ActionHandlerFactory {
|
|
789
|
+
isSupported: () => boolean;
|
|
790
|
+
makeActionHandler(): ActionHandler<BridgeAction>;
|
|
791
|
+
}
|
|
733
792
|
export {};
|
|
734
793
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btsd/aitu-bridge",
|
|
3
|
-
"version": "0.8.0
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/btsdigital/aitu-bridge#readme",
|
|
39
39
|
"devDependencies": {
|
|
40
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
40
41
|
"@microsoft/api-extractor": "^7.55.2",
|
|
41
42
|
"@vitest/coverage-v8": "^4.0.16",
|
|
42
43
|
"jsdom": "^27.4.0",
|
package/dist/utils.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AituEventHandler } from "./types";
|
|
2
|
-
export declare function promisifyStorage(storage: (reqId: string, method: string, props: Record<string, string>) => void, subscribe: (fn: AituEventHandler) => void): {
|
|
3
|
-
setItem: (keyName: string, keyValue: string) => Promise<void>;
|
|
4
|
-
getItem: (keyName: string) => Promise<string | null>;
|
|
5
|
-
clear: () => Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare function promisifyInvoke(invoke: (reqId: string, methodName: string, props: any) => void, subscribe: (fn: AituEventHandler) => void): (invokeMethodName: string, props?: any) => Promise<any | void>;
|
|
8
|
-
export declare function promisifyMethod<Result, Fn extends (...args: any[]) => any = (...args: any) => any>(method: Fn, methodName: string, subscribe: (fn: AituEventHandler) => void): (...args: Parameters<Fn>) => Promise<Result>;
|
|
9
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/waitResponse.d.ts
DELETED
package/dist/webBridge.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RequestMethods } from './types';
|
|
2
|
-
export interface WebBridge {
|
|
3
|
-
execute(method: RequestMethods, reqId: string, ...payload: unknown[]): void;
|
|
4
|
-
origin: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const createWebBridge: () => WebBridge | null;
|
|
7
|
-
//# sourceMappingURL=webBridge.d.ts.map
|