@vkontakte/vk-bridge
Advanced tools
Comparing version 2.9.0-beta.0 to 2.9.0
@@ -1,2 +0,2 @@ | ||
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var p in t=arguments[n])Object.prototype.hasOwnProperty.call(t,p)&&(e[p]=t[p]);return e},e.apply(this,arguments)};function t(e,t,n){if(n||2===arguments.length)for(var o,p=0,r=t.length;p<r;p++)!o&&p in t||(o||(o=Array.prototype.slice.call(t,0,p)),o[p]=t[p]);return e.concat(o||Array.prototype.slice.call(t))}function n(t,n){var o,p,r=(o={current:0,next:function(){return++this.current}},p={},{add:function(e,t){var n=null!=t?t:o.next();return p[n]=e,n},resolve:function(e,t,n){var o=p[e];o&&(n(t)?o.resolve(t):o.reject(t),p[e]=null)}});return n((function(e){if(e.detail&&e.detail.data&&"object"==typeof e.detail.data&&"request_id"in e.detail.data){var t=e.detail.data,n=t.request_id,o=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var p=0;for(o=Object.getOwnPropertySymbols(e);p<o.length;p++)t.indexOf(o[p])<0&&Object.prototype.propertyIsEnumerable.call(e,o[p])&&(n[o[p]]=e[o[p]])}return n}(t,["request_id"]);n&&r.resolve(n,o,(function(e){return!("error_type"in e)}))}})),function(n,o){return void 0===o&&(o={}),new Promise((function(p,i){var a=r.add({resolve:p,reject:i},o.request_id);t(n,e(e({},o),{request_id:a}))}))}}var o="undefined"!=typeof window,p=Boolean(o&&window.AndroidBridge),r=Boolean(o&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.VKWebAppClose),i=Boolean(o&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage),a=o&&!p&&!r,s=a&&/(^\?|&)vk_platform=mobile_web(&|$)/.test(location.search),d=a?"message":"VKWebAppEvent",b=t(["VKWebAppInit","VKWebAppGetCommunityAuthToken","VKWebAppAddToCommunity","VKWebAppAddToHomeScreenInfo","VKWebAppClose","VKWebAppCopyText","VKWebAppCreateHash","VKWebAppGetUserInfo","VKWebAppSetLocation","VKWebAppSendToClient","VKWebAppGetClientVersion","VKWebAppGetPhoneNumber","VKWebAppGetEmail","VKWebAppGetGroupInfo","VKWebAppGetGeodata","VKWebAppGetCommunityToken","VKWebAppGetConfig","VKWebAppGetLaunchParams","VKWebAppSetTitle","VKWebAppGetAuthToken","VKWebAppCallAPIMethod","VKWebAppJoinGroup","VKWebAppLeaveGroup","VKWebAppAllowMessagesFromGroup","VKWebAppDenyNotifications","VKWebAppAllowNotifications","VKWebAppOpenPayForm","VKWebAppOpenApp","VKWebAppShare","VKWebAppShowWallPostBox","VKWebAppScroll","VKWebAppShowOrderBox","VKWebAppShowLeaderBoardBox","VKWebAppShowInviteBox","VKWebAppShowRequestBox","VKWebAppAddToFavorites","VKWebAppShowStoryBox","VKWebAppStorageGet","VKWebAppStorageGetKeys","VKWebAppStorageSet","VKWebAppFlashGetInfo","VKWebAppSubscribeStoryApp","VKWebAppOpenWallPost","VKWebAppCheckAllowedScopes","VKWebAppCheckBannerAd","VKWebAppHideBannerAd","VKWebAppShowBannerAd","VKWebAppCheckNativeAds","VKWebAppShowNativeAds","VKWebAppRetargetingPixel","VKWebAppConversionHit","VKWebAppShowSubscriptionBox","VKWebAppCheckSurvey","VKWebAppShowSurvey","VKWebAppScrollTop","VKWebAppScrollTopStart","VKWebAppScrollTopStop","VKWebAppShowSlidesSheet","VKWebAppTranslate"],a&&!s?["VKWebAppResizeWindow","VKWebAppAddToMenu","VKWebAppShowInstallPushBox","VKWebAppGetFriends","VKWebAppShowCommunityWidgetPreviewBox"]:["VKWebAppShowImages"],!0),u=o?window.AndroidBridge:void 0,A=r?window.webkit.messageHandlers:void 0,l=a?parent:void 0;var c,W,f,V,K,w,S;!function(e){e.REWARD="reward",e.INTERSTITIAL="interstitial"}(c||(c={})),function(e){e.RESIZE="resize",e.OVERLAY="overlay"}(W||(W={})),function(e){e.TOP="top",e.BOTTOM="bottom"}(f||(f={})),function(e){e.CAMERA="camera",e.LOCATION="location",e.PHOTO="photo"}(V||(V={})),function(e){e.RU="ru",e.UK="uk",e.UA="ua",e.EN="en",e.BE="be",e.KZ="kz",e.PT="pt",e.ES="es"}(K||(K={})),function(e){e.ADMIN="admin",e.EDITOR="editor",e.MEMBER="member",e.MODER="moder",e.NONE="none"}(w||(w={})),function(e){e.DESKTOP_WEB="desktop_web",e.DESKTOP_WEB_MESSENGER="desktop_web_messenger",e.DESKTOP_APP_MESSENGER="desktop_app_messenger",e.MOBILE_WEB="mobile_web",e.MOBILE_ANDROID="mobile_android",e.MOBILE_ANDROID_MESSENGER="mobile_android_messenger",e.MOBILE_IPHONE="mobile_iphone",e.MOBILE_IPHONE_MESSENGER="mobile_iphone_messenger",e.MOBILE_IPAD="mobile_ipad"}(S||(S={}));var v=function(e){var o=void 0,s=[];function c(e){s.push(e)}function W(){return r||p}function f(){return a&&window.parent!==window}function V(){return W()||f()}function K(e){if(r||p)return t([],s,!0).map((function(t){return t.call(null,e)}));var n=null==e?void 0:e.data;if(a&&n){if(i&&"string"==typeof n)try{n=JSON.parse(n)}catch(e){}var d=n.type,b=n.data,u=n.frameId;d&&("VKWebAppSettings"!==d?t([],s,!0).map((function(e){return e({detail:{type:d,data:b}})})):o=u)}}i&&/(android)/i.test(navigator.userAgent)?document.addEventListener(d,K):"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener(d,K);var w=n((function(t,n){u&&u[t]?u[t](JSON.stringify(n)):A&&A[t]&&"function"==typeof A[t].postMessage?A[t].postMessage(n):i?window.ReactNativeWebView.postMessage(JSON.stringify({handler:t,params:n})):l&&"function"==typeof l.postMessage&&l.postMessage({handler:t,params:n,type:"vk-connect",webFrameId:o,connectVersion:e},"*")}),c);return{send:w,sendPromise:w,subscribe:c,unsubscribe:function(e){var t=s.indexOf(e);t>-1&&s.splice(t,1)},supports:function(e){return p?!(!u||"function"!=typeof u[e]):r?!(!A||!A[e]||"function"!=typeof A[e].postMessage):!!a&&b.includes(e)},isWebView:W,isIframe:f,isEmbedded:V,isStandalone:function(){return!V()}}}("2.9.0-beta.0");window.vkBridge=window.vkConnect=v}(); | ||
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var p in t=arguments[n])Object.prototype.hasOwnProperty.call(t,p)&&(e[p]=t[p]);return e},e.apply(this,arguments)};function t(e,t,n){if(n||2===arguments.length)for(var o,p=0,r=t.length;p<r;p++)!o&&p in t||(o||(o=Array.prototype.slice.call(t,0,p)),o[p]=t[p]);return e.concat(o||Array.prototype.slice.call(t))}function n(t,n){var o,p,r=(o={current:0,next:function(){return++this.current}},p={},{add:function(e,t){var n=null!=t?t:o.next();return p[n]=e,n},resolve:function(e,t,n){var o=p[e];o&&(n(t)?o.resolve(t):o.reject(t),p[e]=null)}});return n((function(e){if(e.detail&&e.detail.data&&"object"==typeof e.detail.data&&"request_id"in e.detail.data){var t=e.detail.data,n=t.request_id,o=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var p=0;for(o=Object.getOwnPropertySymbols(e);p<o.length;p++)t.indexOf(o[p])<0&&Object.prototype.propertyIsEnumerable.call(e,o[p])&&(n[o[p]]=e[o[p]])}return n}(t,["request_id"]);n&&r.resolve(n,o,(function(e){return!("error_type"in e)}))}})),function(n,o){return void 0===o&&(o={}),new Promise((function(p,i){var a=r.add({resolve:p,reject:i},o.request_id);t(n,e(e({},o),{request_id:a}))}))}}var o="undefined"!=typeof window,p=Boolean(o&&window.AndroidBridge),r=Boolean(o&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.VKWebAppClose),i=Boolean(o&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage),a=o&&!p&&!r,s=a&&/(^\?|&)vk_platform=mobile_web(&|$)/.test(location.search),d=a?"message":"VKWebAppEvent",b=t(["VKWebAppInit","VKWebAppGetCommunityAuthToken","VKWebAppAddToCommunity","VKWebAppAddToHomeScreenInfo","VKWebAppClose","VKWebAppCopyText","VKWebAppCreateHash","VKWebAppGetUserInfo","VKWebAppSetLocation","VKWebAppSendToClient","VKWebAppGetClientVersion","VKWebAppGetPhoneNumber","VKWebAppGetEmail","VKWebAppGetGroupInfo","VKWebAppGetGeodata","VKWebAppGetCommunityToken","VKWebAppGetConfig","VKWebAppGetLaunchParams","VKWebAppSetTitle","VKWebAppGetAuthToken","VKWebAppCallAPIMethod","VKWebAppJoinGroup","VKWebAppLeaveGroup","VKWebAppAllowMessagesFromGroup","VKWebAppDenyNotifications","VKWebAppAllowNotifications","VKWebAppOpenPayForm","VKWebAppOpenApp","VKWebAppShare","VKWebAppShowWallPostBox","VKWebAppScroll","VKWebAppShowOrderBox","VKWebAppShowLeaderBoardBox","VKWebAppShowInviteBox","VKWebAppShowRequestBox","VKWebAppAddToFavorites","VKWebAppShowStoryBox","VKWebAppStorageGet","VKWebAppStorageGetKeys","VKWebAppStorageSet","VKWebAppFlashGetInfo","VKWebAppSubscribeStoryApp","VKWebAppOpenWallPost","VKWebAppCheckAllowedScopes","VKWebAppCheckBannerAd","VKWebAppHideBannerAd","VKWebAppShowBannerAd","VKWebAppCheckNativeAds","VKWebAppShowNativeAds","VKWebAppRetargetingPixel","VKWebAppConversionHit","VKWebAppShowSubscriptionBox","VKWebAppCheckSurvey","VKWebAppShowSurvey","VKWebAppScrollTop","VKWebAppScrollTopStart","VKWebAppScrollTopStop","VKWebAppShowSlidesSheet","VKWebAppTranslate"],a&&!s?["VKWebAppResizeWindow","VKWebAppAddToMenu","VKWebAppShowInstallPushBox","VKWebAppGetFriends","VKWebAppShowCommunityWidgetPreviewBox"]:["VKWebAppShowImages"],!0),u=o?window.AndroidBridge:void 0,A=r?window.webkit.messageHandlers:void 0,l=a?parent:void 0;var c,W,f,V,K,w,S;!function(e){e.REWARD="reward",e.INTERSTITIAL="interstitial"}(c||(c={})),function(e){e.RESIZE="resize",e.OVERLAY="overlay"}(W||(W={})),function(e){e.TOP="top",e.BOTTOM="bottom"}(f||(f={})),function(e){e.CAMERA="camera",e.LOCATION="location",e.PHOTO="photo"}(V||(V={})),function(e){e.RU="ru",e.UK="uk",e.UA="ua",e.EN="en",e.BE="be",e.KZ="kz",e.PT="pt",e.ES="es"}(K||(K={})),function(e){e.ADMIN="admin",e.EDITOR="editor",e.MEMBER="member",e.MODER="moder",e.NONE="none"}(w||(w={})),function(e){e.DESKTOP_WEB="desktop_web",e.DESKTOP_WEB_MESSENGER="desktop_web_messenger",e.DESKTOP_APP_MESSENGER="desktop_app_messenger",e.MOBILE_WEB="mobile_web",e.MOBILE_ANDROID="mobile_android",e.MOBILE_ANDROID_MESSENGER="mobile_android_messenger",e.MOBILE_IPHONE="mobile_iphone",e.MOBILE_IPHONE_MESSENGER="mobile_iphone_messenger",e.MOBILE_IPAD="mobile_ipad"}(S||(S={}));var v=function(e){var o=void 0,s=[];function c(e){s.push(e)}function W(){return r||p}function f(){return a&&window.parent!==window}function V(){return W()||f()}function K(e){if(r||p)return t([],s,!0).map((function(t){return t.call(null,e)}));var n=null==e?void 0:e.data;if(a&&n){if(i&&"string"==typeof n)try{n=JSON.parse(n)}catch(e){}var d=n.type,b=n.data,u=n.frameId;d&&("VKWebAppSettings"!==d?t([],s,!0).map((function(e){return e({detail:{type:d,data:b}})})):o=u)}}i&&/(android)/i.test(navigator.userAgent)?document.addEventListener(d,K):"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener(d,K);var w=n((function(t,n){u&&u[t]?u[t](JSON.stringify(n)):A&&A[t]&&"function"==typeof A[t].postMessage?A[t].postMessage(n):i?window.ReactNativeWebView.postMessage(JSON.stringify({handler:t,params:n})):l&&"function"==typeof l.postMessage&&l.postMessage({handler:t,params:n,type:"vk-connect",webFrameId:o,connectVersion:e},"*")}),c);return{send:w,sendPromise:w,subscribe:c,unsubscribe:function(e){var t=s.indexOf(e);t>-1&&s.splice(t,1)},supports:function(e){return p?!(!u||"function"!=typeof u[e]):r?!(!A||!A[e]||"function"!=typeof A[e].postMessage):!!a&&b.includes(e)},isWebView:W,isIframe:f,isEmbedded:V,isStandalone:function(){return!V()}}}("2.9.0");window.vkBridge=window.vkConnect=v}(); | ||
//# sourceMappingURL=browser.min.js.map |
@@ -418,3 +418,3 @@ /****************************************************************************** | ||
var version = "2.9.0-beta.0"; | ||
var version = "2.9.0"; | ||
@@ -517,6 +517,82 @@ var EAdsFormats; | ||
/** | ||
* @see https://dev.vk.com/mini-apps/development/launch-params | ||
*/ | ||
var parseURLSearchParamsForGetLaunchParams = function (searchParams) { | ||
var launchParams = {}; | ||
try { | ||
var parsedSearchParams = new URLSearchParams(searchParams); | ||
var convertToggleStateFromStringToNumber_1 = function (value) { | ||
switch (value) { | ||
case '0': | ||
return 0; | ||
case '1': | ||
return 1; | ||
default: | ||
return undefined; | ||
} | ||
}; | ||
parsedSearchParams.forEach(function (value, query) { | ||
switch (query) { | ||
case 'vk_ts': | ||
case 'vk_is_recommended': | ||
case 'vk_profile_id': | ||
case 'vk_has_profile_button': | ||
case 'vk_testing_group_id': | ||
case 'vk_user_id': | ||
case 'vk_app_id': | ||
case 'vk_group_id': | ||
launchParams[query] = Number(value); | ||
break; | ||
case 'sign': | ||
case 'vk_chat_id': | ||
case 'vk_ref': | ||
case 'vk_access_token_settings': | ||
launchParams[query] = value; | ||
break; | ||
case 'odr_enabled': | ||
launchParams['odr_enabled'] = value === '1' ? 1 : undefined; | ||
break; | ||
case 'vk_is_app_user': | ||
case 'vk_are_notifications_enabled': | ||
case 'vk_is_favorite': { | ||
launchParams[query] = convertToggleStateFromStringToNumber_1(value); | ||
break; | ||
} | ||
case 'vk_language': { | ||
var validateVKLanguage = function (value) { | ||
return Object.values(EGetLaunchParamsResponseLanguages).some(function (i) { return i === value; }); | ||
}; | ||
launchParams['vk_language'] = validateVKLanguage(value) ? value : undefined; | ||
break; | ||
} | ||
case 'vk_viewer_group_role': { | ||
var validateVKViewerGroupRole = function (value) { | ||
return Object.values(EGetLaunchParamsResponseGroupRole).some(function (i) { return i === value; }); | ||
}; | ||
launchParams['vk_viewer_group_role'] = validateVKViewerGroupRole(value) | ||
? value | ||
: undefined; | ||
break; | ||
} | ||
case 'vk_platform': { | ||
var validateVKPlatform = function (value) { | ||
return Object.values(EGetLaunchParamsResponsePlatforms).some(function (i) { return i === value; }); | ||
}; | ||
launchParams['vk_platform'] = validateVKPlatform(value) ? value : undefined; | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
catch (e) { | ||
console.warn(e); | ||
} | ||
return launchParams; | ||
}; | ||
// VK Bridge API | ||
var bridge = createVKBridge(version); | ||
export { BannerAdLayoutType, BannerAdLocation, EAdsFormats, EGetLaunchParamsResponseGroupRole, EGetLaunchParamsResponseLanguages, EGetLaunchParamsResponsePlatforms, EGrantedPermission, applyMiddleware, bridge as default }; | ||
export { BannerAdLayoutType, BannerAdLocation, EAdsFormats, EGetLaunchParamsResponseGroupRole, EGetLaunchParamsResponseLanguages, EGetLaunchParamsResponsePlatforms, EGrantedPermission, applyMiddleware, bridge as default, parseURLSearchParamsForGetLaunchParams }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return e=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t,o){if(o||2===arguments.length)for(var n,r=0,p=t.length;r<p;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}function o(t,o){var n,r,p=(n={current:0,next:function(){return++this.current}},r={},{add:function(e,t){var o=null!=t?t:n.next();return r[o]=e,o},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data&&"object"==typeof e.detail.data&&"request_id"in e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return void 0===n&&(n={}),new Promise((function(r,a){var i=p.add({resolve:r,reject:a},n.request_id);t(o,e(e({},n),{request_id:i}))}))}}var n="undefined"!=typeof window,r=Boolean(n&&window.AndroidBridge),p=Boolean(n&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.VKWebAppClose),a=Boolean(n&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage),i=n&&!r&&!p,s=i&&/(^\?|&)vk_platform=mobile_web(&|$)/.test(location.search),d=i?"message":"VKWebAppEvent",u=t(["VKWebAppInit","VKWebAppGetCommunityAuthToken","VKWebAppAddToCommunity","VKWebAppAddToHomeScreenInfo","VKWebAppClose","VKWebAppCopyText","VKWebAppCreateHash","VKWebAppGetUserInfo","VKWebAppSetLocation","VKWebAppSendToClient","VKWebAppGetClientVersion","VKWebAppGetPhoneNumber","VKWebAppGetEmail","VKWebAppGetGroupInfo","VKWebAppGetGeodata","VKWebAppGetCommunityToken","VKWebAppGetConfig","VKWebAppGetLaunchParams","VKWebAppSetTitle","VKWebAppGetAuthToken","VKWebAppCallAPIMethod","VKWebAppJoinGroup","VKWebAppLeaveGroup","VKWebAppAllowMessagesFromGroup","VKWebAppDenyNotifications","VKWebAppAllowNotifications","VKWebAppOpenPayForm","VKWebAppOpenApp","VKWebAppShare","VKWebAppShowWallPostBox","VKWebAppScroll","VKWebAppShowOrderBox","VKWebAppShowLeaderBoardBox","VKWebAppShowInviteBox","VKWebAppShowRequestBox","VKWebAppAddToFavorites","VKWebAppShowStoryBox","VKWebAppStorageGet","VKWebAppStorageGetKeys","VKWebAppStorageSet","VKWebAppFlashGetInfo","VKWebAppSubscribeStoryApp","VKWebAppOpenWallPost","VKWebAppCheckAllowedScopes","VKWebAppCheckBannerAd","VKWebAppHideBannerAd","VKWebAppShowBannerAd","VKWebAppCheckNativeAds","VKWebAppShowNativeAds","VKWebAppRetargetingPixel","VKWebAppConversionHit","VKWebAppShowSubscriptionBox","VKWebAppCheckSurvey","VKWebAppShowSurvey","VKWebAppScrollTop","VKWebAppScrollTopStart","VKWebAppScrollTopStop","VKWebAppShowSlidesSheet","VKWebAppTranslate"],i&&!s?["VKWebAppResizeWindow","VKWebAppAddToMenu","VKWebAppShowInstallPushBox","VKWebAppGetFriends","VKWebAppShowCommunityWidgetPreviewBox"]:["VKWebAppShowImages"],!0),l=n?window.AndroidBridge:void 0,b=p?window.webkit.messageHandlers:void 0,c=i?parent:void 0;var A,f,W,V,K,m,w;exports.EAdsFormats=void 0,(A=exports.EAdsFormats||(exports.EAdsFormats={})).REWARD="reward",A.INTERSTITIAL="interstitial",exports.BannerAdLayoutType=void 0,(f=exports.BannerAdLayoutType||(exports.BannerAdLayoutType={})).RESIZE="resize",f.OVERLAY="overlay",exports.BannerAdLocation=void 0,(W=exports.BannerAdLocation||(exports.BannerAdLocation={})).TOP="top",W.BOTTOM="bottom",exports.EGrantedPermission=void 0,(V=exports.EGrantedPermission||(exports.EGrantedPermission={})).CAMERA="camera",V.LOCATION="location",V.PHOTO="photo",exports.EGetLaunchParamsResponseLanguages=void 0,(K=exports.EGetLaunchParamsResponseLanguages||(exports.EGetLaunchParamsResponseLanguages={})).RU="ru",K.UK="uk",K.UA="ua",K.EN="en",K.BE="be",K.KZ="kz",K.PT="pt",K.ES="es",exports.EGetLaunchParamsResponseGroupRole=void 0,(m=exports.EGetLaunchParamsResponseGroupRole||(exports.EGetLaunchParamsResponseGroupRole={})).ADMIN="admin",m.EDITOR="editor",m.MEMBER="member",m.MODER="moder",m.NONE="none",exports.EGetLaunchParamsResponsePlatforms=void 0,(w=exports.EGetLaunchParamsResponsePlatforms||(exports.EGetLaunchParamsResponsePlatforms={})).DESKTOP_WEB="desktop_web",w.DESKTOP_WEB_MESSENGER="desktop_web_messenger",w.DESKTOP_APP_MESSENGER="desktop_app_messenger",w.MOBILE_WEB="mobile_web",w.MOBILE_ANDROID="mobile_android",w.MOBILE_ANDROID_MESSENGER="mobile_android_messenger",w.MOBILE_IPHONE="mobile_iphone",w.MOBILE_IPHONE_MESSENGER="mobile_iphone_messenger",w.MOBILE_IPAD="mobile_ipad";var v=function(e){var n=void 0,s=[];function A(e){s.push(e)}function f(){return p||r}function W(){return i&&window.parent!==window}function V(){return f()||W()}function K(e){if(p||r)return t([],s,!0).map((function(t){return t.call(null,e)}));var o=null==e?void 0:e.data;if(i&&o){if(a&&"string"==typeof o)try{o=JSON.parse(o)}catch(e){}var d=o.type,u=o.data,l=o.frameId;d&&("VKWebAppSettings"!==d?t([],s,!0).map((function(e){return e({detail:{type:d,data:u}})})):n=l)}}a&&/(android)/i.test(navigator.userAgent)?document.addEventListener(d,K):"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener(d,K);var m=o((function(t,o){l&&l[t]?l[t](JSON.stringify(o)):b&&b[t]&&"function"==typeof b[t].postMessage?b[t].postMessage(o):a?window.ReactNativeWebView.postMessage(JSON.stringify({handler:t,params:o})):c&&"function"==typeof c.postMessage&&c.postMessage({handler:t,params:o,type:"vk-connect",webFrameId:n,connectVersion:e},"*")}),A);return{send:m,sendPromise:m,subscribe:A,unsubscribe:function(e){var t=s.indexOf(e);t>-1&&s.splice(t,1)},supports:function(e){return r?!(!l||"function"!=typeof l[e]):p?!(!b||!b[e]||"function"!=typeof b[e].postMessage):!!i&&u.includes(e)},isWebView:f,isIframe:W,isEmbedded:V,isStandalone:function(){return!V()}}}("2.9.0-beta.0");exports.applyMiddleware=function t(){for(var o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return o.includes(void 0)||o.includes(null)?t.apply(void 0,o.filter((function(e){return"function"==typeof e}))):function(t){if(0===o.length)return t;var n,r={subscribe:t.subscribe,send:function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];return t.send.apply(t,e)}},p=o.filter((function(e){return"function"==typeof e})).map((function(e){return e(r)})).reduce((function(e,t){return function(o){return e(t(o))}}));return n=p(t.send),e(e({},t),{send:n})}},exports.default=v; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return e=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t,o){if(o||2===arguments.length)for(var n,r=0,a=t.length;r<a;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}function o(t,o){var n,r,a=(n={current:0,next:function(){return++this.current}},r={},{add:function(e,t){var o=null!=t?t:n.next();return r[o]=e,o},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data&&"object"==typeof e.detail.data&&"request_id"in e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&a.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return void 0===n&&(n={}),new Promise((function(r,p){var s=a.add({resolve:r,reject:p},n.request_id);t(o,e(e({},n),{request_id:s}))}))}}var n="undefined"!=typeof window,r=Boolean(n&&window.AndroidBridge),a=Boolean(n&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.VKWebAppClose),p=Boolean(n&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage),s=n&&!r&&!a,i=s&&/(^\?|&)vk_platform=mobile_web(&|$)/.test(location.search),u=s?"message":"VKWebAppEvent",d=t(["VKWebAppInit","VKWebAppGetCommunityAuthToken","VKWebAppAddToCommunity","VKWebAppAddToHomeScreenInfo","VKWebAppClose","VKWebAppCopyText","VKWebAppCreateHash","VKWebAppGetUserInfo","VKWebAppSetLocation","VKWebAppSendToClient","VKWebAppGetClientVersion","VKWebAppGetPhoneNumber","VKWebAppGetEmail","VKWebAppGetGroupInfo","VKWebAppGetGeodata","VKWebAppGetCommunityToken","VKWebAppGetConfig","VKWebAppGetLaunchParams","VKWebAppSetTitle","VKWebAppGetAuthToken","VKWebAppCallAPIMethod","VKWebAppJoinGroup","VKWebAppLeaveGroup","VKWebAppAllowMessagesFromGroup","VKWebAppDenyNotifications","VKWebAppAllowNotifications","VKWebAppOpenPayForm","VKWebAppOpenApp","VKWebAppShare","VKWebAppShowWallPostBox","VKWebAppScroll","VKWebAppShowOrderBox","VKWebAppShowLeaderBoardBox","VKWebAppShowInviteBox","VKWebAppShowRequestBox","VKWebAppAddToFavorites","VKWebAppShowStoryBox","VKWebAppStorageGet","VKWebAppStorageGetKeys","VKWebAppStorageSet","VKWebAppFlashGetInfo","VKWebAppSubscribeStoryApp","VKWebAppOpenWallPost","VKWebAppCheckAllowedScopes","VKWebAppCheckBannerAd","VKWebAppHideBannerAd","VKWebAppShowBannerAd","VKWebAppCheckNativeAds","VKWebAppShowNativeAds","VKWebAppRetargetingPixel","VKWebAppConversionHit","VKWebAppShowSubscriptionBox","VKWebAppCheckSurvey","VKWebAppShowSurvey","VKWebAppScrollTop","VKWebAppScrollTopStart","VKWebAppScrollTopStop","VKWebAppShowSlidesSheet","VKWebAppTranslate"],s&&!i?["VKWebAppResizeWindow","VKWebAppAddToMenu","VKWebAppShowInstallPushBox","VKWebAppGetFriends","VKWebAppShowCommunityWidgetPreviewBox"]:["VKWebAppShowImages"],!0),c=n?window.AndroidBridge:void 0,l=a?window.webkit.messageHandlers:void 0,b=s?parent:void 0;var A,f,v,m,W,_,w;exports.EAdsFormats=void 0,(A=exports.EAdsFormats||(exports.EAdsFormats={})).REWARD="reward",A.INTERSTITIAL="interstitial",exports.BannerAdLayoutType=void 0,(f=exports.BannerAdLayoutType||(exports.BannerAdLayoutType={})).RESIZE="resize",f.OVERLAY="overlay",exports.BannerAdLocation=void 0,(v=exports.BannerAdLocation||(exports.BannerAdLocation={})).TOP="top",v.BOTTOM="bottom",exports.EGrantedPermission=void 0,(m=exports.EGrantedPermission||(exports.EGrantedPermission={})).CAMERA="camera",m.LOCATION="location",m.PHOTO="photo",exports.EGetLaunchParamsResponseLanguages=void 0,(W=exports.EGetLaunchParamsResponseLanguages||(exports.EGetLaunchParamsResponseLanguages={})).RU="ru",W.UK="uk",W.UA="ua",W.EN="en",W.BE="be",W.KZ="kz",W.PT="pt",W.ES="es",exports.EGetLaunchParamsResponseGroupRole=void 0,(_=exports.EGetLaunchParamsResponseGroupRole||(exports.EGetLaunchParamsResponseGroupRole={})).ADMIN="admin",_.EDITOR="editor",_.MEMBER="member",_.MODER="moder",_.NONE="none",exports.EGetLaunchParamsResponsePlatforms=void 0,(w=exports.EGetLaunchParamsResponsePlatforms||(exports.EGetLaunchParamsResponsePlatforms={})).DESKTOP_WEB="desktop_web",w.DESKTOP_WEB_MESSENGER="desktop_web_messenger",w.DESKTOP_APP_MESSENGER="desktop_app_messenger",w.MOBILE_WEB="mobile_web",w.MOBILE_ANDROID="mobile_android",w.MOBILE_ANDROID_MESSENGER="mobile_android_messenger",w.MOBILE_IPHONE="mobile_iphone",w.MOBILE_IPHONE_MESSENGER="mobile_iphone_messenger",w.MOBILE_IPAD="mobile_ipad";var V=function(e){var n=void 0,i=[];function A(e){i.push(e)}function f(){return a||r}function v(){return s&&window.parent!==window}function m(){return f()||v()}function W(e){if(a||r)return t([],i,!0).map((function(t){return t.call(null,e)}));var o=null==e?void 0:e.data;if(s&&o){if(p&&"string"==typeof o)try{o=JSON.parse(o)}catch(e){}var u=o.type,d=o.data,c=o.frameId;u&&("VKWebAppSettings"!==u?t([],i,!0).map((function(e){return e({detail:{type:u,data:d}})})):n=c)}}p&&/(android)/i.test(navigator.userAgent)?document.addEventListener(u,W):"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener(u,W);var _=o((function(t,o){c&&c[t]?c[t](JSON.stringify(o)):l&&l[t]&&"function"==typeof l[t].postMessage?l[t].postMessage(o):p?window.ReactNativeWebView.postMessage(JSON.stringify({handler:t,params:o})):b&&"function"==typeof b.postMessage&&b.postMessage({handler:t,params:o,type:"vk-connect",webFrameId:n,connectVersion:e},"*")}),A);return{send:_,sendPromise:_,subscribe:A,unsubscribe:function(e){var t=i.indexOf(e);t>-1&&i.splice(t,1)},supports:function(e){return r?!(!c||"function"!=typeof c[e]):a?!(!l||!l[e]||"function"!=typeof l[e].postMessage):!!s&&d.includes(e)},isWebView:f,isIframe:v,isEmbedded:m,isStandalone:function(){return!m()}}}("2.9.0");exports.applyMiddleware=function t(){for(var o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return o.includes(void 0)||o.includes(null)?t.apply(void 0,o.filter((function(e){return"function"==typeof e}))):function(t){if(0===o.length)return t;var n,r={subscribe:t.subscribe,send:function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];return t.send.apply(t,e)}},a=o.filter((function(e){return"function"==typeof e})).map((function(e){return e(r)})).reduce((function(e,t){return function(o){return e(t(o))}}));return n=a(t.send),e(e({},t),{send:n})}},exports.default=V,exports.parseURLSearchParamsForGetLaunchParams=function(e){var t={};try{var o=new URLSearchParams(e);o.forEach((function(e,o){switch(o){case"vk_ts":case"vk_is_recommended":case"vk_profile_id":case"vk_has_profile_button":case"vk_testing_group_id":case"vk_user_id":case"vk_app_id":case"vk_group_id":t[o]=Number(e);break;case"sign":case"vk_chat_id":case"vk_ref":case"vk_access_token_settings":t[o]=e;break;case"odr_enabled":t.odr_enabled="1"===e?1:void 0;break;case"vk_is_app_user":case"vk_are_notifications_enabled":case"vk_is_favorite":t[o]=function(e){switch(e){case"0":return 0;case"1":return 1;default:return}}(e);break;case"vk_language":t.vk_language=function(e){return Object.values(exports.EGetLaunchParamsResponseLanguages).some((function(t){return t===e}))}(e)?e:void 0;break;case"vk_viewer_group_role":t.vk_viewer_group_role=function(e){return Object.values(exports.EGetLaunchParamsResponseGroupRole).some((function(t){return t===e}))}(e)?e:void 0;break;case"vk_platform":t.vk_platform=function(e){return Object.values(exports.EGetLaunchParamsResponsePlatforms).some((function(t){return t===e}))}(e)?e:void 0}}))}catch(e){console.warn(e)}return t}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).vkBridge={})}(this,(function(e){"use strict";var n=function(){return n=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},n.apply(this,arguments)};function t(e,n,t){if(t||2===arguments.length)for(var o,r=0,p=n.length;r<p;r++)!o&&r in n||(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))}function o(e,t){var o,r,p=(o={current:0,next:function(){return++this.current}},r={},{add:function(e,n){var t=null!=n?n:o.next();return r[t]=e,t},resolve:function(e,n,t){var o=r[e];o&&(t(n)?o.resolve(n):o.reject(n),r[e]=null)}});return t((function(e){if(e.detail&&e.detail.data&&"object"==typeof e.detail.data&&"request_id"in e.detail.data){var n=e.detail.data,t=n.request_id,o=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}(n,["request_id"]);t&&p.resolve(t,o,(function(e){return!("error_type"in e)}))}})),function(t,o){return void 0===o&&(o={}),new Promise((function(r,i){var a=p.add({resolve:r,reject:i},o.request_id);e(t,n(n({},o),{request_id:a}))}))}}var r="undefined"!=typeof window,p=Boolean(r&&window.AndroidBridge),i=Boolean(r&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.VKWebAppClose),a=Boolean(r&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage),s=r&&!p&&!i,d=s&&/(^\?|&)vk_platform=mobile_web(&|$)/.test(location.search),u=s?"message":"VKWebAppEvent",l=t(["VKWebAppInit","VKWebAppGetCommunityAuthToken","VKWebAppAddToCommunity","VKWebAppAddToHomeScreenInfo","VKWebAppClose","VKWebAppCopyText","VKWebAppCreateHash","VKWebAppGetUserInfo","VKWebAppSetLocation","VKWebAppSendToClient","VKWebAppGetClientVersion","VKWebAppGetPhoneNumber","VKWebAppGetEmail","VKWebAppGetGroupInfo","VKWebAppGetGeodata","VKWebAppGetCommunityToken","VKWebAppGetConfig","VKWebAppGetLaunchParams","VKWebAppSetTitle","VKWebAppGetAuthToken","VKWebAppCallAPIMethod","VKWebAppJoinGroup","VKWebAppLeaveGroup","VKWebAppAllowMessagesFromGroup","VKWebAppDenyNotifications","VKWebAppAllowNotifications","VKWebAppOpenPayForm","VKWebAppOpenApp","VKWebAppShare","VKWebAppShowWallPostBox","VKWebAppScroll","VKWebAppShowOrderBox","VKWebAppShowLeaderBoardBox","VKWebAppShowInviteBox","VKWebAppShowRequestBox","VKWebAppAddToFavorites","VKWebAppShowStoryBox","VKWebAppStorageGet","VKWebAppStorageGetKeys","VKWebAppStorageSet","VKWebAppFlashGetInfo","VKWebAppSubscribeStoryApp","VKWebAppOpenWallPost","VKWebAppCheckAllowedScopes","VKWebAppCheckBannerAd","VKWebAppHideBannerAd","VKWebAppShowBannerAd","VKWebAppCheckNativeAds","VKWebAppShowNativeAds","VKWebAppRetargetingPixel","VKWebAppConversionHit","VKWebAppShowSubscriptionBox","VKWebAppCheckSurvey","VKWebAppShowSurvey","VKWebAppScrollTop","VKWebAppScrollTopStart","VKWebAppScrollTopStop","VKWebAppShowSlidesSheet","VKWebAppTranslate"],s&&!d?["VKWebAppResizeWindow","VKWebAppAddToMenu","VKWebAppShowInstallPushBox","VKWebAppGetFriends","VKWebAppShowCommunityWidgetPreviewBox"]:["VKWebAppShowImages"],!0),b=r?window.AndroidBridge:void 0,c=i?window.webkit.messageHandlers:void 0,A=s?parent:void 0;var f,W,V,K,m,w,v;e.EAdsFormats=void 0,(f=e.EAdsFormats||(e.EAdsFormats={})).REWARD="reward",f.INTERSTITIAL="interstitial",e.BannerAdLayoutType=void 0,(W=e.BannerAdLayoutType||(e.BannerAdLayoutType={})).RESIZE="resize",W.OVERLAY="overlay",e.BannerAdLocation=void 0,(V=e.BannerAdLocation||(e.BannerAdLocation={})).TOP="top",V.BOTTOM="bottom",e.EGrantedPermission=void 0,(K=e.EGrantedPermission||(e.EGrantedPermission={})).CAMERA="camera",K.LOCATION="location",K.PHOTO="photo",e.EGetLaunchParamsResponseLanguages=void 0,(m=e.EGetLaunchParamsResponseLanguages||(e.EGetLaunchParamsResponseLanguages={})).RU="ru",m.UK="uk",m.UA="ua",m.EN="en",m.BE="be",m.KZ="kz",m.PT="pt",m.ES="es",e.EGetLaunchParamsResponseGroupRole=void 0,(w=e.EGetLaunchParamsResponseGroupRole||(e.EGetLaunchParamsResponseGroupRole={})).ADMIN="admin",w.EDITOR="editor",w.MEMBER="member",w.MODER="moder",w.NONE="none",e.EGetLaunchParamsResponsePlatforms=void 0,(v=e.EGetLaunchParamsResponsePlatforms||(e.EGetLaunchParamsResponsePlatforms={})).DESKTOP_WEB="desktop_web",v.DESKTOP_WEB_MESSENGER="desktop_web_messenger",v.DESKTOP_APP_MESSENGER="desktop_app_messenger",v.MOBILE_WEB="mobile_web",v.MOBILE_ANDROID="mobile_android",v.MOBILE_ANDROID_MESSENGER="mobile_android_messenger",v.MOBILE_IPHONE="mobile_iphone",v.MOBILE_IPHONE_MESSENGER="mobile_iphone_messenger",v.MOBILE_IPAD="mobile_ipad";var E=function(e){var n=void 0,r=[];function d(e){r.push(e)}function f(){return i||p}function W(){return s&&window.parent!==window}function V(){return f()||W()}function K(e){if(i||p)return t([],r,!0).map((function(n){return n.call(null,e)}));var o=null==e?void 0:e.data;if(s&&o){if(a&&"string"==typeof o)try{o=JSON.parse(o)}catch(e){}var d=o.type,u=o.data,l=o.frameId;d&&("VKWebAppSettings"!==d?t([],r,!0).map((function(e){return e({detail:{type:d,data:u}})})):n=l)}}a&&/(android)/i.test(navigator.userAgent)?document.addEventListener(u,K):"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener(u,K);var m=o((function(t,o){b&&b[t]?b[t](JSON.stringify(o)):c&&c[t]&&"function"==typeof c[t].postMessage?c[t].postMessage(o):a?window.ReactNativeWebView.postMessage(JSON.stringify({handler:t,params:o})):A&&"function"==typeof A.postMessage&&A.postMessage({handler:t,params:o,type:"vk-connect",webFrameId:n,connectVersion:e},"*")}),d);return{send:m,sendPromise:m,subscribe:d,unsubscribe:function(e){var n=r.indexOf(e);n>-1&&r.splice(n,1)},supports:function(e){return p?!(!b||"function"!=typeof b[e]):i?!(!c||!c[e]||"function"!=typeof c[e].postMessage):!!s&&l.includes(e)},isWebView:f,isIframe:W,isEmbedded:V,isStandalone:function(){return!V()}}}("2.9.0-beta.0");e.applyMiddleware=function e(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return t.includes(void 0)||t.includes(null)?e.apply(void 0,t.filter((function(e){return"function"==typeof e}))):function(e){if(0===t.length)return e;var o,r={subscribe:e.subscribe,send:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e.send.apply(e,n)}},p=t.filter((function(e){return"function"==typeof e})).map((function(e){return e(r)})).reduce((function(e,n){return function(t){return e(n(t))}}));return o=p(e.send),n(n({},e),{send:o})}},e.default=E,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).vkBridge={})}(this,(function(e){"use strict";var n=function(){return n=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},n.apply(this,arguments)};function t(e,n,t){if(t||2===arguments.length)for(var o,r=0,a=n.length;r<a;r++)!o&&r in n||(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))}function o(e,t){var o,r,a=(o={current:0,next:function(){return++this.current}},r={},{add:function(e,n){var t=null!=n?n:o.next();return r[t]=e,t},resolve:function(e,n,t){var o=r[e];o&&(t(n)?o.resolve(n):o.reject(n),r[e]=null)}});return t((function(e){if(e.detail&&e.detail.data&&"object"==typeof e.detail.data&&"request_id"in e.detail.data){var n=e.detail.data,t=n.request_id,o=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}(n,["request_id"]);t&&a.resolve(t,o,(function(e){return!("error_type"in e)}))}})),function(t,o){return void 0===o&&(o={}),new Promise((function(r,p){var i=a.add({resolve:r,reject:p},o.request_id);e(t,n(n({},o),{request_id:i}))}))}}var r="undefined"!=typeof window,a=Boolean(r&&window.AndroidBridge),p=Boolean(r&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.VKWebAppClose),i=Boolean(r&&window.ReactNativeWebView&&"function"==typeof window.ReactNativeWebView.postMessage),s=r&&!a&&!p,u=s&&/(^\?|&)vk_platform=mobile_web(&|$)/.test(location.search),d=s?"message":"VKWebAppEvent",c=t(["VKWebAppInit","VKWebAppGetCommunityAuthToken","VKWebAppAddToCommunity","VKWebAppAddToHomeScreenInfo","VKWebAppClose","VKWebAppCopyText","VKWebAppCreateHash","VKWebAppGetUserInfo","VKWebAppSetLocation","VKWebAppSendToClient","VKWebAppGetClientVersion","VKWebAppGetPhoneNumber","VKWebAppGetEmail","VKWebAppGetGroupInfo","VKWebAppGetGeodata","VKWebAppGetCommunityToken","VKWebAppGetConfig","VKWebAppGetLaunchParams","VKWebAppSetTitle","VKWebAppGetAuthToken","VKWebAppCallAPIMethod","VKWebAppJoinGroup","VKWebAppLeaveGroup","VKWebAppAllowMessagesFromGroup","VKWebAppDenyNotifications","VKWebAppAllowNotifications","VKWebAppOpenPayForm","VKWebAppOpenApp","VKWebAppShare","VKWebAppShowWallPostBox","VKWebAppScroll","VKWebAppShowOrderBox","VKWebAppShowLeaderBoardBox","VKWebAppShowInviteBox","VKWebAppShowRequestBox","VKWebAppAddToFavorites","VKWebAppShowStoryBox","VKWebAppStorageGet","VKWebAppStorageGetKeys","VKWebAppStorageSet","VKWebAppFlashGetInfo","VKWebAppSubscribeStoryApp","VKWebAppOpenWallPost","VKWebAppCheckAllowedScopes","VKWebAppCheckBannerAd","VKWebAppHideBannerAd","VKWebAppShowBannerAd","VKWebAppCheckNativeAds","VKWebAppShowNativeAds","VKWebAppRetargetingPixel","VKWebAppConversionHit","VKWebAppShowSubscriptionBox","VKWebAppCheckSurvey","VKWebAppShowSurvey","VKWebAppScrollTop","VKWebAppScrollTopStart","VKWebAppScrollTopStop","VKWebAppShowSlidesSheet","VKWebAppTranslate"],s&&!u?["VKWebAppResizeWindow","VKWebAppAddToMenu","VKWebAppShowInstallPushBox","VKWebAppGetFriends","VKWebAppShowCommunityWidgetPreviewBox"]:["VKWebAppShowImages"],!0),l=r?window.AndroidBridge:void 0,b=p?window.webkit.messageHandlers:void 0,f=s?parent:void 0;var A,v,m,W,_,w,V;e.EAdsFormats=void 0,(A=e.EAdsFormats||(e.EAdsFormats={})).REWARD="reward",A.INTERSTITIAL="interstitial",e.BannerAdLayoutType=void 0,(v=e.BannerAdLayoutType||(e.BannerAdLayoutType={})).RESIZE="resize",v.OVERLAY="overlay",e.BannerAdLocation=void 0,(m=e.BannerAdLocation||(e.BannerAdLocation={})).TOP="top",m.BOTTOM="bottom",e.EGrantedPermission=void 0,(W=e.EGrantedPermission||(e.EGrantedPermission={})).CAMERA="camera",W.LOCATION="location",W.PHOTO="photo",e.EGetLaunchParamsResponseLanguages=void 0,(_=e.EGetLaunchParamsResponseLanguages||(e.EGetLaunchParamsResponseLanguages={})).RU="ru",_.UK="uk",_.UA="ua",_.EN="en",_.BE="be",_.KZ="kz",_.PT="pt",_.ES="es",e.EGetLaunchParamsResponseGroupRole=void 0,(w=e.EGetLaunchParamsResponseGroupRole||(e.EGetLaunchParamsResponseGroupRole={})).ADMIN="admin",w.EDITOR="editor",w.MEMBER="member",w.MODER="moder",w.NONE="none",e.EGetLaunchParamsResponsePlatforms=void 0,(V=e.EGetLaunchParamsResponsePlatforms||(e.EGetLaunchParamsResponsePlatforms={})).DESKTOP_WEB="desktop_web",V.DESKTOP_WEB_MESSENGER="desktop_web_messenger",V.DESKTOP_APP_MESSENGER="desktop_app_messenger",V.MOBILE_WEB="mobile_web",V.MOBILE_ANDROID="mobile_android",V.MOBILE_ANDROID_MESSENGER="mobile_android_messenger",V.MOBILE_IPHONE="mobile_iphone",V.MOBILE_IPHONE_MESSENGER="mobile_iphone_messenger",V.MOBILE_IPAD="mobile_ipad";var K=function(e){var n=void 0,r=[];function u(e){r.push(e)}function A(){return p||a}function v(){return s&&window.parent!==window}function m(){return A()||v()}function W(e){if(p||a)return t([],r,!0).map((function(n){return n.call(null,e)}));var o=null==e?void 0:e.data;if(s&&o){if(i&&"string"==typeof o)try{o=JSON.parse(o)}catch(e){}var u=o.type,d=o.data,c=o.frameId;u&&("VKWebAppSettings"!==u?t([],r,!0).map((function(e){return e({detail:{type:u,data:d}})})):n=c)}}i&&/(android)/i.test(navigator.userAgent)?document.addEventListener(d,W):"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener(d,W);var _=o((function(t,o){l&&l[t]?l[t](JSON.stringify(o)):b&&b[t]&&"function"==typeof b[t].postMessage?b[t].postMessage(o):i?window.ReactNativeWebView.postMessage(JSON.stringify({handler:t,params:o})):f&&"function"==typeof f.postMessage&&f.postMessage({handler:t,params:o,type:"vk-connect",webFrameId:n,connectVersion:e},"*")}),u);return{send:_,sendPromise:_,subscribe:u,unsubscribe:function(e){var n=r.indexOf(e);n>-1&&r.splice(n,1)},supports:function(e){return a?!(!l||"function"!=typeof l[e]):p?!(!b||!b[e]||"function"!=typeof b[e].postMessage):!!s&&c.includes(e)},isWebView:A,isIframe:v,isEmbedded:m,isStandalone:function(){return!m()}}}("2.9.0");e.applyMiddleware=function e(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return t.includes(void 0)||t.includes(null)?e.apply(void 0,t.filter((function(e){return"function"==typeof e}))):function(e){if(0===t.length)return e;var o,r={subscribe:e.subscribe,send:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e.send.apply(e,n)}},a=t.filter((function(e){return"function"==typeof e})).map((function(e){return e(r)})).reduce((function(e,n){return function(t){return e(n(t))}}));return o=a(e.send),n(n({},e),{send:o})}},e.default=K,e.parseURLSearchParamsForGetLaunchParams=function(n){var t={};try{var o=new URLSearchParams(n);o.forEach((function(n,o){switch(o){case"vk_ts":case"vk_is_recommended":case"vk_profile_id":case"vk_has_profile_button":case"vk_testing_group_id":case"vk_user_id":case"vk_app_id":case"vk_group_id":t[o]=Number(n);break;case"sign":case"vk_chat_id":case"vk_ref":case"vk_access_token_settings":t[o]=n;break;case"odr_enabled":t.odr_enabled="1"===n?1:void 0;break;case"vk_is_app_user":case"vk_are_notifications_enabled":case"vk_is_favorite":t[o]=function(e){switch(e){case"0":return 0;case"1":return 1;default:return}}(n);break;case"vk_language":t.vk_language=function(n){return Object.values(e.EGetLaunchParamsResponseLanguages).some((function(e){return e===n}))}(n)?n:void 0;break;case"vk_viewer_group_role":t.vk_viewer_group_role=function(n){return Object.values(e.EGetLaunchParamsResponseGroupRole).some((function(e){return e===n}))}(n)?n:void 0;break;case"vk_platform":t.vk_platform=function(n){return Object.values(e.EGetLaunchParamsResponsePlatforms).some((function(e){return e===n}))}(n)?n:void 0}}))}catch(e){console.warn(e)}return t},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -7,2 +7,3 @@ declare const bridge: import("./types/bridge").VKBridge; | ||
export { applyMiddleware } from './applyMiddleware'; | ||
export { parseURLSearchParamsForGetLaunchParams } from './parseURLSearchParamsForGetLaunchParams'; | ||
export { bridge as default }; |
@@ -7,2 +7,3 @@ declare const bridge: import("./types/bridge").VKBridge; | ||
export { applyMiddleware } from './applyMiddleware'; | ||
export { parseURLSearchParamsForGetLaunchParams } from './parseURLSearchParamsForGetLaunchParams'; | ||
export { bridge as default }; |
{ | ||
"name": "@vkontakte/vk-bridge", | ||
"version": "2.9.0-beta.0", | ||
"version": "2.9.0", | ||
"description": "Connects a Mini App with VK client", | ||
@@ -25,3 +25,4 @@ "license": "MIT", | ||
"build:legacy-types": "yarn run --top-level rollup -c rollup.config-legacy-types.mjs >/dev/null", | ||
"prepack": "yarn run build" | ||
"prepack": "yarn run build", | ||
"test": "yarn run --top-level jest --config ../../jest.config.js" | ||
}, | ||
@@ -28,0 +29,0 @@ "author": { |
@@ -176,1 +176,26 @@ # VK Bridge Core | ||
``` | ||
## Functions | ||
### `parseURLSearchParamsForGetLaunchParams(urlSearchParams: string)` | ||
Parse URL search params for get provided to mini app [launch params](https://dev.vk.com/mini-apps/development/launch-params). | ||
**Parameters** | ||
- `urlSearchParams` a.k.a `window.location.search`. | ||
**Example** | ||
```js | ||
import { parseURLSearchParamsForGetLaunchParams } from '@vkontakte/vk-bridge'; | ||
// https://exmample-mini-app.io/?vk_platform=desktop_web&vk_is_app_user=1&vk_user_id=12345 | ||
const { vk_platform, vk_viewer_group_role, vk_user_id } = parseURLSearchParamsForGetLaunchParams( | ||
window.location.search, | ||
); | ||
console.log(vk_platform); // 'desktop_web' | ||
console.log(vk_is_app_user); // 1 | ||
console.log(vk_user_id); // 12345 | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
466251
31
4115
1
201